Loading core/java/android/app/ContextImpl.java +0 −13 Original line number Original line Diff line number Diff line Loading @@ -186,16 +186,6 @@ class ContextImpl extends Context { private static final String XATTR_INODE_CACHE = "user.inode_cache"; private static final String XATTR_INODE_CACHE = "user.inode_cache"; private static final String XATTR_INODE_CODE_CACHE = "user.inode_code_cache"; private static final String XATTR_INODE_CODE_CACHE = "user.inode_code_cache"; /** * Special intent extra that critical system apps can use to hide the notification for a * foreground service. This extra should be placed in the intent passed into {@link * #startForegroundService(Intent)}. * * @hide */ private static final String EXTRA_HIDDEN_FOREGROUND_SERVICE = "android.intent.extra.HIDDEN_FOREGROUND_SERVICE"; /** /** * Map from package name, to preference name, to cached preferences. * Map from package name, to preference name, to cached preferences. */ */ Loading Loading @@ -1717,12 +1707,9 @@ class ContextImpl extends Context { try { try { validateServiceIntent(service); validateServiceIntent(service); service.prepareToLeaveProcess(this); service.prepareToLeaveProcess(this); final boolean hideForegroundNotification = requireForeground && service.getBooleanExtra(EXTRA_HIDDEN_FOREGROUND_SERVICE, false); ComponentName cn = ActivityManager.getService().startService( ComponentName cn = ActivityManager.getService().startService( mMainThread.getApplicationThread(), service, mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(getContentResolver()), requireForeground, service.resolveTypeIfNeeded(getContentResolver()), requireForeground, hideForegroundNotification, getOpPackageName(), getAttributionTag(), user.getIdentifier()); getOpPackageName(), getAttributionTag(), user.getIdentifier()); if (cn != null) { if (cn != null) { if (cn.getPackageName().equals("!")) { if (cn.getPackageName().equals("!")) { Loading core/java/android/app/IActivityManager.aidl +1 −2 Original line number Original line Diff line number Diff line Loading @@ -156,8 +156,7 @@ interface IActivityManager { boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta); boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta); PendingIntent getRunningServiceControlPanel(in ComponentName service); PendingIntent getRunningServiceControlPanel(in ComponentName service); ComponentName startService(in IApplicationThread caller, in Intent service, ComponentName startService(in IApplicationThread caller, in Intent service, in String resolvedType, boolean requireForeground, in String resolvedType, boolean requireForeground, in String callingPackage, boolean hideForegroundNotification, in String callingPackage, in String callingFeatureId, int userId); in String callingFeatureId, int userId); @UnsupportedAppUsage @UnsupportedAppUsage int stopService(in IApplicationThread caller, in Intent service, int stopService(in IApplicationThread caller, in Intent service, Loading services/core/java/com/android/server/am/ActiveServices.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -478,15 +478,15 @@ public final class ActiveServices { } } ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, int callingPid, int callingUid, boolean fgRequired, boolean hideFgNotification, int callingPid, int callingUid, boolean fgRequired, String callingPackage, String callingPackage, @Nullable String callingFeatureId, final int userId) @Nullable String callingFeatureId, final int userId) throws TransactionTooLargeException { throws TransactionTooLargeException { return startServiceLocked(caller, service, resolvedType, callingPid, callingUid, fgRequired, return startServiceLocked(caller, service, resolvedType, callingPid, callingUid, fgRequired, hideFgNotification, callingPackage, callingFeatureId, userId, false, null); callingPackage, callingFeatureId, userId, false, null); } } ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, int callingPid, int callingUid, boolean fgRequired, boolean hideFgNotification, int callingPid, int callingUid, boolean fgRequired, String callingPackage, @Nullable String callingFeatureId, final int userId, String callingPackage, @Nullable String callingFeatureId, final int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) throws TransactionTooLargeException { throws TransactionTooLargeException { Loading Loading @@ -653,7 +653,6 @@ public final class ActiveServices { r.startRequested = true; r.startRequested = true; r.delayedStop = false; r.delayedStop = false; r.fgRequired = fgRequired; r.fgRequired = fgRequired; r.hideFgNotification = hideFgNotification; r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(), r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(), service, neededGrants, callingUid)); service, neededGrants, callingUid)); Loading services/core/java/com/android/server/am/ActivityManagerService.java +5 −31 Original line number Original line Diff line number Diff line Loading @@ -1177,10 +1177,6 @@ public class ActivityManagerService extends IActivityManager.Stub final Injector mInjector; final Injector mInjector; /** The package verifier app. */ private String mPackageVerifier; private int mPackageVerifierUid = UserHandle.USER_NULL; static final class ProcessChangeItem { static final class ProcessChangeItem { static final int CHANGE_ACTIVITIES = 1<<0; static final int CHANGE_ACTIVITIES = 1<<0; static final int CHANGE_FOREGROUND_SERVICES = 1<<1; static final int CHANGE_FOREGROUND_SERVICES = 1<<1; Loading Loading @@ -1809,18 +1805,6 @@ public class ActivityManagerService extends IActivityManager.Stub if (phase == PHASE_SYSTEM_SERVICES_READY) { if (phase == PHASE_SYSTEM_SERVICES_READY) { mService.mBatteryStatsService.systemServicesReady(); mService.mBatteryStatsService.systemServicesReady(); mService.mServices.systemServicesReady(); mService.mServices.systemServicesReady(); mService.mPackageVerifier = ArrayUtils.firstOrNull( LocalServices.getService(PackageManagerInternal.class).getKnownPackageNames( PackageManagerInternal.PACKAGE_VERIFIER, UserHandle.USER_SYSTEM)); if (mService.mPackageVerifier != null) { try { mService.mPackageVerifierUid = getContext().getPackageManager().getPackageUid( mService.mPackageVerifier, UserHandle.USER_SYSTEM); } catch (NameNotFoundException e) { Slog.wtf(TAG, "Package manager couldn't get package verifier uid", e); } } } else if (phase == PHASE_ACTIVITY_MANAGER_READY) { } else if (phase == PHASE_ACTIVITY_MANAGER_READY) { mService.startBroadcastObservers(); mService.startBroadcastObservers(); } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { Loading Loading @@ -12359,8 +12343,8 @@ public class ActivityManagerService extends IActivityManager.Stub @Override @Override public ComponentName startService(IApplicationThread caller, Intent service, public ComponentName startService(IApplicationThread caller, Intent service, String resolvedType, boolean requireForeground, boolean hideForegroundNotification, String resolvedType, boolean requireForeground, String callingPackage, String callingPackage, String callingFeatureId, int userId) String callingFeatureId, int userId) throws TransactionTooLargeException { throws TransactionTooLargeException { enforceNotIsolatedCaller("startService"); enforceNotIsolatedCaller("startService"); // Refuse possible leaked file descriptors // Refuse possible leaked file descriptors Loading @@ -12372,27 +12356,17 @@ public class ActivityManagerService extends IActivityManager.Stub throw new IllegalArgumentException("callingPackage cannot be null"); throw new IllegalArgumentException("callingPackage cannot be null"); } } final int callingUid = Binder.getCallingUid(); if (requireForeground && hideForegroundNotification) { if (!UserHandle.isSameApp(callingUid, mPackageVerifierUid) || !callingPackage.equals(mPackageVerifier)) { throw new IllegalArgumentException( "Only the package verifier can hide its foreground service notification"); } Slog.i(TAG, "Foreground service notification hiding requested by " + callingPackage); } if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "*** startService: " + service + " type=" + resolvedType + " fg=" + requireForeground); "*** startService: " + service + " type=" + resolvedType + " fg=" + requireForeground); synchronized(this) { synchronized(this) { final int callingPid = Binder.getCallingPid(); final int callingPid = Binder.getCallingPid(); final int callingUid = Binder.getCallingUid(); final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity(); ComponentName res; ComponentName res; try { try { res = mServices.startServiceLocked(caller, service, res = mServices.startServiceLocked(caller, service, resolvedType, callingPid, callingUid, resolvedType, callingPid, callingUid, requireForeground, hideForegroundNotification, requireForeground, callingPackage, callingFeatureId, userId); callingPackage, callingFeatureId, userId); } finally { } finally { Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); } } Loading Loading @@ -16305,7 +16279,7 @@ public class ActivityManagerService extends IActivityManager.Stub ComponentName res; ComponentName res; try { try { res = mServices.startServiceLocked(null, service, res = mServices.startServiceLocked(null, service, resolvedType, -1, uid, fgRequired, false, callingPackage, resolvedType, -1, uid, fgRequired, callingPackage, callingFeatureId, userId, allowBackgroundActivityStarts, callingFeatureId, userId, allowBackgroundActivityStarts, backgroundActivityStartsToken); backgroundActivityStartsToken); } finally { } finally { services/core/java/com/android/server/am/ActivityManagerShellCommand.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -655,7 +655,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println("Starting service: " + intent); pw.println("Starting service: " + intent); pw.flush(); pw.flush(); ComponentName cn = mInterface.startService(null, intent, intent.getType(), ComponentName cn = mInterface.startService(null, intent, intent.getType(), asForeground, false, SHELL_PACKAGE_NAME, null, mUserId); asForeground, SHELL_PACKAGE_NAME, null, mUserId); if (cn == null) { if (cn == null) { err.println("Error: Not found; no service started."); err.println("Error: Not found; no service started."); return -1; return -1; Loading Loading
core/java/android/app/ContextImpl.java +0 −13 Original line number Original line Diff line number Diff line Loading @@ -186,16 +186,6 @@ class ContextImpl extends Context { private static final String XATTR_INODE_CACHE = "user.inode_cache"; private static final String XATTR_INODE_CACHE = "user.inode_cache"; private static final String XATTR_INODE_CODE_CACHE = "user.inode_code_cache"; private static final String XATTR_INODE_CODE_CACHE = "user.inode_code_cache"; /** * Special intent extra that critical system apps can use to hide the notification for a * foreground service. This extra should be placed in the intent passed into {@link * #startForegroundService(Intent)}. * * @hide */ private static final String EXTRA_HIDDEN_FOREGROUND_SERVICE = "android.intent.extra.HIDDEN_FOREGROUND_SERVICE"; /** /** * Map from package name, to preference name, to cached preferences. * Map from package name, to preference name, to cached preferences. */ */ Loading Loading @@ -1717,12 +1707,9 @@ class ContextImpl extends Context { try { try { validateServiceIntent(service); validateServiceIntent(service); service.prepareToLeaveProcess(this); service.prepareToLeaveProcess(this); final boolean hideForegroundNotification = requireForeground && service.getBooleanExtra(EXTRA_HIDDEN_FOREGROUND_SERVICE, false); ComponentName cn = ActivityManager.getService().startService( ComponentName cn = ActivityManager.getService().startService( mMainThread.getApplicationThread(), service, mMainThread.getApplicationThread(), service, service.resolveTypeIfNeeded(getContentResolver()), requireForeground, service.resolveTypeIfNeeded(getContentResolver()), requireForeground, hideForegroundNotification, getOpPackageName(), getAttributionTag(), user.getIdentifier()); getOpPackageName(), getAttributionTag(), user.getIdentifier()); if (cn != null) { if (cn != null) { if (cn.getPackageName().equals("!")) { if (cn.getPackageName().equals("!")) { Loading
core/java/android/app/IActivityManager.aidl +1 −2 Original line number Original line Diff line number Diff line Loading @@ -156,8 +156,7 @@ interface IActivityManager { boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta); boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta); PendingIntent getRunningServiceControlPanel(in ComponentName service); PendingIntent getRunningServiceControlPanel(in ComponentName service); ComponentName startService(in IApplicationThread caller, in Intent service, ComponentName startService(in IApplicationThread caller, in Intent service, in String resolvedType, boolean requireForeground, in String resolvedType, boolean requireForeground, in String callingPackage, boolean hideForegroundNotification, in String callingPackage, in String callingFeatureId, int userId); in String callingFeatureId, int userId); @UnsupportedAppUsage @UnsupportedAppUsage int stopService(in IApplicationThread caller, in Intent service, int stopService(in IApplicationThread caller, in Intent service, Loading
services/core/java/com/android/server/am/ActiveServices.java +4 −5 Original line number Original line Diff line number Diff line Loading @@ -478,15 +478,15 @@ public final class ActiveServices { } } ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, int callingPid, int callingUid, boolean fgRequired, boolean hideFgNotification, int callingPid, int callingUid, boolean fgRequired, String callingPackage, String callingPackage, @Nullable String callingFeatureId, final int userId) @Nullable String callingFeatureId, final int userId) throws TransactionTooLargeException { throws TransactionTooLargeException { return startServiceLocked(caller, service, resolvedType, callingPid, callingUid, fgRequired, return startServiceLocked(caller, service, resolvedType, callingPid, callingUid, fgRequired, hideFgNotification, callingPackage, callingFeatureId, userId, false, null); callingPackage, callingFeatureId, userId, false, null); } } ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, ComponentName startServiceLocked(IApplicationThread caller, Intent service, String resolvedType, int callingPid, int callingUid, boolean fgRequired, boolean hideFgNotification, int callingPid, int callingUid, boolean fgRequired, String callingPackage, @Nullable String callingFeatureId, final int userId, String callingPackage, @Nullable String callingFeatureId, final int userId, boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) boolean allowBackgroundActivityStarts, @Nullable IBinder backgroundActivityStartsToken) throws TransactionTooLargeException { throws TransactionTooLargeException { Loading Loading @@ -653,7 +653,6 @@ public final class ActiveServices { r.startRequested = true; r.startRequested = true; r.delayedStop = false; r.delayedStop = false; r.fgRequired = fgRequired; r.fgRequired = fgRequired; r.hideFgNotification = hideFgNotification; r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(), r.pendingStarts.add(new ServiceRecord.StartItem(r, false, r.makeNextStartId(), service, neededGrants, callingUid)); service, neededGrants, callingUid)); Loading
services/core/java/com/android/server/am/ActivityManagerService.java +5 −31 Original line number Original line Diff line number Diff line Loading @@ -1177,10 +1177,6 @@ public class ActivityManagerService extends IActivityManager.Stub final Injector mInjector; final Injector mInjector; /** The package verifier app. */ private String mPackageVerifier; private int mPackageVerifierUid = UserHandle.USER_NULL; static final class ProcessChangeItem { static final class ProcessChangeItem { static final int CHANGE_ACTIVITIES = 1<<0; static final int CHANGE_ACTIVITIES = 1<<0; static final int CHANGE_FOREGROUND_SERVICES = 1<<1; static final int CHANGE_FOREGROUND_SERVICES = 1<<1; Loading Loading @@ -1809,18 +1805,6 @@ public class ActivityManagerService extends IActivityManager.Stub if (phase == PHASE_SYSTEM_SERVICES_READY) { if (phase == PHASE_SYSTEM_SERVICES_READY) { mService.mBatteryStatsService.systemServicesReady(); mService.mBatteryStatsService.systemServicesReady(); mService.mServices.systemServicesReady(); mService.mServices.systemServicesReady(); mService.mPackageVerifier = ArrayUtils.firstOrNull( LocalServices.getService(PackageManagerInternal.class).getKnownPackageNames( PackageManagerInternal.PACKAGE_VERIFIER, UserHandle.USER_SYSTEM)); if (mService.mPackageVerifier != null) { try { mService.mPackageVerifierUid = getContext().getPackageManager().getPackageUid( mService.mPackageVerifier, UserHandle.USER_SYSTEM); } catch (NameNotFoundException e) { Slog.wtf(TAG, "Package manager couldn't get package verifier uid", e); } } } else if (phase == PHASE_ACTIVITY_MANAGER_READY) { } else if (phase == PHASE_ACTIVITY_MANAGER_READY) { mService.startBroadcastObservers(); mService.startBroadcastObservers(); } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { } else if (phase == PHASE_THIRD_PARTY_APPS_CAN_START) { Loading Loading @@ -12359,8 +12343,8 @@ public class ActivityManagerService extends IActivityManager.Stub @Override @Override public ComponentName startService(IApplicationThread caller, Intent service, public ComponentName startService(IApplicationThread caller, Intent service, String resolvedType, boolean requireForeground, boolean hideForegroundNotification, String resolvedType, boolean requireForeground, String callingPackage, String callingPackage, String callingFeatureId, int userId) String callingFeatureId, int userId) throws TransactionTooLargeException { throws TransactionTooLargeException { enforceNotIsolatedCaller("startService"); enforceNotIsolatedCaller("startService"); // Refuse possible leaked file descriptors // Refuse possible leaked file descriptors Loading @@ -12372,27 +12356,17 @@ public class ActivityManagerService extends IActivityManager.Stub throw new IllegalArgumentException("callingPackage cannot be null"); throw new IllegalArgumentException("callingPackage cannot be null"); } } final int callingUid = Binder.getCallingUid(); if (requireForeground && hideForegroundNotification) { if (!UserHandle.isSameApp(callingUid, mPackageVerifierUid) || !callingPackage.equals(mPackageVerifier)) { throw new IllegalArgumentException( "Only the package verifier can hide its foreground service notification"); } Slog.i(TAG, "Foreground service notification hiding requested by " + callingPackage); } if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, "*** startService: " + service + " type=" + resolvedType + " fg=" + requireForeground); "*** startService: " + service + " type=" + resolvedType + " fg=" + requireForeground); synchronized(this) { synchronized(this) { final int callingPid = Binder.getCallingPid(); final int callingPid = Binder.getCallingPid(); final int callingUid = Binder.getCallingUid(); final long origId = Binder.clearCallingIdentity(); final long origId = Binder.clearCallingIdentity(); ComponentName res; ComponentName res; try { try { res = mServices.startServiceLocked(caller, service, res = mServices.startServiceLocked(caller, service, resolvedType, callingPid, callingUid, resolvedType, callingPid, callingUid, requireForeground, hideForegroundNotification, requireForeground, callingPackage, callingFeatureId, userId); callingPackage, callingFeatureId, userId); } finally { } finally { Binder.restoreCallingIdentity(origId); Binder.restoreCallingIdentity(origId); } } Loading Loading @@ -16305,7 +16279,7 @@ public class ActivityManagerService extends IActivityManager.Stub ComponentName res; ComponentName res; try { try { res = mServices.startServiceLocked(null, service, res = mServices.startServiceLocked(null, service, resolvedType, -1, uid, fgRequired, false, callingPackage, resolvedType, -1, uid, fgRequired, callingPackage, callingFeatureId, userId, allowBackgroundActivityStarts, callingFeatureId, userId, allowBackgroundActivityStarts, backgroundActivityStartsToken); backgroundActivityStartsToken); } finally { } finally {
services/core/java/com/android/server/am/ActivityManagerShellCommand.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -655,7 +655,7 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println("Starting service: " + intent); pw.println("Starting service: " + intent); pw.flush(); pw.flush(); ComponentName cn = mInterface.startService(null, intent, intent.getType(), ComponentName cn = mInterface.startService(null, intent, intent.getType(), asForeground, false, SHELL_PACKAGE_NAME, null, mUserId); asForeground, SHELL_PACKAGE_NAME, null, mUserId); if (cn == null) { if (cn == null) { err.println("Error: Not found; no service started."); err.println("Error: Not found; no service started."); return -1; return -1; Loading