@Override public void appDoneExecuting() { synchronized (mPidsSelfLocked) { ProcessRecord r = mPidsSelfLocked.get(VBinder.getCallingPid()); if (r != null) { r.doneExecuting = true; r.lock.open(); } } }
/** @hide */ public static int getCallingUserId() { return getUserId(VBinder.getCallingUid()); }
public static int getBaseCallingUid() { return VUserHandle.getAppId(getCallingUid()); }
@Override public IBinder acquireProviderClient(int userId, ProviderInfo info) { ProcessRecord callerApp; synchronized (mPidsSelfLocked) { callerApp = findProcessLocked(VBinder.getCallingPid()); } if (callerApp == null) { throw new SecurityException("Who are you?"); } String processName = info.processName; ProcessRecord r; synchronized (this) { r = startProcessIfNeedLocked(processName, userId, info.packageName); } if (r != null && r.client.asBinder().pingBinder()) { try { return r.client.acquireProviderClient(info); } catch (RemoteException e) { e.printStackTrace(); } } return null; }
/** @hide */ public static VUserHandle getCallingUserHandle() { int userId = getUserId(VBinder.getCallingUid()); VUserHandle userHandle = userHandles.get(userId); // Intentionally not synchronized to save time if (userHandle == null) { userHandle = new VUserHandle(userId); userHandles.put(userId, userHandle); } return userHandle; }
@Override public void appDoneExecuting() { synchronized (mPidsSelfLocked) { ProcessRecord r = mPidsSelfLocked.get(VBinder.getCallingPid()); if (r != null) { r.doneExecuting = true; r.lock.open(); } } }
@Override public void cancel(int jobId) throws RemoteException { int vuid = VBinder.getCallingUid(); synchronized (mJobStore) { boolean changed = false; Iterator<Map.Entry<JobId, JobConfig>> iterator = mJobStore.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<JobId, JobConfig> entry = iterator.next(); JobId job = entry.getKey(); JobConfig config = entry.getValue(); if (job.vuid == vuid && job.clientJobId == jobId) { changed = true; mScheduler.cancel(config.virtualJobId); iterator.remove(); break; } } if (changed) { saveJobs(); } } }
@Override public void appDoneExecuting() { synchronized (mPidsSelfLocked) { ProcessRecord r = mPidsSelfLocked.get(getCallingPid()); if (r != null) { r.doneExecuting = true; r.lock.open(); } } }
@Override public void cancelAll() throws RemoteException { int vuid = VBinder.getCallingUid(); synchronized (mJobStore) { boolean changed = false; Iterator<Map.Entry<JobId, JobConfig>> iterator = mJobStore.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<JobId, JobConfig> entry = iterator.next(); JobId job = entry.getKey(); if (job.vuid == vuid) { JobConfig config = entry.getValue(); mScheduler.cancel(config.virtualJobId); changed = true; iterator.remove(); break; } } if (changed) { saveJobs(); } } }
@Override public IBinder acquireProviderClient(int userId, ProviderInfo info) { ProcessRecord callerApp; synchronized (mPidsSelfLocked) { callerApp = findProcessLocked(VBinder.getCallingPid()); } if (callerApp == null) { throw new SecurityException("Who are you?"); } String processName = info.processName; ProcessRecord r; synchronized (this) { r = startProcessIfNeedLocked(processName, userId, info.packageName); } if (r != null && r.client.asBinder().pingBinder()) { try { return r.client.acquireProviderClient(info); } catch (RemoteException e) { e.printStackTrace(); } } return null; }
/** * Enforces that only the system UID or root's UID or apps that have the * {android.Manifest.permission.MANAGE_USERS MANAGE_USERS} * permission can make certain calls to the VUserManager. * * @param message used as message if SecurityException is thrown * @throws SecurityException if the caller is not system or root */ private static void checkManageUsersPermission(String message) { final int uid = VBinder.getCallingUid(); if (uid != VirtualCore.get().myUid()) { throw new SecurityException("You need MANAGE_USERS permission to: " + message); } }
@Override public IBinder acquireProviderClient(int userId, ProviderInfo info) { ProcessRecord callerApp; synchronized (mPidsSelfLocked) { callerApp = findProcessLocked(getCallingPid()); } if (callerApp == null) { throw new SecurityException("Who are you?"); } String processName = info.processName; ProcessRecord r; synchronized (this) { r = startProcessIfNeedLocked(processName, userId, info.packageName); } if (r != null && r.client.asBinder().isBinderAlive()) { try { return r.client.acquireProviderClient(info); } catch (RemoteException e) { e.printStackTrace(); } } return null; }
public static VUserHandle getCallingUserHandle() { return new VUserHandle(VUserHandle.getUserId(getCallingUid())); } }
@Override public void processRestarted(String packageName, String processName, int userId) { int callingPid = getCallingPid(); int appId = VAppManagerService.get().getAppId(packageName); int uid = VUserHandle.getUid(userId, appId); synchronized (this) { ProcessRecord app = findProcessLocked(callingPid); if (app == null) { ApplicationInfo appInfo = VPackageManagerService.get().getApplicationInfo(packageName, 0, userId); appInfo.flags |= ApplicationInfo.FLAG_HAS_CODE; String stubProcessName = getProcessName(callingPid); int vpid = parseVPid(stubProcessName); if (vpid != -1) { performStartProcessLocked(uid, vpid, appInfo, processName); } } } }
@Override public List<JobInfo> getAllPendingJobs() throws RemoteException { int vuid = VBinder.getCallingUid(); List<JobInfo> jobs = mScheduler.getAllPendingJobs(); synchronized (mJobStore) { Iterator<JobInfo> iterator = jobs.listIterator(); while (iterator.hasNext()) { JobInfo job = iterator.next(); if (!VASettings.STUB_JOB.equals(job.getService().getClassName())) { // Schedule by Host, invisible in VA. iterator.remove(); continue; } Map.Entry<JobId, JobConfig> jobEntry = findJobByVirtualJobId(job.getId()); if (jobEntry == null) { iterator.remove(); continue; } JobId jobId = jobEntry.getKey(); JobConfig config = jobEntry.getValue(); if (jobId.vuid != vuid) { iterator.remove(); continue; } mirror.android.app.job.JobInfo.jobId.set(job, jobId.clientJobId); mirror.android.app.job.JobInfo.service.set(job, new ComponentName(jobId.packageName, config.serviceName)); } } return jobs; }
private int createSessionInternal(SessionParams params, String installerPackageName, int userId) throws IOException { final int callingUid = VBinder.getCallingUid(); final int sessionId; final PackageInstallerSession session; synchronized (mSessions) { // Sanity check that installer isn't going crazy final int activeCount = getSessionCount(mSessions, callingUid); if (activeCount >= MAX_ACTIVE_SESSIONS) { throw new IllegalStateException( "Too many active sessions for UID " + callingUid); } sessionId = allocateSessionIdLocked(); session = new PackageInstallerSession(mInternalCallback, mContext, mInstallHandler.getLooper(), installerPackageName, sessionId, userId, callingUid, params, VEnvironment.getPackageInstallerStageDir()); } mCallbacks.notifySessionCreated(session.sessionId, session.userId); return sessionId; }
@Override public int schedule(JobInfo job) throws RemoteException { int vuid = VBinder.getCallingUid(); int id = job.getId(); ComponentName service = job.getService(); JobId jobId = new JobId(vuid, service.getPackageName(), id); JobConfig config = mJobStore.get(jobId); if (config == null) { config = new JobConfig(mGlobalJobId++, service.getClassName(), job.getExtras()); mJobStore.put(jobId, config); } else { config.serviceName = service.getClassName(); config.extras = job.getExtras(); } saveJobs(); mirror.android.app.job.JobInfo.jobId.set(job, config.virtualJobId); mirror.android.app.job.JobInfo.service.set(job, mJobProxyComponent); return mScheduler.schedule(job); }
final boolean customTokens = info.desc.customTokens; loginOptions.putInt(AccountManager.KEY_CALLER_UID, VBinder.getCallingUid()); loginOptions.putInt(AccountManager.KEY_CALLER_PID, Binder.getCallingPid()); if (notifyOnAuthFailure) {
/** @hide */ public static int getCallingUserId() { return getUserId(VBinder.getCallingUid()); }
/** @hide */ public static int getCallingUserId() { return getUserId(VBinder.getCallingUid()); }