mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Merge changes I4532e429,I532645de into ub-launcher3-qt-future-dev
* changes: Defer listening on widget host until after the state transition ends Migrate to using DefaultDisplay
This commit is contained in:
@@ -44,7 +44,6 @@ import android.os.Vibrator;
|
||||
import android.provider.Settings;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.annotation.UiThread;
|
||||
@@ -274,7 +273,7 @@ public abstract class BaseSwipeUpHandler<T extends BaseDraggingActivity, Q exten
|
||||
overviewStackBounds = getStackBounds(dp);
|
||||
}
|
||||
dp.updateInsets(targetSet.homeContentInsets);
|
||||
dp.updateIsSeascape(mContext.getSystemService(WindowManager.class));
|
||||
dp.updateIsSeascape(mContext);
|
||||
if (runningTaskTarget != null) {
|
||||
mClipAnimationHelper.updateSource(overviewStackBounds, runningTaskTarget);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
import static android.view.MotionEvent.ACTION_DOWN;
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.ADAPTIVE_ICON_WINDOW_ANIM;
|
||||
import static com.android.launcher3.config.FeatureFlags.APPLY_CONFIG_AT_RUNTIME;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_HINTS_IN_OVERVIEW;
|
||||
@@ -51,8 +52,6 @@ import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Region;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
@@ -62,14 +61,14 @@ import android.os.RemoteException;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
import android.view.Display;
|
||||
import android.view.InputEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.BinderThread;
|
||||
import androidx.annotation.UiThread;
|
||||
import androidx.annotation.WorkerThread;
|
||||
|
||||
import com.android.launcher3.BaseDraggingActivity;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.ResourceUtils;
|
||||
@@ -80,6 +79,7 @@ import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
import com.android.launcher3.provider.RestoreDbTask;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.quickstep.SysUINavigationMode.Mode;
|
||||
import com.android.quickstep.SysUINavigationMode.NavigationModeChangeListener;
|
||||
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
|
||||
@@ -132,7 +132,7 @@ class ArgList extends LinkedList<String> {
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.Q)
|
||||
public class TouchInteractionService extends Service implements
|
||||
NavigationModeChangeListener, DisplayListener {
|
||||
NavigationModeChangeListener, DefaultDisplay.DisplayInfoChangeListener {
|
||||
|
||||
/**
|
||||
* NOTE: This value should be kept same as
|
||||
@@ -323,8 +323,7 @@ public class TouchInteractionService extends Service implements
|
||||
registerReceiver(mUserUnlockedReceiver, new IntentFilter(Intent.ACTION_USER_UNLOCKED));
|
||||
}
|
||||
|
||||
mDefaultDisplayId = getSystemService(WindowManager.class).getDefaultDisplay()
|
||||
.getDisplayId();
|
||||
mDefaultDisplayId = DefaultDisplay.INSTANCE.get(this).getInfo().id;
|
||||
String blockingActivity = getString(R.string.gesture_blocking_activity);
|
||||
mGestureBlockingActivity = TextUtils.isEmpty(blockingActivity) ? null :
|
||||
ComponentName.unflattenFromString(blockingActivity);
|
||||
@@ -391,9 +390,8 @@ public class TouchInteractionService extends Service implements
|
||||
return;
|
||||
}
|
||||
|
||||
Display defaultDisplay = getSystemService(WindowManager.class).getDefaultDisplay();
|
||||
Point realSize = new Point();
|
||||
defaultDisplay.getRealSize(realSize);
|
||||
DefaultDisplay.Info displayInfo = DefaultDisplay.INSTANCE.get(this).getInfo();
|
||||
Point realSize = new Point(displayInfo.realSize);
|
||||
mSwipeTouchRegion.set(0, 0, realSize.x, realSize.y);
|
||||
if (mMode == Mode.NO_BUTTON) {
|
||||
int touchHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
|
||||
@@ -415,7 +413,7 @@ public class TouchInteractionService extends Service implements
|
||||
} else {
|
||||
mAssistantLeftRegion.setEmpty();
|
||||
mAssistantRightRegion.setEmpty();
|
||||
switch (defaultDisplay.getRotation()) {
|
||||
switch (displayInfo.rotation) {
|
||||
case Surface.ROTATION_90:
|
||||
mSwipeTouchRegion.left = mSwipeTouchRegion.right
|
||||
- getNavbarSize(ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE);
|
||||
@@ -438,10 +436,9 @@ public class TouchInteractionService extends Service implements
|
||||
}
|
||||
if (mMode.hasGestures != newMode.hasGestures) {
|
||||
if (newMode.hasGestures) {
|
||||
getSystemService(DisplayManager.class).registerDisplayListener(
|
||||
this, MAIN_EXECUTOR.getHandler());
|
||||
DefaultDisplay.INSTANCE.get(this).addChangeListener(this);
|
||||
} else {
|
||||
getSystemService(DisplayManager.class).unregisterDisplayListener(this);
|
||||
DefaultDisplay.INSTANCE.get(this).removeChangeListener(this);
|
||||
}
|
||||
}
|
||||
mMode = newMode;
|
||||
@@ -457,14 +454,8 @@ public class TouchInteractionService extends Service implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayAdded(int i) { }
|
||||
|
||||
@Override
|
||||
public void onDisplayRemoved(int i) { }
|
||||
|
||||
@Override
|
||||
public void onDisplayChanged(int displayId) {
|
||||
if (displayId != mDefaultDisplayId) {
|
||||
public void onDisplayInfoChanged(DefaultDisplay.Info info, int flags) {
|
||||
if (info.id != mDefaultDisplayId) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -529,7 +520,7 @@ public class TouchInteractionService extends Service implements
|
||||
}
|
||||
disposeEventHandlers();
|
||||
if (mMode.hasGestures) {
|
||||
getSystemService(DisplayManager.class).unregisterDisplayListener(this);
|
||||
DefaultDisplay.INSTANCE.get(this).removeChangeListener(this);
|
||||
}
|
||||
|
||||
sConnected = false;
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.quickstep.inputconsumers;
|
||||
import static android.view.MotionEvent.ACTION_CANCEL;
|
||||
import static android.view.MotionEvent.ACTION_POINTER_DOWN;
|
||||
import static android.view.MotionEvent.ACTION_UP;
|
||||
|
||||
import static com.android.launcher3.Utilities.squaredHypot;
|
||||
import static com.android.launcher3.Utilities.squaredTouchSlop;
|
||||
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
|
||||
@@ -35,9 +36,10 @@ import android.graphics.RectF;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.quickstep.LockScreenRecentsActivity;
|
||||
import com.android.quickstep.MultiStateCallback;
|
||||
import com.android.quickstep.SwipeSharedState;
|
||||
@@ -103,8 +105,7 @@ public class DeviceLockedInputConsumer implements InputConsumer,
|
||||
mRunningTaskId = runningTaskId;
|
||||
|
||||
// Do not use DeviceProfile as the user data might be locked
|
||||
mDisplaySize = new Point();
|
||||
context.getSystemService(WindowManager.class).getDefaultDisplay().getRealSize(mDisplaySize);
|
||||
mDisplaySize = DefaultDisplay.INSTANCE.get(context).getInfo().realSize;
|
||||
|
||||
// Init states
|
||||
mStateCallback = new MultiStateCallback(STATE_NAMES);
|
||||
|
||||
@@ -21,9 +21,9 @@ import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.launcher3.graphics.RotationMode;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.quickstep.SysUINavigationMode;
|
||||
|
||||
/**
|
||||
@@ -36,8 +36,7 @@ public class NavBarPosition {
|
||||
|
||||
public NavBarPosition(Context context) {
|
||||
mMode = SysUINavigationMode.getMode(context);
|
||||
mDisplayRotation = context.getSystemService(WindowManager.class)
|
||||
.getDefaultDisplay().getRotation();
|
||||
mDisplayRotation = DefaultDisplay.INSTANCE.get(context).getInfo().rotation;
|
||||
}
|
||||
|
||||
public boolean isRightEdge() {
|
||||
|
||||
@@ -157,6 +157,6 @@ public abstract class BaseRecentsActivity extends BaseDraggingActivity {
|
||||
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||
super.dump(prefix, fd, writer, args);
|
||||
writer.println(prefix + "Misc:");
|
||||
dumpMisc(writer);
|
||||
dumpMisc(prefix + "\t", writer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.view.ContextThemeWrapper;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
import com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.logging.StatsLogUtils;
|
||||
@@ -44,8 +46,6 @@ import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
public abstract class BaseActivity extends Activity
|
||||
implements UserEventDelegate, LogStateProvider, ActivityContext {
|
||||
|
||||
@@ -265,12 +265,13 @@ public abstract class BaseActivity extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
protected void dumpMisc(PrintWriter writer) {
|
||||
writer.println(" deviceProfile isTransposed=" + getDeviceProfile().isVerticalBarLayout());
|
||||
writer.println(" orientation=" + getResources().getConfiguration().orientation);
|
||||
writer.println(" mSystemUiController: " + mSystemUiController);
|
||||
writer.println(" mActivityFlags: " + mActivityFlags);
|
||||
writer.println(" mForceInvisible: " + mForceInvisible);
|
||||
protected void dumpMisc(String prefix, PrintWriter writer) {
|
||||
writer.println(prefix + "deviceProfile isTransposed="
|
||||
+ getDeviceProfile().isVerticalBarLayout());
|
||||
writer.println(prefix + "orientation=" + getResources().getConfiguration().orientation);
|
||||
writer.println(prefix + "mSystemUiController: " + mSystemUiController);
|
||||
writer.println(prefix + "mActivityFlags: " + mActivityFlags);
|
||||
writer.println(prefix + "mForceInvisible: " + mForceInvisible);
|
||||
}
|
||||
|
||||
public static <T extends BaseActivity> T fromContext(Context context) {
|
||||
|
||||
@@ -30,6 +30,8 @@ import android.view.ActionMode;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings.Favorites;
|
||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
@@ -39,8 +41,6 @@ import com.android.launcher3.uioverrides.WallpaperColorInfo;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.Themes;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Extension of BaseActivity allowing support for drag-n-drop
|
||||
*/
|
||||
@@ -241,14 +241,14 @@ public abstract class BaseDraggingActivity extends BaseActivity
|
||||
protected void onDeviceProfileInitiated() {
|
||||
if (mDeviceProfile.isVerticalBarLayout()) {
|
||||
mRotationListener.enable();
|
||||
mDeviceProfile.updateIsSeascape(getWindowManager());
|
||||
mDeviceProfile.updateIsSeascape(this);
|
||||
} else {
|
||||
mRotationListener.disable();
|
||||
}
|
||||
}
|
||||
|
||||
private void onDeviceRotationChanged() {
|
||||
if (mDeviceProfile.updateIsSeascape(getWindowManager())) {
|
||||
if (mDeviceProfile.updateIsSeascape(this)) {
|
||||
reapplyUi();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Surface;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.android.launcher3.CellLayout.ContainerType;
|
||||
import com.android.launcher3.graphics.IconShape;
|
||||
import com.android.launcher3.icons.DotRenderer;
|
||||
import com.android.launcher3.icons.IconNormalizer;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
|
||||
public class DeviceProfile {
|
||||
|
||||
@@ -544,9 +544,10 @@ public class DeviceProfile {
|
||||
/**
|
||||
* Updates orientation information and returns true if it has changed from the previous value.
|
||||
*/
|
||||
public boolean updateIsSeascape(WindowManager wm) {
|
||||
public boolean updateIsSeascape(Context context) {
|
||||
if (isVerticalBarLayout()) {
|
||||
boolean isSeascape = wm.getDefaultDisplay().getRotation() == Surface.ROTATION_270;
|
||||
boolean isSeascape = DefaultDisplay.INSTANCE.get(context).getInfo().rotation
|
||||
== Surface.ROTATION_270;
|
||||
if (mIsSeascape != isSeascape) {
|
||||
mIsSeascape = isSeascape;
|
||||
return true;
|
||||
|
||||
@@ -40,14 +40,13 @@ import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
import android.util.Xml;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.launcher3.graphics.IconShape;
|
||||
import com.android.launcher3.util.ConfigMonitor;
|
||||
import com.android.launcher3.util.DefaultDisplay;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.Themes;
|
||||
@@ -173,19 +172,17 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
|
||||
private String initGrid(Context context, String gridName) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
Display display = wm.getDefaultDisplay();
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
display.getMetrics(dm);
|
||||
DefaultDisplay.Info displayInfo = DefaultDisplay.INSTANCE.get(context).getInfo();
|
||||
|
||||
Point smallestSize = new Point();
|
||||
Point largestSize = new Point();
|
||||
display.getCurrentSizeRange(smallestSize, largestSize);
|
||||
Point smallestSize = new Point(displayInfo.smallestSize);
|
||||
Point largestSize = new Point(displayInfo.largestSize);
|
||||
|
||||
ArrayList<DisplayOption> allOptions = getPredefinedDeviceProfiles(context, gridName);
|
||||
// This guarantees that width < height
|
||||
float minWidthDps = Utilities.dpiFromPx(Math.min(smallestSize.x, smallestSize.y), dm);
|
||||
float minHeightDps = Utilities.dpiFromPx(Math.min(largestSize.x, largestSize.y), dm);
|
||||
float minWidthDps = Utilities.dpiFromPx(Math.min(smallestSize.x, smallestSize.y),
|
||||
displayInfo.metrics);
|
||||
float minHeightDps = Utilities.dpiFromPx(Math.min(largestSize.x, largestSize.y),
|
||||
displayInfo.metrics);
|
||||
// Sort the profiles based on the closeness to the device size
|
||||
Collections.sort(allOptions, (a, b) ->
|
||||
Float.compare(dist(minWidthDps, minHeightDps, a.minWidthDps, a.minHeightDps),
|
||||
@@ -211,16 +208,15 @@ public class InvariantDeviceProfile {
|
||||
iconSize = interpolatedDisplayOption.iconSize;
|
||||
iconShapePath = getIconShapePath(context);
|
||||
landscapeIconSize = interpolatedDisplayOption.landscapeIconSize;
|
||||
iconBitmapSize = ResourceUtils.pxFromDp(iconSize, dm);
|
||||
iconBitmapSize = ResourceUtils.pxFromDp(iconSize, displayInfo.metrics);
|
||||
iconTextSize = interpolatedDisplayOption.iconTextSize;
|
||||
fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
|
||||
|
||||
// If the partner customization apk contains any grid overrides, apply them
|
||||
// Supported overrides: numRows, numColumns, iconSize
|
||||
applyPartnerDeviceProfileOverrides(context, dm);
|
||||
applyPartnerDeviceProfileOverrides(context, displayInfo.metrics);
|
||||
|
||||
Point realSize = new Point();
|
||||
display.getRealSize(realSize);
|
||||
Point realSize = new Point(displayInfo.realSize);
|
||||
// The real size never changes. smallSide and largeSide will remain the
|
||||
// same in any orientation.
|
||||
int smallSide = Math.min(realSize.x, realSize.y);
|
||||
|
||||
@@ -500,6 +500,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
// Load configuration-specific DeviceProfile
|
||||
mDeviceProfile = idp.getDeviceProfile(this);
|
||||
if (isInMultiWindowMode()) {
|
||||
// Note: Calls to getSize() can't rely on our cached DefaultDisplay since it can return
|
||||
// the app window size
|
||||
Display display = getWindowManager().getDefaultDisplay();
|
||||
Point mwSize = new Point();
|
||||
display.getSize(mwSize);
|
||||
@@ -943,8 +945,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
|
||||
}
|
||||
|
||||
protected void onStateSet(LauncherState state) {
|
||||
getAppWidgetHost().setResumed(state == LauncherState.NORMAL);
|
||||
public void onStateSetStart(LauncherState state) {
|
||||
if (mDeferredResumePending) {
|
||||
handleDeferredResume();
|
||||
}
|
||||
@@ -953,6 +954,12 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
}
|
||||
|
||||
public void onStateSetEnd(LauncherState state) {
|
||||
getAppWidgetHost().setResumed(state == LauncherState.NORMAL);
|
||||
getWorkspace().setClipChildren(!state.disablePageClipping);
|
||||
finishAutoCancelActionMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
RaceConditionTracker.onEvent(ON_RESUME_EVT, ENTER);
|
||||
@@ -2470,14 +2477,16 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns,
|
||||
}
|
||||
|
||||
writer.println(prefix + "Misc:");
|
||||
writer.print(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
|
||||
writer.print(" mPendingRequestArgs=" + mPendingRequestArgs);
|
||||
writer.println(" mPendingActivityResult=" + mPendingActivityResult);
|
||||
writer.println(" mRotationHelper: " + mRotationHelper);
|
||||
dumpMisc(prefix + "\t", writer);
|
||||
writer.println(prefix + "\tmWorkspaceLoading=" + mWorkspaceLoading);
|
||||
writer.println(prefix + "\tmPendingRequestArgs=" + mPendingRequestArgs
|
||||
+ " mPendingActivityResult=" + mPendingActivityResult);
|
||||
writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
|
||||
writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
|
||||
|
||||
// Extra logging for b/116853349
|
||||
mDragLayer.dump(prefix, writer);
|
||||
mStateManager.dump(prefix, writer);
|
||||
dumpMisc(writer);
|
||||
|
||||
try {
|
||||
FileLog.flushAll(writer);
|
||||
|
||||
@@ -105,6 +105,10 @@ public class LauncherAppWidgetHost extends AppWidgetHost {
|
||||
super.stopListening();
|
||||
}
|
||||
|
||||
public boolean isListening() {
|
||||
return (mFlags & FLAG_LISTENING) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the resumed state of the host.
|
||||
* When a host is not resumed, it defers calls to startListening until host is resumed again.
|
||||
|
||||
@@ -136,7 +136,7 @@ public class LauncherStateManager {
|
||||
}
|
||||
|
||||
public void dump(String prefix, PrintWriter writer) {
|
||||
writer.println(prefix + "LauncherState");
|
||||
writer.println(prefix + "LauncherState:");
|
||||
writer.println(prefix + "\tmLastStableState:" + mLastStableState);
|
||||
writer.println(prefix + "\tmCurrentStableState:" + mCurrentStableState);
|
||||
writer.println(prefix + "\tmState:" + mState);
|
||||
@@ -418,7 +418,7 @@ public class LauncherStateManager {
|
||||
" @ " + Log.getStackTraceString(new Throwable()));
|
||||
}
|
||||
mState.onStateEnabled(mLauncher);
|
||||
mLauncher.onStateSet(mState);
|
||||
mLauncher.onStateSetStart(mState);
|
||||
|
||||
if (state.disablePageClipping) {
|
||||
// Only disable clipping if needed, otherwise leave it as previous value.
|
||||
@@ -444,8 +444,7 @@ public class LauncherStateManager {
|
||||
}
|
||||
|
||||
state.onStateTransitionEnd(mLauncher);
|
||||
mLauncher.getWorkspace().setClipChildren(!state.disablePageClipping);
|
||||
mLauncher.finishAutoCancelActionMode();
|
||||
mLauncher.onStateSetEnd(state);
|
||||
|
||||
if (state == NORMAL) {
|
||||
setRestState(null);
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.android.launcher3.util;
|
||||
*/
|
||||
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@@ -25,11 +24,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -37,7 +32,8 @@ import java.util.function.Consumer;
|
||||
* {@link BroadcastReceiver} which watches configuration changes and
|
||||
* notifies the callback in case changes which affect the device profile occur.
|
||||
*/
|
||||
public class ConfigMonitor extends BroadcastReceiver implements DisplayListener {
|
||||
public class ConfigMonitor extends BroadcastReceiver implements
|
||||
DefaultDisplay.DisplayInfoChangeListener {
|
||||
|
||||
private static final String TAG = "ConfigMonitor";
|
||||
|
||||
@@ -61,24 +57,19 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener
|
||||
mFontScale = config.fontScale;
|
||||
mDensity = config.densityDpi;
|
||||
|
||||
Display display = getDefaultDisplay(context);
|
||||
mDisplayId = display.getDisplayId();
|
||||
DefaultDisplay display = DefaultDisplay.INSTANCE.get(context);
|
||||
display.addChangeListener(this);
|
||||
DefaultDisplay.Info displayInfo = display.getInfo();
|
||||
mDisplayId = displayInfo.id;
|
||||
|
||||
mRealSize = new Point();
|
||||
display.getRealSize(mRealSize);
|
||||
|
||||
mSmallestSize = new Point();
|
||||
mLargestSize = new Point();
|
||||
display.getCurrentSizeRange(mSmallestSize, mLargestSize);
|
||||
mRealSize = new Point(displayInfo.realSize);
|
||||
mSmallestSize = new Point(displayInfo.smallestSize);
|
||||
mLargestSize = new Point(displayInfo.largestSize);
|
||||
|
||||
mCallback = callback;
|
||||
|
||||
// Listen for configuration change
|
||||
mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
|
||||
|
||||
// Listen for display manager change
|
||||
mContext.getSystemService(DisplayManager.class)
|
||||
.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,26 +82,19 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisplayAdded(int displayId) { }
|
||||
|
||||
@Override
|
||||
public void onDisplayRemoved(int displayId) { }
|
||||
|
||||
@Override
|
||||
public void onDisplayChanged(int displayId) {
|
||||
if (displayId != mDisplayId) {
|
||||
public void onDisplayInfoChanged(DefaultDisplay.Info info, int flags) {
|
||||
if (info.id != mDisplayId) {
|
||||
return;
|
||||
}
|
||||
Display display = getDefaultDisplay(mContext);
|
||||
display.getRealSize(mTmpPoint1);
|
||||
|
||||
mTmpPoint1.set(info.realSize.x, info.realSize.y);
|
||||
if (!mRealSize.equals(mTmpPoint1) && !mRealSize.equals(mTmpPoint1.y, mTmpPoint1.x)) {
|
||||
Log.d(TAG, String.format("Display size changed from %s to %s", mRealSize, mTmpPoint1));
|
||||
notifyChange();
|
||||
return;
|
||||
}
|
||||
|
||||
display.getCurrentSizeRange(mTmpPoint1, mTmpPoint2);
|
||||
mTmpPoint1.set(info.smallestSize.x, info.smallestSize.y);
|
||||
mTmpPoint2.set(info.largestSize.x, info.largestSize.y);
|
||||
if (!mSmallestSize.equals(mTmpPoint1) || !mLargestSize.equals(mTmpPoint2)) {
|
||||
Log.d(TAG, String.format("Available size changed from [%s, %s] to [%s, %s]",
|
||||
mSmallestSize, mLargestSize, mTmpPoint1, mTmpPoint2));
|
||||
@@ -126,14 +110,11 @@ public class ConfigMonitor extends BroadcastReceiver implements DisplayListener
|
||||
}
|
||||
}
|
||||
|
||||
private Display getDefaultDisplay(Context context) {
|
||||
return context.getSystemService(WindowManager.class).getDefaultDisplay();
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
try {
|
||||
mContext.unregisterReceiver(this);
|
||||
mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this);
|
||||
DefaultDisplay display = DefaultDisplay.INSTANCE.get(mContext);
|
||||
display.removeChangeListener(this);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to unregister config monitor", e);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.hardware.display.DisplayManager;
|
||||
import android.hardware.display.DisplayManager.DisplayListener;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.WindowManager;
|
||||
@@ -124,6 +125,8 @@ public class DefaultDisplay implements DisplayListener {
|
||||
public final Point smallestSize;
|
||||
public final Point largestSize;
|
||||
|
||||
public final DisplayMetrics metrics;
|
||||
|
||||
private Info(Context context) {
|
||||
Display display = context.getSystemService(WindowManager.class).getDefaultDisplay();
|
||||
|
||||
@@ -138,6 +141,9 @@ public class DefaultDisplay implements DisplayListener {
|
||||
largestSize = new Point();
|
||||
display.getRealSize(realSize);
|
||||
display.getCurrentSizeRange(smallestSize, largestSize);
|
||||
|
||||
metrics = new DisplayMetrics();
|
||||
display.getMetrics(metrics);
|
||||
}
|
||||
|
||||
private boolean hasDifferentSize(Info info) {
|
||||
|
||||
@@ -465,7 +465,7 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
}
|
||||
|
||||
public void dump(String prefix, PrintWriter writer) {
|
||||
writer.println(prefix + "DragLayer");
|
||||
writer.println(prefix + "DragLayer:");
|
||||
if (mActiveController != null) {
|
||||
writer.println(prefix + "\tactiveController: " + mActiveController);
|
||||
mActiveController.dump(prefix + "\t", writer);
|
||||
|
||||
Reference in New Issue
Block a user