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:
@@ -32,14 +32,12 @@ import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.content.pm.ShortcutManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.Flags;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.Settings.CreateShortcutActivity;
|
||||
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
|
||||
import com.android.settings.homepage.DeepLinkHomepageActivity;
|
||||
import com.android.settings.search.SearchStateReceiver;
|
||||
@@ -49,7 +47,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Listens to {@link Intent.ACTION_PRE_BOOT_COMPLETED} and {@link Intent.ACTION_USER_INITIALIZED}
|
||||
* Listens to {@link Intent.ACTION_PRE_BOOT_COMPLETED} and {@link Intent.ACTION_USER_INITIALIZE}
|
||||
* performs setup steps for a managed profile (disables the launcher icon of the Settings app,
|
||||
* adds cross-profile intent filters for the appropriate Settings activities), disables the
|
||||
* webview setting for non-admin users, updates the intent flags for any existing shortcuts and
|
||||
@@ -68,7 +66,6 @@ public class SettingsInitialize extends BroadcastReceiver {
|
||||
final PackageManager pm = context.getPackageManager();
|
||||
managedProfileSetup(context, pm, broadcast, userInfo);
|
||||
cloneProfileSetup(context, pm, userInfo);
|
||||
privateProfileSetup(context, pm, userInfo);
|
||||
webviewSettingSetup(context, pm, userInfo);
|
||||
ThreadUtils.postOnBackgroundThread(() -> refreshExistingShortcuts(context));
|
||||
enableTwoPaneDeepLinkActivityIfNecessary(pm, context);
|
||||
@@ -106,7 +103,7 @@ public class SettingsInitialize extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
disableComponentsToHideSettings(context, pm);
|
||||
Utils.disableComponentsToHideSettings(context, pm);
|
||||
}
|
||||
|
||||
private void cloneProfileSetup(Context context, PackageManager pm, UserInfo userInfo) {
|
||||
@@ -114,31 +111,7 @@ public class SettingsInitialize extends BroadcastReceiver {
|
||||
return;
|
||||
}
|
||||
|
||||
disableComponentsToHideSettings(context, pm);
|
||||
}
|
||||
|
||||
private void privateProfileSetup(Context context, PackageManager pm, UserInfo userInfo) {
|
||||
if (Flags.allowPrivateProfile()
|
||||
&& android.multiuser.Flags.enablePrivateSpaceFeatures()) {
|
||||
if (userInfo == null || !userInfo.isPrivateProfile()) {
|
||||
return;
|
||||
}
|
||||
|
||||
disableComponentsToHideSettings(context, pm);
|
||||
}
|
||||
}
|
||||
|
||||
private void disableComponentsToHideSettings(Context context, PackageManager pm) {
|
||||
// Disable settings app launcher icon
|
||||
disableComponent(pm, new ComponentName(context, Settings.class));
|
||||
|
||||
//Disable Shortcut picker
|
||||
disableComponent(pm, new ComponentName(context, CreateShortcutActivity.class));
|
||||
}
|
||||
|
||||
private void disableComponent(PackageManager pm, ComponentName componentName) {
|
||||
pm.setComponentEnabledSetting(componentName,
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
Utils.disableComponentsToHideSettings(context, pm);
|
||||
}
|
||||
|
||||
// Disable WebView Setting if the current user is not an admin
|
||||
|
Reference in New Issue
Block a user