下面列出了android.os.TransactionTooLargeException#android.app.IApplicationThread 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void makeActive(IApplicationThread _thread, ProcessStatsService tracker) {
if (thread == null) {
final ProcessState origBase = baseProcessTracker;
if (origBase != null) {
origBase.setState(ProcessStats.STATE_NOTHING,
tracker.getMemFactorLocked(), SystemClock.uptimeMillis(), pkgList);
origBase.makeInactive();
}
baseProcessTracker = tracker.getProcessStateLocked(info.packageName, uid,
info.longVersionCode, processName);
baseProcessTracker.makeActive();
for (int i=0; i<pkgList.size(); i++) {
ProcessStats.ProcessStateHolder holder = pkgList.valueAt(i);
if (holder.state != null && holder.state != origBase) {
holder.state.makeInactive();
}
holder.state = tracker.getProcessStateLocked(pkgList.keyAt(i), uid,
info.longVersionCode, processName);
if (holder.state != baseProcessTracker) {
holder.state.makeActive();
}
}
}
thread = _thread;
}
public final int broadcastIntent(IApplicationThread caller,
Intent intent, String resolvedType, IIntentReceiver resultTo,
int resultCode, String resultData, Bundle resultExtras,
String[] requiredPermissions, int appOp, Bundle bOptions,
boolean serialized, boolean sticky, int userId) {
try {
PreventRunningUtils.setSender(caller);
int res = broadcastIntent$Pr(caller,
intent, resolvedType, resultTo,
resultCode, resultData, resultExtras,
requiredPermissions, appOp, bOptions,
serialized, sticky, userId);
if (res == 0) {
PreventRunningUtils.onBroadcastIntent(intent);
}
return res;
} finally {
PreventRunningUtils.clearSender();
}
}
public final int broadcastIntent(IApplicationThread caller,
Intent intent, String resolvedType, IIntentReceiver resultTo,
int resultCode, String resultData, Bundle map,
String requiredPermission, int appOp, boolean serialized, boolean sticky, int userId) {
try {
PreventRunningUtils.setSender(caller);
int res = broadcastIntent$Pr(caller,
intent, resolvedType, resultTo,
resultCode, resultData, map,
requiredPermission, appOp, serialized, sticky, userId);
if (res == 0) {
PreventRunningUtils.onBroadcastIntent(intent);
}
return res;
} finally {
PreventRunningUtils.clearSender();
}
}
/** Obtain an instance initialized with provided params. */
public static ClientTransaction obtain(IApplicationThread client, IBinder activityToken) {
ClientTransaction instance = ObjectPool.obtain(ClientTransaction.class);
if (instance == null) {
instance = new ClientTransaction();
}
instance.mClient = client;
instance.mActivityToken = activityToken;
return instance;
}
/** Read from Parcel. */
private ClientTransaction(Parcel in) {
mClient = (IApplicationThread) in.readStrongBinder();
final boolean readActivityToken = in.readBoolean();
if (readActivityToken) {
mActivityToken = in.readStrongBinder();
}
mLifecycleStateRequest = in.readParcelable(getClass().getClassLoader());
final boolean readActivityCallbacks = in.readBoolean();
if (readActivityCallbacks) {
mActivityCallbacks = new ArrayList<>();
in.readParcelableList(mActivityCallbacks, getClass().getClassLoader());
}
}
private int startActivity(IApplicationThread caller, Intent intent, Intent ephemeralIntent,
String resolvedType, ActivityInfo aInfo, ResolveInfo rInfo,
IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
IBinder resultTo, String resultWho, int requestCode, int callingPid, int callingUid,
String callingPackage, int realCallingPid, int realCallingUid, int startFlags,
SafeActivityOptions options, boolean ignoreTargetSecurity, boolean componentSpecified,
ActivityRecord[] outActivity, TaskRecord inTask, String reason,
boolean allowPendingRemoteAnimationRegistryLookup,
PendingIntentRecord originatingPendingIntent) {
if (TextUtils.isEmpty(reason)) {
throw new IllegalArgumentException("Need to specify a reason.");
}
mLastStartReason = reason;
mLastStartActivityTimeMs = System.currentTimeMillis();
mLastStartActivityRecord[0] = null;
// 调用重载方法
mLastStartActivityResult = startActivity(caller, intent, ephemeralIntent, resolvedType,
aInfo, rInfo, voiceSession, voiceInteractor, resultTo, resultWho, requestCode,
callingPid, callingUid, callingPackage, realCallingPid, realCallingUid, startFlags,
options, ignoreTargetSecurity, componentSpecified, mLastStartActivityRecord,
inTask, allowPendingRemoteAnimationRegistryLookup, originatingPendingIntent);
if (outActivity != null) {
// mLastStartActivityRecord[0] is set in the call to startActivity above.
outActivity[0] = mLastStartActivityRecord[0];
}
return getExternalResult(mLastStartActivityResult);
}
int stopServiceLocked(IApplicationThread caller, Intent service,
String resolvedType, int userId) {
if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "stopService: " + service
+ " type=" + resolvedType);
final ProcessRecord callerApp = mAm.getRecordForAppLocked(caller);
if (caller != null && callerApp == null) {
throw new SecurityException(
"Unable to find app for caller " + caller
+ " (pid=" + Binder.getCallingPid()
+ ") when stopping service " + service);
}
// If this service is active, make sure it is stopped.
ServiceLookupResult r = retrieveServiceLocked(service, resolvedType, null,
Binder.getCallingPid(), Binder.getCallingUid(), userId, false, false, false, false);
if (r != null) {
if (r.record != null) {
final long origId = Binder.clearCallingIdentity();
try {
stopServiceLocked(r.record);
} finally {
Binder.restoreCallingIdentity(origId);
}
return 1;
}
return -1;
}
return 0;
}
@Override
public int startActivity(IBinder whoThread, String callingPackage,
Intent intent, String resolvedType, Bundle bOptions) {
checkCaller();
int callingUser = UserHandle.getCallingUserId();
TaskRecord tr;
IApplicationThread appThread;
synchronized (mService) {
tr = mService.mStackSupervisor.anyTaskForIdLocked(mTaskId,
MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
if (tr == null) {
throw new IllegalArgumentException("Unable to find task ID " + mTaskId);
}
appThread = IApplicationThread.Stub.asInterface(whoThread);
if (appThread == null) {
throw new IllegalArgumentException("Bad app thread " + appThread);
}
}
return mService.getActivityStartController().obtainStarter(intent, "AppTaskImpl")
.setCaller(appThread)
.setCallingPackage(callingPackage)
.setResolvedType(resolvedType)
.setActivityOptions(bOptions)
.setMayWait(callingUser)
.setInTask(tr)
.execute();
}
/**
* Schedule a transaction, which may consist of multiple callbacks and a lifecycle request.
* @param transaction A sequence of client transaction items.
* @throws RemoteException
*
* @see ClientTransaction
*/
void scheduleTransaction(ClientTransaction transaction) throws RemoteException {
final IApplicationThread client = transaction.getClient(); // -> ApplicationThread
transaction.schedule(); // ClientTransaction
if (!(client instanceof Binder)) {
// If client is not an instance of Binder - it's a remote call and at this point it is
// safe to recycle the object. All objects used for local calls will be recycled after
// the transaction is executed on client in ActivityThread.
transaction.recycle();
}
}
/**
* @return A new instance of {@link ClientTransaction} with a single lifecycle state request.
*
* @see ClientTransaction
* @see ClientTransactionItem
*/
private static ClientTransaction transactionWithState(@NonNull IApplicationThread client,
@NonNull IBinder activityToken, @NonNull ActivityLifecycleItem stateRequest) {
final ClientTransaction clientTransaction = ClientTransaction.obtain(client, activityToken);
clientTransaction.setLifecycleStateRequest(stateRequest);
return clientTransaction;
}
/**
* @return A new instance of {@link ClientTransaction} with a single callback invocation.
*
* @see ClientTransaction
* @see ClientTransactionItem
*/
private static ClientTransaction transactionWithCallback(@NonNull IApplicationThread client,
IBinder activityToken, @NonNull ClientTransactionItem callback) {
final ClientTransaction clientTransaction = ClientTransaction.obtain(client, activityToken);
clientTransaction.addCallback(callback);
return clientTransaction;
}
/** Obtain an instance initialized with provided params. */
public static ClientTransaction obtain(IApplicationThread client, IBinder activityToken) {
ClientTransaction instance = ObjectPool.obtain(ClientTransaction.class);
if (instance == null) {
instance = new ClientTransaction();
}
instance.mClient = client;
instance.mActivityToken = activityToken;
return instance;
}
/** Read from Parcel. */
private ClientTransaction(Parcel in) {
mClient = (IApplicationThread) in.readStrongBinder();
final boolean readActivityToken = in.readBoolean();
if (readActivityToken) {
mActivityToken = in.readStrongBinder();
}
mLifecycleStateRequest = in.readParcelable(getClass().getClassLoader());
final boolean readActivityCallbacks = in.readBoolean();
if (readActivityCallbacks) {
mActivityCallbacks = new ArrayList<>();
in.readParcelableList(mActivityCallbacks, getClass().getClassLoader());
}
}
/**
* Android O 方法兼容适配。
*/
public Intent registerReceiver(IApplicationThread caller, String callerPackage,
IIntentReceiver receiver, IntentFilter filter,
String requiredPermission, int userId, int flags) {
return mTarget.registerReceiver(caller, mHostContext.getPackageName(), receiver,
filter, requiredPermission, userId, flags);
}
public int stopService(IApplicationThread caller, Intent service,
String resolvedType) {
if (service.getComponent() != null && ProxyEnvironment.hasInstance(service.getComponent().getPackageName())) {
return ServiceProxy.stopServiceExternal(service.getComponent());
} else {
return mTarget.stopService(caller, service, resolvedType);
}
}
public int stopService(IApplicationThread caller, Intent service,
String resolvedType, int userId) {
if (service.getComponent() != null && ProxyEnvironment.hasInstance(service.getComponent().getPackageName())) {
return ServiceProxy.stopServiceExternal(service.getComponent());
} else {
return mTarget.stopService(caller, service, resolvedType, userId);
}
}
public int bindService(IApplicationThread caller, IBinder token,
Intent service, String resolvedType,
IServiceConnection connection, int flags, int userId) {
token = getActivityToken(token);
RemapingUtil.remapServiceIntent(mHostContext, service);
if (userId == INVALID_USER_ID) {
return mTarget.bindService(caller, token, service, resolvedType, connection, flags);
} else {
return mTarget.bindService(caller, token, service, resolvedType, connection, flags, userId);
}
}
/**
* android 6.0
*/
public int bindService(IApplicationThread caller, IBinder token, Intent service,
String resolvedType, IServiceConnection connection, int flags,
String callingPackage, int userId) {
RemapingUtil.remapServiceIntent(mHostContext, service);
return mTarget.bindService(caller, token, service, resolvedType, connection, flags, callingPackage, userId);
}
/**
* android 2.x
*/
public int broadcastIntent(IApplicationThread caller, Intent intent,
String resolvedType, IIntentReceiver resultTo, int resultCode,
String resultData, Bundle map, String requiredPermission,
boolean serialized, boolean sticky) {
remapBroadcastIntent(intent);
return mTarget.broadcastIntent(caller, intent, resolvedType, resultTo, resultCode,
resultData, map, requiredPermission, serialized, sticky);
}
/**
* android 4.x
*/
public int broadcastIntent(IApplicationThread caller, Intent intent,
String resolvedType, IIntentReceiver resultTo, int resultCode,
String resultData, Bundle map, String requiredPermission,
boolean serialized, boolean sticky, int userId) {
remapBroadcastIntent(intent);
return mTarget.broadcastIntent(caller, intent, resolvedType, resultTo, resultCode, resultData, map,
requiredPermission, serialized, sticky, userId);
}
/**
* android 5.x
*/
public int broadcastIntent(IApplicationThread caller, Intent intent,
String resolvedType, IIntentReceiver resultTo, int resultCode,
String resultData, Bundle map, String requiredPermission,
int appOp, boolean serialized, boolean sticky, int userId) {
remapBroadcastIntent(intent);
return mTarget.broadcastIntent(caller, intent, resolvedType, resultTo, resultCode, resultData, map,
requiredPermission, appOp, serialized, sticky, userId);
}
/**
* android 6.x
*/
public int broadcastIntent(IApplicationThread caller, Intent intent,
String resolvedType, IIntentReceiver resultTo, int resultCode,
String resultData, Bundle map, String[] requiredPermissions,
int appOp, Bundle options, boolean serialized, boolean sticky, int userId) {
remapBroadcastIntent(intent);
return mTarget.broadcastIntent(caller, intent, resolvedType, resultTo, resultCode, resultData, map,
requiredPermissions, appOp, options, serialized, sticky, userId);
}
/**
* 2.3
*/
public ContentProviderHolder getContentProvider(IApplicationThread caller, String name) {
ContentProviderHolder holder = getContentProviderHolder(mHostContext, name);
if (holder != null) {
return holder;
}
return mTarget.getContentProvider(caller, name);
}
/**
* 4.x
*/
public ContentProviderHolder getContentProvider(IApplicationThread caller, String name, boolean stable) {
ContentProviderHolder holder = getContentProviderHolder(mHostContext, name);
if (holder != null) {
return holder;
}
return mTarget.getContentProvider(caller, name, stable);
}
/**
* 5.x 6.0
*/
public ContentProviderHolder getContentProvider(IApplicationThread caller, String name, int userId, boolean stable) {
ContentProviderHolder holder = getContentProviderHolder(mHostContext, name);
if (holder != null) {
return holder;
}
return mTarget.getContentProvider(caller, name, userId, stable);
}
public int startActivity(IApplicationThread caller, Intent intent, String resolvedType,
Uri[] grantedUriPermissions, int grantedMode, IBinder resultTo, String resultWho, int requestCode,
boolean onlyIfNeeded, boolean debug) {
RemapingUtil.remapActivityIntent(mHostContext, intent);
return mTarget.startActivity(caller, intent, resolvedType, grantedUriPermissions, grantedMode,
resultTo, resultWho, requestCode, onlyIfNeeded, debug);
}
public int startActivity(IApplicationThread caller, Intent intent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int flags, String profileFile, ParcelFileDescriptor profileFd,
Bundle options) {
RemapingUtil.remapActivityIntent(mHostContext, intent);
return mTarget.startActivity(caller, intent, resolvedType, resultTo, resultWho, requestCode,
flags, profileFile, profileFd, options);
}
public int startActivity(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode, int flags, String profileFile,
ParcelFileDescriptor profileFd, Bundle options) {
try {
RemapingUtil.remapActivityIntent(mHostContext, intent);
} catch (Exception e) {
if (DEBUG) {
e.printStackTrace();
}
}
return mTarget.startActivity(caller, callingPackage, intent, resolvedType, resultTo, resultWho,
requestCode, flags, profileFile, profileFd, options);
}
public int startActivity(IApplicationThread caller, String callingPackage, Intent intent, String resolvedType,
IBinder resultTo, String resultWho, int requestCode, int flags, ProfilerInfo profilerInfo, Bundle options) {
RemapingUtil.remapActivityIntent(mHostContext, intent);
return mTarget.startActivity(caller, callingPackage, intent, resolvedType, resultTo, resultWho, requestCode,
flags, profilerInfo, options);
}
public int startActivity(IApplicationThread caller, Intent intent, String resolvedType,
Uri[] grantedUriPermissions, int grantedMode, IBinder resultTo, String resultWho, int requestCode,
boolean onlyIfNeeded, boolean debug, String profileFile, ParcelFileDescriptor profileFd,
boolean autoStopProfiler) {
RemapingUtil.remapActivityIntent(mHostContext, intent);
return mTarget.startActivity(caller, intent, resolvedType, grantedUriPermissions, grantedMode, resultTo,
resultWho, requestCode, onlyIfNeeded, debug, profileFile, profileFd, autoStopProfiler);
}