Merge "Lock Private space at the end of PS setup." into main

This commit is contained in:
Treehugger Robot
2023-12-11 22:05:12 +00:00
committed by Android (Google) Code Review
3 changed files with 84 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ import android.util.ArraySet;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.internal.annotations.GuardedBy;
@@ -226,6 +227,26 @@ public class PrivateSpaceMaintainer {
HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
}
/**
* Returns true if private space exists and quiet mode is successfully enabled, otherwise
* returns false
*/
public synchronized boolean lockPrivateSpace() {
if (isPrivateProfileRunning()) {
return mUserManager.requestQuietModeEnabled(true, mUserHandle);
}
return false;
}
/** Returns true if private space exists and is running, otherwise returns false */
@VisibleForTesting
synchronized boolean isPrivateProfileRunning() {
if (doesPrivateSpaceExist() && mUserHandle != null) {
return mUserManager.isUserRunning(mUserHandle);
}
return false;
}
private void resetPrivateSpaceSettings() {
setHidePrivateSpaceEntryPointSetting(HIDE_PRIVATE_SPACE_ENTRY_POINT_DISABLED_VAL);
}

View File

@@ -84,6 +84,8 @@ public class SetupSuccessFragment extends InstrumentedFragment {
if (activity != null) {
mMetricsFeatureProvider.action(
getContext(), SettingsEnums.ACTION_PRIVATE_SPACE_SETUP_DONE);
//TODO(b/307729746): Add a test to verify PS is locked after setup completion.
PrivateSpaceMaintainer.getInstance(activity).lockPrivateSpace();
Intent allAppsIntent = new Intent(Intent.ACTION_ALL_APPS);
ResolveInfo resolveInfo =
activity.getPackageManager()