Set SKIP_FIRST_USE_HINTS setting for private space
With this change the value of Secure settings SKIP_FIRST_USE_HINTS is set for private profile after creation of profile in PS setup flow. The value is set for the profile user so that first launch of an app in private space will not display introductory hints. Bug: 325596557 Test: PrivateSpaceMaintainerTest Change-Id: I63a967bba052a3dcb4742c95b89c6da19aba74d5
This commit is contained in:
@@ -20,6 +20,7 @@ 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.SKIP_FIRST_USE_HINTS;
|
||||
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
@@ -122,6 +123,7 @@ public class PrivateSpaceMaintainer {
|
||||
Log.i(TAG, "Private space created with id: " + mUserHandle.getIdentifier());
|
||||
resetPrivateSpaceSettings();
|
||||
setUserSetupComplete();
|
||||
setSkipFirstUseHints();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -350,6 +352,17 @@ public class PrivateSpaceMaintainer {
|
||||
1, mUserHandle.getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SKIP_FIRST_USE_HINTS for private profile so that the first launch of an app in
|
||||
* private space will not display introductory hints.
|
||||
*/
|
||||
@GuardedBy("this")
|
||||
private void setSkipFirstUseHints() {
|
||||
Log.d(TAG, "setting SKIP_FIRST_USE_HINTS = 1 for private profile");
|
||||
Settings.Secure.putIntForUser(mContext.getContentResolver(), SKIP_FIRST_USE_HINTS,
|
||||
1, mUserHandle.getIdentifier());
|
||||
}
|
||||
|
||||
private boolean isPrivateSpaceAutoLockSupported() {
|
||||
return android.os.Flags.allowPrivateProfile()
|
||||
&& android.multiuser.Flags.supportAutolockForPrivateSpace()
|
||||
|
@@ -421,6 +421,30 @@ public class PrivateSpaceMaintainerTest {
|
||||
assertThat(privateSpaceMaintainer.isPrivateSpaceEntryPointEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPrivateSpace_psDoesNotExist_setsSkipFirstUseHints() {
|
||||
mSetFlagsRule.enableFlags(
|
||||
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
|
||||
assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
|
||||
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||
PrivateSpaceMaintainer.getInstance(mContext);
|
||||
privateSpaceMaintainer.createPrivateSpace();
|
||||
assertThat(getSecureSkipFirstUseHints()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createPrivateSpace_pSExists_doesNotChangeSkipFirstUseHints() {
|
||||
mSetFlagsRule.enableFlags(
|
||||
android.multiuser.Flags.FLAG_ENABLE_PRIVATE_SPACE_FEATURES);
|
||||
assumeTrue(mContext.getSystemService(UserManager.class).canAddPrivateProfile());
|
||||
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||
PrivateSpaceMaintainer.getInstance(mContext);
|
||||
privateSpaceMaintainer.createPrivateSpace();
|
||||
assertThat(getSecureSkipFirstUseHints()).isEqualTo(1);
|
||||
privateSpaceMaintainer.createPrivateSpace();
|
||||
assertThat(getSecureSkipFirstUseHints()).isEqualTo(1);
|
||||
}
|
||||
|
||||
private int getSecureUserSetupComplete() {
|
||||
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||
PrivateSpaceMaintainer.getInstance(mContext);
|
||||
@@ -431,6 +455,16 @@ public class PrivateSpaceMaintainerTest {
|
||||
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
|
||||
}
|
||||
|
||||
private int getSecureSkipFirstUseHints() {
|
||||
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||
PrivateSpaceMaintainer.getInstance(mContext);
|
||||
return Settings.Secure.getIntForUser(
|
||||
mContentResolver,
|
||||
Settings.Secure.SKIP_FIRST_USE_HINTS,
|
||||
0,
|
||||
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
|
||||
}
|
||||
|
||||
private int getPsSensitiveNotificationsValue(PrivateSpaceMaintainer privateSpaceMaintainer) {
|
||||
return Settings.Secure.getIntForUser(mContentResolver,
|
||||
LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS,
|
||||
|
Reference in New Issue
Block a user