Loading api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -6346,6 +6346,9 @@ package android.app.admin { method public void onTransferOwnershipComplete(android.content.Context, android.os.PersistableBundle); method public void onUserAdded(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserRemoved(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserStarted(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserStopped(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserSwitched(android.content.Context, android.content.Intent, android.os.UserHandle); field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLED = "android.app.action.DEVICE_ADMIN_DISABLED"; field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED"; field public static final java.lang.String ACTION_DEVICE_ADMIN_ENABLED = "android.app.action.DEVICE_ADMIN_ENABLED"; core/java/android/app/admin/DeviceAdminReceiver.java +73 −1 Original line number Diff line number Diff line Loading @@ -339,13 +339,43 @@ public class DeviceAdminReceiver extends BroadcastReceiver { /** * Broadcast action: notify the device owner that a user or profile has been removed. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the new user. * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_REMOVED = "android.app.action.USER_REMOVED"; /** * Broadcast action: notify the device owner that a user or profile has been started. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_STARTED = "android.app.action.USER_STARTED"; /** * Broadcast action: notify the device owner that a user or profile has been stopped. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_STOPPED = "android.app.action.USER_STOPPED"; /** * Broadcast action: notify the device owner that a user or profile has been switched to. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_SWITCHED = "android.app.action.USER_SWITCHED"; /** * A string containing the SHA-256 hash of the bugreport file. * Loading Loading @@ -913,6 +943,42 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public void onUserRemoved(Context context, Intent intent, UserHandle removedUser) { } /** * Called when a user or profile is started. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @param startedUser The {@link UserHandle} of the user that has just been started. */ public void onUserStarted(Context context, Intent intent, UserHandle startedUser) { } /** * Called when a user or profile is stopped. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @param stoppedUser The {@link UserHandle} of the user that has just been stopped. */ public void onUserStopped(Context context, Intent intent, UserHandle stoppedUser) { } /** * Called when a user or profile is switched to. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @param switchedUser The {@link UserHandle} of the user that has just been switched to. */ public void onUserSwitched(Context context, Intent intent, UserHandle switchedUser) { } /** * Called on the newly assigned owner (either device owner or profile owner) when the ownership * transfer has completed successfully. Loading Loading @@ -989,6 +1055,12 @@ public class DeviceAdminReceiver extends BroadcastReceiver { onUserAdded(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_REMOVED.equals(action)) { onUserRemoved(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_STARTED.equals(action)) { onUserStarted(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_STOPPED.equals(action)) { onUserStopped(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_SWITCHED.equals(action)) { onUserSwitched(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_TRANSFER_OWNERSHIP_COMPLETE.equals(action)) { PersistableBundle bundle = intent.getParcelableExtra(EXTRA_TRANSFER_OWNER_ADMIN_EXTRAS_BUNDLE); Loading services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -653,14 +653,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } if (Intent.ACTION_USER_ADDED.equals(action)) { sendUserAddedOrRemovedCommand(DeviceAdminReceiver.ACTION_USER_ADDED, userHandle); sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_ADDED, userHandle); synchronized (DevicePolicyManagerService.this) { // It might take a while for the user to become affiliated. Make security // and network logging unavailable in the meantime. maybePauseDeviceWideLoggingLocked(); } } else if (Intent.ACTION_USER_REMOVED.equals(action)) { sendUserAddedOrRemovedCommand(DeviceAdminReceiver.ACTION_USER_REMOVED, userHandle); sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_REMOVED, userHandle); synchronized (DevicePolicyManagerService.this) { // Check whether the user is affiliated, *before* removing its data. boolean isRemovedUserAffiliated = isUserAffiliatedWithDeviceLocked(userHandle); Loading @@ -674,12 +674,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } } else if (Intent.ACTION_USER_STARTED.equals(action)) { sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_STARTED, userHandle); synchronized (DevicePolicyManagerService.this) { maybeSendAdminEnabledBroadcastLocked(userHandle); // Reset the policy data mUserData.remove(userHandle); } handlePackagesChanged(null /* check all admins */, userHandle); } else if (Intent.ACTION_USER_STOPPED.equals(action)) { sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_STOPPED, userHandle); } else if (Intent.ACTION_USER_SWITCHED.equals(action)) { sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_SWITCHED, userHandle); } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) { synchronized (DevicePolicyManagerService.this) { maybeSendAdminEnabledBroadcastLocked(userHandle); Loading @@ -698,7 +703,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } private void sendUserAddedOrRemovedCommand(String action, int userHandle) { private void sendDeviceOwnerUserCommand(String action, int userHandle) { synchronized (DevicePolicyManagerService.this) { ActiveAdmin deviceOwner = getDeviceOwnerAdminLocked(); if (deviceOwner != null) { Loading Loading @@ -2046,6 +2051,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { filter.addAction(Intent.ACTION_USER_ADDED); filter.addAction(Intent.ACTION_USER_REMOVED); filter.addAction(Intent.ACTION_USER_STARTED); filter.addAction(Intent.ACTION_USER_STOPPED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_UNLOCKED); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, filter, null, mHandler); Loading Loading
api/current.txt +3 −0 Original line number Diff line number Diff line Loading @@ -6346,6 +6346,9 @@ package android.app.admin { method public void onTransferOwnershipComplete(android.content.Context, android.os.PersistableBundle); method public void onUserAdded(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserRemoved(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserStarted(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserStopped(android.content.Context, android.content.Intent, android.os.UserHandle); method public void onUserSwitched(android.content.Context, android.content.Intent, android.os.UserHandle); field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLED = "android.app.action.DEVICE_ADMIN_DISABLED"; field public static final java.lang.String ACTION_DEVICE_ADMIN_DISABLE_REQUESTED = "android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED"; field public static final java.lang.String ACTION_DEVICE_ADMIN_ENABLED = "android.app.action.DEVICE_ADMIN_ENABLED";
core/java/android/app/admin/DeviceAdminReceiver.java +73 −1 Original line number Diff line number Diff line Loading @@ -339,13 +339,43 @@ public class DeviceAdminReceiver extends BroadcastReceiver { /** * Broadcast action: notify the device owner that a user or profile has been removed. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the new user. * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_REMOVED = "android.app.action.USER_REMOVED"; /** * Broadcast action: notify the device owner that a user or profile has been started. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_STARTED = "android.app.action.USER_STARTED"; /** * Broadcast action: notify the device owner that a user or profile has been stopped. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_STOPPED = "android.app.action.USER_STOPPED"; /** * Broadcast action: notify the device owner that a user or profile has been switched to. * Carries an extra {@link Intent#EXTRA_USER} that has the {@link UserHandle} of * the user. * @hide */ @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) @BroadcastBehavior(explicitOnly = true) public static final String ACTION_USER_SWITCHED = "android.app.action.USER_SWITCHED"; /** * A string containing the SHA-256 hash of the bugreport file. * Loading Loading @@ -913,6 +943,42 @@ public class DeviceAdminReceiver extends BroadcastReceiver { public void onUserRemoved(Context context, Intent intent, UserHandle removedUser) { } /** * Called when a user or profile is started. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @param startedUser The {@link UserHandle} of the user that has just been started. */ public void onUserStarted(Context context, Intent intent, UserHandle startedUser) { } /** * Called when a user or profile is stopped. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @param stoppedUser The {@link UserHandle} of the user that has just been stopped. */ public void onUserStopped(Context context, Intent intent, UserHandle stoppedUser) { } /** * Called when a user or profile is switched to. * * <p>This callback is only applicable to device owners. * * @param context The running context as per {@link #onReceive}. * @param intent The received intent as per {@link #onReceive}. * @param switchedUser The {@link UserHandle} of the user that has just been switched to. */ public void onUserSwitched(Context context, Intent intent, UserHandle switchedUser) { } /** * Called on the newly assigned owner (either device owner or profile owner) when the ownership * transfer has completed successfully. Loading Loading @@ -989,6 +1055,12 @@ public class DeviceAdminReceiver extends BroadcastReceiver { onUserAdded(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_REMOVED.equals(action)) { onUserRemoved(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_STARTED.equals(action)) { onUserStarted(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_STOPPED.equals(action)) { onUserStopped(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_USER_SWITCHED.equals(action)) { onUserSwitched(context, intent, intent.getParcelableExtra(Intent.EXTRA_USER)); } else if (ACTION_TRANSFER_OWNERSHIP_COMPLETE.equals(action)) { PersistableBundle bundle = intent.getParcelableExtra(EXTRA_TRANSFER_OWNER_ADMIN_EXTRAS_BUNDLE); Loading
services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java +11 −4 Original line number Diff line number Diff line Loading @@ -653,14 +653,14 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } if (Intent.ACTION_USER_ADDED.equals(action)) { sendUserAddedOrRemovedCommand(DeviceAdminReceiver.ACTION_USER_ADDED, userHandle); sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_ADDED, userHandle); synchronized (DevicePolicyManagerService.this) { // It might take a while for the user to become affiliated. Make security // and network logging unavailable in the meantime. maybePauseDeviceWideLoggingLocked(); } } else if (Intent.ACTION_USER_REMOVED.equals(action)) { sendUserAddedOrRemovedCommand(DeviceAdminReceiver.ACTION_USER_REMOVED, userHandle); sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_REMOVED, userHandle); synchronized (DevicePolicyManagerService.this) { // Check whether the user is affiliated, *before* removing its data. boolean isRemovedUserAffiliated = isUserAffiliatedWithDeviceLocked(userHandle); Loading @@ -674,12 +674,17 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } } else if (Intent.ACTION_USER_STARTED.equals(action)) { sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_STARTED, userHandle); synchronized (DevicePolicyManagerService.this) { maybeSendAdminEnabledBroadcastLocked(userHandle); // Reset the policy data mUserData.remove(userHandle); } handlePackagesChanged(null /* check all admins */, userHandle); } else if (Intent.ACTION_USER_STOPPED.equals(action)) { sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_STOPPED, userHandle); } else if (Intent.ACTION_USER_SWITCHED.equals(action)) { sendDeviceOwnerUserCommand(DeviceAdminReceiver.ACTION_USER_SWITCHED, userHandle); } else if (Intent.ACTION_USER_UNLOCKED.equals(action)) { synchronized (DevicePolicyManagerService.this) { maybeSendAdminEnabledBroadcastLocked(userHandle); Loading @@ -698,7 +703,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { } } private void sendUserAddedOrRemovedCommand(String action, int userHandle) { private void sendDeviceOwnerUserCommand(String action, int userHandle) { synchronized (DevicePolicyManagerService.this) { ActiveAdmin deviceOwner = getDeviceOwnerAdminLocked(); if (deviceOwner != null) { Loading Loading @@ -2046,6 +2051,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager { filter.addAction(Intent.ACTION_USER_ADDED); filter.addAction(Intent.ACTION_USER_REMOVED); filter.addAction(Intent.ACTION_USER_STARTED); filter.addAction(Intent.ACTION_USER_STOPPED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_UNLOCKED); filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY); mContext.registerReceiverAsUser(mReceiver, UserHandle.ALL, filter, null, mHandler); Loading