E FATAL EXCEPTION: main Process: com.android.vending, PID: 9176 java.lang.RuntimeException: Unable to start service com.google.android.finsky.setup.VpaService@14bce4b with Intent { dat=vpaservice://startvpafordeferredsetupnotification/... cmp=com.android.vending/com.google.android.finsky.setup.VpaService }: java.lang.SecurityException: Starting FGS with type systemExempted callerApp=ProcessRecord{119f011 9176:com.android.vending/u0a128} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED] any of the permissions allOf=false [android.permission.SCHEDULE_EXACT_ALARM, android.permission.USE_EXACT_ALARM, android:activate_vpn] at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5100) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2432) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8592) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878) Caused by: java.lang.SecurityException: Starting FGS with type systemExempted callerApp=ProcessRecord{119f011 9176:com.android.vending/u0a128} targetSDK=34requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_SYSTEM_EXEMPTED] any of the permissions allOf=false [android.permission.SCHEDULE_EXACT_ALARM, android.permission.USE_EXACT_ALARM, android:activate_vpn] at android.os.Parcel.createExceptionOrNull(Parcel.java:3183) at android.os.Parcel.createException(Parcel.java:3167) at android.os.Parcel.readException(Parcel.java:3150) at android.os.Parcel.readException(Parcel.java:3092) at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6960) at android.app.Service.startForeground(Service.java:776) at com.google.android.finsky.setup.VpaService.onStartCommand(PG:112) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5082) at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2432) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loopOnce(Looper.java:232) at android.os.Looper.loop(Looper.java:317) at android.app.ActivityThread.main(ActivityThread.java:8592) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878) Caused by: android.os.RemoteException: Remote stack trace: at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2842) at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2530) at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1806) at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13793) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3483)
@Override publicintcheckPermission(@NonNull Context context, int callerUid, int callerPid, @NonNull String packageName, boolean allowWhileInUse) { finalAppRestrictionControllerappRestrictionController= mAm.mAppRestrictionController; @ReasonCodeintreason= appRestrictionController .getPotentialSystemExemptionReason(callerUid); if (reason == REASON_DENIED) { reason = appRestrictionController .getPotentialSystemExemptionReason(callerUid, packageName); if (reason == REASON_DENIED) { reason = appRestrictionController .getPotentialUserAllowedExemptionReason(callerUid, packageName); } } if (reason == REASON_DENIED) { if (ArrayUtils.contains(mAm.getPackageManagerInternal().getKnownPackageNames( KnownPackages.PACKAGE_INSTALLER, UserHandle.USER_SYSTEM), packageName)) { reason = REASON_PACKAGE_INSTALLER; } }
switch (reason) { case REASON_SYSTEM_UID: case REASON_SYSTEM_ALLOW_LISTED: case REASON_DEVICE_DEMO_MODE: case REASON_DISALLOW_APPS_CONTROL: case REASON_DEVICE_OWNER: case REASON_PROFILE_OWNER: case REASON_PROC_STATE_PERSISTENT: case REASON_PROC_STATE_PERSISTENT_UI: case REASON_SYSTEM_MODULE: case REASON_CARRIER_PRIVILEGED_APP: case REASON_DPO_PROTECTED_APP: case REASON_ACTIVE_DEVICE_ADMIN: case REASON_ROLE_EMERGENCY: case REASON_ALLOWLISTED_PACKAGE: case REASON_PACKAGE_INSTALLER: case REASON_SYSTEM_EXEMPT_APP_OP: return PERMISSION_GRANTED; default: return PERMISSION_DENIED; } } }
/** * @param uid The uid to check. * @return The potential exemption reason of the given uid. The caller must decide * whether or not it should be exempted. */ @ReasonCode intgetPotentialSystemExemptionReason(int uid) { if (UserHandle.isCore(uid)) { return REASON_SYSTEM_UID; } if (isOnSystemDeviceIdleAllowlist(uid)) { return REASON_SYSTEM_ALLOW_LISTED; } if (UserManager.isDeviceInDemoMode(mContext)) { return REASON_DEVICE_DEMO_MODE; } finalintuserId= UserHandle.getUserId(uid); if (mInjector.getUserManagerInternal() .hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL, userId)) { return REASON_DISALLOW_APPS_CONTROL; } finalActivityManagerInternalam= mInjector.getActivityManagerInternal(); if (am.isDeviceOwner(uid)) { return REASON_DEVICE_OWNER; } if (am.isProfileOwner(uid)) { return REASON_PROFILE_OWNER; } finalintuidProcState= am.getUidProcessState(uid); if (uidProcState <= PROCESS_STATE_PERSISTENT) { return REASON_PROC_STATE_PERSISTENT; } elseif (uidProcState <= PROCESS_STATE_PERSISTENT_UI) { return REASON_PROC_STATE_PERSISTENT_UI; } return REASON_DENIED; }