Loading apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -2590,13 +2590,14 @@ public class JobSchedulerService extends com.android.server.SystemService // job that runs one of the app's services, as well as verifying that the // job that runs one of the app's services, as well as verifying that the // named service properly requires the BIND_JOB_SERVICE permission // named service properly requires the BIND_JOB_SERVICE permission private void enforceValidJobRequest(int uid, JobInfo job) { private void enforceValidJobRequest(int uid, JobInfo job) { final IPackageManager pm = AppGlobals.getPackageManager(); final PackageManager pm = getContext() .createContextAsUser(UserHandle.getUserHandleForUid(uid), 0) .getPackageManager(); final ComponentName service = job.getService(); final ComponentName service = job.getService(); try { try { ServiceInfo si = pm.getServiceInfo(service, ServiceInfo si = pm.getServiceInfo(service, PackageManager.MATCH_DIRECT_BOOT_AWARE PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, | PackageManager.MATCH_DIRECT_BOOT_UNAWARE); UserHandle.getUserId(uid)); if (si == null) { if (si == null) { throw new IllegalArgumentException("No such service " + service); throw new IllegalArgumentException("No such service " + service); } } Loading @@ -2608,8 +2609,10 @@ public class JobSchedulerService extends com.android.server.SystemService throw new IllegalArgumentException("Scheduled service " + service throw new IllegalArgumentException("Scheduled service " + service + " does not require android.permission.BIND_JOB_SERVICE permission"); + " does not require android.permission.BIND_JOB_SERVICE permission"); } } } catch (RemoteException e) { } catch (NameNotFoundException e) { // Can't happen; the Package Manager is in this same process throw new IllegalArgumentException( "Tried to schedule job for non-existent package: " + service.getPackageName()); } } } } Loading apex/jobscheduler/service/java/com/android/server/job/controllers/ComponentController.java +10 −6 Original line number Original line Diff line number Diff line Loading @@ -18,16 +18,15 @@ package com.android.server.job.controllers; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.AppGlobals; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo; import android.net.Uri; import android.net.Uri; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserHandle; import android.util.IndentingPrintWriter; import android.util.IndentingPrintWriter; import android.util.Log; import android.util.Log; Loading Loading @@ -116,10 +115,15 @@ public class ComponentController extends StateController { ServiceInfo si = mServiceInfoCache.get(userId, service); ServiceInfo si = mServiceInfoCache.get(userId, service); if (si == null) { if (si == null) { try { try { si = AppGlobals.getPackageManager().getServiceInfo( // createContextAsUser may potentially be expensive service, PackageManager.MATCH_DIRECT_BOOT_AUTO, userId); // TODO: cache user context or improve ContextImpl implementation if this becomes } catch (RemoteException e) { // a problem throw new RuntimeException(e); si = mContext.createContextAsUser(UserHandle.of(userId), 0) .getPackageManager() .getServiceInfo(service, PackageManager.MATCH_DIRECT_BOOT_AUTO); } catch (NameNotFoundException e) { Slog.e(TAG, "Job exists for non-existent package: " + service.getPackageName()); return null; } } mServiceInfoCache.add(userId, service, si); mServiceInfoCache.add(userId, service, si); } } Loading Loading
apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +8 −5 Original line number Original line Diff line number Diff line Loading @@ -2590,13 +2590,14 @@ public class JobSchedulerService extends com.android.server.SystemService // job that runs one of the app's services, as well as verifying that the // job that runs one of the app's services, as well as verifying that the // named service properly requires the BIND_JOB_SERVICE permission // named service properly requires the BIND_JOB_SERVICE permission private void enforceValidJobRequest(int uid, JobInfo job) { private void enforceValidJobRequest(int uid, JobInfo job) { final IPackageManager pm = AppGlobals.getPackageManager(); final PackageManager pm = getContext() .createContextAsUser(UserHandle.getUserHandleForUid(uid), 0) .getPackageManager(); final ComponentName service = job.getService(); final ComponentName service = job.getService(); try { try { ServiceInfo si = pm.getServiceInfo(service, ServiceInfo si = pm.getServiceInfo(service, PackageManager.MATCH_DIRECT_BOOT_AWARE PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, | PackageManager.MATCH_DIRECT_BOOT_UNAWARE); UserHandle.getUserId(uid)); if (si == null) { if (si == null) { throw new IllegalArgumentException("No such service " + service); throw new IllegalArgumentException("No such service " + service); } } Loading @@ -2608,8 +2609,10 @@ public class JobSchedulerService extends com.android.server.SystemService throw new IllegalArgumentException("Scheduled service " + service throw new IllegalArgumentException("Scheduled service " + service + " does not require android.permission.BIND_JOB_SERVICE permission"); + " does not require android.permission.BIND_JOB_SERVICE permission"); } } } catch (RemoteException e) { } catch (NameNotFoundException e) { // Can't happen; the Package Manager is in this same process throw new IllegalArgumentException( "Tried to schedule job for non-existent package: " + service.getPackageName()); } } } } Loading
apex/jobscheduler/service/java/com/android/server/job/controllers/ComponentController.java +10 −6 Original line number Original line Diff line number Diff line Loading @@ -18,16 +18,15 @@ package com.android.server.job.controllers; import android.annotation.NonNull; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.Nullable; import android.app.AppGlobals; import android.content.BroadcastReceiver; import android.content.BroadcastReceiver; import android.content.ComponentName; import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo; import android.net.Uri; import android.net.Uri; import android.os.RemoteException; import android.os.UserHandle; import android.os.UserHandle; import android.util.IndentingPrintWriter; import android.util.IndentingPrintWriter; import android.util.Log; import android.util.Log; Loading Loading @@ -116,10 +115,15 @@ public class ComponentController extends StateController { ServiceInfo si = mServiceInfoCache.get(userId, service); ServiceInfo si = mServiceInfoCache.get(userId, service); if (si == null) { if (si == null) { try { try { si = AppGlobals.getPackageManager().getServiceInfo( // createContextAsUser may potentially be expensive service, PackageManager.MATCH_DIRECT_BOOT_AUTO, userId); // TODO: cache user context or improve ContextImpl implementation if this becomes } catch (RemoteException e) { // a problem throw new RuntimeException(e); si = mContext.createContextAsUser(UserHandle.of(userId), 0) .getPackageManager() .getServiceInfo(service, PackageManager.MATCH_DIRECT_BOOT_AUTO); } catch (NameNotFoundException e) { Slog.e(TAG, "Job exists for non-existent package: " + service.getPackageName()); return null; } } mServiceInfoCache.add(userId, service, si); mServiceInfoCache.add(userId, service, si); } } Loading