Hide settings app for private profile from launcher.
Bug: 296994499 Test: Manually verifed that settings app is not shown for Private Profile from launcher. Change-Id: Ie8c328eacbd0f42772562f10026ced78d095956f
This commit is contained in:
@@ -32,6 +32,7 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.content.pm.ShortcutManager;
|
import android.content.pm.ShortcutManager;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
|
import android.os.Flags;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -67,6 +68,7 @@ public class SettingsInitialize extends BroadcastReceiver {
|
|||||||
final PackageManager pm = context.getPackageManager();
|
final PackageManager pm = context.getPackageManager();
|
||||||
managedProfileSetup(context, pm, broadcast, userInfo);
|
managedProfileSetup(context, pm, broadcast, userInfo);
|
||||||
cloneProfileSetup(context, pm, userInfo);
|
cloneProfileSetup(context, pm, userInfo);
|
||||||
|
privateProfileSetup(context, pm, userInfo);
|
||||||
webviewSettingSetup(context, pm, userInfo);
|
webviewSettingSetup(context, pm, userInfo);
|
||||||
ThreadUtils.postOnBackgroundThread(() -> refreshExistingShortcuts(context));
|
ThreadUtils.postOnBackgroundThread(() -> refreshExistingShortcuts(context));
|
||||||
enableTwoPaneDeepLinkActivityIfNecessary(pm, context);
|
enableTwoPaneDeepLinkActivityIfNecessary(pm, context);
|
||||||
@@ -104,17 +106,29 @@ public class SettingsInitialize extends BroadcastReceiver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable launcher icon
|
disableComponentsToHideSettings(context, pm);
|
||||||
disableComponent(pm, new ComponentName(context, Settings.class));
|
|
||||||
// Disable shortcut picker.
|
|
||||||
disableComponent(pm, new ComponentName(context, CreateShortcutActivity.class));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cloneProfileSetup(Context context, PackageManager pm, UserInfo userInfo) {
|
private void cloneProfileSetup(Context context, PackageManager pm, UserInfo userInfo) {
|
||||||
if (userInfo == null || !userInfo.isCloneProfile()) {
|
if (userInfo == null || !userInfo.isCloneProfile()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Disable launcher icon
|
|
||||||
|
disableComponentsToHideSettings(context, pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void privateProfileSetup(Context context, PackageManager pm, UserInfo userInfo) {
|
||||||
|
if (Flags.allowPrivateProfile()) {
|
||||||
|
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));
|
disableComponent(pm, new ComponentName(context, Settings.class));
|
||||||
|
|
||||||
//Disable Shortcut picker
|
//Disable Shortcut picker
|
||||||
|
Reference in New Issue
Block a user