From 621918fedaa45c4f64d6e0cc16fbe08e8cd12b79 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 18 Sep 2024 11:31:58 -0700 Subject: [PATCH] Changing min-sdk version of Launcher to 31 Bug: 368071216 Flag: EXEMPT refactor -> dead code removal Test: Presubmit Change-Id: I1f0113c56de56f12f3a174eb31c3f8e8a09407e6 --- Android.bp | 2 +- .../QuickstepInteractionHandler.java | 3 +- .../quickstep/interaction/AllSetActivity.java | 2 +- .../views/FloatingWidgetBackgroundView.java | 4 +- .../android/quickstep/views/RecentsView.java | 2 +- src/com/android/launcher3/Launcher.java | 23 ++----- src/com/android/launcher3/ModelCallbacks.kt | 32 +++++----- src/com/android/launcher3/Utilities.java | 3 - .../graphics/LauncherPreviewRenderer.java | 16 ++--- .../android/launcher3/model/WidgetItem.java | 6 +- .../launcher3/model/WorkspaceItemProcessor.kt | 63 +++++++++---------- .../model/data/LauncherAppWidgetInfo.java | 7 +-- .../launcher3/util/DisplayController.java | 55 +++++----------- .../launcher3/util/EdgeEffectCompat.java | 17 ----- .../launcher3/util/OverlayEdgeEffect.java | 1 + .../launcher3/util/PackageManagerHelper.java | 5 +- src/com/android/launcher3/util/Themes.java | 6 +- .../launcher3/util/VibratorWrapper.java | 4 +- .../launcher3/util/WallpaperColorHints.kt | 34 +++++----- .../util/window/WindowManagerProxy.java | 23 ++----- .../launcher3/views/SpringRelativeLayout.java | 8 +-- .../widget/BaseLauncherAppWidgetHostView.java | 2 +- .../widget/DatabaseWidgetPreviewLoader.java | 19 +++--- .../widget/LauncherAppWidgetProviderInfo.java | 41 +++++------- .../widget/PendingItemDragHelper.java | 4 +- .../widget/RoundedCornerEnforcement.java | 9 --- .../launcher3/util/DisplayControllerTest.kt | 8 +-- 27 files changed, 139 insertions(+), 260 deletions(-) diff --git a/Android.bp b/Android.bp index bcbd3626e9..4e1c9d3d11 100644 --- a/Android.bp +++ b/Android.bp @@ -17,7 +17,7 @@ package { default_applicable_licenses: ["Android-Apache-2.0"], } -min_launcher3_sdk_version = "30" +min_launcher3_sdk_version = "31" // Targets that don't inherit framework aconfig libs (i.e., those that don't set // `platform_apis: true`) must manually link them. diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java index 93cbdc73a3..26a1322ea6 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java @@ -29,7 +29,6 @@ import android.view.View; import android.widget.RemoteViews; import android.window.SplashScreen; -import com.android.launcher3.Utilities; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.util.ActivityOptionsWrapper; @@ -66,7 +65,7 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { Pair options = remoteResponse.getLaunchOptions(view); ActivityOptionsWrapper activityOptions = mLauncher.getAppTransitionManager() .getActivityLaunchOptions(hostView, (ItemInfo) hostView.getTag()); - if (Utilities.ATLEAST_S && !pendingIntent.isActivity()) { + if (!pendingIntent.isActivity()) { // In the event this pending intent eventually launches an activity, i.e. a trampoline, // use the Quickstep transition animation. try { diff --git a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java index b56958a340..f7f3157230 100644 --- a/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java +++ b/quickstep/src/com/android/quickstep/interaction/AllSetActivity.java @@ -219,7 +219,7 @@ public class AllSetActivity extends Activity { } private void startBackgroundAnimation(boolean forTablet) { - if (!Utilities.ATLEAST_S || mVibrator == null) { + if (mVibrator == null) { return; } boolean supportsThud = mVibrator.areAllPrimitivesSupported( diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java index 4ea77532bc..f17be05d42 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetBackgroundView.java @@ -32,7 +32,6 @@ import androidx.annotation.Nullable; import com.android.launcher3.R; import com.android.launcher3.widget.LauncherAppWidgetHostView; -import com.android.launcher3.widget.RoundedCornerEnforcement; import java.util.stream.IntStream; @@ -171,8 +170,7 @@ final class FloatingWidgetBackgroundView extends View { /** Corner radius from source view's outline, or enforced view. */ private static float getOutlineRadius(LauncherAppWidgetHostView hostView, View v) { - if (RoundedCornerEnforcement.isRoundedCornerEnabled() - && hostView.hasEnforcedCornerRadius()) { + if (hostView.hasEnforcedCornerRadius()) { return hostView.getEnforcedCornerRadius(); } else if (v.getOutlineProvider() instanceof RemoteViewOutlineProvider && v.getClipToOutline()) { diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index bb46a2c3ed..f502e31de6 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -343,7 +343,7 @@ public abstract class RecentsView< }; public static final int SCROLL_VIBRATION_PRIMITIVE = - Utilities.ATLEAST_S ? VibrationEffect.Composition.PRIMITIVE_LOW_TICK : -1; + VibrationEffect.Composition.PRIMITIVE_LOW_TICK; public static final float SCROLL_VIBRATION_PRIMITIVE_SCALE = 0.6f; public static final VibrationEffect SCROLL_VIBRATION_FALLBACK = VibrationConstants.EFFECT_TEXTURE_TICK; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 0bc192d03d..b0ec9b0573 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -448,12 +448,10 @@ public class Launcher extends StatefulActivity .logStart(LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION) .logStart(LAUNCHER_LATENCY_STARTUP_ACTIVITY_ON_CREATE); // Only use a hard-coded cookie since we only want to trace this once. - if (Utilities.ATLEAST_S) { - Trace.beginAsyncSection( - DISPLAY_WORKSPACE_TRACE_METHOD_NAME, DISPLAY_WORKSPACE_TRACE_COOKIE); - Trace.beginAsyncSection(DISPLAY_ALL_APPS_TRACE_METHOD_NAME, - DISPLAY_ALL_APPS_TRACE_COOKIE); - } + Trace.beginAsyncSection( + DISPLAY_WORKSPACE_TRACE_METHOD_NAME, DISPLAY_WORKSPACE_TRACE_COOKIE); + Trace.beginAsyncSection(DISPLAY_ALL_APPS_TRACE_METHOD_NAME, + DISPLAY_ALL_APPS_TRACE_COOKIE); TraceHelper.INSTANCE.beginSection(ON_CREATE_EVT); if (DEBUG_STRICT_MODE) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() @@ -732,13 +730,6 @@ public class Launcher extends StatefulActivity public void onEnterAnimationComplete() { super.onEnterAnimationComplete(); mRotationHelper.setCurrentTransitionRequest(REQUEST_NONE); - // Starting with Android S, onEnterAnimationComplete is sent immediately - // causing the surface to get removed before the animation completed (b/175345344). - // Instead we rely on next user touch event to remove the view and optionally a callback - // from system from Android T onwards. - if (!Utilities.ATLEAST_S) { - AbstractFloatingView.closeOpenViews(this, false, TYPE_ICON_SURFACE); - } } @Override @@ -2579,10 +2570,8 @@ public class Launcher extends StatefulActivity public void bindAllApplications(AppInfo[] apps, int flags, Map packageUserKeytoUidMap) { mModelCallbacks.bindAllApplications(apps, flags, packageUserKeytoUidMap); - if (Utilities.ATLEAST_S) { - Trace.endAsyncSection(DISPLAY_ALL_APPS_TRACE_METHOD_NAME, - DISPLAY_ALL_APPS_TRACE_COOKIE); - } + Trace.endAsyncSection(DISPLAY_ALL_APPS_TRACE_METHOD_NAME, + DISPLAY_ALL_APPS_TRACE_COOKIE); } /** diff --git a/src/com/android/launcher3/ModelCallbacks.kt b/src/com/android/launcher3/ModelCallbacks.kt index d57f8a0dbe..496d517e9a 100644 --- a/src/com/android/launcher3/ModelCallbacks.kt +++ b/src/com/android/launcher3/ModelCallbacks.kt @@ -61,7 +61,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { AbstractFloatingView.closeOpenViews( launcher, true, - AbstractFloatingView.TYPE_ALL and AbstractFloatingView.TYPE_REBIND_SAFE.inv() + AbstractFloatingView.TYPE_ALL and AbstractFloatingView.TYPE_REBIND_SAFE.inv(), ) workspaceLoading = true @@ -76,7 +76,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { TAG, "startBinding: " + "hotseat layout was vertical: ${launcher.hotseat?.isHasVerticalHotseat}" + - " and is setting to ${launcher.deviceProfile.isVerticalBarLayout}" + " and is setting to ${launcher.deviceProfile.isVerticalBarLayout}", ) launcher.hotseat?.resetLayout(launcher.deviceProfile.isVerticalBarLayout) TraceHelper.INSTANCE.endSection() @@ -88,14 +88,12 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { pendingTasks: RunnableList, onCompleteSignal: RunnableList, workspaceItemCount: Int, - isBindSync: Boolean + isBindSync: Boolean, ) { - if (Utilities.ATLEAST_S) { - Trace.endAsyncSection( - TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME, - TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE - ) - } + Trace.endAsyncSection( + TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME, + TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE, + ) synchronouslyBoundPages = boundPages pagesToBindSynchronously = LIntSet() clearPendingBinds() @@ -149,14 +147,14 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { // Cache one page worth of icons launcher.viewCache.setCacheSize( R.layout.folder_application, - deviceProfile.numFolderColumns * deviceProfile.numFolderRows + deviceProfile.numFolderColumns * deviceProfile.numFolderRows, ) launcher.viewCache.setCacheSize(R.layout.folder_page, 2) TraceHelper.INSTANCE.endSection() launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true) launcher.workspace.pageIndicator.setPauseScroll( /*pause=*/ false, - deviceProfile.isTwoPanels + deviceProfile.isTwoPanels, ) TestEventEmitter.INSTANCE.get(launcher).sendEvent(TestEvent.WORKSPACE_FINISH_LOADING) } @@ -182,7 +180,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { val snackbar = AbstractFloatingView.getOpenView( launcher, - AbstractFloatingView.TYPE_SNACKBAR + AbstractFloatingView.TYPE_SNACKBAR, ) snackbar?.post { snackbar.close(true) } } @@ -191,7 +189,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { override fun bindAllApplications( apps: Array?, flags: Int, - packageUserKeytoUidMap: Map? + packageUserKeytoUidMap: Map?, ) { Preconditions.assertUIThread() val hadWorkApps = launcher.appsView.shouldShowTabs() @@ -312,7 +310,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { val info = PendingAddWidgetInfo( widgetsListBaseEntry.mWidgets[0].widgetInfo, - LauncherSettings.Favorites.CONTAINER_DESKTOP + LauncherSettings.Favorites.CONTAINER_DESKTOP, ) launcher.addPendingItem( info, @@ -320,14 +318,14 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { WorkspaceLayoutManager.FIRST_SCREEN_ID, intArrayOf(0, 0), info.spanX, - info.spanY + info.spanY, ) } override fun bindScreens(orderedScreenIds: LIntArray) { launcher.workspace.pageIndicator.setPauseScroll( /*pause=*/ true, - launcher.deviceProfile.isTwoPanels + launcher.deviceProfile.isTwoPanels, ) val firstScreenPosition = 0 if ( @@ -354,7 +352,7 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { override fun bindAppsAdded( newScreens: LIntArray?, addNotAnimated: java.util.ArrayList?, - addAnimated: java.util.ArrayList? + addAnimated: java.util.ArrayList?, ) { // Add the new screens if (newScreens != null) { diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index fde701424f..f8ac48a7df 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -122,9 +122,6 @@ public final class Utilities { public static final String[] EMPTY_STRING_ARRAY = new String[0]; public static final Person[] EMPTY_PERSON_ARRAY = new Person[0]; - @ChecksSdkIntAtLeast(api = VERSION_CODES.S) - public static final boolean ATLEAST_S = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S; - @ChecksSdkIntAtLeast(api = VERSION_CODES.TIRAMISU, codename = "T") public static final boolean ATLEAST_T = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU; diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index 4af9e2f507..40c0cc65c9 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -69,7 +69,6 @@ import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.WorkspaceLayoutManager; import com.android.launcher3.apppairs.AppPairIcon; @@ -207,15 +206,12 @@ public class LauncherPreviewRenderer extends ContextWrapper mWorkspaceScreens.put(Workspace.SECOND_SCREEN_ID, rightPanel); } - if (Utilities.ATLEAST_S) { - WallpaperColors wallpaperColors = wallpaperColorsOverride != null - ? wallpaperColorsOverride - : WallpaperManager.getInstance(context).getWallpaperColors(FLAG_SYSTEM); - mWallpaperColorResources = wallpaperColors != null ? LocalColorExtractor.newInstance( - context).generateColorsOverride(wallpaperColors) : null; - } else { - mWallpaperColorResources = null; - } + WallpaperColors wallpaperColors = wallpaperColorsOverride != null + ? wallpaperColorsOverride + : WallpaperManager.getInstance(context).getWallpaperColors(FLAG_SYSTEM); + mWallpaperColorResources = wallpaperColors != null + ? LocalColorExtractor.newInstance(context).generateColorsOverride(wallpaperColors) + : null; mAppWidgetHost = new LauncherPreviewAppWidgetHost(context); } diff --git a/src/com/android/launcher3/model/WidgetItem.java b/src/com/android/launcher3/model/WidgetItem.java index 3f887176b7..ac9f2d68eb 100644 --- a/src/com/android/launcher3/model/WidgetItem.java +++ b/src/com/android/launcher3/model/WidgetItem.java @@ -4,8 +4,6 @@ import static android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREE import static android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD; import static android.appwidget.AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX; -import static com.android.launcher3.Utilities.ATLEAST_S; - import android.annotation.SuppressLint; import android.content.Context; import android.content.pm.ActivityInfo; @@ -48,7 +46,7 @@ public class WidgetItem extends ComponentKey { super(info.provider, info.getProfile()); label = iconCache.getTitleNoCache(info); - description = ATLEAST_S ? info.loadDescription(context) : null; + description = info.loadDescription(context); widgetInfo = info; activityInfo = null; @@ -107,7 +105,7 @@ public class WidgetItem extends ComponentKey { /** Returns whether this {@link WidgetItem} has a preview layout that can be used. */ @SuppressLint("NewApi") // Already added API check. public boolean hasPreviewLayout() { - return ATLEAST_S && widgetInfo != null && widgetInfo.previewLayout != Resources.ID_NULL; + return widgetInfo != null && widgetInfo.previewLayout != Resources.ID_NULL; } /** Returns whether this {@link WidgetItem} is for a shortcut rather than an app widget. */ diff --git a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt index 90e47d66cc..1f1e514ee3 100644 --- a/src/com/android/launcher3/model/WorkspaceItemProcessor.kt +++ b/src/com/android/launcher3/model/WorkspaceItemProcessor.kt @@ -30,7 +30,6 @@ import com.android.launcher3.Flags import com.android.launcher3.InvariantDeviceProfile import com.android.launcher3.LauncherAppState import com.android.launcher3.LauncherSettings.Favorites -import com.android.launcher3.Utilities import com.android.launcher3.backuprestore.LauncherRestoreEventLogger.RestoreError import com.android.launcher3.config.FeatureFlags import com.android.launcher3.logging.FileLog @@ -76,7 +75,7 @@ class WorkspaceItemProcessor( private val pmHelper: PackageManagerHelper, private val iconRequestInfos: MutableList>, private val unlockedUsers: LongSparseArray, - private val allDeepShortcuts: MutableList + private val allDeepShortcuts: MutableList, ) { private val isSafeMode = app.isSafeModeEnabled @@ -97,7 +96,7 @@ class WorkspaceItemProcessor( // User has been deleted, remove the item. c.markDeleted( "User has been deleted for item id=${c.id}", - RestoreError.PROFILE_DELETED + RestoreError.PROFILE_DELETED, ) return } @@ -168,7 +167,7 @@ class WorkspaceItemProcessor( FileLog.d( TAG, "Activity not enabled for id=${c.id}, component=$cn, user=${c.user}." + - " Will attempt to find fallback Activity for targetPkg=$targetPkg." + " Will attempt to find fallback Activity for targetPkg=$targetPkg.", ) intent = pmHelper.getAppLaunchIntent(targetPkg, c.user) if (intent != null) { @@ -178,7 +177,7 @@ class WorkspaceItemProcessor( c.markDeleted( "No Activities found for id=${c.id}, targetPkg=$targetPkg, component=$cn." + " Unable to create launch Intent.", - RestoreError.MISSING_INFO + RestoreError.MISSING_INFO, ) return } @@ -213,7 +212,7 @@ class WorkspaceItemProcessor( else -> { c.markDeleted( "removing app that is not restored and not installing. package: $targetPkg", - RestoreError.APP_NOT_INSTALLED + RestoreError.APP_NOT_INSTALLED, ) return } @@ -238,7 +237,7 @@ class WorkspaceItemProcessor( // Do not wait for external media load anymore. c.markDeleted( "Invalid package removed: $targetPkg", - RestoreError.APP_NOT_INSTALLED + RestoreError.APP_NOT_INSTALLED, ) return } @@ -270,7 +269,7 @@ class WorkspaceItemProcessor( // The shortcut is no longer valid. c.markDeleted( "Pinned shortcut not found from request. package=${key.packageName}, user=${c.user}", - RestoreError.SHORTCUT_NOT_FOUND + RestoreError.SHORTCUT_NOT_FOUND, ) return } @@ -337,7 +336,7 @@ class WorkspaceItemProcessor( activityInfo, userCache.getUserInfo(c.user), ApiWrapper.INSTANCE[app.context], - pmHelper + pmHelper, ) } if ( @@ -445,7 +444,7 @@ class WorkspaceItemProcessor( ", id=${c.id}," + ", appWidgetId=${c.appWidgetId}," + ", component=${component}", - RestoreError.INVALID_LOCATION + RestoreError.INVALID_LOCATION, ) return } @@ -456,7 +455,7 @@ class WorkspaceItemProcessor( ", appWidgetId=${c.appWidgetId}," + ", component=${component}," + ", container=${c.container}", - RestoreError.INVALID_LOCATION + RestoreError.INVALID_LOCATION, ) return } @@ -470,7 +469,7 @@ class WorkspaceItemProcessor( TAG, "processWidget: id=${c.id}" + ", appWidgetId=${c.appWidgetId}" + - ", inflationResult=$inflationResult" + ", inflationResult=$inflationResult", ) when (inflationResult.type) { WidgetInflater.TYPE_DELETE -> { @@ -496,7 +495,7 @@ class WorkspaceItemProcessor( ", appWidgetId=${c.appWidgetId}" + ", component=${component}" + ", restoreFlag:=${c.restoreFlag}", - RestoreError.APP_NOT_INSTALLED + RestoreError.APP_NOT_INSTALLED, ) return } else if ( @@ -512,7 +511,7 @@ class WorkspaceItemProcessor( WidgetsModel.newPendingItemInfo( app.context, appWidgetInfo.providerName, - appWidgetInfo.user + appWidgetInfo.user, ) iconCache.getTitleAndIconForApp(appWidgetInfo.pendingItemInfo, false) } @@ -522,7 +521,7 @@ class WorkspaceItemProcessor( lapi, app.context, appWidgetInfo.spanX, - appWidgetInfo.spanY + appWidgetInfo.spanY, ) } @@ -541,7 +540,7 @@ class WorkspaceItemProcessor( " processWidget: Widget ${lapi.component} minSizes not met: span=${appWidgetInfo.spanX}x${appWidgetInfo.spanY} minSpan=${lapi.minSpanX}x${lapi.minSpanY}," + " id: ${c.id}," + " appWidgetId: ${c.appWidgetId}," + - " component=${component}" + " component=${component}", ) logWidgetInfo(app.invariantDeviceProfile, lapi) } @@ -554,7 +553,7 @@ class WorkspaceItemProcessor( private fun logWidgetInfo( idp: InvariantDeviceProfile, - widgetProviderInfo: LauncherAppWidgetProviderInfo + widgetProviderInfo: LauncherAppWidgetProviderInfo, ) { val cellSize = Point() for (deviceProfile in idp.supportedProfiles) { @@ -565,7 +564,7 @@ class WorkspaceItemProcessor( " available height: ${deviceProfile.availableHeightPx}," + " cellLayoutBorderSpacePx Horizontal: ${deviceProfile.cellLayoutBorderSpacePx.x}," + " cellLayoutBorderSpacePx Vertical: ${deviceProfile.cellLayoutBorderSpacePx.y}," + - " cellSize: $cellSize" + " cellSize: $cellSize", ) } val widgetDimension = StringBuilder() @@ -583,21 +582,19 @@ class WorkspaceItemProcessor( .append("defaultHeight: ") .append(widgetProviderInfo.minHeight) .append("\n") - if (Utilities.ATLEAST_S) { - widgetDimension - .append("targetCellWidth: ") - .append(widgetProviderInfo.targetCellWidth) - .append("\n") - .append("targetCellHeight: ") - .append(widgetProviderInfo.targetCellHeight) - .append("\n") - .append("maxResizeWidth: ") - .append(widgetProviderInfo.maxResizeWidth) - .append("\n") - .append("maxResizeHeight: ") - .append(widgetProviderInfo.maxResizeHeight) - .append("\n") - } + widgetDimension + .append("targetCellWidth: ") + .append(widgetProviderInfo.targetCellWidth) + .append("\n") + .append("targetCellHeight: ") + .append(widgetProviderInfo.targetCellHeight) + .append("\n") + .append("maxResizeWidth: ") + .append(widgetProviderInfo.maxResizeWidth) + .append("\n") + .append("maxResizeHeight: ") + .append(widgetProviderInfo.maxResizeHeight) + .append("\n") FileLog.d(TAG, widgetDimension.toString()) } } diff --git a/src/com/android/launcher3/model/data/LauncherAppWidgetInfo.java b/src/com/android/launcher3/model/data/LauncherAppWidgetInfo.java index f4dda5593a..361f09d418 100644 --- a/src/com/android/launcher3/model/data/LauncherAppWidgetInfo.java +++ b/src/com/android/launcher3/model/data/LauncherAppWidgetInfo.java @@ -21,7 +21,6 @@ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_BOTTOM_ import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_PIN_WIDGETS; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_PREDICTION; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_WIDGETS_TRAY; -import static com.android.launcher3.Utilities.ATLEAST_S; import android.appwidget.AppWidgetHostView; import android.content.ComponentName; @@ -233,16 +232,16 @@ public class LauncherAppWidgetInfo extends ItemInfo { if (providerInfo.isConfigurationOptional()) { widgetFeatures |= FEATURE_OPTIONAL_CONFIGURATION; } - if (ATLEAST_S && providerInfo.previewLayout != Resources.ID_NULL) { + if (providerInfo.previewLayout != Resources.ID_NULL) { widgetFeatures |= FEATURE_PREVIEW_LAYOUT; } - if (ATLEAST_S && providerInfo.targetCellWidth > 0 || providerInfo.targetCellHeight > 0) { + if (providerInfo.targetCellWidth > 0 || providerInfo.targetCellHeight > 0) { widgetFeatures |= FEATURE_TARGET_CELL_SIZE; } if (providerInfo.minResizeWidth > 0 || providerInfo.minResizeHeight > 0) { widgetFeatures |= FEATURE_MIN_SIZE; } - if (ATLEAST_S && providerInfo.maxResizeWidth > 0 || providerInfo.maxResizeHeight > 0) { + if (providerInfo.maxResizeWidth > 0 || providerInfo.maxResizeHeight > 0) { widgetFeatures |= FEATURE_MAX_SIZE; } if (hostView instanceof LauncherAppWidgetHostView && diff --git a/src/com/android/launcher3/util/DisplayController.java b/src/com/android/launcher3/util/DisplayController.java index dff9a0785d..afa5075190 100644 --- a/src/com/android/launcher3/util/DisplayController.java +++ b/src/com/android/launcher3/util/DisplayController.java @@ -15,7 +15,6 @@ */ package com.android.launcher3.util; -import static android.content.Intent.ACTION_CONFIGURATION_CHANGED; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; @@ -33,7 +32,6 @@ import static com.android.launcher3.util.FlagDebugUtils.appendFlag; import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.content.ComponentCallbacks; import android.content.Context; import android.content.Intent; @@ -42,7 +40,6 @@ import android.content.res.Configuration; import android.graphics.Point; import android.graphics.Rect; import android.hardware.display.DisplayManager; -import android.os.Build; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; @@ -132,21 +129,15 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { } Display display = mDM.getDisplay(DEFAULT_DISPLAY); - if (Utilities.ATLEAST_S) { - mWindowContext = mContext.createWindowContext(display, TYPE_APPLICATION, null); - mWindowContext.registerComponentCallbacks(this); - } else { - mWindowContext = null; - mReceiver.register(mContext, ACTION_CONFIGURATION_CHANGED); - } + mWindowContext = mContext.createWindowContext(display, TYPE_APPLICATION, null); + mWindowContext.registerComponentCallbacks(this); // Initialize navigation mode change listener mReceiver.registerPkgActions(mContext, TARGET_OVERLAY_PACKAGE, ACTION_OVERLAY_CHANGED); WindowManagerProxy wmProxy = WindowManagerProxy.INSTANCE.get(context); - Context displayInfoContext = getDisplayInfoContext(display); - mInfo = new Info(displayInfoContext, wmProxy, - wmProxy.estimateInternalDisplayBounds(displayInfoContext)); + mInfo = new Info(mWindowContext, wmProxy, + wmProxy.estimateInternalDisplayBounds(mWindowContext)); FileLog.i(TAG, "(CTOR) perDisplayBounds: " + mInfo.mPerDisplayBounds); } @@ -161,7 +152,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { && mInfo.mIsTaskbarPinnedInDesktopMode != prefs.get( TASKBAR_PINNING_IN_DESKTOP_MODE); if (isTaskbarPinningChanged || isTaskbarPinningDesktopModeChanged) { - handleInfoChange(mWindowContext.getDisplay()); + handleInfoChange(); } }; @@ -191,14 +182,14 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { * Handles info change for desktop mode. */ public static void handleInfoChangeForDesktopMode(Context context) { - INSTANCE.get(context).handleInfoChange(context.getDisplay()); + INSTANCE.get(context).handleInfoChange(); } /** * Handles info change for launcher visibility. */ public static void handleInfoChangeForLauncherVisibilityChanged(Context context) { - INSTANCE.get(context).handleInfoChange(context.getDisplay()); + INSTANCE.get(context).handleInfoChange(); } /** @@ -266,36 +257,22 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { if (mDestroyed) { return; } - boolean reconfigure = false; if (ACTION_OVERLAY_CHANGED.equals(intent.getAction())) { - reconfigure = true; - } else if (ACTION_CONFIGURATION_CHANGED.equals(intent.getAction())) { - Configuration config = mContext.getResources().getConfiguration(); - reconfigure = mInfo.fontScale != config.fontScale - || mInfo.densityDpi != config.densityDpi; - } - - if (reconfigure) { - Log.d(TAG, "Configuration changed, notifying listeners"); - Display display = mDM.getDisplay(DEFAULT_DISPLAY); - if (display != null) { - handleInfoChange(display); - } + Log.d(TAG, "Overlay changed, notifying listeners"); + handleInfoChange(); } } @UiThread @Override - @TargetApi(Build.VERSION_CODES.S) public final void onConfigurationChanged(Configuration config) { Log.d(TASKBAR_NOT_DESTROYED_TAG, "DisplayController#onConfigurationChanged: " + config); - Display display = mWindowContext.getDisplay(); if (config.densityDpi != mInfo.densityDpi || config.fontScale != mInfo.fontScale - || display.getRotation() != mInfo.rotation || !mInfo.mScreenSizeDp.equals( - new PortraitSize(config.screenHeightDp, config.screenWidthDp))) { - handleInfoChange(display); + new PortraitSize(config.screenHeightDp, config.screenWidthDp)) + || mWindowContext.getDisplay().getRotation() != mInfo.rotation) { + handleInfoChange(); } } @@ -318,17 +295,13 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable { return mInfo; } - private Context getDisplayInfoContext(Display display) { - return Utilities.ATLEAST_S ? mWindowContext : mContext.createDisplayContext(display); - } - @AnyThread @VisibleForTesting - public void handleInfoChange(Display display) { + public void handleInfoChange() { WindowManagerProxy wmProxy = WindowManagerProxy.INSTANCE.get(mContext); Info oldInfo = mInfo; - Context displayInfoContext = getDisplayInfoContext(display); + Context displayInfoContext = mWindowContext; Info newInfo = new Info(displayInfoContext, wmProxy, oldInfo.mPerDisplayBounds); if (newInfo.densityDpi != oldInfo.densityDpi || newInfo.fontScale != oldInfo.fontScale diff --git a/src/com/android/launcher3/util/EdgeEffectCompat.java b/src/com/android/launcher3/util/EdgeEffectCompat.java index ca3725923e..a949f50ca1 100644 --- a/src/com/android/launcher3/util/EdgeEffectCompat.java +++ b/src/com/android/launcher3/util/EdgeEffectCompat.java @@ -19,8 +19,6 @@ import android.content.Context; import android.view.MotionEvent; import android.widget.EdgeEffect; -import com.android.launcher3.Utilities; - /** * Extension of {@link EdgeEffect} to allow backwards compatibility */ @@ -30,21 +28,6 @@ public class EdgeEffectCompat extends EdgeEffect { super(context); } - @Override - public float getDistance() { - return Utilities.ATLEAST_S ? super.getDistance() : 0; - } - - @Override - public float onPullDistance(float deltaDistance, float displacement) { - if (Utilities.ATLEAST_S) { - return super.onPullDistance(deltaDistance, displacement); - } else { - onPull(deltaDistance, displacement); - return deltaDistance; - } - } - public float onPullDistance(float deltaDistance, float displacement, MotionEvent ev) { return onPullDistance(deltaDistance, displacement); } diff --git a/src/com/android/launcher3/util/OverlayEdgeEffect.java b/src/com/android/launcher3/util/OverlayEdgeEffect.java index d09d801d66..0623af7e43 100644 --- a/src/com/android/launcher3/util/OverlayEdgeEffect.java +++ b/src/com/android/launcher3/util/OverlayEdgeEffect.java @@ -46,6 +46,7 @@ public class OverlayEdgeEffect extends EdgeEffectCompat { return mDistance; } + @Override public float onPullDistance(float deltaDistance, float displacement) { // Fallback implementation, will never actually get called if (BuildConfig.IS_DEBUG_DEVICE) { diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java index 469e363f8b..b1913c0164 100644 --- a/src/com/android/launcher3/util/PackageManagerHelper.java +++ b/src/com/android/launcher3/util/PackageManagerHelper.java @@ -303,10 +303,7 @@ public class PackageManagerHelper implements SafeCloseable{ /** Returns the incremental download progress for the given shortcut's app. */ public static int getLoadingProgress(LauncherActivityInfo info) { - if (Utilities.ATLEAST_S) { - return (int) (100 * info.getLoadingProgress()); - } - return 100; + return (int) (100 * info.getLoadingProgress()); } /** Returns true in case app is installed on the device or in archived state. */ diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java index 60951ba05a..104040afff 100644 --- a/src/com/android/launcher3/util/Themes.java +++ b/src/com/android/launcher3/util/Themes.java @@ -52,10 +52,8 @@ public class Themes { } public static int getActivityThemeRes(Context context, int wallpaperColorHints) { - boolean supportsDarkText = Utilities.ATLEAST_S - && (wallpaperColorHints & HINT_SUPPORTS_DARK_TEXT) != 0; - boolean isMainColorDark = Utilities.ATLEAST_S - && (wallpaperColorHints & HINT_SUPPORTS_DARK_THEME) != 0; + boolean supportsDarkText = (wallpaperColorHints & HINT_SUPPORTS_DARK_TEXT) != 0; + boolean isMainColorDark = (wallpaperColorHints & HINT_SUPPORTS_DARK_THEME) != 0; if (Utilities.isDarkTheme(context)) { return supportsDarkText ? R.style.AppTheme_Dark_DarkText diff --git a/src/com/android/launcher3/util/VibratorWrapper.java b/src/com/android/launcher3/util/VibratorWrapper.java index a4b8eb0f86..adb8f9d053 100644 --- a/src/com/android/launcher3/util/VibratorWrapper.java +++ b/src/com/android/launcher3/util/VibratorWrapper.java @@ -31,8 +31,6 @@ import android.provider.Settings; import androidx.annotation.VisibleForTesting; -import com.android.launcher3.Utilities; - /** * Wrapper around {@link Vibrator} to easily perform haptic feedback where necessary. */ @@ -129,7 +127,7 @@ public class VibratorWrapper implements SafeCloseable { /** Indicates that Taskbar has been invoked. */ public void vibrateForTaskbarUnstash() { - if (Utilities.ATLEAST_S && mVibrator.areAllPrimitivesSupported(PRIMITIVE_LOW_TICK)) { + if (mVibrator.areAllPrimitivesSupported(PRIMITIVE_LOW_TICK)) { VibrationEffect primitiveLowTickEffect = VibrationEffect .startComposition() .addPrimitive(PRIMITIVE_LOW_TICK, LOW_TICK_SCALE) diff --git a/src/com/android/launcher3/util/WallpaperColorHints.kt b/src/com/android/launcher3/util/WallpaperColorHints.kt index 1361c1ed21..11d4c25689 100644 --- a/src/com/android/launcher3/util/WallpaperColorHints.kt +++ b/src/com/android/launcher3/util/WallpaperColorHints.kt @@ -23,7 +23,6 @@ import android.app.WallpaperManager.OnColorsChangedListener import android.content.Context import androidx.annotation.MainThread import androidx.annotation.VisibleForTesting -import com.android.launcher3.Utilities import com.android.launcher3.util.Executors.MAIN_EXECUTOR import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR @@ -34,36 +33,34 @@ import com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR class WallpaperColorHints(private val context: Context) : SafeCloseable { var hints: Int = 0 private set + private val wallpaperManager get() = context.getSystemService(WallpaperManager::class.java)!! + private val onColorHintsChangedListeners = mutableListOf() private val onClose: SafeCloseable init { - if (Utilities.ATLEAST_S) { - hints = wallpaperManager.getWallpaperColors(FLAG_SYSTEM)?.colorHints ?: 0 - val onColorsChangedListener = OnColorsChangedListener { colors, which -> - onColorsChanged(colors, which) - } + hints = wallpaperManager.getWallpaperColors(FLAG_SYSTEM)?.colorHints ?: 0 + val onColorsChangedListener = OnColorsChangedListener { colors, which -> + onColorsChanged(colors, which) + } + UI_HELPER_EXECUTOR.execute { + wallpaperManager.addOnColorsChangedListener( + onColorsChangedListener, + MAIN_EXECUTOR.handler, + ) + } + onClose = SafeCloseable { UI_HELPER_EXECUTOR.execute { - wallpaperManager.addOnColorsChangedListener( - onColorsChangedListener, - MAIN_EXECUTOR.handler - ) + wallpaperManager.removeOnColorsChangedListener(onColorsChangedListener) } - onClose = SafeCloseable { - UI_HELPER_EXECUTOR.execute { - wallpaperManager.removeOnColorsChangedListener(onColorsChangedListener) - } - } - } else { - onClose = SafeCloseable {} } } @MainThread private fun onColorsChanged(colors: WallpaperColors?, which: Int) { - if ((which and FLAG_SYSTEM) != 0 && Utilities.ATLEAST_S) { + if ((which and FLAG_SYSTEM) != 0) { val newHints = colors?.colorHints ?: 0 if (newHints != hints) { hints = newHints @@ -86,6 +83,7 @@ class WallpaperColorHints(private val context: Context) : SafeCloseable { @VisibleForTesting @JvmField val INSTANCE = MainThreadInitializedObject { WallpaperColorHints(it) } + @JvmStatic fun get(context: Context): WallpaperColorHints = INSTANCE.get(context) } } diff --git a/src/com/android/launcher3/util/window/WindowManagerProxy.java b/src/com/android/launcher3/util/window/WindowManagerProxy.java index 22ecf684e9..84b4a36399 100644 --- a/src/com/android/launcher3/util/window/WindowManagerProxy.java +++ b/src/com/android/launcher3/util/window/WindowManagerProxy.java @@ -32,7 +32,6 @@ import static com.android.launcher3.util.RotationUtils.deltaRotation; import static com.android.launcher3.util.RotationUtils.rotateRect; import static com.android.launcher3.util.RotationUtils.rotateSize; -import android.annotation.TargetApi; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; @@ -40,7 +39,6 @@ import android.graphics.Insets; import android.graphics.Point; 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; @@ -54,7 +52,6 @@ import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.testing.shared.ResourceUtils; import com.android.launcher3.util.MainThreadInitializedObject; import com.android.launcher3.util.NavigationMode; @@ -230,7 +227,7 @@ public class WindowManagerProxy implements ResourceBasedOverride, SafeCloseable int screenWidthPx, @NonNull WindowInsets windowInsets, @NonNull WindowInsets.Builder insetsBuilder) { - if (!isLargeScreen || !Utilities.ATLEAST_S) { + if (!isLargeScreen) { return; } @@ -405,25 +402,16 @@ public class WindowManagerProxy implements ResourceBasedOverride, SafeCloseable /** * Returns a CachedDisplayInfo initialized for the current display */ - @TargetApi(Build.VERSION_CODES.S) public CachedDisplayInfo getDisplayInfo(Context displayInfoContext) { int rotation = getRotation(displayInfoContext); - if (Utilities.ATLEAST_S) { - WindowMetrics windowMetrics = displayInfoContext.getSystemService(WindowManager.class) - .getMaximumWindowMetrics(); - return getDisplayInfo(windowMetrics, rotation); - } else { - Point size = new Point(); - Display display = getDisplay(displayInfoContext); - display.getRealSize(size); - return new CachedDisplayInfo(size, rotation); - } + WindowMetrics windowMetrics = displayInfoContext.getSystemService(WindowManager.class) + .getMaximumWindowMetrics(); + return getDisplayInfo(windowMetrics, rotation); } /** * Returns a CachedDisplayInfo initialized for the current display */ - @TargetApi(Build.VERSION_CODES.S) protected CachedDisplayInfo getDisplayInfo(WindowMetrics windowMetrics, int rotation) { Point size = new Point(windowMetrics.getBounds().right, windowMetrics.getBounds().bottom); return new CachedDisplayInfo(size, rotation, @@ -492,8 +480,7 @@ public class WindowManagerProxy implements ResourceBasedOverride, SafeCloseable } } } - return Utilities.ATLEAST_S ? NavigationMode.NO_BUTTON : - NavigationMode.THREE_BUTTONS; + return NavigationMode.NO_BUTTON; } @Override diff --git a/src/com/android/launcher3/views/SpringRelativeLayout.java b/src/com/android/launcher3/views/SpringRelativeLayout.java index 923eb19d3b..a13152ec76 100644 --- a/src/com/android/launcher3/views/SpringRelativeLayout.java +++ b/src/com/android/launcher3/views/SpringRelativeLayout.java @@ -25,8 +25,6 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView.EdgeEffectFactory; -import com.android.launcher3.Utilities; - /** * View group to allow rendering overscroll effect in a child at the parent level */ @@ -46,10 +44,8 @@ public class SpringRelativeLayout extends RelativeLayout { public SpringRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mEdgeGlowTop = Utilities.ATLEAST_S - ? new EdgeEffect(context, attrs) : new EdgeEffect(context); - mEdgeGlowBottom = Utilities.ATLEAST_S - ? new EdgeEffect(context, attrs) : new EdgeEffect(context); + mEdgeGlowTop = new EdgeEffect(context, attrs); + mEdgeGlowBottom = new EdgeEffect(context, attrs); setWillNotDraw(false); } diff --git a/src/com/android/launcher3/widget/BaseLauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/BaseLauncherAppWidgetHostView.java index 856f4b36b6..12a14c2d0e 100644 --- a/src/com/android/launcher3/widget/BaseLauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/BaseLauncherAppWidgetHostView.java @@ -104,7 +104,7 @@ public abstract class BaseLauncherAppWidgetHostView extends NavigableAppWidgetHo @UiThread private void enforceRoundedCorners() { - if (mEnforcedCornerRadius <= 0 || !RoundedCornerEnforcement.isRoundedCornerEnabled()) { + if (mEnforcedCornerRadius <= 0) { resetRoundedCorners(); return; } diff --git a/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java b/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java index 2817299d4a..ab42839e20 100644 --- a/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java +++ b/src/com/android/launcher3/widget/DatabaseWidgetPreviewLoader.java @@ -183,19 +183,14 @@ public class DatabaseWidgetPreviewLoader { // Draw horizontal and vertical lines to represent individual columns. final Paint p = new Paint(Paint.ANTI_ALIAS_FLAG); + boxRect = new RectF(/* left= */ 0, /* top= */ 0, /* right= */ + previewWidthF, /* bottom= */ previewHeightF); - if (Utilities.ATLEAST_S) { - boxRect = new RectF(/* left= */ 0, /* top= */ 0, /* right= */ - previewWidthF, /* bottom= */ previewHeightF); - - p.setStyle(Paint.Style.FILL); - p.setColor(Color.WHITE); - float roundedCorner = mContext.getResources().getDimension( - android.R.dimen.system_app_widget_background_radius); - c.drawRoundRect(boxRect, roundedCorner, roundedCorner, p); - } else { - boxRect = drawBoxWithShadow(c, previewWidthF, previewHeightF); - } + p.setStyle(Paint.Style.FILL); + p.setColor(Color.WHITE); + float roundedCorner = mContext.getResources().getDimension( + android.R.dimen.system_app_widget_background_radius); + c.drawRoundRect(boxRect, roundedCorner, roundedCorner, p); p.setStyle(Paint.Style.STROKE); p.setStrokeWidth(mContext.getResources() diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java index 3e4fd8caa8..e77ba249bd 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java @@ -1,7 +1,5 @@ package com.android.launcher3.widget; -import static com.android.launcher3.Utilities.ATLEAST_S; - import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.Context; @@ -116,15 +114,13 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo getSpanY(widgetPadding, minResizeHeight, dp.cellLayoutBorderSpacePx.y, cellSize.y)); - if (ATLEAST_S) { - if (maxResizeWidth > 0) { - maxSpanX = Math.min(maxSpanX, getSpanX(widgetPadding, maxResizeWidth, - dp.cellLayoutBorderSpacePx.x, cellSize.x)); - } - if (maxResizeHeight > 0) { - maxSpanY = Math.min(maxSpanY, getSpanY(widgetPadding, maxResizeHeight, - dp.cellLayoutBorderSpacePx.y, cellSize.y)); - } + if (maxResizeWidth > 0) { + maxSpanX = Math.min(maxSpanX, getSpanX(widgetPadding, maxResizeWidth, + dp.cellLayoutBorderSpacePx.x, cellSize.x)); + } + if (maxResizeHeight > 0) { + maxSpanY = Math.min(maxSpanY, getSpanY(widgetPadding, maxResizeHeight, + dp.cellLayoutBorderSpacePx.y, cellSize.y)); } spanX = Math.max(spanX, @@ -135,18 +131,16 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo cellSize.y)); } - if (ATLEAST_S) { - // Ensures maxSpan >= minSpan - maxSpanX = Math.max(maxSpanX, minSpanX); - maxSpanY = Math.max(maxSpanY, minSpanY); + // Ensures maxSpan >= minSpan + maxSpanX = Math.max(maxSpanX, minSpanX); + maxSpanY = Math.max(maxSpanY, minSpanY); - // Use targetCellWidth/Height if it is within the min/max ranges. - // Otherwise, use the span of minWidth/Height. - if (targetCellWidth >= minSpanX && targetCellWidth <= maxSpanX - && targetCellHeight >= minSpanY && targetCellHeight <= maxSpanY) { - spanX = targetCellWidth; - spanY = targetCellHeight; - } + // Use targetCellWidth/Height if it is within the min/max ranges. + // Otherwise, use the span of minWidth/Height. + if (targetCellWidth >= minSpanX && targetCellWidth <= maxSpanX + && targetCellHeight >= minSpanY && targetCellHeight <= maxSpanY) { + spanX = targetCellWidth; + spanY = targetCellHeight; } // If minSpanX/Y > spanX/Y, ignore the minSpanX/Y to match the behavior described in @@ -213,8 +207,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo } public boolean isConfigurationOptional() { - return ATLEAST_S - && isReconfigurable() + return isReconfigurable() && (getWidgetFeatures() & WIDGET_FEATURE_CONFIGURATION_OPTIONAL) != 0; } diff --git a/src/com/android/launcher3/widget/PendingItemDragHelper.java b/src/com/android/launcher3/widget/PendingItemDragHelper.java index 8857774922..130d533ca4 100644 --- a/src/com/android/launcher3/widget/PendingItemDragHelper.java +++ b/src/com/android/launcher3/widget/PendingItemDragHelper.java @@ -136,9 +136,7 @@ public class PendingItemDragHelper extends DragPreviewProvider { Drawable p = new FastBitmapDrawable(new DatabaseWidgetPreviewLoader(launcher) .generateWidgetPreview( createWidgetInfo.info, maxWidth, previewSizeBeforeScale)); - if (RoundedCornerEnforcement.isRoundedCornerEnabled()) { - p = new RoundDrawableWrapper(p, mEnforcedRoundedCornersForWidget); - } + p = new RoundDrawableWrapper(p, mEnforcedRoundedCornersForWidget); preview = p; } diff --git a/src/com/android/launcher3/widget/RoundedCornerEnforcement.java b/src/com/android/launcher3/widget/RoundedCornerEnforcement.java index a2fac46871..cadaf89ef0 100644 --- a/src/com/android/launcher3/widget/RoundedCornerEnforcement.java +++ b/src/com/android/launcher3/widget/RoundedCornerEnforcement.java @@ -28,7 +28,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import java.util.ArrayList; import java.util.List; @@ -70,11 +69,6 @@ public class RoundedCornerEnforcement { return background.getId() == android.R.id.background && background.getClipToOutline(); } - /** Check if the app widget is in the deny list. */ - public static boolean isRoundedCornerEnabled() { - return Utilities.ATLEAST_S; - } - /** * Computes the rounded rectangle needed for this app widget. * @@ -101,9 +95,6 @@ public class RoundedCornerEnforcement { * in the given context. */ public static float computeEnforcedRadius(@NonNull Context context) { - if (!Utilities.ATLEAST_S) { - return 0; - } Resources res = context.getResources(); float systemRadius = res.getDimension(android.R.dimen.system_app_widget_background_radius); float defaultRadius = res.getDimension(R.dimen.enforced_rounded_corner_max_radius); diff --git a/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt b/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt index d4e4bd253f..a749bb8af9 100644 --- a/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt +++ b/tests/multivalentTests/src/com/android/launcher3/util/DisplayControllerTest.kt @@ -81,7 +81,7 @@ class DisplayControllerTest { WindowBounds(Rect(0, 0, width, height), Rect(0, inset, 0, 0), Surface.ROTATION_0), WindowBounds(Rect(0, 0, height, width), Rect(0, inset, 0, 0), Surface.ROTATION_90), WindowBounds(Rect(0, 0, width, height), Rect(0, inset, 0, 0), Surface.ROTATION_180), - WindowBounds(Rect(0, 0, height, width), Rect(0, inset, 0, 0), Surface.ROTATION_270) + WindowBounds(Rect(0, 0, height, width), Rect(0, inset, 0, 0), Surface.ROTATION_270), ) private val configuration = Configuration(appContext.resources.configuration).apply { @@ -170,7 +170,7 @@ class DisplayControllerTest { @UiThreadTest fun testTaskbarPinning() { whenever(launcherPrefs.get(TASKBAR_PINNING)).thenReturn(true) - displayController.handleInfoChange(display) + displayController.handleInfoChange() verify(displayInfoChangeListener) .onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING)) } @@ -179,7 +179,7 @@ class DisplayControllerTest { @UiThreadTest fun testTaskbarPinningChangeInDesktopMode() { whenever(launcherPrefs.get(TASKBAR_PINNING_IN_DESKTOP_MODE)).thenReturn(false) - displayController.handleInfoChange(display) + displayController.handleInfoChange() verify(displayInfoChangeListener) .onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING)) } @@ -194,7 +194,7 @@ class DisplayControllerTest { DisplayController.enableTaskbarModePreferenceForTests(true) assertTrue(displayController.getInfo().isTransientTaskbar()) - displayController.handleInfoChange(display) + displayController.handleInfoChange() verify(displayInfoChangeListener) .onDisplayInfoChanged(any(), any(), eq(CHANGE_TASKBAR_PINNING)) assertFalse(displayController.getInfo().isTransientTaskbar())