Loading core/java/android/provider/CallLog.java +9 −2 Original line number Diff line number Diff line Loading @@ -98,6 +98,13 @@ public class CallLog { */ public static final String LIMIT_PARAM_KEY = "limit"; /** * Form of {@link #CONTENT_URI} which limits the query results to a single result. */ private static final Uri CONTENT_URI_LIMIT_1 = CONTENT_URI.buildUpon() .appendQueryParameter(LIMIT_PARAM_KEY, "1") .build(); /** * Query parameter used to specify the starting record to return. * <p> Loading Loading @@ -842,11 +849,11 @@ public class CallLog { Cursor c = null; try { c = resolver.query( CONTENT_URI, CONTENT_URI_LIMIT_1, new String[] {NUMBER}, TYPE + " = " + OUTGOING_TYPE, null, DEFAULT_SORT_ORDER + " LIMIT 1"); DEFAULT_SORT_ORDER); if (c == null || !c.moveToFirst()) { return ""; } Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +9 −28 Original line number Diff line number Diff line Loading @@ -863,27 +863,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } /** * Detects whether we should show a lock screen in front of this task for a locked user. * <p> * We'll do this if either of the following holds: * <ul> * <li>The top activity explicitly belongs to {@param userId}.</li> * <li>The top activity returns a result to an activity belonging to {@param userId}.</li> * </ul> * * @return {@code true} if the top activity looks like it belongs to {@param userId}. */ private boolean taskTopActivityIsUser(TaskRecord task, @UserIdInt int userId) { // To handle the case that work app is in the task but just is not the top one. final ActivityRecord activityRecord = task.getTopActivity(); final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null); return (activityRecord != null && activityRecord.userId == userId) || (resultTo != null && resultTo.userId == userId); } /** * Find all visible task stacks containing {@param userId} and intercept them with an activity * Find all task stacks containing {@param userId} and intercept them with an activity * to block out the contents and possibly start a credential-confirming intent. * * @param userId user handle for the locked managed profile. Loading @@ -898,13 +878,14 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D final List<TaskRecord> tasks = stack.getAllTasks(); for (int taskNdx = tasks.size() - 1; taskNdx >= 0; taskNdx--) { final TaskRecord task = tasks.get(taskNdx); // Check the task for a top activity belonging to userId, or returning a // result to an activity belonging to userId. Example case: a document // picker for personal files, opened by a work app, should still get locked. if (taskTopActivityIsUser(task, userId)) { for (int activityNdx = task.mActivities.size() - 1; activityNdx >= 0; activityNdx--) { final ActivityRecord activity = task.mActivities.get(activityNdx); if (!activity.finishing && activity.userId == userId) { mService.mTaskChangeNotificationController.notifyTaskProfileLocked( task.taskId, userId); break; } } } } Loading services/core/java/com/android/server/connectivity/NetworkMonitor.java +0 −110 Original line number Diff line number Diff line Loading @@ -46,22 +46,12 @@ import android.net.metrics.IpConnectivityLog; import android.net.metrics.NetworkEvent; import android.net.metrics.ValidationProbeEvent; import android.net.util.Stopwatch; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.LocalLog; Loading Loading @@ -889,10 +879,6 @@ public class NetworkMonitor extends StateMachine { return mSettings.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_USE_HTTPS, 1) == 1; } public boolean getWifiScansAlwaysAvailableDisabled() { return mSettings.getSetting(mContext, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 0; } private String getCaptivePortalServerHttpsUrl() { return mSettings.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, DEFAULT_HTTPS_URL); Loading Loading @@ -1029,10 +1015,6 @@ public class NetworkMonitor extends StateMachine { long endTime = SystemClock.elapsedRealtime(); sendNetworkConditionsBroadcast(true /* response received */, result.isPortal() /* isCaptivePortal */, startTime, endTime); return result; } Loading Loading @@ -1270,98 +1252,6 @@ public class NetworkMonitor extends StateMachine { return null; } /** * @param responseReceived - whether or not we received a valid HTTP response to our request. * If false, isCaptivePortal and responseTimestampMs are ignored * TODO: This should be moved to the transports. The latency could be passed to the transports * along with the captive portal result. Currently the TYPE_MOBILE broadcasts appear unused so * perhaps this could just be added to the WiFi transport only. */ private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, long requestTimestampMs, long responseTimestampMs) { if (getWifiScansAlwaysAvailableDisabled()) { return; } if (!systemReady) { return; } Intent latencyBroadcast = new Intent(ConnectivityConstants.ACTION_NETWORK_CONDITIONS_MEASURED); switch (mNetworkAgentInfo.networkInfo.getType()) { case ConnectivityManager.TYPE_WIFI: WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo(); if (currentWifiInfo != null) { // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not // surrounded by double quotation marks (thus violating the Javadoc), but this // was changed to match the Javadoc in API 17. Since clients may have started // sanitizing the output of this method since API 17 was released, we should // not change it here as it would become impossible to tell whether the SSID is // simply being surrounded by quotes due to the API, or whether those quotes // are actually part of the SSID. latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_SSID, currentWifiInfo.getSSID()); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_BSSID, currentWifiInfo.getBSSID()); } else { if (VDBG) logw("network info is TYPE_WIFI but no ConnectionInfo found"); return; } break; case ConnectivityManager.TYPE_MOBILE: latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType()); List<CellInfo> info = mTelephonyManager.getAllCellInfo(); if (info == null) return; int numRegisteredCellInfo = 0; for (CellInfo cellInfo : info) { if (cellInfo.isRegistered()) { numRegisteredCellInfo++; if (numRegisteredCellInfo > 1) { if (VDBG) logw("more than one registered CellInfo." + " Can't tell which is active. Bailing."); return; } if (cellInfo instanceof CellInfoCdma) { CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoGsm) { CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoLte) { CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoWcdma) { CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else { if (VDBG) logw("Registered cellinfo is unrecognized"); return; } } } break; default: return; } latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CONNECTIVITY_TYPE, mNetworkAgentInfo.networkInfo.getType()); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_RESPONSE_RECEIVED, responseReceived); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_REQUEST_TIMESTAMP_MS, requestTimestampMs); if (responseReceived) { latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_IS_CAPTIVE_PORTAL, isCaptivePortal); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_RESPONSE_TIMESTAMP_MS, responseTimestampMs); } mContext.sendBroadcastAsUser(latencyBroadcast, UserHandle.CURRENT, ConnectivityConstants.PERMISSION_ACCESS_NETWORK_CONDITIONS); } private void logNetworkEvent(int evtype) { int[] transports = mNetworkAgentInfo.networkCapabilities.getTransportTypes(); mMetricsLog.log(mNetId, transports, new NetworkEvent(evtype)); Loading services/core/java/com/android/server/notification/NotificationManagerService.java +2 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,7 @@ import com.android.server.lights.LightsManager; import com.android.server.notification.ManagedServices.ManagedServiceInfo; import com.android.server.notification.ManagedServices.UserProfiles; import com.android.server.policy.PhoneWindowManager; import com.android.server.pm.PackageManagerService; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -4857,6 +4858,7 @@ public class NotificationManagerService extends SystemService { final PendingIntent pi = PendingIntent.getBroadcast(getContext(), REQUEST_CODE_TIMEOUT, new Intent(ACTION_NOTIFICATION_TIMEOUT) .setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME) .setData(new Uri.Builder().scheme(SCHEME_TIMEOUT) .appendPath(record.getKey()).build()) .addFlags(Intent.FLAG_RECEIVER_FOREGROUND) Loading services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java +32 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,7 @@ import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE; import static android.content.pm.ActivityInfo.FLAG_SHOW_WHEN_LOCKED; import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_DESTROYING; import static com.android.server.am.ActivityStackSupervisor .MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; Loading @@ -46,6 +45,8 @@ import static org.mockito.Mockito.verify; import android.app.ActivityOptions; import android.app.WaitResult; import android.graphics.Rect; import android.os.RemoteException; import android.os.UserHandle; import android.platform.test.annotations.Presubmit; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; Loading Loading @@ -407,4 +408,33 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase { // Assert that the primary stack is returned. assertEquals(primaryStack, result); } @Test public void testLockAllProfileTasks() throws Exception { // Make an activity visible with the user id set to 1 final TaskRecord task = new TaskBuilder(mSupervisor).setStack(mFullscreenStack).build(); final ActivityRecord activity = new ActivityBuilder(mService).setTask(task) .setUid(UserHandle.PER_USER_RANGE + 1).build(); // Create another activity on top and the user id is 2 final ActivityRecord topActivity = new ActivityBuilder(mService) .setTask(task).setUid(UserHandle.PER_USER_RANGE + 2).build(); // Make sure the listeners will be notified for putting the task to locked state LocalTaskStackListener listener = new LocalTaskStackListener(); mService.registerTaskStackListener(listener); mService.mStackSupervisor.lockAllProfileTasks(1); assertTrue(listener.mTaskProfileLocked); mService.unregisterTaskStackListener(listener); } private class LocalTaskStackListener extends android.app.TaskStackListener { boolean mTaskProfileLocked; @Override public void onTaskProfileLocked(int taskId, int userId) throws RemoteException { super.onTaskProfileLocked(taskId, userId); mTaskProfileLocked = true; } } } Loading
core/java/android/provider/CallLog.java +9 −2 Original line number Diff line number Diff line Loading @@ -98,6 +98,13 @@ public class CallLog { */ public static final String LIMIT_PARAM_KEY = "limit"; /** * Form of {@link #CONTENT_URI} which limits the query results to a single result. */ private static final Uri CONTENT_URI_LIMIT_1 = CONTENT_URI.buildUpon() .appendQueryParameter(LIMIT_PARAM_KEY, "1") .build(); /** * Query parameter used to specify the starting record to return. * <p> Loading Loading @@ -842,11 +849,11 @@ public class CallLog { Cursor c = null; try { c = resolver.query( CONTENT_URI, CONTENT_URI_LIMIT_1, new String[] {NUMBER}, TYPE + " = " + OUTGOING_TYPE, null, DEFAULT_SORT_ORDER + " LIMIT 1"); DEFAULT_SORT_ORDER); if (c == null || !c.moveToFirst()) { return ""; } Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +9 −28 Original line number Diff line number Diff line Loading @@ -863,27 +863,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } /** * Detects whether we should show a lock screen in front of this task for a locked user. * <p> * We'll do this if either of the following holds: * <ul> * <li>The top activity explicitly belongs to {@param userId}.</li> * <li>The top activity returns a result to an activity belonging to {@param userId}.</li> * </ul> * * @return {@code true} if the top activity looks like it belongs to {@param userId}. */ private boolean taskTopActivityIsUser(TaskRecord task, @UserIdInt int userId) { // To handle the case that work app is in the task but just is not the top one. final ActivityRecord activityRecord = task.getTopActivity(); final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null); return (activityRecord != null && activityRecord.userId == userId) || (resultTo != null && resultTo.userId == userId); } /** * Find all visible task stacks containing {@param userId} and intercept them with an activity * Find all task stacks containing {@param userId} and intercept them with an activity * to block out the contents and possibly start a credential-confirming intent. * * @param userId user handle for the locked managed profile. Loading @@ -898,13 +878,14 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D final List<TaskRecord> tasks = stack.getAllTasks(); for (int taskNdx = tasks.size() - 1; taskNdx >= 0; taskNdx--) { final TaskRecord task = tasks.get(taskNdx); // Check the task for a top activity belonging to userId, or returning a // result to an activity belonging to userId. Example case: a document // picker for personal files, opened by a work app, should still get locked. if (taskTopActivityIsUser(task, userId)) { for (int activityNdx = task.mActivities.size() - 1; activityNdx >= 0; activityNdx--) { final ActivityRecord activity = task.mActivities.get(activityNdx); if (!activity.finishing && activity.userId == userId) { mService.mTaskChangeNotificationController.notifyTaskProfileLocked( task.taskId, userId); break; } } } } Loading
services/core/java/com/android/server/connectivity/NetworkMonitor.java +0 −110 Original line number Diff line number Diff line Loading @@ -46,22 +46,12 @@ import android.net.metrics.IpConnectivityLog; import android.net.metrics.NetworkEvent; import android.net.metrics.ValidationProbeEvent; import android.net.util.Stopwatch; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; import android.telephony.CellIdentityCdma; import android.telephony.CellIdentityGsm; import android.telephony.CellIdentityLte; import android.telephony.CellIdentityWcdma; import android.telephony.CellInfo; import android.telephony.CellInfoCdma; import android.telephony.CellInfoGsm; import android.telephony.CellInfoLte; import android.telephony.CellInfoWcdma; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.LocalLog; Loading Loading @@ -889,10 +879,6 @@ public class NetworkMonitor extends StateMachine { return mSettings.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_USE_HTTPS, 1) == 1; } public boolean getWifiScansAlwaysAvailableDisabled() { return mSettings.getSetting(mContext, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 0; } private String getCaptivePortalServerHttpsUrl() { return mSettings.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL, DEFAULT_HTTPS_URL); Loading Loading @@ -1029,10 +1015,6 @@ public class NetworkMonitor extends StateMachine { long endTime = SystemClock.elapsedRealtime(); sendNetworkConditionsBroadcast(true /* response received */, result.isPortal() /* isCaptivePortal */, startTime, endTime); return result; } Loading Loading @@ -1270,98 +1252,6 @@ public class NetworkMonitor extends StateMachine { return null; } /** * @param responseReceived - whether or not we received a valid HTTP response to our request. * If false, isCaptivePortal and responseTimestampMs are ignored * TODO: This should be moved to the transports. The latency could be passed to the transports * along with the captive portal result. Currently the TYPE_MOBILE broadcasts appear unused so * perhaps this could just be added to the WiFi transport only. */ private void sendNetworkConditionsBroadcast(boolean responseReceived, boolean isCaptivePortal, long requestTimestampMs, long responseTimestampMs) { if (getWifiScansAlwaysAvailableDisabled()) { return; } if (!systemReady) { return; } Intent latencyBroadcast = new Intent(ConnectivityConstants.ACTION_NETWORK_CONDITIONS_MEASURED); switch (mNetworkAgentInfo.networkInfo.getType()) { case ConnectivityManager.TYPE_WIFI: WifiInfo currentWifiInfo = mWifiManager.getConnectionInfo(); if (currentWifiInfo != null) { // NOTE: getSSID()'s behavior changed in API 17; before that, SSIDs were not // surrounded by double quotation marks (thus violating the Javadoc), but this // was changed to match the Javadoc in API 17. Since clients may have started // sanitizing the output of this method since API 17 was released, we should // not change it here as it would become impossible to tell whether the SSID is // simply being surrounded by quotes due to the API, or whether those quotes // are actually part of the SSID. latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_SSID, currentWifiInfo.getSSID()); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_BSSID, currentWifiInfo.getBSSID()); } else { if (VDBG) logw("network info is TYPE_WIFI but no ConnectionInfo found"); return; } break; case ConnectivityManager.TYPE_MOBILE: latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_NETWORK_TYPE, mTelephonyManager.getNetworkType()); List<CellInfo> info = mTelephonyManager.getAllCellInfo(); if (info == null) return; int numRegisteredCellInfo = 0; for (CellInfo cellInfo : info) { if (cellInfo.isRegistered()) { numRegisteredCellInfo++; if (numRegisteredCellInfo > 1) { if (VDBG) logw("more than one registered CellInfo." + " Can't tell which is active. Bailing."); return; } if (cellInfo instanceof CellInfoCdma) { CellIdentityCdma cellId = ((CellInfoCdma) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoGsm) { CellIdentityGsm cellId = ((CellInfoGsm) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoLte) { CellIdentityLte cellId = ((CellInfoLte) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else if (cellInfo instanceof CellInfoWcdma) { CellIdentityWcdma cellId = ((CellInfoWcdma) cellInfo).getCellIdentity(); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CELL_ID, cellId); } else { if (VDBG) logw("Registered cellinfo is unrecognized"); return; } } } break; default: return; } latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_CONNECTIVITY_TYPE, mNetworkAgentInfo.networkInfo.getType()); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_RESPONSE_RECEIVED, responseReceived); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_REQUEST_TIMESTAMP_MS, requestTimestampMs); if (responseReceived) { latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_IS_CAPTIVE_PORTAL, isCaptivePortal); latencyBroadcast.putExtra(ConnectivityConstants.EXTRA_RESPONSE_TIMESTAMP_MS, responseTimestampMs); } mContext.sendBroadcastAsUser(latencyBroadcast, UserHandle.CURRENT, ConnectivityConstants.PERMISSION_ACCESS_NETWORK_CONDITIONS); } private void logNetworkEvent(int evtype) { int[] transports = mNetworkAgentInfo.networkCapabilities.getTransportTypes(); mMetricsLog.log(mNetId, transports, new NetworkEvent(evtype)); Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +2 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,7 @@ import com.android.server.lights.LightsManager; import com.android.server.notification.ManagedServices.ManagedServiceInfo; import com.android.server.notification.ManagedServices.UserProfiles; import com.android.server.policy.PhoneWindowManager; import com.android.server.pm.PackageManagerService; import com.android.server.statusbar.StatusBarManagerInternal; import com.android.server.wm.WindowManagerInternal; Loading Loading @@ -4857,6 +4858,7 @@ public class NotificationManagerService extends SystemService { final PendingIntent pi = PendingIntent.getBroadcast(getContext(), REQUEST_CODE_TIMEOUT, new Intent(ACTION_NOTIFICATION_TIMEOUT) .setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME) .setData(new Uri.Builder().scheme(SCHEME_TIMEOUT) .appendPath(record.getKey()).build()) .addFlags(Intent.FLAG_RECEIVER_FOREGROUND) Loading
services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java +32 −2 Original line number Diff line number Diff line Loading @@ -27,8 +27,7 @@ import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE; import static android.content.pm.ActivityInfo.FLAG_SHOW_WHEN_LOCKED; import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_DESTROYING; import static com.android.server.am.ActivityStackSupervisor .MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_OR_RECENT_TASKS_AND_RESTORE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; Loading @@ -46,6 +45,8 @@ import static org.mockito.Mockito.verify; import android.app.ActivityOptions; import android.app.WaitResult; import android.graphics.Rect; import android.os.RemoteException; import android.os.UserHandle; import android.platform.test.annotations.Presubmit; import android.support.test.filters.MediumTest; import android.support.test.runner.AndroidJUnit4; Loading Loading @@ -407,4 +408,33 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase { // Assert that the primary stack is returned. assertEquals(primaryStack, result); } @Test public void testLockAllProfileTasks() throws Exception { // Make an activity visible with the user id set to 1 final TaskRecord task = new TaskBuilder(mSupervisor).setStack(mFullscreenStack).build(); final ActivityRecord activity = new ActivityBuilder(mService).setTask(task) .setUid(UserHandle.PER_USER_RANGE + 1).build(); // Create another activity on top and the user id is 2 final ActivityRecord topActivity = new ActivityBuilder(mService) .setTask(task).setUid(UserHandle.PER_USER_RANGE + 2).build(); // Make sure the listeners will be notified for putting the task to locked state LocalTaskStackListener listener = new LocalTaskStackListener(); mService.registerTaskStackListener(listener); mService.mStackSupervisor.lockAllProfileTasks(1); assertTrue(listener.mTaskProfileLocked); mService.unregisterTaskStackListener(listener); } private class LocalTaskStackListener extends android.app.TaskStackListener { boolean mTaskProfileLocked; @Override public void onTaskProfileLocked(int taskId, int userId) throws RemoteException { super.onTaskProfileLocked(taskId, userId); mTaskProfileLocked = true; } } }