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

@@ -1464,4 +1464,22 @@ public final class Utils extends com.android.settingslib.Utils {
}
};
}
/**
* Disables the launcher icon and shortcut picker component for the Settings app corresponding
* to the context user.
*/
public static void disableComponentsToHideSettings(@NonNull Context context,
@NonNull PackageManager pm) {
// Disable settings app launcher icon
disableComponent(pm, new ComponentName(context, Settings.class));
//Disable Shortcut picker
disableComponent(pm, new ComponentName(context, Settings.CreateShortcutActivity.class));
}
private static void disableComponent(PackageManager pm, ComponentName componentName) {
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
}