Loading quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +1 −9 Original line number Diff line number Diff line Loading @@ -117,8 +117,6 @@ import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; import com.android.launcher3.util.UiThreadHelper.AsyncCommand; import com.android.launcher3.util.ViewCapture; import com.android.launcher3.widget.LauncherAppWidgetHost; import com.android.quickstep.OverviewCommandHelper; Loading Loading @@ -160,11 +158,6 @@ public class QuickstepLauncher extends Launcher { SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", false); public static final boolean GO_LOW_RAM_RECENTS_ENABLED = false; /** * Reusable command for applying the shelf height on the background thread. */ public static final AsyncCommand SET_SHELF_HEIGHT = (context, arg1, arg2) -> SystemUiProxy.INSTANCE.get(context).setShelfHeight(arg1 != 0, arg2); private FixedContainerItems mAllAppsPredictions; private HotseatPredictionController mHotseatPredictionController; Loading Loading @@ -349,8 +342,7 @@ public class QuickstepLauncher extends Launcher { boolean visible = (state == NORMAL || state == OVERVIEW) && (willUserBeActive || isUserActive()) && !profile.isVerticalBarLayout(); UiThreadHelper.runAsyncCommand(this, SET_SHELF_HEIGHT, visible ? 1 : 0, profile.hotseatBarSizePx); SystemUiProxy.INSTANCE.get(this).setShelfHeight(visible, profile.hotseatBarSizePx); } } if (state == NORMAL && !inTransition) { Loading quickstep/src/com/android/quickstep/SystemUiProxy.java +31 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.quickstep; import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.ActivityManager; import android.app.PendingIntent; Loading @@ -31,8 +32,10 @@ import android.content.pm.ShortcutInfo; import android.graphics.Insets; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.IBinder.DeathRecipient; import android.os.Message; import android.os.RemoteException; import android.os.UserHandle; import android.util.Log; Loading @@ -42,6 +45,8 @@ import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.window.IOnBackInvokedCallback; import androidx.annotation.WorkerThread; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.systemui.shared.recents.ISystemUiProxy; Loading Loading @@ -75,6 +80,8 @@ public class SystemUiProxy implements ISystemUiProxy { public static final MainThreadInitializedObject<SystemUiProxy> INSTANCE = new MainThreadInitializedObject<>(SystemUiProxy::new); private static final int MSG_SET_SHELF_HEIGHT = 1; private ISystemUiProxy mSystemUiProxy; private IPip mPip; private ISysuiUnlockAnimationController mSysuiUnlockAnimationController; Loading Loading @@ -103,13 +110,16 @@ public class SystemUiProxy implements ISystemUiProxy { // Used to dedupe calls to SystemUI private int mLastShelfHeight; private boolean mLastShelfVisible; private Context mContext; private final Context mContext; private final Handler mAsyncHandler; // TODO(141886704): Find a way to remove this private int mLastSystemUiStateFlags; public SystemUiProxy(Context context) { mContext = context; mAsyncHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::handleMessageAsync); } @Override Loading Loading @@ -435,12 +445,20 @@ public class SystemUiProxy implements ISystemUiProxy { * Sets the shelf height. */ public void setShelfHeight(boolean visible, int shelfHeight) { Message.obtain(mAsyncHandler, MSG_SET_SHELF_HEIGHT, visible ? 1 : 0 , shelfHeight).sendToTarget(); } @WorkerThread private void setShelfHeightAsync(int visibleInt, int shelfHeight) { boolean visible = visibleInt != 0; boolean changed = visible != mLastShelfVisible || shelfHeight != mLastShelfHeight; if (mPip != null && changed) { IPip pip = mPip; if (pip != null && changed) { mLastShelfVisible = visible; mLastShelfHeight = shelfHeight; try { mPip.setShelfHeight(visible, shelfHeight); pip.setShelfHeight(visible, shelfHeight); } catch (RemoteException e) { Log.w(TAG, "Failed call setShelfHeight visible: " + visible + " height: " + shelfHeight, e); Loading Loading @@ -856,4 +874,14 @@ public class SystemUiProxy implements ISystemUiProxy { } return new ArrayList<>(); } private boolean handleMessageAsync(Message msg) { switch (msg.what) { case MSG_SET_SHELF_HEIGHT: setShelfHeightAsync(msg.arg1, msg.arg2); return true; } return false; } } src/com/android/launcher3/states/RotationHelper.java +12 −4 Original line number Diff line number Diff line Loading @@ -21,17 +21,19 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Handler; import android.os.Message; import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.UiThreadHelper; /** * Utility class to manage launcher rotation Loading @@ -39,8 +41,6 @@ import com.android.launcher3.util.UiThreadHelper; public class RotationHelper implements OnSharedPreferenceChangeListener, DisplayController.DisplayInfoChangeListener { private static final String TAG = "RotationHelper"; public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation"; /** Loading @@ -60,6 +60,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, private BaseActivity mActivity; private SharedPreferences mSharedPrefs = null; private final Handler mRequestOrientationHandler; private boolean mIgnoreAutoRotateSettings; private boolean mForceAllowRotationForTesting; Loading Loading @@ -89,6 +90,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public RotationHelper(BaseActivity activity) { mActivity = activity; mRequestOrientationHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::setOrientationAsync); } private void setIgnoreAutoRotateSettings(boolean ignoreAutoRotateSettings) { Loading Loading @@ -202,8 +205,13 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, } if (activityFlags != mLastActivityFlags) { mLastActivityFlags = activityFlags; UiThreadHelper.setOrientationAsync(mActivity, activityFlags); mRequestOrientationHandler.sendEmptyMessage(activityFlags); } } private boolean setOrientationAsync(Message msg) { mActivity.setRequestedOrientation(msg.what); return true; } /** Loading src/com/android/launcher3/util/UiThreadHelper.javadeleted 100644 → 0 +0 −71 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.util; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Message; /** * Utility class for offloading some class from UI thread */ public class UiThreadHelper { private static final MainThreadInitializedObject<Handler> HANDLER = new MainThreadInitializedObject<>( c -> new Handler(UI_HELPER_EXECUTOR.getLooper(), new UiCallbacks(c))); private static final int MSG_SET_ORIENTATION = 1; private static final int MSG_RUN_COMMAND = 2; public static void setOrientationAsync(Activity activity, int orientation) { Message.obtain(HANDLER.get(activity), MSG_SET_ORIENTATION, orientation, 0, activity) .sendToTarget(); } public static void runAsyncCommand(Context context, AsyncCommand command, int arg1, int arg2) { Message.obtain(HANDLER.get(context), MSG_RUN_COMMAND, arg1, arg2, command).sendToTarget(); } private static class UiCallbacks implements Handler.Callback { private final Context mContext; UiCallbacks(Context context) { mContext = context; } @Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_SET_ORIENTATION: ((Activity) message.obj).setRequestedOrientation(message.arg1); return true; case MSG_RUN_COMMAND: ((AsyncCommand) message.obj).execute(mContext, message.arg1, message.arg2); return true; } return false; } } public interface AsyncCommand { void execute(Context proxy, int arg1, int arg2); } } Loading
quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +1 −9 Original line number Diff line number Diff line Loading @@ -117,8 +117,6 @@ import com.android.launcher3.util.RunnableList; import com.android.launcher3.util.SafeCloseable; import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.UiThreadHelper; import com.android.launcher3.util.UiThreadHelper.AsyncCommand; import com.android.launcher3.util.ViewCapture; import com.android.launcher3.widget.LauncherAppWidgetHost; import com.android.quickstep.OverviewCommandHelper; Loading Loading @@ -160,11 +158,6 @@ public class QuickstepLauncher extends Launcher { SystemProperties.getBoolean("persist.wm.debug.enable_pip_keep_clear_algorithm", false); public static final boolean GO_LOW_RAM_RECENTS_ENABLED = false; /** * Reusable command for applying the shelf height on the background thread. */ public static final AsyncCommand SET_SHELF_HEIGHT = (context, arg1, arg2) -> SystemUiProxy.INSTANCE.get(context).setShelfHeight(arg1 != 0, arg2); private FixedContainerItems mAllAppsPredictions; private HotseatPredictionController mHotseatPredictionController; Loading Loading @@ -349,8 +342,7 @@ public class QuickstepLauncher extends Launcher { boolean visible = (state == NORMAL || state == OVERVIEW) && (willUserBeActive || isUserActive()) && !profile.isVerticalBarLayout(); UiThreadHelper.runAsyncCommand(this, SET_SHELF_HEIGHT, visible ? 1 : 0, profile.hotseatBarSizePx); SystemUiProxy.INSTANCE.get(this).setShelfHeight(visible, profile.hotseatBarSizePx); } } if (state == NORMAL && !inTransition) { Loading
quickstep/src/com/android/quickstep/SystemUiProxy.java +31 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.quickstep; import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.ActivityManager; import android.app.PendingIntent; Loading @@ -31,8 +32,10 @@ import android.content.pm.ShortcutInfo; import android.graphics.Insets; import android.graphics.Rect; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.IBinder.DeathRecipient; import android.os.Message; import android.os.RemoteException; import android.os.UserHandle; import android.util.Log; Loading @@ -42,6 +45,8 @@ import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.window.IOnBackInvokedCallback; import androidx.annotation.WorkerThread; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.systemui.shared.recents.ISystemUiProxy; Loading Loading @@ -75,6 +80,8 @@ public class SystemUiProxy implements ISystemUiProxy { public static final MainThreadInitializedObject<SystemUiProxy> INSTANCE = new MainThreadInitializedObject<>(SystemUiProxy::new); private static final int MSG_SET_SHELF_HEIGHT = 1; private ISystemUiProxy mSystemUiProxy; private IPip mPip; private ISysuiUnlockAnimationController mSysuiUnlockAnimationController; Loading Loading @@ -103,13 +110,16 @@ public class SystemUiProxy implements ISystemUiProxy { // Used to dedupe calls to SystemUI private int mLastShelfHeight; private boolean mLastShelfVisible; private Context mContext; private final Context mContext; private final Handler mAsyncHandler; // TODO(141886704): Find a way to remove this private int mLastSystemUiStateFlags; public SystemUiProxy(Context context) { mContext = context; mAsyncHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::handleMessageAsync); } @Override Loading Loading @@ -435,12 +445,20 @@ public class SystemUiProxy implements ISystemUiProxy { * Sets the shelf height. */ public void setShelfHeight(boolean visible, int shelfHeight) { Message.obtain(mAsyncHandler, MSG_SET_SHELF_HEIGHT, visible ? 1 : 0 , shelfHeight).sendToTarget(); } @WorkerThread private void setShelfHeightAsync(int visibleInt, int shelfHeight) { boolean visible = visibleInt != 0; boolean changed = visible != mLastShelfVisible || shelfHeight != mLastShelfHeight; if (mPip != null && changed) { IPip pip = mPip; if (pip != null && changed) { mLastShelfVisible = visible; mLastShelfHeight = shelfHeight; try { mPip.setShelfHeight(visible, shelfHeight); pip.setShelfHeight(visible, shelfHeight); } catch (RemoteException e) { Log.w(TAG, "Failed call setShelfHeight visible: " + visible + " height: " + shelfHeight, e); Loading Loading @@ -856,4 +874,14 @@ public class SystemUiProxy implements ISystemUiProxy { } return new ArrayList<>(); } private boolean handleMessageAsync(Message msg) { switch (msg.what) { case MSG_SET_SHELF_HEIGHT: setShelfHeightAsync(msg.arg1, msg.arg2); return true; } return false; } }
src/com/android/launcher3/states/RotationHelper.java +12 −4 Original line number Diff line number Diff line Loading @@ -21,17 +21,19 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE; import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Handler; import android.os.Message; import com.android.launcher3.BaseActivity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.UiThreadHelper; /** * Utility class to manage launcher rotation Loading @@ -39,8 +41,6 @@ import com.android.launcher3.util.UiThreadHelper; public class RotationHelper implements OnSharedPreferenceChangeListener, DisplayController.DisplayInfoChangeListener { private static final String TAG = "RotationHelper"; public static final String ALLOW_ROTATION_PREFERENCE_KEY = "pref_allowRotation"; /** Loading @@ -60,6 +60,7 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, private BaseActivity mActivity; private SharedPreferences mSharedPrefs = null; private final Handler mRequestOrientationHandler; private boolean mIgnoreAutoRotateSettings; private boolean mForceAllowRotationForTesting; Loading Loading @@ -89,6 +90,8 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, public RotationHelper(BaseActivity activity) { mActivity = activity; mRequestOrientationHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::setOrientationAsync); } private void setIgnoreAutoRotateSettings(boolean ignoreAutoRotateSettings) { Loading Loading @@ -202,8 +205,13 @@ public class RotationHelper implements OnSharedPreferenceChangeListener, } if (activityFlags != mLastActivityFlags) { mLastActivityFlags = activityFlags; UiThreadHelper.setOrientationAsync(mActivity, activityFlags); mRequestOrientationHandler.sendEmptyMessage(activityFlags); } } private boolean setOrientationAsync(Message msg) { mActivity.setRequestedOrientation(msg.what); return true; } /** Loading
src/com/android/launcher3/util/UiThreadHelper.javadeleted 100644 → 0 +0 −71 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.launcher3.util; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.app.Activity; import android.content.Context; import android.os.Handler; import android.os.Message; /** * Utility class for offloading some class from UI thread */ public class UiThreadHelper { private static final MainThreadInitializedObject<Handler> HANDLER = new MainThreadInitializedObject<>( c -> new Handler(UI_HELPER_EXECUTOR.getLooper(), new UiCallbacks(c))); private static final int MSG_SET_ORIENTATION = 1; private static final int MSG_RUN_COMMAND = 2; public static void setOrientationAsync(Activity activity, int orientation) { Message.obtain(HANDLER.get(activity), MSG_SET_ORIENTATION, orientation, 0, activity) .sendToTarget(); } public static void runAsyncCommand(Context context, AsyncCommand command, int arg1, int arg2) { Message.obtain(HANDLER.get(context), MSG_RUN_COMMAND, arg1, arg2, command).sendToTarget(); } private static class UiCallbacks implements Handler.Callback { private final Context mContext; UiCallbacks(Context context) { mContext = context; } @Override public boolean handleMessage(Message message) { switch (message.what) { case MSG_SET_ORIENTATION: ((Activity) message.obj).setRequestedOrientation(message.arg1); return true; case MSG_RUN_COMMAND: ((AsyncCommand) message.obj).execute(mContext, message.arg1, message.arg2); return true; } return false; } } public interface AsyncCommand { void execute(Context proxy, int arg1, int arg2); } }