Merge "Migrate to using config change to update bounds" into sc-dev
This commit is contained in:
@@ -70,7 +70,6 @@ import android.database.ContentObserver;
|
|||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.hardware.display.DisplayManager;
|
|
||||||
import android.inputmethodservice.InputMethodService;
|
import android.inputmethodservice.InputMethodService;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
@@ -160,7 +159,7 @@ import dagger.Lazy;
|
|||||||
*/
|
*/
|
||||||
public class NavigationBar implements View.OnAttachStateChangeListener,
|
public class NavigationBar implements View.OnAttachStateChangeListener,
|
||||||
Callbacks, NavigationModeController.ModeChangedListener,
|
Callbacks, NavigationModeController.ModeChangedListener,
|
||||||
AccessibilityButtonModeObserver.ModeChangedListener, DisplayManager.DisplayListener {
|
AccessibilityButtonModeObserver.ModeChangedListener {
|
||||||
|
|
||||||
public static final String TAG = "NavigationBar";
|
public static final String TAG = "NavigationBar";
|
||||||
private static final boolean DEBUG = false;
|
private static final boolean DEBUG = false;
|
||||||
@@ -660,7 +659,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
|
mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
|
||||||
if (mOrientationHandle != null) {
|
if (mOrientationHandle != null) {
|
||||||
resetSecondaryHandle();
|
resetSecondaryHandle();
|
||||||
mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this);
|
|
||||||
getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener);
|
getBarTransitions().removeDarkIntensityListener(mOrientationHandleIntensityListener);
|
||||||
mWindowManager.removeView(mOrientationHandle);
|
mWindowManager.removeView(mOrientationHandle);
|
||||||
mOrientationHandle.getViewTreeObserver().removeOnGlobalLayoutListener(
|
mOrientationHandle.getViewTreeObserver().removeOnGlobalLayoutListener(
|
||||||
@@ -699,7 +697,15 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
mLayoutDirection = ld;
|
mLayoutDirection = ld;
|
||||||
refreshLayout(ld);
|
refreshLayout(ld);
|
||||||
}
|
}
|
||||||
|
|
||||||
repositionNavigationBar();
|
repositionNavigationBar();
|
||||||
|
if (canShowSecondaryHandle()) {
|
||||||
|
int rotation = newConfig.windowConfiguration.getRotation();
|
||||||
|
if (rotation != mCurrentRotation) {
|
||||||
|
mCurrentRotation = rotation;
|
||||||
|
orientSecondaryHomeHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSecondaryHomeHandleForRotation() {
|
private void initSecondaryHomeHandleForRotation() {
|
||||||
@@ -707,9 +713,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mContext.getSystemService(DisplayManager.class)
|
|
||||||
.registerDisplayListener(this, new Handler(Looper.getMainLooper()));
|
|
||||||
|
|
||||||
mOrientationHandle = new QuickswitchOrientedNavHandle(mContext);
|
mOrientationHandle = new QuickswitchOrientedNavHandle(mContext);
|
||||||
mOrientationHandle.setId(R.id.secondary_home_handle);
|
mOrientationHandle.setId(R.id.secondary_home_handle);
|
||||||
|
|
||||||
@@ -1604,30 +1607,6 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
private final AccessibilityServicesStateChangeListener mAccessibilityListener =
|
private final AccessibilityServicesStateChangeListener mAccessibilityListener =
|
||||||
this::updateAccessibilityServicesState;
|
this::updateAccessibilityServicesState;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayAdded(int displayId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayRemoved(int displayId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayChanged(int displayId) {
|
|
||||||
if (!canShowSecondaryHandle()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int rotation = mContext.getResources().getConfiguration()
|
|
||||||
.windowConfiguration.getRotation();
|
|
||||||
if (rotation != mCurrentRotation) {
|
|
||||||
mCurrentRotation = rotation;
|
|
||||||
orientSecondaryHomeHandle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canShowSecondaryHandle() {
|
private boolean canShowSecondaryHandle() {
|
||||||
return mNavBarMode == NAV_BAR_MODE_GESTURAL && mOrientationHandle != null;
|
return mNavBarMode == NAV_BAR_MODE_GESTURAL && mOrientationHandle != null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1186,6 +1186,7 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
boolean uiCarModeChanged = updateCarMode();
|
boolean uiCarModeChanged = updateCarMode();
|
||||||
updateIcons(mTmpLastConfiguration);
|
updateIcons(mTmpLastConfiguration);
|
||||||
updateRecentsIcon();
|
updateRecentsIcon();
|
||||||
|
mEdgeBackGestureHandler.onConfigurationChanged(mConfiguration);
|
||||||
mRecentsOnboarding.onConfigurationChanged(mConfiguration);
|
mRecentsOnboarding.onConfigurationChanged(mConfiguration);
|
||||||
if (uiCarModeChanged || mTmpLastConfiguration.densityDpi != mConfiguration.densityDpi
|
if (uiCarModeChanged || mTmpLastConfiguration.densityDpi != mConfiguration.densityDpi
|
||||||
|| mTmpLastConfiguration.getLayoutDirection() != mConfiguration.getLayoutDirection()) {
|
|| mTmpLastConfiguration.getLayoutDirection() != mConfiguration.getLayoutDirection()) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
@@ -50,6 +51,7 @@ import android.view.Surface;
|
|||||||
import android.view.ViewConfiguration;
|
import android.view.ViewConfiguration;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManagerGlobal;
|
import android.view.WindowManagerGlobal;
|
||||||
|
import android.view.WindowMetrics;
|
||||||
|
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.internal.policy.GestureNavigationSettingsObserver;
|
import com.android.internal.policy.GestureNavigationSettingsObserver;
|
||||||
@@ -86,8 +88,8 @@ import java.util.concurrent.Executor;
|
|||||||
/**
|
/**
|
||||||
* Utility class to handle edge swipes for back gesture
|
* Utility class to handle edge swipes for back gesture
|
||||||
*/
|
*/
|
||||||
public class EdgeBackGestureHandler extends CurrentUserTracker implements DisplayListener,
|
public class EdgeBackGestureHandler extends CurrentUserTracker
|
||||||
PluginListener<NavigationEdgeBackPlugin>, ProtoTraceable<SystemUiTraceProto> {
|
implements PluginListener<NavigationEdgeBackPlugin>, ProtoTraceable<SystemUiTraceProto> {
|
||||||
|
|
||||||
private static final String TAG = "EdgeBackGestureHandler";
|
private static final String TAG = "EdgeBackGestureHandler";
|
||||||
private static final int MAX_LONG_PRESS_TIMEOUT = SystemProperties.getInt(
|
private static final int MAX_LONG_PRESS_TIMEOUT = SystemProperties.getInt(
|
||||||
@@ -123,7 +125,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
|
|||||||
@Override
|
@Override
|
||||||
public void onQuickSwitchToNewTask(@Surface.Rotation int rotation) {
|
public void onQuickSwitchToNewTask(@Surface.Rotation int rotation) {
|
||||||
mStartingQuickstepRotation = rotation;
|
mStartingQuickstepRotation = rotation;
|
||||||
updateDisabledForQuickstep();
|
updateDisabledForQuickstep(mContext.getResources().getConfiguration());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -414,7 +416,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
|
|||||||
|
|
||||||
if (!mIsEnabled) {
|
if (!mIsEnabled) {
|
||||||
mGestureNavigationSettingsObserver.unregister();
|
mGestureNavigationSettingsObserver.unregister();
|
||||||
mContext.getSystemService(DisplayManager.class).unregisterDisplayListener(this);
|
|
||||||
if (DEBUG_MISSING_GESTURE) {
|
if (DEBUG_MISSING_GESTURE) {
|
||||||
Log.d(DEBUG_MISSING_GESTURE_TAG, "Unregister display listener");
|
Log.d(DEBUG_MISSING_GESTURE_TAG, "Unregister display listener");
|
||||||
}
|
}
|
||||||
@@ -433,8 +434,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
|
|||||||
} else {
|
} else {
|
||||||
mGestureNavigationSettingsObserver.register();
|
mGestureNavigationSettingsObserver.register();
|
||||||
updateDisplaySize();
|
updateDisplaySize();
|
||||||
mContext.getSystemService(DisplayManager.class).registerDisplayListener(this,
|
|
||||||
mContext.getMainThreadHandler());
|
|
||||||
if (DEBUG_MISSING_GESTURE) {
|
if (DEBUG_MISSING_GESTURE) {
|
||||||
Log.d(DEBUG_MISSING_GESTURE_TAG, "Register display listener");
|
Log.d(DEBUG_MISSING_GESTURE_TAG, "Register display listener");
|
||||||
}
|
}
|
||||||
@@ -805,35 +804,28 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
|
|||||||
Dependency.get(ProtoTracer.class).scheduleFrameUpdate();
|
Dependency.get(ProtoTracer.class).scheduleFrameUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisabledForQuickstep() {
|
private void updateDisabledForQuickstep(Configuration newConfig) {
|
||||||
int rotation = mContext.getResources().getConfiguration().windowConfiguration.getRotation();
|
int rotation = newConfig.windowConfiguration.getRotation();
|
||||||
mDisabledForQuickstep = mStartingQuickstepRotation > -1 &&
|
mDisabledForQuickstep = mStartingQuickstepRotation > -1 &&
|
||||||
mStartingQuickstepRotation != rotation;
|
mStartingQuickstepRotation != rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
public void onDisplayAdded(int displayId) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayRemoved(int displayId) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisplayChanged(int displayId) {
|
|
||||||
if (mStartingQuickstepRotation > -1) {
|
if (mStartingQuickstepRotation > -1) {
|
||||||
updateDisabledForQuickstep();
|
updateDisabledForQuickstep(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DEBUG_MISSING_GESTURE) {
|
if (DEBUG_MISSING_GESTURE) {
|
||||||
Log.d(DEBUG_MISSING_GESTURE_TAG, "Display changed: mDisplayId=" + mDisplayId
|
Log.d(DEBUG_MISSING_GESTURE_TAG, "Config changed: config=" + newConfig);
|
||||||
+ " displayId=" + displayId);
|
|
||||||
}
|
|
||||||
if (displayId == mDisplayId) {
|
|
||||||
updateDisplaySize();
|
|
||||||
}
|
}
|
||||||
|
updateDisplaySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDisplaySize() {
|
private void updateDisplaySize() {
|
||||||
mContext.getDisplay().getRealSize(mDisplaySize);
|
WindowMetrics metrics = mContext.getSystemService(WindowManager.class)
|
||||||
|
.getMaximumWindowMetrics();
|
||||||
|
Rect bounds = metrics.getBounds();
|
||||||
|
mDisplaySize.set(bounds.width(), bounds.height());
|
||||||
if (DEBUG_MISSING_GESTURE) {
|
if (DEBUG_MISSING_GESTURE) {
|
||||||
Log.d(DEBUG_MISSING_GESTURE_TAG, "Update display size: mDisplaySize=" + mDisplaySize);
|
Log.d(DEBUG_MISSING_GESTURE_TAG, "Update display size: mDisplaySize=" + mDisplaySize);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user