Merge "Update language to comply with Android's inclusive language guidance" am: 48c50ccdfe

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1426648

Change-Id: I5b1d2fb0544011d23f93f2390bdb639f0fd5ee77
This commit is contained in:
Treehugger Robot
2020-09-23 23:52:42 +00:00
committed by Automerger Merge Worker
13 changed files with 160 additions and 159 deletions

View File

@@ -963,7 +963,7 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
/** @hide */
public static final int LOCK_TASK_LAUNCH_MODE_ALWAYS = 2;
/** @hide */
public static final int LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED = 3;
public static final int LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED = 3;
/** @hide */
public static final String lockTaskLaunchModeToString(int lockTaskLaunchMode) {
@@ -974,8 +974,8 @@ public class ActivityInfo extends ComponentInfo implements Parcelable {
return "LOCK_TASK_LAUNCH_MODE_NEVER";
case LOCK_TASK_LAUNCH_MODE_ALWAYS:
return "LOCK_TASK_LAUNCH_MODE_ALWAYS";
case LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED:
return "LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED";
case LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED:
return "LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED";
default:
return "unknown=" + lockTaskLaunchMode;
}

View File

@@ -32,13 +32,13 @@ final class PendingTempWhitelists {
void put(int uid, ActivityManagerService.PendingTempWhitelist value) {
mPendingTempWhitelist.put(uid, value);
mService.mAtmInternal.onUidAddedToPendingTempWhitelist(uid, value.tag);
mService.mAtmInternal.onUidAddedToPendingTempAllowlist(uid, value.tag);
}
void removeAt(int index) {
final int uid = mPendingTempWhitelist.keyAt(index);
mPendingTempWhitelist.removeAt(index);
mService.mAtmInternal.onUidRemovedFromPendingTempWhitelist(uid);
mService.mAtmInternal.onUidRemovedFromPendingTempAllowlist(uid);
}
ActivityManagerService.PendingTempWhitelist get(int uid) {

View File

@@ -70,7 +70,7 @@ import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TOP;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
import static android.content.pm.ActivityInfo.PERSIST_ACROSS_REBOOTS;
import static android.content.pm.ActivityInfo.PERSIST_ROOT_ONLY;
@@ -1679,7 +1679,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (options != null) {
final boolean useLockTask = options.getLockTaskMode();
if (useLockTask && lockTaskLaunchMode == LOCK_TASK_LAUNCH_MODE_DEFAULT) {
lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
lockTaskLaunchMode = LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED;
}
}
return lockTaskLaunchMode;

View File

@@ -75,9 +75,9 @@ import static com.android.server.wm.RootWindowContainer.TAG_STATES;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_RECENTS;
import static com.android.server.wm.Task.FLAG_FORCE_HIDDEN_FOR_PINNED_TASK;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_ALLOWLISTED;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_LAUNCHABLE;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_WHITELISTED;
import static com.android.server.wm.Task.REPARENT_KEEP_STACK_AT_FRONT;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
@@ -788,7 +788,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
final LockTaskController lockTaskController = mService.getLockTaskController();
if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
|| task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV
|| (task.mLockTaskAuth == LOCK_TASK_AUTH_WHITELISTED
|| (task.mLockTaskAuth == LOCK_TASK_AUTH_ALLOWLISTED
&& lockTaskController.getLockTaskModeState()
== LOCK_TASK_MODE_LOCKED)) {
lockTaskController.startLockTaskMode(task, false, 0 /* blank UID */);

View File

@@ -510,8 +510,8 @@ public abstract class ActivityTaskManagerInternal {
public abstract void onActiveUidsCleared();
public abstract void onUidProcStateChanged(int uid, int procState);
public abstract void onUidAddedToPendingTempWhitelist(int uid, String tag);
public abstract void onUidRemovedFromPendingTempWhitelist(int uid);
public abstract void onUidAddedToPendingTempAllowlist(int uid, String tag);
public abstract void onUidRemovedFromPendingTempAllowlist(int uid);
/** Handle app crash event in {@link android.app.IActivityController} if there is one. */
public abstract boolean handleAppCrashInActivityController(String processName, int pid,

View File

@@ -386,7 +386,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
private AppOpsManager mAppOpsManager;
/** All active uids in the system. */
private final MirrorActiveUids mActiveUids = new MirrorActiveUids();
private final SparseArray<String> mPendingTempWhitelist = new SparseArray<>();
private final SparseArray<String> mPendingTempAllowlist = new SparseArray<>();
/** All processes currently running that might have a window organized by name. */
final ProcessMap<WindowProcessController> mProcessNames = new ProcessMap<>();
/** All processes we currently have running mapped by pid and uid */
@@ -1103,7 +1103,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
@Override
public int startActivityIntentSender(IApplicationThread caller, IIntentSender target,
IBinder whitelistToken, Intent fillInIntent, String resolvedType, IBinder resultTo,
IBinder allowlistToken, Intent fillInIntent, String resolvedType, IBinder resultTo,
String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions) {
enforceNotIsolatedCaller("startActivityIntentSender");
// Refuse possible leaked file descriptors
@@ -1126,7 +1126,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
mAppSwitchesAllowedTime = 0;
}
}
return pir.sendInner(0, fillInIntent, resolvedType, whitelistToken, null, null,
return pir.sendInner(0, fillInIntent, resolvedType, allowlistToken, null, null,
resultTo, resultWho, requestCode, flagsMask, flagsValues, bOptions);
}
@@ -3035,7 +3035,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
// system or a specific app.
// * System-initiated requests will only start the pinned mode (screen pinning)
// * App-initiated requests
// - will put the device in fully locked mode (LockTask), if the app is whitelisted
// - will put the device in fully locked mode (LockTask), if the app is allowlisted
// - will start the pinned mode, otherwise
final int callingUid = Binder.getCallingUid();
long ident = Binder.clearCallingIdentity();
@@ -3075,7 +3075,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
"updateLockTaskPackages()");
}
synchronized (mGlobalLock) {
if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Whitelisting " + userId + ":"
if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Allowlisting " + userId + ":"
+ Arrays.toString(packages));
getLockTaskController().updateLockTaskPackages(userId, packages);
}
@@ -5964,11 +5964,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
/**
* @return whitelist tag for a uid from mPendingTempWhitelist, null if not currently on
* the whitelist
* @return allowlist tag for a uid from mPendingTempAllowlist, null if not currently on
* the allowlist
*/
String getPendingTempWhitelistTagForUidLocked(int uid) {
return mPendingTempWhitelist.get(uid);
String getPendingTempAllowlistTagForUidLocked(int uid) {
return mPendingTempAllowlist.get(uid);
}
void logAppTooSlow(WindowProcessController app, long startTime, String msg) {
@@ -7297,16 +7297,16 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
@Override
public void onUidAddedToPendingTempWhitelist(int uid, String tag) {
public void onUidAddedToPendingTempAllowlist(int uid, String tag) {
synchronized (mGlobalLockWithoutBoost) {
mPendingTempWhitelist.put(uid, tag);
mPendingTempAllowlist.put(uid, tag);
}
}
@Override
public void onUidRemovedFromPendingTempWhitelist(int uid) {
public void onUidRemovedFromPendingTempAllowlist(int uid) {
synchronized (mGlobalLockWithoutBoost) {
mPendingTempWhitelist.remove(uid);
mPendingTempAllowlist.remove(uid);
}
}

View File

@@ -33,11 +33,11 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_LOCKTAS
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_LOCKTASK;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_ALLOWLISTED;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_LAUNCHABLE;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_PINNABLE;
import static com.android.server.wm.Task.LOCK_TASK_AUTH_WHITELISTED;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -264,12 +264,12 @@ public class LockTaskController {
}
/**
* @return whether the requested task is allowed to be locked (either whitelisted, or declares
* @return whether the requested task is allowed to be locked (either allowlisted, or declares
* lockTaskMode="always" in the manifest).
*/
boolean isTaskWhitelisted(Task task) {
boolean isTaskAllowlisted(Task task) {
switch(task.mLockTaskAuth) {
case LOCK_TASK_AUTH_WHITELISTED:
case LOCK_TASK_AUTH_ALLOWLISTED:
case LOCK_TASK_AUTH_LAUNCHABLE:
case LOCK_TASK_AUTH_LAUNCHABLE_PRIV:
return true;
@@ -311,7 +311,7 @@ public class LockTaskController {
private boolean isLockTaskModeViolationInternal(Task task, boolean isNewClearTask) {
// TODO: Double check what's going on here. If the task is already in lock task mode, it's
// likely whitelisted, so will return false below.
// likely allowlisted, so will return false below.
if (isTaskLocked(task) && !isNewClearTask) {
// If the task is already at the top and won't be cleared, then allow the operation
return false;
@@ -327,7 +327,7 @@ public class LockTaskController {
return false;
}
return !(isTaskWhitelisted(task) || mLockTaskModeTasks.isEmpty());
return !(isTaskAllowlisted(task) || mLockTaskModeTasks.isEmpty());
}
private boolean isRecentsAllowed(int userId) {
@@ -356,7 +356,7 @@ public class LockTaskController {
return false;
default:
}
return isPackageWhitelisted(userId, packageName);
return isPackageAllowlisted(userId, packageName);
}
private boolean isEmergencyCallTask(Task task) {
@@ -556,7 +556,7 @@ public class LockTaskController {
if (!isSystemCaller) {
task.mLockTaskUid = callingUid;
if (task.mLockTaskAuth == LOCK_TASK_AUTH_PINNABLE) {
// startLockTask() called by app, but app is not part of lock task whitelist. Show
// startLockTask() called by app, but app is not part of lock task allowlist. Show
// app pinning request. We will come back here with isSystemCaller true.
if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Mode default, asking user");
StatusBarManagerInternal statusBarManager = LocalServices.getService(
@@ -649,8 +649,8 @@ public class LockTaskController {
/**
* Update packages that are allowed to be launched in lock task mode.
* @param userId Which user this whitelist is associated with
* @param packages The whitelist of packages allowed in lock task mode
* @param userId Which user this allowlist is associated with
* @param packages The allowlist of packages allowed in lock task mode
* @see #mLockTaskPackages
*/
void updateLockTaskPackages(int userId, String[] packages) {
@@ -659,19 +659,19 @@ public class LockTaskController {
boolean taskChanged = false;
for (int taskNdx = mLockTaskModeTasks.size() - 1; taskNdx >= 0; --taskNdx) {
final Task lockedTask = mLockTaskModeTasks.get(taskNdx);
final boolean wasWhitelisted = lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
|| lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_WHITELISTED;
final boolean wasAllowlisted = lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
|| lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_ALLOWLISTED;
lockedTask.setLockTaskAuth();
final boolean isWhitelisted = lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
|| lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_WHITELISTED;
final boolean isAllowlisted = lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE
|| lockedTask.mLockTaskAuth == LOCK_TASK_AUTH_ALLOWLISTED;
if (mLockTaskModeState != LOCK_TASK_MODE_LOCKED
|| lockedTask.mUserId != userId
|| !wasWhitelisted || isWhitelisted) {
|| !wasAllowlisted || isAllowlisted) {
continue;
}
// Terminate locked tasks that have recently lost whitelist authorization.
// Terminate locked tasks that have recently lost allowlist authorization.
if (DEBUG_LOCKTASK) Slog.d(TAG_LOCKTASK, "onLockTaskPackagesUpdated: removing " +
lockedTask + " mLockTaskAuth()=" + lockedTask.lockTaskAuthToString());
removeLockedTask(lockedTask);
@@ -697,17 +697,17 @@ public class LockTaskController {
}
}
boolean isPackageWhitelisted(int userId, String pkg) {
boolean isPackageAllowlisted(int userId, String pkg) {
if (pkg == null) {
return false;
}
String[] whitelist;
whitelist = mLockTaskPackages.get(userId);
if (whitelist == null) {
String[] allowlist;
allowlist = mLockTaskPackages.get(userId);
if (allowlist == null) {
return false;
}
for (String whitelistedPkg : whitelist) {
if (pkg.equals(whitelistedPkg)) {
for (String allowlistedPkg : allowlist) {
if (pkg.equals(allowlistedPkg)) {
return true;
}
}

View File

@@ -196,40 +196,40 @@ class PolicyControl {
private static final String ALL = "*";
private static final String APPS = "apps";
private final ArraySet<String> mWhitelist;
private final ArraySet<String> mBlacklist;
private final ArraySet<String> mAllowlist;
private final ArraySet<String> mDenylist;
private Filter(ArraySet<String> whitelist, ArraySet<String> blacklist) {
mWhitelist = whitelist;
mBlacklist = blacklist;
private Filter(ArraySet<String> allowlist, ArraySet<String> denylist) {
mAllowlist = allowlist;
mDenylist = denylist;
}
boolean matches(LayoutParams attrs) {
if (attrs == null) return false;
boolean isApp = attrs.type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW
&& attrs.type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW;
if (isApp && mBlacklist.contains(APPS)) return false;
if (onBlacklist(attrs.packageName)) return false;
if (isApp && mWhitelist.contains(APPS)) return true;
return onWhitelist(attrs.packageName);
if (isApp && mDenylist.contains(APPS)) return false;
if (onDenylist(attrs.packageName)) return false;
if (isApp && mAllowlist.contains(APPS)) return true;
return onAllowlist(attrs.packageName);
}
boolean matches(String packageName) {
return !onBlacklist(packageName) && onWhitelist(packageName);
return !onDenylist(packageName) && onAllowlist(packageName);
}
private boolean onBlacklist(String packageName) {
return mBlacklist.contains(packageName) || mBlacklist.contains(ALL);
private boolean onDenylist(String packageName) {
return mDenylist.contains(packageName) || mDenylist.contains(ALL);
}
private boolean onWhitelist(String packageName) {
return mWhitelist.contains(ALL) || mWhitelist.contains(packageName);
private boolean onAllowlist(String packageName) {
return mAllowlist.contains(ALL) || mAllowlist.contains(packageName);
}
void dump(PrintWriter pw) {
pw.print("Filter[");
dump("whitelist", mWhitelist, pw); pw.print(',');
dump("blacklist", mBlacklist, pw); pw.print(']');
dump("allowlist", mAllowlist, pw); pw.print(',');
dump("denylist", mDenylist, pw); pw.print(']');
}
private void dump(String name, ArraySet<String> set, PrintWriter pw) {
@@ -253,18 +253,18 @@ class PolicyControl {
// e.g. "com.package1", or "apps, com.android.keyguard" or "*"
static Filter parse(String value) {
if (value == null) return null;
ArraySet<String> whitelist = new ArraySet<String>();
ArraySet<String> blacklist = new ArraySet<String>();
ArraySet<String> allowlist = new ArraySet<String>();
ArraySet<String> denylist = new ArraySet<String>();
for (String token : value.split(",")) {
token = token.trim();
if (token.startsWith("-") && token.length() > 1) {
token = token.substring(1);
blacklist.add(token);
denylist.add(token);
} else {
whitelist.add(token);
allowlist.add(token);
}
}
return new Filter(whitelist, blacklist);
return new Filter(allowlist, denylist);
}
}
}

View File

@@ -655,7 +655,8 @@ class RecentTasks {
}
for (int i = mTasks.size() - 1; i >= 0; --i) {
final Task task = mTasks.get(i);
if (task.mUserId == userId && !mService.getLockTaskController().isTaskWhitelisted(task)) {
if (task.mUserId == userId
&& !mService.getLockTaskController().isTaskAllowlisted(task)) {
remove(task);
}
}

View File

@@ -2582,7 +2582,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
mDisplayAccessUIDs.clear();
for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {
final DisplayContent displayContent = getChildAt(displayNdx);
// Only bother calculating the whitelist for private displays
// Only bother calculating the allowlist for private displays
if (displayContent.isPrivate()) {
mDisplayAccessUIDs.append(
displayContent.mDisplayId, displayContent.getPresentUIDs());

View File

@@ -233,10 +233,10 @@ public class SafeActivityOptions {
Slog.w(TAG, msg);
throw new SecurityException(msg);
}
// Check if someone tries to launch an unwhitelisted activity into LockTask mode.
// Check if someone tries to launch an unallowlisted activity into LockTask mode.
final boolean lockTaskMode = options.getLockTaskMode();
if (aInfo != null && lockTaskMode
&& !supervisor.mService.getLockTaskController().isPackageWhitelisted(
&& !supervisor.mService.getLockTaskController().isPackageAllowlisted(
UserHandle.getUserId(callingUid), aInfo.packageName)) {
final String msg = "Permission Denial: starting " + getIntentString(intent)
+ " from " + callerApp + " (pid=" + callingPid

View File

@@ -40,7 +40,7 @@ import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
import static android.content.pm.ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_ALWAYS;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_DEFAULT;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED;
import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY;
@@ -264,7 +264,7 @@ class Task extends WindowContainer<WindowContainer> {
/** Starts in LOCK_TASK_MODE_LOCKED automatically. Can start over existing lockTask task. */
final static int LOCK_TASK_AUTH_LAUNCHABLE = 2;
/** Can enter lockTask without user approval. Can start over existing lockTask task. */
final static int LOCK_TASK_AUTH_WHITELISTED = 3;
final static int LOCK_TASK_AUTH_ALLOWLISTED = 3;
/** Priv-app that starts in LOCK_TASK_MODE_LOCKED automatically. Can start over existing
* lockTask task. */
final static int LOCK_TASK_AUTH_LAUNCHABLE_PRIV = 4;
@@ -1377,7 +1377,7 @@ class Task extends WindowContainer<WindowContainer> {
getDisplayArea().addStackReferenceIfNeeded((ActivityStack) child);
}
// Make sure the list of display UID whitelists is updated
// Make sure the list of display UID allowlists is updated
// now that this record is in a new task.
mRootWindowContainer.updateUIDsPresentOnDisplay();
@@ -1594,7 +1594,7 @@ class Task extends WindowContainer<WindowContainer> {
case LOCK_TASK_AUTH_DONT_LOCK: return "LOCK_TASK_AUTH_DONT_LOCK";
case LOCK_TASK_AUTH_PINNABLE: return "LOCK_TASK_AUTH_PINNABLE";
case LOCK_TASK_AUTH_LAUNCHABLE: return "LOCK_TASK_AUTH_LAUNCHABLE";
case LOCK_TASK_AUTH_WHITELISTED: return "LOCK_TASK_AUTH_WHITELISTED";
case LOCK_TASK_AUTH_ALLOWLISTED: return "LOCK_TASK_AUTH_ALLOWLISTED";
case LOCK_TASK_AUTH_LAUNCHABLE_PRIV: return "LOCK_TASK_AUTH_LAUNCHABLE_PRIV";
default: return "unknown=" + mLockTaskAuth;
}
@@ -1614,8 +1614,8 @@ class Task extends WindowContainer<WindowContainer> {
final LockTaskController lockTaskController = mAtmService.getLockTaskController();
switch (r.lockTaskLaunchMode) {
case LOCK_TASK_LAUNCH_MODE_DEFAULT:
mLockTaskAuth = lockTaskController.isPackageWhitelisted(mUserId, pkg)
? LOCK_TASK_AUTH_WHITELISTED : LOCK_TASK_AUTH_PINNABLE;
mLockTaskAuth = lockTaskController.isPackageAllowlisted(mUserId, pkg)
? LOCK_TASK_AUTH_ALLOWLISTED : LOCK_TASK_AUTH_PINNABLE;
break;
case LOCK_TASK_LAUNCH_MODE_NEVER:
@@ -1626,8 +1626,8 @@ class Task extends WindowContainer<WindowContainer> {
mLockTaskAuth = LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
break;
case LOCK_TASK_LAUNCH_MODE_IF_WHITELISTED:
mLockTaskAuth = lockTaskController.isPackageWhitelisted(mUserId, pkg)
case LOCK_TASK_LAUNCH_MODE_IF_ALLOWLISTED:
mLockTaskAuth = lockTaskController.isPackageAllowlisted(mUserId, pkg)
? LOCK_TASK_AUTH_LAUNCHABLE : LOCK_TASK_AUTH_PINNABLE;
break;
}

View File

@@ -168,8 +168,8 @@ public class LockTaskControllerTest {
@Test
public void testStartLockTaskMode_once() throws Exception {
// GIVEN a task record with whitelisted auth
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN a task record with allowlisted auth
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
// WHEN calling setLockTaskMode for LOCKED mode without resuming
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
@@ -185,9 +185,9 @@ public class LockTaskControllerTest {
@Test
public void testStartLockTaskMode_twice() throws Exception {
// GIVEN two task records with whitelisted auth
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN two task records with allowlisted auth
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
// WHEN calling setLockTaskMode for LOCKED mode on both tasks
mLockTaskController.startLockTaskMode(tr1, false, TEST_UID);
@@ -205,7 +205,7 @@ public class LockTaskControllerTest {
@Test
public void testStartLockTaskMode_pinningRequest() {
// GIVEN a task record that is not whitelisted, i.e. with pinned auth
// GIVEN a task record that is not allowlisted, i.e. with pinned auth
Task tr = getTask(Task.LOCK_TASK_AUTH_PINNABLE);
// WHEN calling startLockTaskMode
@@ -236,23 +236,23 @@ public class LockTaskControllerTest {
@Test
public void testLockTaskViolation() {
// GIVEN one task record with whitelisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN one task record with allowlisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// THEN it's not a lock task violation to try and launch this task without clearing
assertFalse(mLockTaskController.isLockTaskModeViolation(tr, false));
// THEN it's a lock task violation to launch another task that is not whitelisted
// THEN it's a lock task violation to launch another task that is not allowlisted
assertTrue(mLockTaskController.isLockTaskModeViolation(getTask(
Task.LOCK_TASK_AUTH_PINNABLE)));
// THEN it's a lock task violation to launch another task that is disallowed from lock task
assertTrue(mLockTaskController.isLockTaskModeViolation(getTask(
Task.LOCK_TASK_AUTH_DONT_LOCK)));
// THEN it's no a lock task violation to launch another task that is whitelisted
// THEN it's no a lock task violation to launch another task that is allowlisted
assertFalse(mLockTaskController.isLockTaskModeViolation(getTask(
Task.LOCK_TASK_AUTH_WHITELISTED)));
Task.LOCK_TASK_AUTH_ALLOWLISTED)));
assertFalse(mLockTaskController.isLockTaskModeViolation(getTask(
Task.LOCK_TASK_AUTH_LAUNCHABLE)));
// THEN it's not a lock task violation to launch another task that is priv launchable
@@ -262,8 +262,8 @@ public class LockTaskControllerTest {
@Test
public void testLockTaskViolation_emergencyCall() {
// GIVEN one task record with whitelisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN one task record with allowlisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// GIVEN tasks necessary for emergency calling
@@ -294,8 +294,8 @@ public class LockTaskControllerTest {
@Test
public void testStopLockTaskMode() throws Exception {
// GIVEN one task record with whitelisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN one task record with allowlisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// WHEN the same caller calls stopLockTaskMode
@@ -311,8 +311,8 @@ public class LockTaskControllerTest {
@Test(expected = SecurityException.class)
public void testStopLockTaskMode_differentCaller() {
// GIVEN one task record with whitelisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN one task record with allowlisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// WHEN a different caller calls stopLockTaskMode
@@ -323,8 +323,8 @@ public class LockTaskControllerTest {
@Test
public void testStopLockTaskMode_systemCaller() {
// GIVEN one task record with whitelisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN one task record with allowlisted auth that is in lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// WHEN system calls stopLockTaskMode
@@ -336,9 +336,9 @@ public class LockTaskControllerTest {
@Test
public void testStopLockTaskMode_twoTasks() throws Exception {
// GIVEN two task records with whitelisted auth that is in lock task mode
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN two task records with allowlisted auth that is in lock task mode
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, false, TEST_UID);
mLockTaskController.startLockTaskMode(tr2, false, TEST_UID);
@@ -357,9 +357,9 @@ public class LockTaskControllerTest {
@Test
public void testStopLockTaskMode_rootTask() throws Exception {
// GIVEN two task records with whitelisted auth that is in lock task mode
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN two task records with allowlisted auth that is in lock task mode
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, false, TEST_UID);
mLockTaskController.startLockTaskMode(tr2, false, TEST_UID);
@@ -405,9 +405,9 @@ public class LockTaskControllerTest {
@Test
public void testClearLockedTasks() throws Exception {
// GIVEN two task records with whitelisted auth that is in lock task mode
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
// GIVEN two task records with allowlisted auth that is in lock task mode
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
Task tr2 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, false, TEST_UID);
mLockTaskController.startLockTaskMode(tr2, false, TEST_UID);
@@ -434,7 +434,7 @@ public class LockTaskControllerTest {
.thenReturn(DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
// AND there is a task record
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
@@ -454,7 +454,7 @@ public class LockTaskControllerTest {
.thenReturn(true);
// AND there is a task record
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
@@ -471,7 +471,7 @@ public class LockTaskControllerTest {
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, 1, mContext.getUserId());
// AND there is a task record
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
@@ -488,7 +488,7 @@ public class LockTaskControllerTest {
Settings.Secure.LOCK_TO_APP_EXIT_LOCKED, 0, mContext.getUserId());
// AND there is a task record
Task tr1 = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr1 = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr1, true, TEST_UID);
// WHEN calling clearLockedTasks on the root task
@@ -500,45 +500,45 @@ public class LockTaskControllerTest {
@Test
public void testUpdateLockTaskPackages() {
String[] whitelist1 = {TEST_PACKAGE_NAME, TEST_PACKAGE_NAME_2};
String[] whitelist2 = {TEST_PACKAGE_NAME};
String[] allowlist1 = {TEST_PACKAGE_NAME, TEST_PACKAGE_NAME_2};
String[] allowlist2 = {TEST_PACKAGE_NAME};
// No package is whitelisted initially
for (String pkg : whitelist1) {
assertFalse("Package shouldn't be whitelisted: " + pkg,
mLockTaskController.isPackageWhitelisted(TEST_USER_ID, pkg));
assertFalse("Package shouldn't be whitelisted for user 0: " + pkg,
mLockTaskController.isPackageWhitelisted(0, pkg));
// No package is allowlisted initially
for (String pkg : allowlist1) {
assertFalse("Package shouldn't be allowlisted: " + pkg,
mLockTaskController.isPackageAllowlisted(TEST_USER_ID, pkg));
assertFalse("Package shouldn't be allowlisted for user 0: " + pkg,
mLockTaskController.isPackageAllowlisted(0, pkg));
}
// Apply whitelist
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, whitelist1);
// Apply allowlist
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist1);
// Assert the whitelist is applied to the correct user
for (String pkg : whitelist1) {
assertTrue("Package should be whitelisted: " + pkg,
mLockTaskController.isPackageWhitelisted(TEST_USER_ID, pkg));
assertFalse("Package shouldn't be whitelisted for user 0: " + pkg,
mLockTaskController.isPackageWhitelisted(0, pkg));
// Assert the allowlist is applied to the correct user
for (String pkg : allowlist1) {
assertTrue("Package should be allowlisted: " + pkg,
mLockTaskController.isPackageAllowlisted(TEST_USER_ID, pkg));
assertFalse("Package shouldn't be allowlisted for user 0: " + pkg,
mLockTaskController.isPackageAllowlisted(0, pkg));
}
// Update whitelist
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, whitelist2);
// Update allowlist
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist2);
// Assert the new whitelist is applied
assertTrue("Package should remain whitelisted: " + TEST_PACKAGE_NAME,
mLockTaskController.isPackageWhitelisted(TEST_USER_ID, TEST_PACKAGE_NAME));
assertFalse("Package should no longer be whitelisted: " + TEST_PACKAGE_NAME_2,
mLockTaskController.isPackageWhitelisted(TEST_USER_ID, TEST_PACKAGE_NAME_2));
// Assert the new allowlist is applied
assertTrue("Package should remain allowlisted: " + TEST_PACKAGE_NAME,
mLockTaskController.isPackageAllowlisted(TEST_USER_ID, TEST_PACKAGE_NAME));
assertFalse("Package should no longer be allowlisted: " + TEST_PACKAGE_NAME_2,
mLockTaskController.isPackageAllowlisted(TEST_USER_ID, TEST_PACKAGE_NAME_2));
}
@Test
public void testUpdateLockTaskPackages_taskRemoved() throws Exception {
// GIVEN two tasks which are whitelisted initially
// GIVEN two tasks which are allowlisted initially
Task tr1 = getTaskForUpdate(TEST_PACKAGE_NAME, true);
Task tr2 = getTaskForUpdate(TEST_PACKAGE_NAME_2, false);
String[] whitelist = {TEST_PACKAGE_NAME, TEST_PACKAGE_NAME_2};
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, whitelist);
String[] allowlist = {TEST_PACKAGE_NAME, TEST_PACKAGE_NAME_2};
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
// GIVEN the tasks are launched into LockTask mode
mLockTaskController.startLockTaskMode(tr1, false, TEST_UID);
@@ -548,9 +548,9 @@ public class LockTaskControllerTest {
assertTrue(mLockTaskController.isTaskLocked(tr2));
verifyLockTaskStarted(STATUS_BAR_MASK_LOCKED, DISABLE2_MASK);
// WHEN removing one package from whitelist
whitelist = new String[] {TEST_PACKAGE_NAME};
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, whitelist);
// WHEN removing one package from allowlist
allowlist = new String[] {TEST_PACKAGE_NAME};
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
// THEN the task running that package should be stopped
verify(tr2).performClearTaskLocked();
@@ -560,9 +560,9 @@ public class LockTaskControllerTest {
assertTrue(mLockTaskController.isTaskLocked(tr1));
verifyLockTaskStarted(STATUS_BAR_MASK_LOCKED, DISABLE2_MASK);
// WHEN removing the last package from whitelist
whitelist = new String[] {};
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, whitelist);
// WHEN removing the last package from allowlist
allowlist = new String[] {};
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
// THEN the last task should be cleared, and the system should quit LockTask mode
verify(tr1).performClearTaskLocked();
@@ -574,7 +574,7 @@ public class LockTaskControllerTest {
@Test
public void testUpdateLockTaskFeatures() throws Exception {
// GIVEN a locked task
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// THEN lock task mode should be started with default status bar masks
@@ -616,7 +616,7 @@ public class LockTaskControllerTest {
@Test
public void testUpdateLockTaskFeatures_differentUser() throws Exception {
// GIVEN a locked task
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// THEN lock task mode should be started with default status bar masks
@@ -638,7 +638,7 @@ public class LockTaskControllerTest {
@Test
public void testUpdateLockTaskFeatures_keyguard() {
// GIVEN a locked task
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// THEN keyguard should be disabled
@@ -704,7 +704,7 @@ public class LockTaskControllerTest {
TEST_USER_ID, TEST_PACKAGE_NAME, LOCK_TASK_LAUNCH_MODE_DEFAULT));
// Start lock task mode
Task tr = getTask(Task.LOCK_TASK_AUTH_WHITELISTED);
Task tr = getTask(Task.LOCK_TASK_AUTH_ALLOWLISTED);
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// WHEN LOCK_TASK_FEATURE_BLOCK_ACTIVITY_START_IN_TASK is not enabled
@@ -719,15 +719,15 @@ public class LockTaskControllerTest {
assertTrue(mLockTaskController.isActivityAllowed(
TEST_USER_ID, TEST_PACKAGE_NAME, LOCK_TASK_LAUNCH_MODE_ALWAYS));
// unwhitelisted package should not be allowed
// unallowlisted package should not be allowed
assertFalse(mLockTaskController.isActivityAllowed(
TEST_USER_ID, TEST_PACKAGE_NAME, LOCK_TASK_LAUNCH_MODE_DEFAULT));
// update the whitelist
String[] whitelist = new String[] { TEST_PACKAGE_NAME };
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, whitelist);
// update the allowlist
String[] allowlist = new String[] { TEST_PACKAGE_NAME };
mLockTaskController.updateLockTaskPackages(TEST_USER_ID, allowlist);
// whitelisted package should be allowed
// allowlisted package should be allowed
assertTrue(mLockTaskController.isActivityAllowed(
TEST_USER_ID, TEST_PACKAGE_NAME, LOCK_TASK_LAUNCH_MODE_DEFAULT));
@@ -755,17 +755,17 @@ public class LockTaskControllerTest {
}
/**
* @param isAppAware {@code true} if the app has marked if_whitelisted in its manifest
* @param isAppAware {@code true} if the app has marked if_allowlisted in its manifest
*/
private Task getTaskForUpdate(String pkg, boolean isAppAware) {
final int authIfWhitelisted = isAppAware
final int authIfAllowlisted = isAppAware
? Task.LOCK_TASK_AUTH_LAUNCHABLE
: Task.LOCK_TASK_AUTH_WHITELISTED;
Task tr = getTask(pkg, authIfWhitelisted);
: Task.LOCK_TASK_AUTH_ALLOWLISTED;
Task tr = getTask(pkg, authIfAllowlisted);
doAnswer((invocation) -> {
boolean isWhitelisted =
mLockTaskController.isPackageWhitelisted(TEST_USER_ID, pkg);
tr.mLockTaskAuth = isWhitelisted ? authIfWhitelisted : Task.LOCK_TASK_AUTH_PINNABLE;
boolean isAllowlisted =
mLockTaskController.isPackageAllowlisted(TEST_USER_ID, pkg);
tr.mLockTaskAuth = isAllowlisted ? authIfAllowlisted : Task.LOCK_TASK_AUTH_PINNABLE;
return null;
}).when(tr).setLockTaskAuth();
return tr;