Merge "Update references to the RUN_LONG_JOBS permission."
This commit is contained in:
@@ -437,7 +437,7 @@ public class Settings extends SettingsActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/** Actviity to manage apps with {@link android.Manifest.permission#RUN_LONG_JOBS} */
|
||||
/** Actviity to manage apps with {@link android.Manifest.permission#RUN_USER_INITIATED_JOBS} */
|
||||
public static class LongBackgroundTasksActivity extends SettingsActivity { /* empty */ }
|
||||
/** App specific version of {@link LongBackgroundTasksActivity} */
|
||||
public static class LongBackgroundTasksAppActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -37,11 +37,11 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* Connects app op info to the ApplicationsState. Extends {@link AppStateAppOpsBridge} to tailor
|
||||
* to the semantics of {@link Manifest.permission#RUN_LONG_JOBS}.
|
||||
* to the semantics of {@link Manifest.permission#RUN_USER_INITIATED_JOBS}.
|
||||
* Also provides app filters that can use the info.
|
||||
*/
|
||||
public class AppStateLongBackgroundTasksBridge extends AppStateBaseBridge {
|
||||
private static final String PERMISSION = Manifest.permission.RUN_LONG_JOBS;
|
||||
private static final String PERMISSION = Manifest.permission.RUN_USER_INITIATED_JOBS;
|
||||
private static final String TAG = "LongBackgroundTasksBridge";
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -64,15 +64,15 @@ public class AppStateLongBackgroundTasksBridge extends AppStateBaseBridge {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information regarding {@link Manifest.permission#RUN_LONG_JOBS} for the given
|
||||
* package and uid.
|
||||
* Returns information regarding {@link Manifest.permission#RUN_USER_INITIATED_JOBS} for the
|
||||
* given package and uid.
|
||||
*/
|
||||
public LongBackgroundTasksState createPermissionState(String packageName, int uid) {
|
||||
final int userId = UserHandle.getUserId(uid);
|
||||
|
||||
final boolean permissionRequested = ArrayUtils.contains(mRequesterPackages, packageName);
|
||||
final boolean permissionGranted = mJobScheduler.hasRunLongJobsPermission(packageName,
|
||||
userId);
|
||||
final boolean permissionGranted = mJobScheduler.hasRunUserInitiatedJobsPermission(
|
||||
packageName, userId);
|
||||
return new LongBackgroundTasksState(permissionRequested, permissionGranted);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class AppStateLongBackgroundTasksBridge extends AppStateBaseBridge {
|
||||
|
||||
/**
|
||||
* Class to denote the state of an app regarding
|
||||
* {@link Manifest.permission#RUN_LONG_JOBS}.
|
||||
* {@link Manifest.permission#RUN_USER_INITIATED_JOBS}.
|
||||
*/
|
||||
public static class LongBackgroundTasksState {
|
||||
private boolean mPermissionRequested;
|
||||
|
@@ -16,8 +16,8 @@
|
||||
|
||||
package com.android.settings.applications;
|
||||
|
||||
import static android.Manifest.permission.RUN_LONG_JOBS;
|
||||
import static android.app.AppOpsManager.OP_RUN_LONG_JOBS;
|
||||
import static android.Manifest.permission.RUN_USER_INITIATED_JOBS;
|
||||
import static android.app.AppOpsManager.OP_RUN_USER_INITIATED_JOBS;
|
||||
import static android.app.AppOpsManager.opToPermission;
|
||||
|
||||
import android.Manifest;
|
||||
@@ -345,6 +345,7 @@ public class ApplicationFeatureProviderImpl implements ApplicationFeatureProvide
|
||||
|
||||
@Override
|
||||
public boolean isLongBackgroundTaskPermissionToggleSupported() {
|
||||
return TextUtils.equals(RUN_LONG_JOBS, opToPermission(OP_RUN_LONG_JOBS));
|
||||
return TextUtils.equals(RUN_USER_INITIATED_JOBS,
|
||||
opToPermission(OP_RUN_USER_INITIATED_JOBS));
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
|
||||
/**
|
||||
* App specific activity to show details about
|
||||
* {@link android.Manifest.permission#RUN_LONG_JOBS}.
|
||||
* {@link android.Manifest.permission#RUN_USER_INITIATED_JOBS}.
|
||||
*/
|
||||
public class LongBackgroundTasksDetails extends AppInfoWithHeader
|
||||
implements OnPreferenceChangeListener {
|
||||
@@ -52,7 +52,7 @@ public class LongBackgroundTasksDetails extends AppInfoWithHeader
|
||||
|
||||
/**
|
||||
* Returns the string that states whether the app has access to
|
||||
* {@link android.Manifest.permission#RUN_LONG_JOBS}.
|
||||
* {@link android.Manifest.permission#RUN_USER_INITIATED_JOBS}.
|
||||
*/
|
||||
public static CharSequence getSummary(Context context, AppEntry entry) {
|
||||
final AppStateLongBackgroundTasksBridge.LongBackgroundTasksState state =
|
||||
@@ -104,9 +104,9 @@ public class LongBackgroundTasksDetails extends AppInfoWithHeader
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setCanRunLongJobs(boolean newState) {
|
||||
private void setCanRunUserInitiatedJobs(boolean newState) {
|
||||
final int uid = mPackageInfo.applicationInfo.uid;
|
||||
mAppOpsManager.setUidMode(AppOpsManager.OPSTR_RUN_LONG_JOBS, uid,
|
||||
mAppOpsManager.setUidMode(AppOpsManager.OPSTR_RUN_USER_INITIATED_JOBS, uid,
|
||||
newState ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_ERRORED);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class LongBackgroundTasksDetails extends AppInfoWithHeader
|
||||
}
|
||||
if (mPermissionState != null && mUncommittedState != null
|
||||
&& mUncommittedState != mPermissionState.isAllowed()) {
|
||||
setCanRunLongJobs(mUncommittedState);
|
||||
setCanRunUserInitiatedJobs(mUncommittedState);
|
||||
logPermissionChange(mUncommittedState, mPackageName);
|
||||
mUncommittedState = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user