Private space auto lock on device restart during setup
After creation of private space value of auto-lock setting is explicitly set to lock on device restarts. Just before the end of the setup flow the auto-lock setting is changed to auto-lock on device lock before the last screen of private space setup. Bug: 342398315 Test: atest PrivateSpaceMaintainerTest Change-Id: I8eeb0058c7ecb31d6e30b4cc78ec5877ed316f75
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.privatespace;
|
|||||||
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
|
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.HIDE_PRIVATESPACE_ENTRY_POINT;
|
||||||
import static android.provider.Settings.Secure.PRIVATE_SPACE_AUTO_LOCK;
|
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.PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK;
|
||||||
import static android.provider.Settings.Secure.SKIP_FIRST_USE_HINTS;
|
import static android.provider.Settings.Secure.SKIP_FIRST_USE_HINTS;
|
||||||
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
||||||
@@ -70,6 +71,10 @@ public class PrivateSpaceMaintainer {
|
|||||||
@Settings.Secure.PrivateSpaceAutoLockOption
|
@Settings.Secure.PrivateSpaceAutoLockOption
|
||||||
public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL =
|
public static final int PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL =
|
||||||
PRIVATE_SPACE_AUTO_LOCK_ON_DEVICE_LOCK;
|
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. */
|
/** Default value for the hide private space sensitive notifications on lockscreen. */
|
||||||
public static final int HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL = 0;
|
public static final int HIDE_PRIVATE_SPACE_SENSITIVE_NOTIFICATIONS_DISABLED_VAL = 0;
|
||||||
|
|
||||||
@@ -327,7 +332,7 @@ public class PrivateSpaceMaintainer {
|
|||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
private void resetPrivateSpaceSettings() {
|
private void resetPrivateSpaceSettings() {
|
||||||
setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
|
setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
|
||||||
setPrivateSpaceAutoLockSetting(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
|
setPrivateSpaceAutoLockSetting(PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL);
|
||||||
setPrivateSpaceSensitiveNotificationsDefaultValue();
|
setPrivateSpaceSensitiveNotificationsDefaultValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,6 +19,8 @@ package com.android.settings.privatespace;
|
|||||||
import static android.content.Intent.ACTION_PROFILE_INACCESSIBLE;
|
import static android.content.Intent.ACTION_PROFILE_INACCESSIBLE;
|
||||||
import static android.content.Intent.ACTION_PROFILE_UNAVAILABLE;
|
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.app.settings.SettingsEnums;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -101,8 +103,13 @@ public class SetupPreFinishDelayFragment extends InstrumentedFragment {
|
|||||||
};
|
};
|
||||||
requireActivity().getOnBackPressedDispatcher().addCallback(this, callback);
|
requireActivity().getOnBackPressedDispatcher().addCallback(this, callback);
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
// TODO(b/307729746): Add a test to verify PS is locked after setup completion.
|
// TODO(b/307729746): Add test to verify PS is locked and auto-lock value is set to
|
||||||
PrivateSpaceMaintainer.getInstance(getActivity()).lockPrivateSpace();
|
// 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;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
@@ -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_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_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.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;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -336,9 +336,9 @@ public class PrivateSpaceMaintainerTest {
|
|||||||
privateSpaceMaintainer.deletePrivateSpace();
|
privateSpaceMaintainer.deletePrivateSpace();
|
||||||
privateSpaceMaintainer.createPrivateSpace();
|
privateSpaceMaintainer.createPrivateSpace();
|
||||||
assertThat(privateSpaceMaintainer.getPrivateSpaceAutoLockSetting())
|
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))
|
assertThat(Settings.Secure.getInt(mContentResolver, PRIVATE_SPACE_AUTO_LOCK, -1))
|
||||||
.isEqualTo(PRIVATE_SPACE_AUTO_LOCK_DEFAULT_VAL);
|
.isEqualTo(PRIVATE_SPACE_CREATE_AUTO_LOCK_VAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user