Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1d36150 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deprecate (and log usage) of DPMS.getMainUserId()" into main

parents 8f8d0451 5c03be60
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -501,6 +501,7 @@ import android.util.AtomicFile;
import android.util.DebugUtils;
import android.util.IndentingPrintWriter;
import android.util.IntArray;
import android.util.Log;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
@@ -10143,12 +10144,25 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        }
    }
    /**
     * @deprecated TODO(b/420745998): the concept of main user is deprecated, callers should use
     * other signals like checking if the user is admin, current user, system user, et.c..
     */
    @Deprecated
    private @UserIdInt int getMainUserId() {
        boolean logIt = Log.isLoggable(LOG_TAG, Log.VERBOSE);
        int mainUserId = mUserManagerInternal.getMainUserId();
        if (mainUserId == UserHandle.USER_NULL) {
            Slogf.d(LOG_TAG, "getMainUserId(): no main user, returning USER_SYSTEM");
            if (logIt) {
                Slogf.w(LOG_TAG, new Exception("getMainUserId() called when it's null:"));
            } else {
                Slogf.w(LOG_TAG, "getMainUserId(): no main user, returning USER_SYSTEM");
            }
            return UserHandle.USER_SYSTEM;
        }
        if (logIt) {
            Slogf.v(LOG_TAG, new Exception(), "getMainUserId() returning %d at:", mainUserId);
        }
        return mainUserId;
    }