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

Commit d38308e4 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Fix DPM unit tests"

parents e909d94e 3f3657a6
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1459,6 +1459,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        void settingsGlobalPutString(String name, String value) {
            Settings.Global.putString(mContext.getContentResolver(), name, value);
        }

        void securityLogSetLoggingEnabledProperty(boolean enabled) {
            SecurityLog.setLoggingEnabledProperty(enabled);
        }
    }

    /**
@@ -8315,7 +8319,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {

    private void disableDeviceLoggingIfNotCompliant() {
        if (!isDeviceOwnerManagedSingleUserDevice()) {
            SecurityLog.setLoggingEnabledProperty(false);
            mInjector.securityLogSetLoggingEnabledProperty(false);
            Slog.w(LOG_TAG, "Device logging turned off as it's no longer a single user device.");
        }
    }
@@ -8326,7 +8330,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        ensureDeviceOwnerManagingSingleUser(admin);

        synchronized (this) {
            SecurityLog.setLoggingEnabledProperty(enabled);
            mInjector.securityLogSetLoggingEnabledProperty(enabled);
            if (enabled) {
                mSecurityLogMonitor.start();
            } else {
+10 −0
Original line number Diff line number Diff line
@@ -281,5 +281,15 @@ public class DevicePolicyManagerServiceTestable extends DevicePolicyManagerServi
        void settingsGlobalPutString(String name, String value) {
            context.settings.settingsGlobalPutString(name, value);
        }

        @Override
        int settingsGlobalGetInt(String name, int def) {
            return context.settings.settingsGlobalGetInt(name, def);
        }

        @Override
        void securityLogSetLoggingEnabledProperty(boolean enabled) {
            context.settings.securityLogSetLoggingEnabledProperty(enabled);
        }
    }
}
+7 −0
Original line number Diff line number Diff line
@@ -191,6 +191,13 @@ public class DpmMockContext extends MockContext {

        void settingsGlobalPutString(String name, String value) {
        }

        int settingsGlobalGetInt(String name, int def) {
            return 0;
        }

        void securityLogSetLoggingEnabledProperty(boolean enabled) {
        }
    }

    public final Context realTestContext;