Merge "Add a new intent to navigate to the long background tasks page."
This commit is contained in:
committed by
Android (Google) Code Review
commit
7e9b6513b6
@@ -102,6 +102,15 @@ public class JobSchedulerImpl extends JobScheduler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRunLongJobsPermission(String packageName, int userId) {
|
||||
try {
|
||||
return mBinder.hasRunLongJobsPermission(packageName, userId);
|
||||
} catch (RemoteException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JobInfo> getStartedJobs() {
|
||||
try {
|
||||
|
||||
@@ -33,6 +33,7 @@ interface IJobScheduler {
|
||||
void cancelAll();
|
||||
ParceledListSlice getAllPendingJobs();
|
||||
JobInfo getPendingJob(int jobId);
|
||||
boolean hasRunLongJobsPermission(String packageName, int userId);
|
||||
List<JobInfo> getStartedJobs();
|
||||
ParceledListSlice getAllJobSnapshots();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.annotation.Nullable;
|
||||
import android.annotation.RequiresPermission;
|
||||
import android.annotation.SystemApi;
|
||||
import android.annotation.SystemService;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.compat.annotation.ChangeId;
|
||||
import android.compat.annotation.EnabledAfter;
|
||||
import android.content.ClipData;
|
||||
@@ -248,6 +249,15 @@ public abstract class JobScheduler {
|
||||
*/
|
||||
public abstract @Nullable JobInfo getPendingJob(int jobId);
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the app currently holds the
|
||||
* {@link android.Manifest.permission#RUN_LONG_JOBS} permission, allowing it to run long jobs.
|
||||
* @hide
|
||||
*/
|
||||
public boolean hasRunLongJobsPermission(@NonNull String packageName, @UserIdInt int userId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>For internal system callers only!</b>
|
||||
* Returns a list of all currently-executing jobs.
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManagerInternal;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.IUidObserver;
|
||||
import android.app.compat.CompatChanges;
|
||||
import android.app.job.IJobScheduler;
|
||||
@@ -304,6 +305,7 @@ public class JobSchedulerService extends com.android.server.SystemService
|
||||
final JobHandler mHandler;
|
||||
final JobSchedulerStub mJobSchedulerStub;
|
||||
|
||||
private AppOpsManager mAppOps;
|
||||
PackageManagerInternal mLocalPM;
|
||||
ActivityManagerInternal mActivityManagerInternal;
|
||||
DeviceIdleInternal mLocalDeviceIdleController;
|
||||
@@ -1804,6 +1806,8 @@ public class JobSchedulerService extends com.android.server.SystemService
|
||||
controller.onSystemServicesReady();
|
||||
}
|
||||
|
||||
mAppOps = (AppOpsManager) getContext().getSystemService(Context.APP_OPS_SERVICE);
|
||||
|
||||
mAppStateTracker = (AppStateTrackerImpl) Objects.requireNonNull(
|
||||
LocalServices.getService(AppStateTracker.class));
|
||||
|
||||
@@ -3409,6 +3413,21 @@ public class JobSchedulerService extends com.android.server.SystemService
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRunLongJobsPermission(@NonNull String packageName,
|
||||
@UserIdInt int userId) {
|
||||
final int uid = mLocalPM.getPackageUid(packageName, 0, userId);
|
||||
final int callingUid = Binder.getCallingUid();
|
||||
if (callingUid != uid && !UserHandle.isCore(callingUid)) {
|
||||
throw new SecurityException("Uid " + callingUid
|
||||
+ " cannot query canRunLongJobs for package " + packageName);
|
||||
}
|
||||
|
||||
final int mode = mAppOps.checkOpNoThrow(AppOpsManager.OP_RUN_LONG_JOBS, uid,
|
||||
packageName);
|
||||
return mode == AppOpsManager.MODE_ALLOWED || mode == AppOpsManager.MODE_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* "dumpsys" infrastructure
|
||||
*/
|
||||
|
||||
@@ -35860,6 +35860,7 @@ package android.provider {
|
||||
field public static final String ACTION_MANAGE_ALL_SIM_PROFILES_SETTINGS = "android.settings.MANAGE_ALL_SIM_PROFILES_SETTINGS";
|
||||
field public static final String ACTION_MANAGE_APPLICATIONS_SETTINGS = "android.settings.MANAGE_APPLICATIONS_SETTINGS";
|
||||
field public static final String ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION = "android.settings.MANAGE_APP_ALL_FILES_ACCESS_PERMISSION";
|
||||
field public static final String ACTION_MANAGE_APP_LONG_JOBS = "android.settings.MANAGE_APP_LONG_JOBS";
|
||||
field public static final String ACTION_MANAGE_DEFAULT_APPS_SETTINGS = "android.settings.MANAGE_DEFAULT_APPS_SETTINGS";
|
||||
field public static final String ACTION_MANAGE_OVERLAY_PERMISSION = "android.settings.action.MANAGE_OVERLAY_PERMISSION";
|
||||
field public static final String ACTION_MANAGE_SUPERVISOR_RESTRICTED_SETTING = "android.settings.MANAGE_SUPERVISOR_RESTRICTED_SETTING";
|
||||
|
||||
@@ -586,6 +586,22 @@ public final class Settings {
|
||||
public static final String ACTION_REQUEST_MANAGE_MEDIA =
|
||||
"android.settings.REQUEST_MANAGE_MEDIA";
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to allow configuration of
|
||||
* {@link Manifest.permission#RUN_LONG_JOBS} permission
|
||||
*
|
||||
* Input: Optionally, the Intent's data URI can specify the application package name to
|
||||
* directly invoke the management GUI specific to the package name. For example
|
||||
* "package:com.my.app".
|
||||
* <p>
|
||||
* Output: When a package data uri is passed as input, the activity result is set to
|
||||
* {@link android.app.Activity#RESULT_OK} if the permission was granted to the app. Otherwise,
|
||||
* the result is set to {@link android.app.Activity#RESULT_CANCELED}.
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
|
||||
public static final String ACTION_MANAGE_APP_LONG_JOBS =
|
||||
"android.settings.MANAGE_APP_LONG_JOBS";
|
||||
|
||||
/**
|
||||
* Activity Action: Show settings to allow configuration of cross-profile access for apps
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user