Update USER_SETUP_COMPLETE setting after starting private space
On setting USER_SETUP_COMPLETE for private profile device is reapplied to the profile Bug: 311348071 Test: Verified device theme color is applied to profile Change-Id: I25f3013aaf6cfc6925d858b461c1f2c6beb534f6
This commit is contained in:
@@ -18,6 +18,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.USER_SETUP_COMPLETE;
|
||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.IActivityManager;
|
import android.app.IActivityManager;
|
||||||
@@ -96,6 +97,7 @@ public class PrivateSpaceMaintainer {
|
|||||||
|
|
||||||
IActivityManager am = ActivityManager.getService();
|
IActivityManager am = ActivityManager.getService();
|
||||||
try {
|
try {
|
||||||
|
//TODO(b/313926659): To check and handle failure of startProfile
|
||||||
am.startProfile(mUserHandle.getIdentifier());
|
am.startProfile(mUserHandle.getIdentifier());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Failed to start private profile");
|
Log.e(TAG, "Failed to start private profile");
|
||||||
@@ -104,6 +106,7 @@ public class PrivateSpaceMaintainer {
|
|||||||
|
|
||||||
Log.i(TAG, "Private space created with id: " + mUserHandle.getIdentifier());
|
Log.i(TAG, "Private space created with id: " + mUserHandle.getIdentifier());
|
||||||
resetPrivateSpaceSettings();
|
resetPrivateSpaceSettings();
|
||||||
|
setUserSetupComplete();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -250,4 +253,14 @@ public class PrivateSpaceMaintainer {
|
|||||||
private void resetPrivateSpaceSettings() {
|
private void resetPrivateSpaceSettings() {
|
||||||
setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
|
setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the USER_SETUP_COMPLETE for private profile on which device theme is applied to the
|
||||||
|
* profile.
|
||||||
|
*/
|
||||||
|
@GuardedBy("this")
|
||||||
|
private void setUserSetupComplete() {
|
||||||
|
Settings.Secure.putIntForUser(mContext.getContentResolver(), USER_SETUP_COMPLETE,
|
||||||
|
1, mUserHandle.getIdentifier());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -198,4 +198,40 @@ public class PrivateSpaceMaintainerTest {
|
|||||||
assertThat(privateSpaceMaintainer.doesPrivateSpaceExist()).isFalse();
|
assertThat(privateSpaceMaintainer.doesPrivateSpaceExist()).isFalse();
|
||||||
assertThat(privateSpaceMaintainer.lockPrivateSpace()).isFalse();
|
assertThat(privateSpaceMaintainer.lockPrivateSpace()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that {@link PrivateSpaceMaintainer#createPrivateSpace()} when no PS exists sets
|
||||||
|
* USER_SETUP_COMPLETE setting.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void createPrivateSpace_psDoesNotExist_setsUserSetupComplete() {
|
||||||
|
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||||
|
PrivateSpaceMaintainer.getInstance(mContext);
|
||||||
|
privateSpaceMaintainer.createPrivateSpace();
|
||||||
|
assertThat(getSecureUserSetupComplete()).isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that {@link PrivateSpaceMaintainer#createPrivateSpace()} when PS exists does not
|
||||||
|
* change USER_SETUP_COMPLETE setting.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void createPrivateSpace_pSExists_doesNotChangeUserSetupSetting() {
|
||||||
|
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||||
|
PrivateSpaceMaintainer.getInstance(mContext);
|
||||||
|
privateSpaceMaintainer.createPrivateSpace();
|
||||||
|
assertThat(getSecureUserSetupComplete()).isEqualTo(1);
|
||||||
|
privateSpaceMaintainer.createPrivateSpace();
|
||||||
|
assertThat(getSecureUserSetupComplete()).isEqualTo(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getSecureUserSetupComplete() {
|
||||||
|
PrivateSpaceMaintainer privateSpaceMaintainer =
|
||||||
|
PrivateSpaceMaintainer.getInstance(mContext);
|
||||||
|
return Settings.Secure.getIntForUser(
|
||||||
|
mContentResolver,
|
||||||
|
Settings.Secure.USER_SETUP_COMPLETE,
|
||||||
|
0,
|
||||||
|
privateSpaceMaintainer.getPrivateProfileHandle().getIdentifier());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user