UserController/Manager loglines

Adds a few more important, infrequent loglines to
UserController and UserManager.

Also marks their private methods as private (if not already so marked)
to make it clearer which methods are called from external classes.

Test: compiles
Test: atest UserManagerServiceTest UserManagerServiceUserInfoTest UserManagerServiceUserTypeTest UserManagerTest UserSystemPackageInstallerTest UserControllerTest
Change-Id: I67340178c8576461d0adde395c90215d85d1f56e
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 45d31f3..fa7eae3 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -425,6 +425,7 @@
     }
 
     @GuardedBy("mLock")
+    @VisibleForTesting
     List<Integer> getRunningUsersLU() {
         ArrayList<Integer> runningUsers = new ArrayList<>();
         for (Integer userId : mUserLru) {
@@ -450,7 +451,7 @@
     }
 
     @GuardedBy("mLock")
-    void stopRunningUsersLU(int maxRunningUsers) {
+    private void stopRunningUsersLU(int maxRunningUsers) {
         List<Integer> currentlyRunning = getRunningUsersLU();
         Iterator<Integer> iterator = currentlyRunning.iterator();
         while (currentlyRunning.size() > maxRunningUsers && iterator.hasNext()) {
@@ -616,7 +617,7 @@
      * Step from {@link UserState#STATE_RUNNING_UNLOCKING} to
      * {@link UserState#STATE_RUNNING_UNLOCKED}.
      */
-    void finishUserUnlocked(final UserState uss) {
+    private void finishUserUnlocked(final UserState uss) {
         final int userId = uss.mHandle.getIdentifier();
         EventLog.writeEvent(EventLogTags.UC_FINISH_USER_UNLOCKED, userId);
         // Only keep marching forward if user is actually unlocked
@@ -911,7 +912,7 @@
     private void stopSingleUserLU(final int userId, boolean allowDelayedLocking,
             final IStopUserCallback stopUserCallback,
             KeyEvictedCallback keyEvictedCallback) {
-        if (DEBUG_MU) Slogf.i(TAG, "stopSingleUserLocked userId=" + userId);
+        Slogf.i(TAG, "stopSingleUserLU userId=" + userId);
         final UserState uss = mStartedUsers.get(userId);
         if (uss == null) {  // User is not started
             // If mDelayUserDataLocking is set and allowDelayedLocking is not set, we need to lock
@@ -1004,7 +1005,7 @@
         }
     }
 
-    void finishUserStopping(final int userId, final UserState uss,
+    private void finishUserStopping(final int userId, final UserState uss,
             final boolean allowDelayedLocking) {
         EventLog.writeEvent(EventLogTags.UC_FINISH_USER_STOPPING, userId);
         synchronized (mLock) {
@@ -1045,6 +1046,7 @@
                 Binder.getCallingPid(), userId);
     }
 
+    @VisibleForTesting
     void finishUserStopped(UserState uss, boolean allowDelayedLocking) {
         final int userId = uss.mHandle.getIdentifier();
         if (DEBUG_MU) {
@@ -1268,7 +1270,7 @@
         });
     }
 
-    void startProfiles() {
+    private void startProfiles() {
         int currentUserId = getCurrentUserId();
         if (DEBUG_MU) Slogf.i(TAG, "startProfilesLocked");
         List<UserInfo> profiles = mInjector.getUserManager().getProfiles(
@@ -1321,6 +1323,7 @@
         return startUserNoChecks(userId, /* foreground= */ false, /* unlockListener= */ null);
     }
 
+    @VisibleForTesting
     boolean startUser(final @UserIdInt int userId, final boolean foreground) {
         return startUser(userId, foreground, null);
     }
@@ -1783,6 +1786,7 @@
     }
 
     /** Called on handler thread */
+    @VisibleForTesting
     void dispatchUserSwitchComplete(@UserIdInt int userId) {
         mInjector.getWindowManager().setSwitchingUser(false);
         final int observerCount = mUserSwitchObservers.beginBroadcast();
@@ -1856,6 +1860,7 @@
         }
     }
 
+    @VisibleForTesting
     void dispatchUserSwitch(final UserState uss, final int oldUserId, final int newUserId) {
         final TimingsTraceAndSlog t = new TimingsTraceAndSlog();
         t.traceBegin("dispatchUserSwitch-" + oldUserId + "-to-" + newUserId);
@@ -1916,13 +1921,14 @@
     }
 
     @GuardedBy("mLock")
-    void sendContinueUserSwitchLU(UserState uss, int oldUserId, int newUserId) {
+    private void sendContinueUserSwitchLU(UserState uss, int oldUserId, int newUserId) {
         mCurWaitingUserSwitchCallbacks = null;
         mHandler.removeMessages(USER_SWITCH_TIMEOUT_MSG);
         mHandler.sendMessage(mHandler.obtainMessage(CONTINUE_USER_SWITCH_MSG,
                 oldUserId, newUserId, uss));
     }
 
+    @VisibleForTesting
     void continueUserSwitch(UserState uss, int oldUserId, int newUserId) {
         final TimingsTraceAndSlog t = new TimingsTraceAndSlog();
         t.traceBegin("continueUserSwitch-" + oldUserId + "-to-" + newUserId);
@@ -2373,7 +2379,7 @@
     }
 
     @GuardedBy("mLock")
-    UserInfo getCurrentUserLU() {
+    private UserInfo getCurrentUserLU() {
         int userId = getCurrentOrTargetUserIdLU();
         return getUserInfo(userId);
     }
@@ -2385,12 +2391,12 @@
     }
 
     @GuardedBy("mLock")
-    int getCurrentOrTargetUserIdLU() {
+    private int getCurrentOrTargetUserIdLU() {
         return mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId;
     }
 
     @GuardedBy("mLock")
-    int getCurrentUserIdLU() {
+    private int getCurrentUserIdLU() {
         return mCurrentUserId;
     }
 
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 89f2bfe..190e7bc 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -117,6 +117,7 @@
 import com.android.server.pm.UserManagerInternal.UserLifecycleListener;
 import com.android.server.pm.UserManagerInternal.UserRestrictionsListener;
 import com.android.server.storage.DeviceStorageMonitorInternal;
+import com.android.server.utils.Slogf;
 import com.android.server.utils.TimingsTraceAndSlog;
 import com.android.server.wm.ActivityTaskManagerInternal;
 
@@ -727,7 +728,7 @@
     }
 
     /* Prunes out any partially created or partially removed users. */
-    void cleanupPartialUsers() {
+    private void cleanupPartialUsers() {
         ArrayList<UserInfo> partials = new ArrayList<>();
         synchronized (mUsersLock) {
             final int userSize = mUsers.size();
@@ -755,7 +756,7 @@
      * Removes any pre-created users from the system. Should be invoked after OTAs, to ensure
      * pre-created users are not stale. New pre-created pool can be re-created after the update.
      */
-    void cleanupPreCreatedUsers() {
+    private void cleanupPreCreatedUsers() {
         final ArrayList<UserInfo> preCreatedUsers;
         synchronized (mUsersLock) {
             final int userSize = mUsers.size();
@@ -1213,6 +1214,10 @@
 
     private void logQuietModeEnabled(@UserIdInt int userId, boolean enableQuietMode,
             @Nullable String callingPackage) {
+        Slogf.i(LOG_TAG,
+                "requestQuietModeEnabled called by package %s, with enableQuietMode %b.",
+                callingPackage,
+                enableQuietMode);
         UserData userData;
         synchronized (mUsersLock) {
             userData = getUserDataLU(userId);
@@ -2293,13 +2298,13 @@
 
     // Package private for the inner class.
     @GuardedBy("mRestrictionsLock")
-    void applyUserRestrictionsLR(@UserIdInt int userId) {
+    private void applyUserRestrictionsLR(@UserIdInt int userId) {
         updateUserRestrictionsInternalLR(null, userId);
     }
 
     @GuardedBy("mRestrictionsLock")
     // Package private for the inner class.
-    void applyUserRestrictionsForAllUsersLR() {
+    private void applyUserRestrictionsForAllUsersLR() {
         if (DBG) {
             debug("applyUserRestrictionsForAllUsersLR");
         }
@@ -2900,8 +2905,7 @@
     }
 
     @GuardedBy("mUsersLock")
-    @VisibleForTesting
-    void upgradeUserTypesLU(@NonNull List<UserTypeFactory.UserTypeUpgrade> upgradeOps,
+    private void upgradeUserTypesLU(@NonNull List<UserTypeFactory.UserTypeUpgrade> upgradeOps,
             @NonNull ArrayMap<String, UserTypeDetails> userTypes,
             final int formerUserTypeVersion,
             @NonNull Set<Integer> userIdsToWrite) {
@@ -3880,6 +3884,7 @@
     }
 
     /** Checks that the flags do not contain mutually exclusive types/properties. */
+    @VisibleForTesting
     static boolean checkUserTypeConsistency(@UserInfoFlag int flags) {
         // Mask to check that flags don't refer to multiple user types.
         final int userTypeFlagMask = UserInfo.FLAG_GUEST | UserInfo.FLAG_DEMO
@@ -4186,6 +4191,7 @@
                         return false;
                     }
 
+                    Slog.i(LOG_TAG, "Removing user " + userId);
                     addRemovingUserIdLocked(userId);
                 }
 
@@ -4308,8 +4314,8 @@
         }
     }
 
-    void finishRemoveUser(final @UserIdInt int userId) {
-        if (DBG) Slog.i(LOG_TAG, "finishRemoveUser " + userId);
+    private void finishRemoveUser(final @UserIdInt int userId) {
+        Slog.i(LOG_TAG, "finishRemoveUser " + userId);
 
         UserInfo user;
         synchronized (mUsersLock) {
@@ -4368,6 +4374,7 @@
     }
 
     private void removeUserState(final @UserIdInt int userId) {
+        Slog.i(LOG_TAG, "Removing user state of user " + userId);
         try {
             mContext.getSystemService(StorageManager.class).destroyUserKey(userId);
         } catch (IllegalStateException e) {
@@ -4991,7 +4998,7 @@
         (new Shell()).exec(this, in, out, err, args, callback, resultReceiver);
     }
 
-    int onShellCommand(Shell shell, String cmd) {
+    private int onShellCommand(Shell shell, String cmd) {
         if (cmd == null) {
             return shell.handleDefaultCommands(cmd);
         }