类android.app.IApplicationThread源码实例Demo

下面列出了怎么用android.app.IApplicationThread的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: ProcessRecord.java
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;
}
 
源代码2 项目: prevent   文件: ActivityManagerService.java
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();
    }
}
 
源代码3 项目: prevent   文件: ActivityManagerService.java
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());
    }
}
 
源代码6 项目: android_9.0.0_r45   文件: ActivityStarter.java
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);
}
 
源代码7 项目: android_9.0.0_r45   文件: ActiveServices.java
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;
}
 
源代码8 项目: android_9.0.0_r45   文件: AppTaskImpl.java
@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();
    }
}
 
源代码10 项目: android_9.0.0_r45   文件: ClientLifecycleManager.java
/**
 * @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;
}
 
源代码11 项目: android_9.0.0_r45   文件: ClientLifecycleManager.java
/**
 * @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;
}
 
源代码12 项目: android_9.0.0_r45   文件: ClientTransaction.java
/** 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;
}
 
源代码13 项目: android_9.0.0_r45   文件: ClientTransaction.java
/** 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());
    }
}
 
源代码14 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码15 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
    }
}
 
源代码16 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
    }
}
 
源代码17 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
    }
}
 
源代码18 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码19 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码20 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码21 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码22 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);

}
 
源代码23 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 2.3
 */
public ContentProviderHolder getContentProvider(IApplicationThread caller, String name) {
    ContentProviderHolder holder = getContentProviderHolder(mHostContext, name);
    if (holder != null) {
        return holder;
    }

    return mTarget.getContentProvider(caller, name);
}
 
源代码24 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码25 项目: GPT   文件: ActivityManagerNativeWorker.java
/**
 * 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);
}
 
源代码26 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
}
 
源代码27 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
}
 
源代码28 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
}
 
源代码29 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
}
 
源代码30 项目: GPT   文件: ActivityManagerNativeWorker.java
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);
}
 
 类所在包
 类方法
 同包方法