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

Commit 3f3657a6 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Fix DPM unit tests

Bug 26911599

Change-Id: I874c9cd4f63c79bc984777ef3b1b654a414c4911
parent 3641a80a
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);
        }
    }

    /**
@@ -8317,7 +8321,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.");
        }
    }
@@ -8328,7 +8332,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;