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

Commit de3f9370 authored by Momoko Hattori's avatar Momoko Hattori
Browse files

Rename MultiuserDeprecationReporter to MultiuserNonComplianceLogger

... since the class will also cover activities and notifications on HSU
as well as the deprecated API calls.

Bug: 414326600
Test: adb shell dumpsys user --non-compliance
Flag: EXEMPT refactoring

Change-Id: I63b4f9a162982f54f5366d4576084466cbe53547
parent a5a25a9b
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -31,14 +31,14 @@ import com.android.server.LocalServices;


import java.io.PrintWriter;
import java.io.PrintWriter;


// TODO(b/414326600): rename (and add unit tests) once the final design is ready (notice that it's
// also used to log UI actions on HSU
/**
/**
 * Class used to report deprecated calls.
 * Class used to report events that indicate the potential existence of non-multiuser-compliant
 * features, such as the API calls to check for "main user" (deprecated) and the activities and
 * notifications on headless system user.
 */
 */
final class MultiuserDeprecationReporter {
final class MultiuserNonComplianceLogger {


    private static final String PROP_ENABLE_IT = "fw.user.log_deprecation";
    private static final String PROP_ENABLE_IT = "fw.user.log_non_compliance";
    private static final int PROP_ENABLED = 1;
    private static final int PROP_ENABLED = 1;
    private static final int PROP_DEFAULT = -1;
    private static final int PROP_DEFAULT = -1;


@@ -62,7 +62,7 @@ final class MultiuserDeprecationReporter {
    @Nullable
    @Nullable
    private PackageManagerInternal mPmInternal;
    private PackageManagerInternal mPmInternal;


    MultiuserDeprecationReporter(Handler handler) {
    MultiuserNonComplianceLogger(Handler handler) {
        mHandler = handler;
        mHandler = handler;
        if (Build.isDebuggable()
        if (Build.isDebuggable()
                || SystemProperties.getInt(PROP_ENABLE_IT, PROP_DEFAULT) == PROP_ENABLED) {
                || SystemProperties.getInt(PROP_ENABLE_IT, PROP_DEFAULT) == PROP_ENABLED) {
+9 −10
Original line number Original line Diff line number Diff line
@@ -404,7 +404,7 @@ public class UserManagerService extends IUserManager.Stub {
    private final Object mAppRestrictionsLock = NamedLock.create("mAppRestrictionsLock");
    private final Object mAppRestrictionsLock = NamedLock.create("mAppRestrictionsLock");


    private final Handler mHandler;
    private final Handler mHandler;
    private final MultiuserDeprecationReporter mDeprecationReporter;
    private final MultiuserNonComplianceLogger mNonComplianceLogger;


    private final ThreadPoolExecutor mInternalExecutor;
    private final ThreadPoolExecutor mInternalExecutor;


@@ -1119,7 +1119,7 @@ public class UserManagerService extends IUserManager.Stub {
        mPackagesLock = packagesLock;
        mPackagesLock = packagesLock;
        mUsers = users != null ? users : new SparseArray<>();
        mUsers = users != null ? users : new SparseArray<>();
        mHandler = new MainHandler();
        mHandler = new MainHandler();
        mDeprecationReporter = new MultiuserDeprecationReporter(mHandler);
        mNonComplianceLogger = new MultiuserNonComplianceLogger(mHandler);
        mInternalExecutor = new ThreadPoolExecutor(/* corePoolSize */ 0, /* maximumPoolSize */ 1,
        mInternalExecutor = new ThreadPoolExecutor(/* corePoolSize */ 0, /* maximumPoolSize */ 1,
                /* keepAliveTime */ 24, TimeUnit.HOURS, new LinkedBlockingQueue<>());
                /* keepAliveTime */ 24, TimeUnit.HOURS, new LinkedBlockingQueue<>());
        mUserVisibilityMediator = new UserVisibilityMediator(mHandler);
        mUserVisibilityMediator = new UserVisibilityMediator(mHandler);
@@ -1377,7 +1377,7 @@ public class UserManagerService extends IUserManager.Stub {
    @Override
    @Override
    public @CanBeNULL @UserIdInt int getMainUserId() {
    public @CanBeNULL @UserIdInt int getMainUserId() {
        checkQueryOrCreateUsersPermission("get main user id");
        checkQueryOrCreateUsersPermission("get main user id");
        mDeprecationReporter.logGetMainUserCall();
        mNonComplianceLogger.logGetMainUserCall();
        return getMainUserIdUnchecked();
        return getMainUserIdUnchecked();
    }
    }


@@ -1402,7 +1402,7 @@ public class UserManagerService extends IUserManager.Stub {


    @Override
    @Override
    public boolean isMainUser(int userId) {
    public boolean isMainUser(int userId) {
        mDeprecationReporter.logIsMainUserCall();
        mNonComplianceLogger.logIsMainUserCall();
        UserInfo user = getUserInfo(userId);
        UserInfo user = getUserInfo(userId);
        return user != null && user.isMainUnlogged();
        return user != null && user.isMainUnlogged();
    }
    }
@@ -8127,12 +8127,11 @@ public class UserManagerService extends IUserManager.Stub {
                case "--visibility-mediator":
                case "--visibility-mediator":
                    mUserVisibilityMediator.dump(pw, args);
                    mUserVisibilityMediator.dump(pw, args);
                    return;
                    return;
                // TODO(b/414326600): use a different arg for HSU SysUI actions
                case "--non-compliance":
                case "--deprecated-calls":
                    if (args.length > 1 && args[1].equals("reset")) {
                    if (args.length > 1 && args[1].equals("reset")) {
                        mDeprecationReporter.reset(pw);
                        mNonComplianceLogger.reset(pw);
                    } else {
                    } else {
                        mDeprecationReporter.dump(pw);
                        mNonComplianceLogger.dump(pw);
                    }
                    }
                    return;
                    return;
            }
            }
@@ -8275,7 +8274,7 @@ public class UserManagerService extends IUserManager.Stub {
        }
        }


        pw.println();
        pw.println();
        mDeprecationReporter.dump(pw);
        mNonComplianceLogger.dump(pw);


        // NOTE: add new stuff here, as pw is closed after the try-with-resources block below
        // NOTE: add new stuff here, as pw is closed after the try-with-resources block below


@@ -8965,7 +8964,7 @@ public class UserManagerService extends IUserManager.Stub {


        @Override
        @Override
        public void logLaunchedHsuActivity(ComponentName activity) {
        public void logLaunchedHsuActivity(ComponentName activity) {
            mDeprecationReporter.logLaunchedHsuActivity(activity);
            mNonComplianceLogger.logLaunchedHsuActivity(activity);
        }
        }


    } // class LocalService
    } // class LocalService