1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.quickstep; 17 18 import android.annotation.TargetApi; 19 import android.content.Context; 20 import android.content.pm.PackageManager; 21 import android.os.Build; 22 import android.os.UserManager; 23 import android.util.Log; 24 25 import com.android.launcher3.BuildConfig; 26 import com.android.launcher3.MainProcessInitializer; 27 import com.android.systemui.shared.system.InteractionJankMonitorWrapper; 28 import com.android.systemui.shared.system.ThreadedRendererCompat; 29 30 @SuppressWarnings("unused") 31 @TargetApi(Build.VERSION_CODES.R) 32 public class QuickstepProcessInitializer extends MainProcessInitializer { 33 34 private static final String TAG = "QuickstepProcessInitializer"; 35 private static final int SETUP_DELAY_MILLIS = 5000; 36 QuickstepProcessInitializer(Context context)37 public QuickstepProcessInitializer(Context context) { 38 // Fake call to create an instance of InteractionJankMonitor to avoid binder calls during 39 // its initialization during transitions. 40 InteractionJankMonitorWrapper.cancel(-1); 41 } 42 43 @Override init(Context context)44 protected void init(Context context) { 45 // Workaround for b/120550382, an external app can cause the launcher process to start for 46 // a work profile user which we do not support. Disable the application immediately when we 47 // detect this to be the case. 48 UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE); 49 if (um.isManagedProfile()) { 50 PackageManager pm = context.getPackageManager(); 51 pm.setApplicationEnabledSetting(context.getPackageName(), 52 PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 0 /* flags */); 53 Log.w(TAG, "Disabling " + BuildConfig.APPLICATION_ID 54 + ", unable to run in a managed profile"); 55 return; 56 } 57 58 super.init(context); 59 60 // Elevate GPU priority for Quickstep and Remote animations. 61 ThreadedRendererCompat.setContextPriority( 62 ThreadedRendererCompat.EGL_CONTEXT_PRIORITY_HIGH_IMG); 63 } 64 } 65