Hide private space settings app post setup

Currently, the changes to disable private space settings app component
are located in SettiingsInitialize.java. These get triggered when
ACTION_USER_INITIALIZE is received by the settings app inside the
private profile user. However, we are stopping the private profile user
at the end of the setup flow. This can lead to a scenario wherein
ACTION_USER_INITIALIZE is relayed by the system server but not received
by the private space settings app, since it was stopped. To over come
this issue, we move the changes to disable the private space settings
app component inside the private space setup flow (right after the user
is created and started).

Bug: 342165140
Test: atest PrivateSpaceMaintainerTest#createPrivateSpace_psDoesNotExist_setsPrivateSpaceSettingsComponentDisabled
Flag: ACONFIG android.multiuser.enable_private_space_features NEXTFOOD
Change-Id: Ib9baac1e9d835ea5a27c15d499e10615b84cf97b
This commit is contained in:
Jigar Thakkar
2024-05-30 17:15:33 +00:00
parent 176f1a630a
commit b48a4469ac
4 changed files with 74 additions and 30 deletions

View File

@@ -30,6 +30,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.content.pm.UserInfo;
import android.os.Flags;
import android.os.UserHandle;
@@ -43,6 +44,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.internal.annotations.GuardedBy;
import com.android.settings.Utils;
import java.util.List;
@@ -124,6 +126,7 @@ public class PrivateSpaceMaintainer {
resetPrivateSpaceSettings();
setUserSetupComplete();
setSkipFirstUseHints();
disableComponentsToHidePrivateSpaceSettings();
}
return true;
}
@@ -351,6 +354,24 @@ public class PrivateSpaceMaintainer {
1, mUserHandle.getIdentifier());
}
/**
* Disables the launcher icon and shortcut picker component for the Settings app instance
* inside the private space
*/
@GuardedBy("this")
private void disableComponentsToHidePrivateSpaceSettings() {
if (mUserHandle == null) {
Log.e(TAG, "User handle null while hiding settings icon");
return;
}
Context privateSpaceUserContext = mContext.createContextAsUser(mUserHandle, /* flags */ 0);
PackageManager packageManager = privateSpaceUserContext.getPackageManager();
Log.d(TAG, "Hiding settings app launcher icon for " + mUserHandle);
Utils.disableComponentsToHideSettings(privateSpaceUserContext, packageManager);
}
/**
* 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.