/** @hide */ public static int getCallingUserId() { return getUserId(VBinder.getCallingUid()); }
public static int getBaseCallingUid() { return VUserHandle.getAppId(getCallingUid()); }
/** @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 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 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(); } } }
/** * 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); } }
public static VUserHandle getCallingUserHandle() { return new VUserHandle(VUserHandle.getUserId(getCallingUid())); } }
@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()); }
public static int getBaseCallingUid() { return VUserHandle.getAppId(getCallingUid()); }
public static int getBaseCallingUid() { return VUserHandle.getAppId(getCallingUid()); }
/** @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; }
/** @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; }
/** * 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); } }
public static VUserHandle getCallingUserHandle() { return new VUserHandle(VUserHandle.getUserId(getCallingUid())); } }
public static VUserHandle getCallingUserHandle() { return new VUserHandle(VUserHandle.getUserId(getCallingUid())); } }