mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 19:38:21 +00:00
Merge "Use real IDP in DeviceProfileTest" into tm-qpr-dev am: 0f1001c7b1
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/19717456 Change-Id: I8b6e68788cde685ee9ed66786714d836b4ffaa13 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package com.android.launcher3.statehandlers;
|
||||
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.launcher3.util.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.quickstep.AnimatedFloat.VALUE;
|
||||
|
||||
import com.android.launcher3.LauncherState;
|
||||
|
||||
@@ -80,7 +80,7 @@ import com.android.launcher3.testing.TestLogging;
|
||||
import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.touch.ItemClickHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.TraceHelper;
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.taskbar.unfold.NonDestroyableScopedUnfoldTransitionProgressProvider;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.SimpleBroadcastReceiver;
|
||||
import com.android.quickstep.RecentsActivity;
|
||||
@@ -83,7 +84,7 @@ public class TaskbarManager {
|
||||
// It's destruction/creation will be managed by the activity.
|
||||
private final ScopedUnfoldTransitionProgressProvider mUnfoldProgressProvider =
|
||||
new NonDestroyableScopedUnfoldTransitionProgressProvider();
|
||||
private DisplayController.NavigationMode mNavMode;
|
||||
private NavigationMode mNavMode;
|
||||
|
||||
private TaskbarActivityContext mTaskbarActivityContext;
|
||||
private StatefulActivity mActivity;
|
||||
|
||||
@@ -45,9 +45,9 @@ import static com.android.launcher3.testing.shared.TestProtocol.OVERVIEW_STATE_O
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.QUICK_SWITCH_STATE_ORDINAL;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.launcher3.util.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
@@ -114,8 +114,8 @@ import com.android.launcher3.uioverrides.touchcontrollers.TransposedQuickSwitchT
|
||||
import com.android.launcher3.uioverrides.touchcontrollers.TwoButtonNavbarTouchController;
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.IntSet;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.ObjectWrapper;
|
||||
import com.android.launcher3.util.PendingRequestArgs;
|
||||
import com.android.launcher3.util.PendingSplitSelectInfo;
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.android.launcher3.states.StateAnimationConfig;
|
||||
import com.android.launcher3.touch.AbstractStateChangeTouchController;
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.quickstep.TaskUtils;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
|
||||
@@ -55,7 +55,7 @@ import com.android.launcher3.statemanager.StatefulActivity;
|
||||
import com.android.launcher3.taskbar.TaskbarUIController;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.views.ScrimView;
|
||||
import com.android.quickstep.util.ActivityInitListener;
|
||||
import com.android.quickstep.util.AnimatorControllerWithResistance;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package com.android.quickstep;
|
||||
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
|
||||
import static com.android.quickstep.fallback.RecentsState.BACKGROUND_APP;
|
||||
import static com.android.quickstep.fallback.RecentsState.DEFAULT;
|
||||
import static com.android.quickstep.fallback.RecentsState.HOME;
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.android.launcher3.taskbar.LauncherTaskbarUIController;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.GestureState.GestureEndTarget;
|
||||
import com.android.quickstep.util.ActivityInitListener;
|
||||
import com.android.quickstep.util.AnimatorControllerWithResistance;
|
||||
|
||||
@@ -34,7 +34,7 @@ import android.view.Surface;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.window.CachedDisplayInfo;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@@ -23,9 +23,9 @@ import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.NavigationMode.TWO_BUTTONS;
|
||||
import static com.android.launcher3.util.SettingsCache.ONE_HANDED_ENABLED;
|
||||
import static com.android.launcher3.util.SettingsCache.ONE_HANDED_SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_A11Y_BUTTON_CLICKABLE;
|
||||
@@ -67,7 +67,7 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.quickstep.TopTaskTracker.CachedTaskInfo;
|
||||
import com.android.quickstep.util.NavBarPosition;
|
||||
|
||||
@@ -23,8 +23,8 @@ import static com.android.launcher3.util.DisplayController.CHANGE_ALL;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION;
|
||||
import static com.android.launcher3.util.DisplayController.CHANGE_SUPPORTED_BOUNDS;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
@@ -35,8 +35,8 @@ import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.DisplayInfoChangeListener;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
import com.android.systemui.shared.system.TaskStackChangeListener;
|
||||
|
||||
@@ -22,7 +22,7 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.TouchController;
|
||||
import com.android.quickstep.RecentsActivity;
|
||||
import com.android.quickstep.util.NavBarPosition;
|
||||
|
||||
@@ -44,10 +44,10 @@ import android.view.ViewConfiguration;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.util.MotionPauseDetector;
|
||||
import com.android.quickstep.util.NavBarPosition;
|
||||
import com.android.quickstep.util.TriggerSwipeUpTouchTracker;
|
||||
|
||||
@@ -46,8 +46,8 @@ import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||
import com.android.launcher3.model.DeviceGridState;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.SettingsCache;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.view.ViewGroup;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.LauncherActivityInterface;
|
||||
|
||||
public class LayoutUtils {
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.android.quickstep.util;
|
||||
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
|
||||
|
||||
import android.view.Surface;
|
||||
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
|
||||
/**
|
||||
* Utility class to check nav bar position.
|
||||
|
||||
@@ -21,7 +21,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS;
|
||||
import static com.android.launcher3.LauncherState.HINT_STATE;
|
||||
import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.NavigationMode;
|
||||
import com.android.launcher3.util.MultiValueAlpha;
|
||||
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.quickstep.TaskOverlayFactory.OverlayUICallbacks;
|
||||
import com.android.quickstep.util.LayoutUtils;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.android.quickstep.views;
|
||||
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,7 +19,7 @@ package com.android.quickstep;
|
||||
|
||||
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
|
||||
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.NO_BUTTON;
|
||||
import static com.android.launcher3.util.NavigationMode.NO_BUTTON;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.DisplayController.Info;
|
||||
import com.android.launcher3.util.LauncherModelHelper;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.ReflectionHelpers;
|
||||
import com.android.launcher3.util.RotationUtils;
|
||||
import com.android.launcher3.util.WindowBounds;
|
||||
@@ -164,6 +165,7 @@ public class TaskViewSimulatorTest {
|
||||
WindowManagerProxy wmProxy = mock(WindowManagerProxy.class);
|
||||
doReturn(cdi).when(wmProxy).getDisplayInfo(any());
|
||||
doReturn(wm).when(wmProxy).getRealBounds(any(), any());
|
||||
doReturn(NavigationMode.NO_BUTTON).when(wmProxy).getNavigationMode(any());
|
||||
|
||||
ArrayMap<CachedDisplayInfo, WindowBounds[]> perDisplayBoundsCache =
|
||||
new ArrayMap<>();
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.android.launcher3.util.WindowBounds;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class DeviceProfile {
|
||||
@@ -1354,6 +1355,10 @@ public class DeviceProfile {
|
||||
return "\t" + name + ": " + value + "px (" + dpiFromPx(value, mMetrics.densityDpi) + "dp)";
|
||||
}
|
||||
|
||||
private String dpPointFToString(String name, PointF value) {
|
||||
return String.format(Locale.ENGLISH, "\t%s: PointF(%.1f, %.1f)dp", name, value.x, value.y);
|
||||
}
|
||||
|
||||
/** Dumps various DeviceProfile variables to the specified writer. */
|
||||
public void dump(Context context, String prefix, PrintWriter writer) {
|
||||
writer.println(prefix + "DeviceProfile:");
|
||||
@@ -1389,7 +1394,7 @@ public class DeviceProfile {
|
||||
writer.println(prefix + "\tinv.numSearchContainerColumns: "
|
||||
+ inv.numSearchContainerColumns);
|
||||
|
||||
writer.println(prefix + "\tminCellSize: " + inv.minCellSize[mTypeIndex] + "dp");
|
||||
writer.println(prefix + dpPointFToString("minCellSize", inv.minCellSize[mTypeIndex]));
|
||||
|
||||
writer.println(prefix + pxToDpStr("cellWidthPx", cellWidthPx));
|
||||
writer.println(prefix + pxToDpStr("cellHeightPx", cellHeightPx));
|
||||
@@ -1669,7 +1674,7 @@ public class DeviceProfile {
|
||||
mTransposeLayoutWithOrientation = !mInfo.isTablet(mWindowBounds);
|
||||
}
|
||||
if (mIsGestureMode == null) {
|
||||
mIsGestureMode = DisplayController.getNavigationMode(mContext).hasGestures;
|
||||
mIsGestureMode = mInfo.navigationMode.hasGestures;
|
||||
}
|
||||
if (mDotRendererCache == null) {
|
||||
mDotRendererCache = new SparseArray<>();
|
||||
|
||||
@@ -36,6 +36,8 @@ public class ResourceUtils {
|
||||
public static final String STATUS_BAR_HEIGHT_LANDSCAPE = "status_bar_height_landscape";
|
||||
public static final String STATUS_BAR_HEIGHT_PORTRAIT = "status_bar_height_portrait";
|
||||
|
||||
public static final String NAV_BAR_INTERACTION_MODE_RES_NAME = "config_navBarInteractionMode";
|
||||
|
||||
public static int getNavbarSize(String resName, Resources res) {
|
||||
return getDimenByName(resName, res, DEFAULT_NAVBAR_VALUE);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
|
||||
import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;
|
||||
import static com.android.launcher3.util.DisplayController.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.NavigationMode.THREE_BUTTONS;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
||||
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
||||
|
||||
|
||||
@@ -19,11 +19,7 @@ import static android.content.Intent.ACTION_CONFIGURATION_CHANGED;
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_2_BUTTON;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_3_BUTTON;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.PackageManagerHelper.getPackageFilter;
|
||||
import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH;
|
||||
@@ -46,9 +42,7 @@ import android.view.Display;
|
||||
import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent;
|
||||
import com.android.launcher3.util.window.CachedDisplayInfo;
|
||||
import com.android.launcher3.util.window.WindowManagerProxy;
|
||||
|
||||
@@ -56,6 +50,7 @@ import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -81,7 +76,6 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
| CHANGE_DENSITY | CHANGE_SUPPORTED_BOUNDS | CHANGE_NAVIGATION_MODE;
|
||||
|
||||
private static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
|
||||
private static final String NAV_BAR_INTERACTION_MODE_RES_NAME = "config_navBarInteractionMode";
|
||||
private static final String TARGET_OVERLAY_PACKAGE = "android";
|
||||
|
||||
private final Context mContext;
|
||||
@@ -294,7 +288,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
// Used for testing
|
||||
public Info(Context displayInfoContext,
|
||||
WindowManagerProxy wmProxy,
|
||||
ArrayMap<CachedDisplayInfo, WindowBounds[]> perDisplayBoundsCache) {
|
||||
Map<CachedDisplayInfo, WindowBounds[]> perDisplayBoundsCache) {
|
||||
CachedDisplayInfo displayInfo = wmProxy.getDisplayInfo(displayInfoContext);
|
||||
normalizedDisplayInfo = displayInfo.normalize();
|
||||
rotation = displayInfo.rotation;
|
||||
@@ -305,7 +299,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
fontScale = config.fontScale;
|
||||
densityDpi = config.densityDpi;
|
||||
mScreenSizeDp = new PortraitSize(config.screenHeightDp, config.screenWidthDp);
|
||||
navigationMode = parseNavigationMode(displayInfoContext);
|
||||
navigationMode = wmProxy.getNavigationMode(displayInfoContext);
|
||||
|
||||
mPerDisplayBounds.putAll(perDisplayBoundsCache);
|
||||
WindowBounds[] cachedValue = mPerDisplayBounds.get(normalizedDisplayInfo);
|
||||
@@ -405,35 +399,4 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
public enum NavigationMode {
|
||||
THREE_BUTTONS(false, 0, LAUNCHER_NAVIGATION_MODE_3_BUTTON),
|
||||
TWO_BUTTONS(true, 1, LAUNCHER_NAVIGATION_MODE_2_BUTTON),
|
||||
NO_BUTTON(true, 2, LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON);
|
||||
|
||||
public final boolean hasGestures;
|
||||
public final int resValue;
|
||||
public final LauncherEvent launcherEvent;
|
||||
|
||||
NavigationMode(boolean hasGestures, int resValue, LauncherEvent launcherEvent) {
|
||||
this.hasGestures = hasGestures;
|
||||
this.resValue = resValue;
|
||||
this.launcherEvent = launcherEvent;
|
||||
}
|
||||
}
|
||||
|
||||
private static NavigationMode parseNavigationMode(Context context) {
|
||||
int modeInt = ResourceUtils.getIntegerByName(NAV_BAR_INTERACTION_MODE_RES_NAME,
|
||||
context.getResources(), INVALID_RESOURCE_HANDLE);
|
||||
|
||||
if (modeInt == INVALID_RESOURCE_HANDLE) {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
} else {
|
||||
for (NavigationMode m : NavigationMode.values()) {
|
||||
if (m.resValue == modeInt) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Utilities.ATLEAST_S ? NavigationMode.NO_BUTTON : NavigationMode.THREE_BUTTONS;
|
||||
}
|
||||
}
|
||||
|
||||
42
src/com/android/launcher3/util/NavigationMode.java
Normal file
42
src/com/android/launcher3/util/NavigationMode.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_2_BUTTON;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_3_BUTTON;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON;
|
||||
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
|
||||
/**
|
||||
* Navigation mode used in the device.
|
||||
*/
|
||||
public enum NavigationMode {
|
||||
THREE_BUTTONS(false, 0, LAUNCHER_NAVIGATION_MODE_3_BUTTON),
|
||||
TWO_BUTTONS(true, 1, LAUNCHER_NAVIGATION_MODE_2_BUTTON),
|
||||
NO_BUTTON(true, 2, LAUNCHER_NAVIGATION_MODE_GESTURE_BUTTON);
|
||||
|
||||
public final boolean hasGestures;
|
||||
public final int resValue;
|
||||
public final StatsLogManager.LauncherEvent launcherEvent;
|
||||
|
||||
NavigationMode(boolean hasGestures, int resValue, StatsLogManager.LauncherEvent launcherEvent) {
|
||||
this.hasGestures = hasGestures;
|
||||
this.resValue = resValue;
|
||||
this.launcherEvent = launcherEvent;
|
||||
}
|
||||
}
|
||||
@@ -17,14 +17,15 @@ package com.android.launcher3.util.window;
|
||||
|
||||
import static android.view.Display.DEFAULT_DISPLAY;
|
||||
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.INVALID_RESOURCE_HANDLE;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_HEIGHT;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_HEIGHT_LANDSCAPE;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.NAVBAR_LANDSCAPE_LEFT_RIGHT_SIZE;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.NAV_BAR_INTERACTION_MODE_RES_NAME;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.STATUS_BAR_HEIGHT;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.STATUS_BAR_HEIGHT_LANDSCAPE;
|
||||
import static com.android.launcher3.testing.shared.ResourceUtils.STATUS_BAR_HEIGHT_PORTRAIT;
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
import static com.android.launcher3.util.MainThreadInitializedObject.forOverride;
|
||||
import static com.android.launcher3.util.RotationUtils.deltaRotation;
|
||||
import static com.android.launcher3.util.RotationUtils.rotateRect;
|
||||
@@ -40,6 +41,7 @@ import android.graphics.Rect;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Build;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.Surface;
|
||||
@@ -48,9 +50,10 @@ import android.view.WindowManager;
|
||||
import android.view.WindowMetrics;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.testing.shared.ResourceUtils;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.launcher3.util.NavigationMode;
|
||||
import com.android.launcher3.util.ResourceBasedOverride;
|
||||
import com.android.launcher3.util.WindowBounds;
|
||||
|
||||
@@ -59,6 +62,7 @@ import com.android.launcher3.util.WindowBounds;
|
||||
*/
|
||||
public class WindowManagerProxy implements ResourceBasedOverride {
|
||||
|
||||
private static final String TAG = "WindowManagerProxy";
|
||||
public static final int MIN_TABLET_WIDTH = 600;
|
||||
|
||||
public static final MainThreadInitializedObject<WindowManagerProxy> INSTANCE =
|
||||
@@ -343,4 +347,24 @@ public class WindowManagerProxy implements ResourceBasedOverride {
|
||||
return displayInfoContext.getSystemService(DisplayManager.class).getDisplay(
|
||||
DEFAULT_DISPLAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current navigation mode from resource.
|
||||
*/
|
||||
public NavigationMode getNavigationMode(Context context) {
|
||||
int modeInt = ResourceUtils.getIntegerByName(NAV_BAR_INTERACTION_MODE_RES_NAME,
|
||||
context.getResources(), INVALID_RESOURCE_HANDLE);
|
||||
|
||||
if (modeInt == INVALID_RESOURCE_HANDLE) {
|
||||
Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?");
|
||||
} else {
|
||||
for (NavigationMode m : NavigationMode.values()) {
|
||||
if (m.resValue == modeInt) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Utilities.ATLEAST_S ? NavigationMode.NO_BUTTON :
|
||||
NavigationMode.THREE_BUTTONS;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user