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

Commit 9ebdedd2 authored by Joseph Vincent's avatar Joseph Vincent Committed by Android (Google) Code Review
Browse files

Merge "Private space auto lock on device restart during setup" into main

parents 1df39c3d 7ef9c46a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
import static android.provider.Settings.Secure.HIDE_PRIVATESPACE_ENTRY_POINT;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_AFTER_DEVICE_RESTART;
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK;
import static android.provider.Settings.Secure.SKIP_FIRST_USE_HINTS;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
@@ -70,6 +71,10 @@ public class PrivateSpaceMaintainer {
    @Settings.Secure.PrivateSpaceAutoLockOption
    public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL =
            PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK;
    /** Value for private space auto lock settings after private space creation. */
    @Settings.Secure.PrivateSpaceAutoLockOption
    public static final int PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL =
            PRIVATE_SPACE_AUTO_LOCK_AFTER_DEVICE_RESTART;
    /** Default value for the hide private space sensitive notifications on lockscreen. */
    public static final int HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL = 0;

@@ -327,7 +332,7 @@ public class PrivateSpaceMaintainer {
    @GuardedBy("this")
    private void resetPrivateSpaceSettings() {
        setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
        setPrivateSpaceAutoLockSetting(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
        setPrivateSpaceAutoLockSetting(PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL);
        setPrivateSpaceSensitiveNotificationsDefaultValue();
    }

+9 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.settings.privatespace;
import static android.content.Intent.ACTION_PROFILE_INACCESSIBLE;
import static android.content.Intent.ACTION_PROFILE_UNAVAILABLE;

import static com.android.settings.privatespace.PrivateSpaceMaintainer.PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL;

import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -101,8 +103,13 @@ public class SetupPreFinishDelayFragment extends InstrumentedFragment {
                };
        requireActivity().getOnBackPressedDispatcher().addCallback(this, callback);
        if (savedInstanceState == null) {
            // TODO(b/307729746): Add a test to verify PS is locked after setup completion.
            PrivateSpaceMaintainer.getInstance(getActivity()).lockPrivateSpace();
            // TODO(b/307729746): Add test to verify PS is locked and auto-lock value is set to
            // auto-lock on device lock after setup completion.
            PrivateSpaceMaintainer privateSpaceMaintainer =
                    PrivateSpaceMaintainer.getInstance(getActivity());
            privateSpaceMaintainer.setPrivateSpaceAutoLockSetting(
                    PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
            privateSpaceMaintainer.lockPrivateSpace();
        }
        return rootView;
    }
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_ENTRY_POINT_ENABLED_VAL;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL;
import static com.android.settings.privatespace.PrivateSpaceMaintainer.PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL;

import static com.google.common.truth.Truth.assertThat;

@@ -336,9 +336,9 @@ public class PrivateSpaceMaintainerTest {
        privateSpaceMaintainer.deletePrivateSpace();
        privateSpaceMaintainer.createPrivateSpace();
        assertThat(privateSpaceMaintainer.getPrivateSpaceAutoLockSetting())
                .isEqualTo(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
                .isEqualTo(PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL);
        assertThat(Settings.Secure.getInt(mContentResolver, PRIVATE_SPACE_AUTO_LOCK, -1))
                .isEqualTo(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
                .isEqualTo(PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL);
    }

    /**