Send showNewUserDisclaimer broadcast when user switching

Previously, showNewUserDisclaimer broadcast is sent just after user unlocked.
Since the new user is not yet ready to get broadcast messages at that time,
it is failed to deliver the broadcast message to the target user.

To make the new user get the message and show a notification correctly,
send the broadcast when the user is switching to foreground.

Bug: 347611453
Test: Run CTS-Verifier "Check new user disclaimer" test and see a notification and a dialog are shown.
Flag: EXEMPT bugfix

Change-Id: I00eb7e02b2d348cb6baae74a48ef170372fde385
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index e122fe0..032d6b5 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -1131,9 +1131,9 @@
         }
 
         @Override
-        public void onUserUnlocked(@NonNull TargetUser user) {
-            if (user.isPreCreated()) return;
-            mService.handleOnUserUnlocked(user.getUserIdentifier());
+        public void onUserSwitching(@NonNull TargetUser from, @NonNull TargetUser to) {
+            if (to.isPreCreated()) return;
+            mService.handleOnUserSwitching(from.getUserIdentifier(), to.getUserIdentifier());
         }
     }
 
@@ -3831,8 +3831,8 @@
         mDevicePolicyEngine.handleUnlockUser(userId);
     }
 
-    void handleOnUserUnlocked(int userId) {
-        showNewUserDisclaimerIfNecessary(userId);
+    void handleOnUserSwitching(int fromUserId, int toUserId) {
+        showNewUserDisclaimerIfNecessary(toUserId);
     }
 
     void handleStopUser(int userId) {