Disable Launcher when starting in a managed profile

- The launcher package is automatically enabled for work profiles due to
  DPM interpreting it as a critical component since it does not have any
  launchable activities. Once enabled, it is possible for an explicit
  broadcast to update smartspace or assistant state to trigger the process
  to be created for the work profile user, which ends up initializing logic
  which may call into LauncherApps (which is not allowed from the work
  profile).

  As a workaround, we disable the launcher application immediately upon
  detecting that it is running in a work profile.

Bug: 120550382
Change-Id: I72c52fe598d41440a1fb59304b494a000277384b
This commit is contained in:
Winson Chung 2019-02-15 15:42:16 -08:00
parent d202bf40bf
commit 9fea3de8f5
1 changed files with 19 additions and 0 deletions

View File

@ -16,17 +16,36 @@
package com.android.quickstep;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.UserManager;
import android.util.Log;
import com.android.launcher3.BuildConfig;
import com.android.launcher3.MainProcessInitializer;
import com.android.systemui.shared.system.ThreadedRendererCompat;
@SuppressWarnings("unused")
public class QuickstepProcessInitializer extends MainProcessInitializer {
private static final String TAG = "QuickstepProcessInitializer";
public QuickstepProcessInitializer(Context context) { }
@Override
protected void init(Context context) {
// Workaround for b/120550382, an external app can cause the launcher process to start for
// a work profile user which we do not support. Disable the application immediately when we
// detect this to be the case.
UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);
if (um.isManagedProfile()) {
PackageManager pm = context.getPackageManager();
pm.setApplicationEnabledSetting(context.getPackageName(),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0 /* flags */);
Log.w(TAG, "Disabling " + BuildConfig.APPLICATION_ID
+ ", unable to run in a managed profile");
return;
}
super.init(context);
// Elevate GPU priority for Quickstep and Remote animations.