From b922dccbf557d2ad5bab2e1f542676bed7204ea1 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 24 Jan 2024 14:38:48 -0800 Subject: [PATCH] Cleanup API checks for P, Q, and R. Test: Build with gradle Flag: NA Change-Id: I3ef17090741d14bebd76cf09cf3dc5ac4f11e686 --- .../launcher3/LauncherAnimationRunner.java | 3 -- .../launcher3/LauncherInitListener.java | 4 -- .../appprediction/PredictionRowView.java | 3 -- .../launcher3/model/AppEventProducer.java | 3 -- .../launcher3/model/WellbeingModel.java | 3 -- .../TaskViewTouchController.java | 2 +- .../android/quickstep/AbsSwipeUpHandler.java | 3 -- .../quickstep/BaseActivityInterface.java | 3 -- .../quickstep/FallbackSwipeHandler.java | 4 -- .../com/android/quickstep/GestureState.java | 3 -- .../quickstep/OverviewCommandHelper.java | 3 -- .../QuickstepProcessInitializer.java | 3 -- .../android/quickstep/RecentTasksList.java | 3 -- .../com/android/quickstep/TaskViewUtils.java | 3 -- .../quickstep/TouchInteractionService.java | 3 -- .../fallback/FallbackRecentsView.java | 3 -- .../OtherActivityInputConsumer.java | 3 -- .../HomeGestureTutorialController.java | 3 -- .../OverviewGestureTutorialController.java | 3 -- .../SwipeUpGestureTutorialController.java | 3 -- .../logging/StatsLogCompatManager.java | 5 +-- .../util/SurfaceTransactionApplier.java | 3 -- .../views/DigitalWellBeingToast.java | 3 -- .../android/quickstep/views/RecentsView.java | 3 -- .../com/android/quickstep/views/TaskView.java | 6 +-- .../launcher3/AppWidgetResizeFrame.java | 12 +++--- .../launcher3/BaseDraggingActivity.java | 13 +----- .../android/launcher3/GestureNavContract.java | 6 --- src/com/android/launcher3/Launcher.java | 4 +- .../android/launcher3/LauncherRootView.java | 6 +-- src/com/android/launcher3/Utilities.java | 9 ---- .../allapps/LauncherAllAppsContainerView.java | 7 +--- .../launcher3/allapps/UserProfileManager.java | 8 +--- .../launcher3/allapps/WorkModeSwitch.java | 8 ++-- .../launcher3/allapps/WorkPausedCard.java | 9 ++-- .../launcher3/allapps/WorkProfileManager.java | 3 +- .../launcher3/anim/PendingAnimation.java | 3 +- .../compat/AccessibilityManagerCompat.java | 5 +-- .../launcher3/dragndrop/DragController.java | 8 +--- .../dragndrop/FolderAdaptiveIcon.java | 5 --- src/com/android/launcher3/folder/Folder.java | 30 ++++++-------- .../graphics/GridCustomizationsProvider.java | 6 +-- .../graphics/LauncherPreviewRenderer.java | 3 -- .../graphics/PreviewSurfaceRenderer.java | 6 +-- .../launcher3/model/ModelDbController.java | 2 +- .../model/data/WorkspaceItemInfo.java | 3 +- .../launcher3/pm/InstallSessionHelper.java | 11 ++--- .../popup/PopupContainerWithArrow.java | 6 +-- .../launcher3/popup/RemoteActionShortcut.java | 3 -- .../launcher3/provider/RestoreDbTask.java | 3 -- .../launcher3/settings/SettingsActivity.java | 3 +- .../testing/TestInformationHandler.java | 5 +-- .../launcher3/touch/ItemClickHandler.java | 14 +++---- src/com/android/launcher3/util/IOUtils.java | 13 +----- .../android/launcher3/util/TraceHelper.java | 10 +---- .../launcher3/util/VibratorWrapper.java | 8 +--- .../util/window/WindowManagerProxy.java | 34 +++------------ .../launcher3/views/ActivityContext.java | 41 +++++++++---------- .../launcher3/views/BaseDragLayer.java | 32 +++++++-------- .../android/launcher3/views/ClipIconView.java | 3 -- .../launcher3/views/FloatingIconView.java | 3 -- .../launcher3/views/FloatingSurfaceView.java | 3 -- .../views/RecyclerViewFastScroller.java | 25 ++++------- .../widget/AddItemWidgetsBottomSheet.java | 17 ++------ .../launcher3/widget/BaseWidgetSheet.java | 4 +- .../widget/LauncherAppWidgetHostView.java | 17 +++----- .../widget/LauncherAppWidgetProviderInfo.java | 7 +--- 67 files changed, 117 insertions(+), 382 deletions(-) diff --git a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java index 5d4e19dbcc..842f0ef96e 100644 --- a/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java +++ b/quickstep/src/com/android/launcher3/LauncherAnimationRunner.java @@ -24,9 +24,7 @@ import static com.android.systemui.shared.recents.utilities.Utilities.postAtFron import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; -import android.annotation.TargetApi; import android.content.Context; -import android.os.Build; import android.os.Handler; import android.os.RemoteException; import android.view.IRemoteAnimationFinishedCallback; @@ -57,7 +55,6 @@ import java.lang.ref.WeakReference; * the runner implementation. When this animation manager is destroyed, we remove the Launcher * reference to the runner, leaving only the weak ref from the runner. */ -@TargetApi(Build.VERSION_CODES.P) public class LauncherAnimationRunner extends RemoteAnimationRunnerCompat { private static final RemoteAnimationFactory DEFAULT_FACTORY = diff --git a/quickstep/src/com/android/launcher3/LauncherInitListener.java b/quickstep/src/com/android/launcher3/LauncherInitListener.java index f64b5cfafe..523923df6a 100644 --- a/quickstep/src/com/android/launcher3/LauncherInitListener.java +++ b/quickstep/src/com/android/launcher3/LauncherInitListener.java @@ -15,14 +15,10 @@ */ package com.android.launcher3; -import android.annotation.TargetApi; -import android.os.Build; - import com.android.quickstep.util.ActivityInitListener; import java.util.function.BiPredicate; -@TargetApi(Build.VERSION_CODES.P) public class LauncherInitListener extends ActivityInitListener { /** diff --git a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java index e680ea90b6..caf8a0bf1e 100644 --- a/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java +++ b/quickstep/src/com/android/launcher3/appprediction/PredictionRowView.java @@ -16,10 +16,8 @@ package com.android.launcher3.appprediction; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; -import android.os.Build; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -50,7 +48,6 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -@TargetApi(Build.VERSION_CODES.P) public class PredictionRowView extends LinearLayout implements OnDeviceProfileChangeListener, FloatingHeaderRow { diff --git a/quickstep/src/com/android/launcher3/model/AppEventProducer.java b/quickstep/src/com/android/launcher3/model/AppEventProducer.java index e17fc8879c..a931f36f3f 100644 --- a/quickstep/src/com/android/launcher3/model/AppEventProducer.java +++ b/quickstep/src/com/android/launcher3/model/AppEventProducer.java @@ -45,14 +45,12 @@ import static com.android.launcher3.model.PredictionHelper.isTrackedForHotseatPr import static com.android.launcher3.model.PredictionHelper.isTrackedForWidgetPrediction; import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; -import android.annotation.TargetApi; import android.app.prediction.AppTarget; import android.app.prediction.AppTargetEvent; import android.app.prediction.AppTargetId; import android.content.ComponentName; import android.content.Context; import android.content.pm.ShortcutInfo; -import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.Process; @@ -84,7 +82,6 @@ import java.util.function.ObjIntConsumer; /** * Utility class to track stats log and emit corresponding app events */ -@TargetApi(Build.VERSION_CODES.R) public class AppEventProducer implements StatsLogConsumer { private static final int MSG_LAUNCH = 0; diff --git a/quickstep/src/com/android/launcher3/model/WellbeingModel.java b/quickstep/src/com/android/launcher3/model/WellbeingModel.java index 003c2fc292..3d04cb6828 100644 --- a/quickstep/src/com/android/launcher3/model/WellbeingModel.java +++ b/quickstep/src/com/android/launcher3/model/WellbeingModel.java @@ -20,7 +20,6 @@ import static android.content.ContentResolver.SCHEME_CONTENT; import static com.android.launcher3.util.SimpleBroadcastReceiver.getPackageFilter; -import android.annotation.TargetApi; import android.app.RemoteAction; import android.content.ContentProviderClient; import android.content.ContentResolver; @@ -30,7 +29,6 @@ import android.content.IntentFilter; import android.content.pm.LauncherApps; import android.database.ContentObserver; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.DeadObjectException; import android.os.Handler; @@ -63,7 +61,6 @@ import java.util.Map; /** * Data model for digital wellbeing status of apps. */ -@TargetApi(Build.VERSION_CODES.Q) public final class WellbeingModel extends BgObjectWithLooper { private static final String TAG = "WellbeingModel"; private static final int[] RETRY_TIMES_MS = {5000, 15000, 30000}; diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java index 19bfe069c8..ec84550898 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/TaskViewTouchController.java @@ -59,7 +59,7 @@ public abstract class TaskViewTouchController private static final long MAX_TASK_DISMISS_ANIMATION_DURATION = 600; public static final int TASK_DISMISS_VIBRATION_PRIMITIVE = - Utilities.ATLEAST_R ? VibrationEffect.Composition.PRIMITIVE_TICK : -1; + VibrationEffect.Composition.PRIMITIVE_TICK; public static final float TASK_DISMISS_VIBRATION_PRIMITIVE_SCALE = 1f; public static final VibrationEffect TASK_DISMISS_VIBRATION_FALLBACK = VibrationConstants.EFFECT_TEXTURE_TICK; diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index cbf6ad67f1..60d0e2ba45 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -64,7 +64,6 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ValueAnimator; -import android.annotation.TargetApi; import android.app.ActivityManager; import android.app.TaskInfo; import android.app.WindowConfiguration; @@ -75,7 +74,6 @@ import android.graphics.Matrix; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.os.IBinder; import android.os.SystemClock; import android.util.Log; @@ -161,7 +159,6 @@ import java.util.function.Consumer; /** * Handles the navigation gestures when Launcher is the default home activity. */ -@TargetApi(Build.VERSION_CODES.R) public abstract class AbsSwipeUpHandler, Q extends RecentsView, S extends BaseState> extends SwipeUpAnimationLogic implements OnApplyWindowInsetsListener, diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index 2dd6a29093..377b866d09 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -35,13 +35,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; -import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; import android.graphics.Color; import android.graphics.PointF; import android.graphics.Rect; -import android.os.Build; import android.view.Gravity; import android.view.MotionEvent; import android.view.RemoteAnimationTarget; @@ -77,7 +75,6 @@ import java.util.function.Predicate; /** * Utility class which abstracts out the logical differences between Launcher and RecentsActivity. */ -@TargetApi(Build.VERSION_CODES.P) public abstract class BaseActivityInterface, ACTIVITY_TYPE extends StatefulActivity> { diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java index 57b9a396da..e77a4504e5 100644 --- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java @@ -29,7 +29,6 @@ import static com.android.launcher3.anim.AnimatorListeners.forEndCallback; import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely; import android.animation.ObjectAnimator; -import android.annotation.TargetApi; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityOptions; import android.content.Context; @@ -37,7 +36,6 @@ import android.content.Intent; import android.graphics.Matrix; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -66,7 +64,6 @@ import com.android.launcher3.states.StateAnimationConfig; import com.android.launcher3.util.DisplayController; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.fallback.RecentsState; -import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.quickstep.util.TransformParams; @@ -82,7 +79,6 @@ import java.util.function.Consumer; /** * Handles the navigation gestures when a 3rd party launcher is the default home activity. */ -@TargetApi(Build.VERSION_CODES.R) public class FallbackSwipeHandler extends AbsSwipeUpHandler { diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 575be5f8df..d02909c527 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -29,9 +29,7 @@ import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_HOME; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_NEW_TASK; -import android.annotation.TargetApi; import android.content.Intent; -import android.os.Build; import android.view.MotionEvent; import android.view.RemoteAnimationTarget; @@ -58,7 +56,6 @@ import java.util.function.Predicate; * Manages the state for an active system gesture, listens for events from the system and Launcher, * and fires events when the states change. */ -@TargetApi(Build.VERSION_CODES.R) public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationListener { final Predicate mLastStartedTaskIdPredicate = new Predicate<>() { diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index b2429ad3ec..315316d56e 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -18,10 +18,8 @@ package com.android.quickstep; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; -import android.annotation.TargetApi; import android.content.Intent; import android.graphics.PointF; -import android.os.Build; import android.os.SystemClock; import android.os.Trace; import android.view.View; @@ -51,7 +49,6 @@ import java.util.HashMap; /** * Helper class to handle various atomic commands for switching between Overview. */ -@TargetApi(Build.VERSION_CODES.P) public class OverviewCommandHelper { public static final int TYPE_SHOW = 1; diff --git a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java index d1939efa78..3c902e6f91 100644 --- a/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java +++ b/quickstep/src/com/android/quickstep/QuickstepProcessInitializer.java @@ -15,10 +15,8 @@ */ package com.android.quickstep; -import android.annotation.TargetApi; import android.content.Context; import android.content.pm.PackageManager; -import android.os.Build; import android.os.Looper; import android.os.Trace; import android.os.UserManager; @@ -30,7 +28,6 @@ import com.android.launcher3.MainProcessInitializer; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; @SuppressWarnings("unused") -@TargetApi(Build.VERSION_CODES.R) public class QuickstepProcessInitializer extends MainProcessInitializer { private static final String TAG = "QuickstepProcessInitializer"; diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 7c263b87cd..f3704e0950 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -23,12 +23,10 @@ import static com.android.quickstep.util.SplitScreenUtils.convertShellSplitBound import static com.android.quickstep.views.DesktopTaskView.isDesktopModeSupported; import static com.android.wm.shell.util.GroupedRecentTaskInfo.TYPE_FREEFORM; -import android.annotation.TargetApi; import android.app.ActivityManager; import android.app.KeyguardManager; import android.app.TaskInfo; import android.content.ComponentName; -import android.os.Build; import android.os.Process; import android.os.RemoteException; import android.util.SparseBooleanArray; @@ -53,7 +51,6 @@ import java.util.stream.Collectors; /** * Manages the recent task list from the system, caching it as necessary. */ -@TargetApi(Build.VERSION_CODES.R) public class RecentTasksList { private static final TaskLoadResult INVALID_RESULT = new TaskLoadResult(-1, false, 0); diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 4e84f4a6c4..3f5c1642c6 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -43,14 +43,12 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ValueAnimator; -import android.annotation.TargetApi; import android.content.ComponentName; import android.content.Context; import android.graphics.Matrix; import android.graphics.Matrix.ScaleToFit; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.view.RemoteAnimationTarget; import android.view.SurfaceControl; import android.view.View; @@ -94,7 +92,6 @@ import java.util.function.Consumer; /** * Utility class for helpful methods related to {@link TaskView} objects and their tasks. */ -@TargetApi(Build.VERSION_CODES.R) public final class TaskViewUtils { private TaskViewUtils() {} diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index ce6ddd8218..55a7985598 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -56,7 +56,6 @@ import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_SH import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_SPLIT_SCREEN; import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_STARTING_WINDOW; -import android.annotation.TargetApi; import android.app.PendingIntent; import android.app.RemoteAction; import android.app.Service; @@ -66,7 +65,6 @@ import android.content.Intent; import android.content.res.Configuration; import android.graphics.Region; import android.graphics.drawable.Icon; -import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.os.Looper; @@ -152,7 +150,6 @@ import java.util.function.Function; /** * Service connected by system-UI for handling touch interaction. */ -@TargetApi(Build.VERSION_CODES.R) public class TouchInteractionService extends Service { private static final String SUBSTRING_PREFIX = "; "; diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index 1008da36fa..0ee50a46b2 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -24,9 +24,7 @@ import static com.android.quickstep.fallback.RecentsState.MODAL_TASK; import static com.android.quickstep.fallback.RecentsState.OVERVIEW_SPLIT_SELECT; import android.animation.AnimatorSet; -import android.annotation.TargetApi; import android.content.Context; -import android.os.Build; import android.util.AttributeSet; import android.view.MotionEvent; @@ -55,7 +53,6 @@ import com.android.systemui.shared.recents.model.Task; import java.util.ArrayList; -@TargetApi(Build.VERSION_CODES.R) public class FallbackRecentsView extends RecentsView implements StateListener { diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index eedd20485b..c8c7dc2597 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -31,12 +31,10 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.VelocityUtils.PX_PER_MS; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; -import android.annotation.TargetApi; import android.content.Context; import android.content.ContextWrapper; import android.content.Intent; import android.graphics.PointF; -import android.os.Build; import android.util.Log; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -71,7 +69,6 @@ import java.util.function.Consumer; /** * Input consumer for handling events originating from an activity other than Launcher */ -@TargetApi(Build.VERSION_CODES.P) public class OtherActivityInputConsumer extends ContextWrapper implements InputConsumer { public static final String DOWN_EVT = "OtherActivityInputConsumer.DOWN"; diff --git a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java index df552cffc6..1129e025c5 100644 --- a/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/HomeGestureTutorialController.java @@ -17,9 +17,7 @@ package com.android.quickstep.interaction; import static com.android.launcher3.config.FeatureFlags.ENABLE_NEW_GESTURE_NAV_TUTORIAL; -import android.annotation.TargetApi; import android.graphics.PointF; -import android.os.Build; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -30,7 +28,6 @@ import com.android.quickstep.util.LottieAnimationColorUtils; import java.util.Map; /** A {@link TutorialController} for the Home tutorial. */ -@TargetApi(Build.VERSION_CODES.R) final class HomeGestureTutorialController extends SwipeUpGestureTutorialController { HomeGestureTutorialController(HomeGestureTutorialFragment fragment, TutorialType tutorialType) { diff --git a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java index 65f3a01149..a04dd4456b 100644 --- a/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/OverviewGestureTutorialController.java @@ -21,9 +21,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_NEW_GESTURE_NAV_T import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; -import android.annotation.TargetApi; import android.graphics.PointF; -import android.os.Build; import android.os.Handler; import androidx.annotation.ColorInt; @@ -42,7 +40,6 @@ import java.util.ArrayList; import java.util.Map; /** A {@link TutorialController} for the Overview tutorial. */ -@TargetApi(Build.VERSION_CODES.R) final class OverviewGestureTutorialController extends SwipeUpGestureTutorialController { private static final float LAUNCHER_COLOR_BLENDING_RATIO = 0.4f; diff --git a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java index 87defc5252..d5cc447670 100644 --- a/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java +++ b/quickstep/src/com/android/quickstep/interaction/SwipeUpGestureTutorialController.java @@ -29,13 +29,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ValueAnimator; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Outline; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.view.View; import android.view.ViewOutlineProvider; @@ -63,7 +61,6 @@ import com.android.quickstep.util.SurfaceTransaction; import com.android.quickstep.util.SurfaceTransaction.MockProperties; import com.android.quickstep.util.TransformParams; -@TargetApi(Build.VERSION_CODES.R) abstract class SwipeUpGestureTutorialController extends TutorialController { private static final int FAKE_PREVIOUS_TASK_MARGIN = Utilities.dpToPx(24); diff --git a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java index cf9fc74819..d265918e18 100644 --- a/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java +++ b/quickstep/src/com/android/quickstep/logging/StatsLogCompatManager.java @@ -139,7 +139,7 @@ public class StatsLogCompatManager extends StatsLogManager { if (IS_VERBOSE) { Log.d(TAG, String.format("\nwriteSnapshot(%d):\n%s", instanceId.getId(), info)); } - if (!Utilities.ATLEAST_R || Utilities.isRunningInTestHarness()) { + if (Utilities.isRunningInTestHarness()) { return; } SysUiStatsLog.write(SysUiStatsLog.LAUNCHER_SNAPSHOT, @@ -342,9 +342,6 @@ public class StatsLogCompatManager extends StatsLogManager { @Override public void log(EventEnum event) { - if (!Utilities.ATLEAST_R) { - return; - } if (DEBUG) { String name = (event instanceof Enum) ? ((Enum) event).name() : event.getId() + ""; diff --git a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java index df5765cb24..a26d056da1 100644 --- a/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java +++ b/quickstep/src/com/android/quickstep/util/SurfaceTransactionApplier.java @@ -15,8 +15,6 @@ */ package com.android.quickstep.util; -import android.annotation.TargetApi; -import android.os.Build; import android.os.Handler; import android.os.Message; import android.view.SurfaceControl; @@ -34,7 +32,6 @@ import com.android.quickstep.RemoteAnimationTargets.ReleaseCheck; * android.view.SyncRtSurfaceTransactionApplier * with some Launcher specific utility methods */ -@TargetApi(Build.VERSION_CODES.R) public class SurfaceTransactionApplier extends ReleaseCheck { private static final int MSG_UPDATE_SEQUENCE_NUMBER = 0; diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java index 57b265b2b4..937a7281b6 100644 --- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java +++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.java @@ -21,7 +21,6 @@ import static android.provider.Settings.ACTION_APP_USAGE_SETTINGS; import static com.android.launcher3.Utilities.prefixTextWithIcon; import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; -import android.annotation.TargetApi; import android.app.ActivityOptions; import android.content.ActivityNotFoundException; import android.content.Intent; @@ -33,7 +32,6 @@ import android.icu.text.MeasureFormat; import android.icu.text.MeasureFormat.FormatWidth; import android.icu.util.Measure; import android.icu.util.MeasureUnit; -import android.os.Build; import android.os.UserHandle; import android.util.Log; import android.util.Pair; @@ -61,7 +59,6 @@ import java.lang.annotation.RetentionPolicy; import java.time.Duration; import java.util.Locale; -@TargetApi(Build.VERSION_CODES.Q) public final class DigitalWellBeingToast { private static final float THRESHOLD_LEFT_ICON_ONLY = 0.4f; diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 997624f3d1..6b3484d388 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -81,7 +81,6 @@ import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.app.WindowConfiguration; import android.content.Context; import android.content.Intent; @@ -98,7 +97,6 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Typeface; import android.graphics.drawable.Drawable; -import android.os.Build; import android.os.Bundle; import android.os.SystemClock; import android.os.UserHandle; @@ -231,7 +229,6 @@ import java.util.stream.Collectors; /** * A list of recent tasks. */ -@TargetApi(Build.VERSION_CODES.R) public abstract class RecentsView, STATE_TYPE extends BaseState> extends PagedView implements Insettable, TaskThumbnailCache.HighResLoadingState.HighResLoadingStateChangedCallback, diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index 66a880b1f1..26f6cfdcb5 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -1348,10 +1348,8 @@ public class TaskView extends FrameLayout implements Reusable { setPivotX((right - left) * 0.5f); setPivotY(mSnapshotView.getTop() + mSnapshotView.getHeight() * 0.5f); } - if (Utilities.ATLEAST_Q) { - SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(0, 0, getWidth(), getHeight()); - setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT); - } + SYSTEM_GESTURE_EXCLUSION_RECT.get(0).set(0, 0, getWidth(), getHeight()); + setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT); } /** diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 79b831e117..4a277f0ed5 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -191,14 +191,12 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - if (Utilities.ATLEAST_Q) { - for (int i = 0; i < HANDLE_COUNT; i++) { - View dragHandle = mDragHandles[i]; - mSystemGestureExclusionRects.get(i).set(dragHandle.getLeft(), dragHandle.getTop(), - dragHandle.getRight(), dragHandle.getBottom()); - } - setSystemGestureExclusionRects(mSystemGestureExclusionRects); + for (int i = 0; i < HANDLE_COUNT; i++) { + View dragHandle = mDragHandles[i]; + mSystemGestureExclusionRects.get(i).set(dragHandle.getLeft(), dragHandle.getTop(), + dragHandle.getRight(), dragHandle.getBottom()); } + setSystemGestureExclusionRects(mSystemGestureExclusionRects); } public static void showForWidget(LauncherAppWidgetHostView widget, CellLayout cellLayout) { diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index b6f66152dc..1c2ed4343d 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -20,11 +20,8 @@ import static com.android.launcher3.util.DisplayController.CHANGE_ROTATION; import android.content.Context; import android.content.res.Configuration; -import android.graphics.Point; -import android.graphics.Rect; import android.os.Bundle; import android.view.ActionMode; -import android.view.Display; import android.view.View; import androidx.annotation.MainThread; @@ -165,15 +162,7 @@ public abstract class BaseDraggingActivity extends BaseActivity protected abstract void reapplyUi(); protected WindowBounds getMultiWindowDisplaySize() { - if (Utilities.ATLEAST_R) { - return WindowBounds.fromWindowMetrics(getWindowManager().getCurrentWindowMetrics()); - } - // 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); - return new WindowBounds(new Rect(0, 0, mwSize.x, mwSize.y), new Rect()); + return WindowBounds.fromWindowMetrics(getWindowManager().getCurrentWindowMetrics()); } @Override diff --git a/src/com/android/launcher3/GestureNavContract.java b/src/com/android/launcher3/GestureNavContract.java index c782dca4ca..9ef6edc6cf 100644 --- a/src/com/android/launcher3/GestureNavContract.java +++ b/src/com/android/launcher3/GestureNavContract.java @@ -20,11 +20,9 @@ import static android.content.Intent.EXTRA_USER; import static com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE; -import android.annotation.TargetApi; import android.content.ComponentName; import android.content.Intent; import android.graphics.RectF; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; @@ -69,7 +67,6 @@ public class GestureNavContract { /** * Sends the position information to the receiver */ - @TargetApi(Build.VERSION_CODES.R) public void sendEndPosition(RectF position, ActivityContext context, @Nullable SurfaceControl surfaceControl) { Bundle result = new Bundle(); @@ -95,9 +92,6 @@ public class GestureNavContract { * Clears and returns the GestureNavContract if it was present in the intent. */ public static GestureNavContract fromIntent(Intent intent) { - if (!Utilities.ATLEAST_R) { - return null; - } Bundle extras = intent.getBundleExtra(EXTRA_GESTURE_CONTRACT); if (extras == null) { return null; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 6b97c2c5fd..cd7c3bc9f8 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -581,9 +581,7 @@ public class Launcher extends StatefulActivity mRotationHelper.initialize(); TraceHelper.INSTANCE.endSection(); - if (Utilities.ATLEAST_R) { - getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_NOTHING); - } + getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_ADJUST_NOTHING); setTitle(R.string.home_screen); mStartupLatencyLogger.logEnd(LAUNCHER_LATENCY_STARTUP_ACTIVITY_ON_CREATE); diff --git a/src/com/android/launcher3/LauncherRootView.java b/src/com/android/launcher3/LauncherRootView.java index 1592154c3a..7176733786 100644 --- a/src/com/android/launcher3/LauncherRootView.java +++ b/src/com/android/launcher3/LauncherRootView.java @@ -2,11 +2,9 @@ package com.android.launcher3; import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; -import android.os.Build; import android.util.AttributeSet; import android.view.ViewDebug; import android.view.WindowInsets; @@ -112,15 +110,13 @@ public class LauncherRootView extends InsettableFrameLayout { mSysUiScrim.setSize(r - l, b - t); } - @TargetApi(Build.VERSION_CODES.Q) public void setForceHideBackArrow(boolean forceHideBackArrow) { this.mForceHideBackArrow = forceHideBackArrow; setDisallowBackGesture(mDisallowBackGesture); } - @TargetApi(Build.VERSION_CODES.Q) public void setDisallowBackGesture(boolean disallowBackGesture) { - if (!Utilities.ATLEAST_Q || SEPARATE_RECENTS_ACTIVITY.get()) { + if (SEPARATE_RECENTS_ACTIVITY.get()) { return; } mDisallowBackGesture = disallowBackGesture; diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index e0f6101056..2b886e4570 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -121,15 +121,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.P) - public static final boolean ATLEAST_P = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P; - - @ChecksSdkIntAtLeast(api = VERSION_CODES.Q) - public static final boolean ATLEAST_Q = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q; - - @ChecksSdkIntAtLeast(api = VERSION_CODES.R) - public static final boolean ATLEAST_R = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R; - @ChecksSdkIntAtLeast(api = VERSION_CODES.S) public static final boolean ATLEAST_S = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S; diff --git a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java index 5e48177d75..63a168e4e3 100644 --- a/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/LauncherAllAppsContainerView.java @@ -21,7 +21,6 @@ import android.view.WindowInsets; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; -import com.android.launcher3.Utilities; import com.android.launcher3.statemanager.StateManager; /** @@ -43,11 +42,7 @@ public class LauncherAllAppsContainerView extends ActivityAllAppsContainerView { + UI_HELPER_EXECUTOR.post(() -> mUserCache.getUserProfiles() .stream() .filter(getUserMatcher()) .findFirst() .ifPresent(userHandle -> - mUserManager.requestQuietModeEnabled(enabled, userHandle)); - }); - } + mUserManager.requestQuietModeEnabled(enabled, userHandle))); } /** Sets current state for the profile type. */ diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java index 48400b23b9..eb7d429f56 100644 --- a/src/com/android/launcher3/allapps/WorkModeSwitch.java +++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java @@ -83,11 +83,9 @@ public class WorkModeSwitch extends LinearLayout implements Insettable, mIcon = findViewById(R.id.work_icon); mTextView = findViewById(R.id.pause_text); setSelected(true); - if (Utilities.ATLEAST_R) { - KeyboardInsetAnimationCallback keyboardInsetAnimationCallback = - new KeyboardInsetAnimationCallback(this); - setWindowInsetsAnimationCallback(keyboardInsetAnimationCallback); - } + KeyboardInsetAnimationCallback keyboardInsetAnimationCallback = + new KeyboardInsetAnimationCallback(this); + setWindowInsetsAnimationCallback(keyboardInsetAnimationCallback); setInsets(mActivityContext.getDeviceProfile().getInsets()); updateStringFromCache(); diff --git a/src/com/android/launcher3/allapps/WorkPausedCard.java b/src/com/android/launcher3/allapps/WorkPausedCard.java index 18826673a1..e1eeabe258 100644 --- a/src/com/android/launcher3/allapps/WorkPausedCard.java +++ b/src/com/android/launcher3/allapps/WorkPausedCard.java @@ -26,7 +26,6 @@ import android.widget.LinearLayout; import android.widget.TextView; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.model.StringCache; import com.android.launcher3.views.ActivityContext; @@ -80,11 +79,9 @@ public class WorkPausedCard extends LinearLayout implements View.OnClickListener @Override public void onClick(View view) { - if (Utilities.ATLEAST_P) { - setEnabled(false); - mActivityContext.getAppsView().getWorkManager().setWorkProfileEnabled(true); - mActivityContext.getStatsLogManager().logger().log(LAUNCHER_TURN_ON_WORK_APPS_TAP); - } + setEnabled(false); + mActivityContext.getAppsView().getWorkManager().setWorkProfileEnabled(true); + mActivityContext.getStatsLogManager().logger().log(LAUNCHER_TURN_ON_WORK_APPS_TAP); } @Override diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java index c430a36279..a54e52c905 100644 --- a/src/com/android/launcher3/allapps/WorkProfileManager.java +++ b/src/com/android/launcher3/allapps/WorkProfileManager.java @@ -199,8 +199,7 @@ public class WorkProfileManager extends UserProfileManager } private void onWorkFabClicked(View view) { - if (Utilities.ATLEAST_P && getCurrentState() == STATE_ENABLED - && mWorkModeSwitch.isEnabled()) { + if (getCurrentState() == STATE_ENABLED && mWorkModeSwitch.isEnabled()) { logEvents(LAUNCHER_TURN_OFF_WORK_APPS_TAP); setWorkProfileEnabled(false); } diff --git a/src/com/android/launcher3/anim/PendingAnimation.java b/src/com/android/launcher3/anim/PendingAnimation.java index fd731f473e..586beb2d5e 100644 --- a/src/com/android/launcher3/anim/PendingAnimation.java +++ b/src/com/android/launcher3/anim/PendingAnimation.java @@ -25,7 +25,6 @@ import android.animation.ValueAnimator; import android.os.Trace; import android.util.FloatProperty; -import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorPlaybackController.Holder; import java.util.ArrayList; @@ -86,7 +85,7 @@ public class PendingAnimation extends AnimatedPropertySetter { /** If trace is enabled, add counter to trace animation progress. */ public void logAnimationProgressToTrace(String counterName) { - if (Utilities.ATLEAST_Q && Trace.isEnabled()) { + if (Trace.isEnabled()) { super.addOnFrameListener( animation -> Trace.setCounter( counterName, (long) (animation.getAnimatedFraction() * 100))); diff --git a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java index d37b1f08e3..5f786a4a68 100644 --- a/src/com/android/launcher3/compat/AccessibilityManagerCompat.java +++ b/src/com/android/launcher3/compat/AccessibilityManagerCompat.java @@ -110,9 +110,6 @@ public class AccessibilityManagerCompat { } public static int getRecommendedTimeoutMillis(Context context, int originalTimeout, int flags) { - if (Utilities.ATLEAST_Q) { - return getManager(context).getRecommendedTimeoutMillis(originalTimeout, flags); - } - return originalTimeout; + return getManager(context).getRecommendedTimeoutMillis(originalTimeout, flags); } } diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index aa5329b8d7..3ccde0ac6a 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -16,8 +16,6 @@ package com.android.launcher3.dragndrop; -import static com.android.launcher3.Utilities.ATLEAST_Q; - import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; @@ -404,9 +402,7 @@ public abstract class DragController mMotionDown.set(dragLayerPos.x, dragLayerPos.y); } - if (ATLEAST_Q) { - mLastTouchClassification = ev.getClassification(); - } + mLastTouchClassification = ev.getClassification(); return mDragDriver != null && mDragDriver.onInterceptTouchEvent(ev); } @@ -441,7 +437,7 @@ public abstract class DragController mLastTouch.set(x, y); int distanceDragged = mDistanceSinceScroll; - if (ATLEAST_Q && mLastTouchClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS) { + if (mLastTouchClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS) { distanceDragged /= DEEP_PRESS_DISTANCE_FACTOR; } if (mIsInPreDrag && mOptions.preDragCondition != null diff --git a/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java b/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java index 6f295e6c50..6a43b24366 100644 --- a/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java +++ b/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java @@ -37,7 +37,6 @@ import android.util.Log; import androidx.annotation.Nullable; import androidx.annotation.UiThread; -import com.android.launcher3.Utilities; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.folder.PreviewBackground; import com.android.launcher3.icons.BitmapRenderer; @@ -74,13 +73,9 @@ public class FolderAdaptiveIcon extends AdaptiveIconDrawable { return mBadge; } - @TargetApi(Build.VERSION_CODES.P) public static @Nullable FolderAdaptiveIcon createFolderAdaptiveIcon( ActivityContext activity, int folderId, Point size) { Preconditions.assertNonUiThread(); - if (!Utilities.ATLEAST_P) { - return null; - } // assume square if (size.x != size.y) { diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 084f829884..7ae70e097f 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -297,10 +297,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mFooter = findViewById(R.id.folder_footer); mFooterHeight = dp.folderFooterHeightPx; - if (Utilities.ATLEAST_R) { - mKeyboardInsetAnimationCallback = new KeyboardInsetAnimationCallback(this); - setWindowInsetsAnimationCallback(mKeyboardInsetAnimationCallback); - } + mKeyboardInsetAnimationCallback = new KeyboardInsetAnimationCallback(this); + setWindowInsetsAnimationCallback(mKeyboardInsetAnimationCallback); } public boolean onLongClick(View v) { @@ -422,18 +420,16 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo @Override public WindowInsets onApplyWindowInsets(WindowInsets windowInsets) { - if (Utilities.ATLEAST_R) { - this.setTranslationY(0); + this.setTranslationY(0); - if (windowInsets.isVisible(WindowInsets.Type.ime())) { - Insets keyboardInsets = windowInsets.getInsets(WindowInsets.Type.ime()); - int folderHeightFromBottom = getHeightFromBottom(); + if (windowInsets.isVisible(WindowInsets.Type.ime())) { + Insets keyboardInsets = windowInsets.getInsets(WindowInsets.Type.ime()); + int folderHeightFromBottom = getHeightFromBottom(); - if (keyboardInsets.bottom > folderHeightFromBottom) { - // Translate this folder above the keyboard, then add the folder name's padding - this.setTranslationY(folderHeightFromBottom - keyboardInsets.bottom - - mFolderName.getPaddingBottom()); - } + if (keyboardInsets.bottom > folderHeightFromBottom) { + // Translate this folder above the keyboard, then add the folder name's padding + this.setTranslationY(folderHeightFromBottom - keyboardInsets.bottom + - mFolderName.getPaddingBottom()); } } @@ -812,15 +808,13 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo a.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { - if (Utilities.ATLEAST_R) { - setWindowInsetsAnimationCallback(null); - } + setWindowInsetsAnimationCallback(null); mIsAnimatingClosed = true; } @Override public void onAnimationEnd(Animator animation) { - if (Utilities.ATLEAST_R && mKeyboardInsetAnimationCallback != null) { + if (mKeyboardInsetAnimationCallback != null) { setWindowInsetsAnimationCallback(mKeyboardInsetAnimationCallback); } closeComplete(true); diff --git a/src/com/android/launcher3/graphics/GridCustomizationsProvider.java b/src/com/android/launcher3/graphics/GridCustomizationsProvider.java index 18200f6447..dc8694d2f6 100644 --- a/src/com/android/launcher3/graphics/GridCustomizationsProvider.java +++ b/src/com/android/launcher3/graphics/GridCustomizationsProvider.java @@ -19,7 +19,6 @@ import static com.android.launcher3.LauncherPrefs.THEMED_ICONS; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.Themes.isThemedIconEnabled; -import android.annotation.TargetApi; import android.content.ContentProvider; import android.content.ContentValues; import android.content.pm.PackageManager; @@ -27,7 +26,6 @@ import android.database.Cursor; import android.database.MatrixCursor; import android.net.Uri; import android.os.Binder; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; @@ -41,7 +39,6 @@ import android.util.Pair; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.InvariantDeviceProfile.GridOption; import com.android.launcher3.LauncherPrefs; -import com.android.launcher3.Utilities; import com.android.launcher3.util.Executors; /** @@ -184,13 +181,12 @@ public class GridCustomizationsProvider extends ContentProvider { return null; } - if (!Utilities.ATLEAST_R || !METHOD_GET_PREVIEW.equals(method)) { + if (!METHOD_GET_PREVIEW.equals(method)) { return null; } return getPreview(extras); } - @TargetApi(Build.VERSION_CODES.R) private synchronized Bundle getPreview(Bundle request) { PreviewLifecycleObserver observer = null; try { diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java index 7dcc8a8637..e0a66276b6 100644 --- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java +++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java @@ -26,7 +26,6 @@ import static com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidge import static com.android.launcher3.model.ModelUtils.filterCurrentWorkspaceItems; import static com.android.launcher3.model.ModelUtils.getMissingHotseatRanks; -import android.annotation.TargetApi; import android.app.Fragment; import android.app.WallpaperColors; import android.app.WallpaperManager; @@ -39,7 +38,6 @@ import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.PointF; import android.graphics.Rect; -import android.os.Build; import android.os.Handler; import android.os.Looper; import android.util.AttributeSet; @@ -121,7 +119,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; * 3) Place appropriate elements like icons and first-page qsb * 4) Measure and draw the view on a canvas */ -@TargetApi(Build.VERSION_CODES.R) public class LauncherPreviewRenderer extends ContextWrapper implements ActivityContext, WorkspaceLayoutManager, LayoutInflater.Factory2 { diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java index ec6b94dfeb..051fb6f4fe 100644 --- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java +++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java @@ -49,7 +49,6 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; -import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.graphics.LauncherPreviewRenderer.PreviewContext; import com.android.launcher3.model.BgDataModel; @@ -211,10 +210,7 @@ public class PreviewSurfaceRenderer { return new ContextThemeWrapper(context, Themes.getActivityThemeRes(context)); } - if (Utilities.ATLEAST_R) { - context = context.createWindowContext( - LayoutParams.TYPE_APPLICATION_OVERLAY, null); - } + context = context.createWindowContext(LayoutParams.TYPE_APPLICATION_OVERLAY, null); LocalColorExtractor.newInstance(context) .applyColorsOverride(context, mWallpaperColors); return new ContextThemeWrapper(context, diff --git a/src/com/android/launcher3/model/ModelDbController.java b/src/com/android/launcher3/model/ModelDbController.java index 6c6471347e..ba2b64d9c1 100644 --- a/src/com/android/launcher3/model/ModelDbController.java +++ b/src/com/android/launcher3/model/ModelDbController.java @@ -458,7 +458,7 @@ public class ModelDbController { LauncherWidgetHolder widgetHolder) { ContentResolver cr = mContext.getContentResolver(); String blobHandlerDigest = Settings.Secure.getString(cr, LAYOUT_DIGEST_KEY); - if (Utilities.ATLEAST_R && !TextUtils.isEmpty(blobHandlerDigest)) { + if (!TextUtils.isEmpty(blobHandlerDigest)) { BlobStoreManager blobManager = mContext.getSystemService(BlobStoreManager.class); try (InputStream in = new ParcelFileDescriptor.AutoCloseInputStream( blobManager.openBlob(BlobHandle.createWithSha256( diff --git a/src/com/android/launcher3/model/data/WorkspaceItemInfo.java b/src/com/android/launcher3/model/data/WorkspaceItemInfo.java index c67ec5a40d..965f261c74 100644 --- a/src/com/android/launcher3/model/data/WorkspaceItemInfo.java +++ b/src/com/android/launcher3/model/data/WorkspaceItemInfo.java @@ -182,8 +182,7 @@ public class WorkspaceItemInfo extends ItemInfoWithIcon { runtimeStatusFlags |= FLAG_DISABLED_BY_PUBLISHER; } disabledMessage = shortcutInfo.getDisabledMessage(); - if (Utilities.ATLEAST_P - && shortcutInfo.getDisabledReason() == ShortcutInfo.DISABLED_REASON_VERSION_LOWER) { + if (shortcutInfo.getDisabledReason() == ShortcutInfo.DISABLED_REASON_VERSION_LOWER) { runtimeStatusFlags |= FLAG_DISABLED_VERSION_LOWER; } else { runtimeStatusFlags &= ~FLAG_DISABLED_VERSION_LOWER; diff --git a/src/com/android/launcher3/pm/InstallSessionHelper.java b/src/com/android/launcher3/pm/InstallSessionHelper.java index ca27eb28c4..0d474628b2 100644 --- a/src/com/android/launcher3/pm/InstallSessionHelper.java +++ b/src/com/android/launcher3/pm/InstallSessionHelper.java @@ -24,7 +24,6 @@ import android.content.pm.LauncherApps; import android.content.pm.PackageInstaller; import android.content.pm.PackageInstaller.SessionInfo; import android.content.pm.PackageManager; -import android.os.Process; import android.os.UserHandle; import android.text.TextUtils; @@ -34,7 +33,6 @@ import androidx.annotation.WorkerThread; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.SessionCommitReceiver; -import com.android.launcher3.Utilities; import com.android.launcher3.logging.FileLog; import com.android.launcher3.model.ItemInstallQueue; import com.android.launcher3.util.IntArray; @@ -132,7 +130,7 @@ public class InstallSessionHelper { public SessionInfo getActiveSessionInfo(UserHandle user, String pkg) { for (SessionInfo info : getAllVerifiedSessions()) { boolean match = pkg.equals(info.getAppPackageName()); - if (Utilities.ATLEAST_Q && !user.equals(getUserHandle(info))) { + if (!user.equals(getUserHandle(info))) { match = false; } if (match) { @@ -180,9 +178,8 @@ public class InstallSessionHelper { @NonNull public List getAllVerifiedSessions() { - List list = new ArrayList<>(Utilities.ATLEAST_Q - ? Objects.requireNonNull(mLauncherApps).getAllPackageInstallerSessions() - : mInstaller.getAllSessions()); + List list = new ArrayList<>( + Objects.requireNonNull(mLauncherApps).getAllPackageInstallerSessions()); Iterator it = list.iterator(); while (it.hasNext()) { if (verify(it.next()) == null) { @@ -252,6 +249,6 @@ public class InstallSessionHelper { } public static UserHandle getUserHandle(@NonNull final SessionInfo info) { - return Utilities.ATLEAST_Q ? info.getUser() : Process.myUserHandle(); + return info.getUser(); } } diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index 934d43b187..c9c5fd3d98 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -17,7 +17,6 @@ package com.android.launcher3.popup; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_SHORTCUTS; -import static com.android.launcher3.Utilities.ATLEAST_P; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; import static com.android.launcher3.popup.PopupPopulator.MAX_SHORTCUTS; @@ -248,10 +247,7 @@ public class PopupContainerWithArrow * Animates and loads shortcuts on background thread for this popup container */ private void loadAppShortcuts(ItemInfo originalItemInfo) { - - if (ATLEAST_P) { - setAccessibilityPaneTitle(getTitleForAccessibility()); - } + setAccessibilityPaneTitle(getTitleForAccessibility()); mOriginalIcon.setForceHideDot(true); // All views are added. Animate layout from now on. setLayoutTransition(new LayoutTransition()); diff --git a/src/com/android/launcher3/popup/RemoteActionShortcut.java b/src/com/android/launcher3/popup/RemoteActionShortcut.java index 8df58d2146..688da4934f 100644 --- a/src/com/android/launcher3/popup/RemoteActionShortcut.java +++ b/src/com/android/launcher3/popup/RemoteActionShortcut.java @@ -20,13 +20,11 @@ import static com.android.launcher3.Utilities.allowBGLaunch; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_PAUSE_TAP; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import android.annotation.TargetApi; import android.app.ActivityOptions; import android.app.PendingIntent; import android.app.RemoteAction; import android.content.Context; import android.content.Intent; -import android.os.Build; import android.util.Log; import android.view.View; import android.view.accessibility.AccessibilityNodeInfo; @@ -42,7 +40,6 @@ import com.android.launcher3.model.data.ItemInfo; import java.lang.ref.WeakReference; -@TargetApi(Build.VERSION_CODES.Q) public class RemoteActionShortcut extends SystemShortcut { private static final String TAG = "RemoteActionShortcut"; private static final boolean DEBUG = Utilities.IS_DEBUG_DEVICE; diff --git a/src/com/android/launcher3/provider/RestoreDbTask.java b/src/com/android/launcher3/provider/RestoreDbTask.java index 1c53855adb..22bc13bb25 100644 --- a/src/com/android/launcher3/provider/RestoreDbTask.java +++ b/src/com/android/launcher3/provider/RestoreDbTask.java @@ -326,9 +326,6 @@ public class RestoreDbTask { */ private UserHandle getUserForAncestralSerialNumber(BackupManager backupManager, long ancestralSerialNumber) { - if (!Utilities.ATLEAST_Q) { - return null; - } return backupManager.getUserForAncestralSerialNumber(ancestralSerialNumber); } diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 8cb15a5e6c..a5f9c2a53f 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -52,7 +52,6 @@ import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.BuildConfig; import com.android.launcher3.LauncherFiles; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.model.WidgetsModel; import com.android.launcher3.states.RotationHelper; import com.android.launcher3.uioverrides.flags.DeveloperOptionsUI; @@ -120,7 +119,7 @@ public class SettingsActivity extends FragmentActivity } private boolean startPreference(String fragment, Bundle args, String key) { - if (Utilities.ATLEAST_P && getSupportFragmentManager().isStateSaved()) { + if (getSupportFragmentManager().isStateSaved()) { // Sometimes onClick can come after onPause because of being posted on the handler. // Skip starting new preferences in that case. return false; diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index ccff095c0e..315b5e3a93 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -15,19 +15,17 @@ */ package com.android.launcher3.testing; -import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; import static com.android.launcher3.Flags.enableGridOnlyOverview; +import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST; import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.res.Resources; import android.graphics.Insets; import android.graphics.Point; import android.graphics.Rect; -import android.os.Build; import android.os.Bundle; import android.view.WindowInsets; @@ -60,7 +58,6 @@ import java.util.function.Supplier; /** * Class to handle requests from tests */ -@TargetApi(Build.VERSION_CODES.Q) public class TestInformationHandler implements ResourceBasedOverride { public static TestInformationHandler newInstance(Context context) { diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index ff8b381779..237b1c43d6 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -189,16 +189,12 @@ public class ItemClickHandler { boolean downloadStarted) { ItemInfo item = (ItemInfo) v.getTag(); CompletableFuture siFuture; - if (Utilities.ATLEAST_Q) { - siFuture = CompletableFuture.supplyAsync(() -> - InstallSessionHelper.INSTANCE.get(launcher) - .getActiveSessionInfo(item.user, packageName), - UI_HELPER_EXECUTOR); - } else { - siFuture = CompletableFuture.completedFuture(null); - } + siFuture = CompletableFuture.supplyAsync(() -> + InstallSessionHelper.INSTANCE.get(launcher) + .getActiveSessionInfo(item.user, packageName), + UI_HELPER_EXECUTOR); Consumer marketLaunchAction = sessionInfo -> { - if (sessionInfo != null && Utilities.ATLEAST_Q) { + if (sessionInfo != null) { LauncherApps launcherApps = launcher.getSystemService(LauncherApps.class); try { launcherApps.startPackageInstallerSessionDetailsActivity(sessionInfo, null, diff --git a/src/com/android/launcher3/util/IOUtils.java b/src/com/android/launcher3/util/IOUtils.java index 1cec0ecc10..296efe9277 100644 --- a/src/com/android/launcher3/util/IOUtils.java +++ b/src/com/android/launcher3/util/IOUtils.java @@ -19,7 +19,6 @@ package com.android.launcher3.util; import android.os.FileUtils; import android.util.Log; -import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import java.io.ByteArrayOutputStream; @@ -51,17 +50,7 @@ public class IOUtils { } public static long copy(InputStream from, OutputStream to) throws IOException { - if (Utilities.ATLEAST_Q) { - return FileUtils.copy(from, to); - } - byte[] buf = new byte[BUF_SIZE]; - long total = 0; - int r; - while ((r = from.read(buf)) != -1) { - to.write(buf, 0, r); - total += r; - } - return total; + return FileUtils.copy(from, to); } public static void closeSilently(Closeable c) { diff --git a/src/com/android/launcher3/util/TraceHelper.java b/src/com/android/launcher3/util/TraceHelper.java index 138cc4af3e..edcd3f6059 100644 --- a/src/com/android/launcher3/util/TraceHelper.java +++ b/src/com/android/launcher3/util/TraceHelper.java @@ -20,12 +20,10 @@ import android.os.Trace; import androidx.annotation.MainThread; -import com.android.launcher3.Utilities; +import kotlin.random.Random; import java.util.function.Supplier; -import kotlin.random.Random; - /** * A wrapper around {@link Trace} to allow better testing. * @@ -67,9 +65,6 @@ public class TraceHelper { @SuppressWarnings("NewApi") @SuppressLint("NewApi") public SafeCloseable beginAsyncSection(String sectionName) { - if (!Utilities.ATLEAST_Q) { - return () -> { }; - } int cookie = Random.Default.nextInt(); Trace.beginAsyncSection(sectionName, cookie); return () -> Trace.endAsyncSection(sectionName, cookie); @@ -81,9 +76,6 @@ public class TraceHelper { @SuppressWarnings("NewApi") @SuppressLint("NewApi") public SafeCloseable allowIpcs(String rpcName) { - if (!Utilities.ATLEAST_Q) { - return () -> { }; - } int cookie = Random.Default.nextInt(); Trace.beginAsyncSection(rpcName, cookie); return () -> Trace.endAsyncSection(rpcName, cookie); diff --git a/src/com/android/launcher3/util/VibratorWrapper.java b/src/com/android/launcher3/util/VibratorWrapper.java index 4f20bbcf44..fef1c723eb 100644 --- a/src/com/android/launcher3/util/VibratorWrapper.java +++ b/src/com/android/launcher3/util/VibratorWrapper.java @@ -28,12 +28,10 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.annotation.SuppressLint; -import android.annotation.TargetApi; import android.content.ContentResolver; import android.content.Context; import android.database.ContentObserver; import android.media.AudioAttributes; -import android.os.Build; import android.os.SystemClock; import android.os.VibrationEffect; import android.os.Vibrator; @@ -48,7 +46,6 @@ import com.android.launcher3.config.FeatureFlags; /** * Wrapper around {@link Vibrator} to easily perform haptic feedback where necessary. */ -@TargetApi(Build.VERSION_CODES.Q) public class VibratorWrapper { public static final MainThreadInitializedObject INSTANCE = @@ -138,7 +135,7 @@ public class VibratorWrapper { mThresholdUntilNextDragCallMillis = 0; } - if (Utilities.ATLEAST_R && mVibrator.areAllPrimitivesSupported( + if (mVibrator.areAllPrimitivesSupported( VibrationEffect.Composition.PRIMITIVE_QUICK_RISE, VibrationEffect.Composition.PRIMITIVE_TICK)) { if (FeatureFlags.ENABLE_SEARCH_HAPTIC_HINT.get()) { @@ -226,8 +223,7 @@ public class VibratorWrapper { public void vibrate(int primitiveId, float primitiveScale, VibrationEffect fallbackEffect) { if (mHasVibrator && mIsHapticFeedbackEnabled) { UI_HELPER_EXECUTOR.execute(() -> { - if (Utilities.ATLEAST_R && primitiveId >= 0 - && mVibrator.areAllPrimitivesSupported(primitiveId)) { + if (primitiveId >= 0 && mVibrator.areAllPrimitivesSupported(primitiveId)) { mVibrator.vibrate(VibrationEffect.startComposition() .addPrimitive(primitiveId, primitiveScale) .compose(), VIBRATION_ATTRS); diff --git a/src/com/android/launcher3/util/window/WindowManagerProxy.java b/src/com/android/launcher3/util/window/WindowManagerProxy.java index 51a96c4d8a..209a3dc779 100644 --- a/src/com/android/launcher3/util/window/WindowManagerProxy.java +++ b/src/com/android/launcher3/util/window/WindowManagerProxy.java @@ -105,24 +105,7 @@ public class WindowManagerProxy implements ResourceBasedOverride { /** * Returns the real bounds for the provided display after applying any insets normalization */ - @TargetApi(Build.VERSION_CODES.R) public WindowBounds getRealBounds(Context displayInfoContext, CachedDisplayInfo info) { - if (!Utilities.ATLEAST_R) { - Point smallestSize = new Point(); - Point largestSize = new Point(); - getDisplay(displayInfoContext).getCurrentSizeRange(smallestSize, largestSize); - - if (info.size.y > info.size.x) { - // Portrait - return new WindowBounds(info.size.x, info.size.y, smallestSize.x, largestSize.y, - info.rotation); - } else { - // Landscape - return new WindowBounds(info.size.x, info.size.y, largestSize.x, smallestSize.y, - info.rotation); - } - } - WindowMetrics windowMetrics = displayInfoContext.getSystemService(WindowManager.class) .getMaximumWindowMetrics(); Rect insets = new Rect(); @@ -133,10 +116,9 @@ public class WindowManagerProxy implements ResourceBasedOverride { /** * Returns an updated insets, accounting for various Launcher UI specific overrides like taskbar */ - @TargetApi(Build.VERSION_CODES.R) public WindowInsets normalizeWindowInsets(Context context, WindowInsets oldInsets, Rect outInsets) { - if (!Utilities.ATLEAST_R || !mTaskbarDrawnInProcess) { + if (!mTaskbarDrawnInProcess) { outInsets.set(oldInsets.getSystemWindowInsetLeft(), oldInsets.getSystemWindowInsetTop(), oldInsets.getSystemWindowInsetRight(), oldInsets.getSystemWindowInsetBottom()); return oldInsets; @@ -220,8 +202,7 @@ public class WindowManagerProxy implements ResourceBasedOverride { } boolean isTablet = swDp >= MIN_TABLET_WIDTH; - boolean isTabletOrGesture = isTablet - || (Utilities.ATLEAST_R && isGestureNav(context)); + boolean isTabletOrGesture = isTablet || isGestureNav(context); // Use the status bar height resources because current system API to get the status bar // height doesn't allow to do this for an arbitrary display, it returns value only @@ -360,17 +341,14 @@ public class WindowManagerProxy implements ResourceBasedOverride { } /** - * * Returns the display associated with the context, or DEFAULT_DISPLAY if the context isn't * associated with a display. */ protected Display getDisplay(Context displayInfoContext) { - if (Utilities.ATLEAST_R) { - try { - return displayInfoContext.getDisplay(); - } catch (UnsupportedOperationException e) { - // Ignore - } + try { + return displayInfoContext.getDisplay(); + } catch (UnsupportedOperationException e) { + // Ignore } return displayInfoContext.getSystemService(DisplayManager.class).getDisplay( DEFAULT_DISPLAY); diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index bf46bb0a97..72e5342642 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -265,29 +265,26 @@ public interface ActivityContext { if (root == null) { return; } - if (Utilities.ATLEAST_R) { - Preconditions.assertUIThread(); - // Hide keyboard with WindowInsetsController if could. In case - // hideSoftInputFromWindow may get ignored by input connection being finished - // when the screen is off. - // - // In addition, inside IMF, the keyboards are closed asynchronously that launcher no - // longer need to post to the message queue. - final WindowInsetsController wic = root.getWindowInsetsController(); - WindowInsets insets = root.getRootWindowInsets(); - boolean isImeShown = insets != null && insets.isVisible(WindowInsets.Type.ime()); - if (wic != null) { - // Only hide the keyboard if it is actually showing. - if (isImeShown) { - // this method cannot be called cross threads - wic.hide(WindowInsets.Type.ime()); - getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED); - } - - // If the WindowInsetsController is not null, we end here regardless of whether we - // hid the keyboard or not. - return; + Preconditions.assertUIThread(); + // Hide keyboard with WindowInsetsController if could. In case hideSoftInputFromWindow may + // get ignored by input connection being finished when the screen is off. + // + // In addition, inside IMF, the keyboards are closed asynchronously that launcher no longer + // need to post to the message queue. + final WindowInsetsController wic = root.getWindowInsetsController(); + WindowInsets insets = root.getRootWindowInsets(); + boolean isImeShown = insets != null && insets.isVisible(WindowInsets.Type.ime()); + if (wic != null) { + // Only hide the keyboard if it is actually showing. + if (isImeShown) { + // this method cannot be called cross threads + wic.hide(WindowInsets.Type.ime()); + getStatsLogManager().logger().log(LAUNCHER_ALLAPPS_KEYBOARD_CLOSED); } + + // If the WindowInsetsController is not null, we end here regardless of whether we hid + // the keyboard or not. + return; } InputMethodManager imm = root.getContext().getSystemService(InputMethodManager.class); diff --git a/src/com/android/launcher3/views/BaseDragLayer.java b/src/com/android/launcher3/views/BaseDragLayer.java index a1cd697eee..abc5ef88dd 100644 --- a/src/com/android/launcher3/views/BaseDragLayer.java +++ b/src/com/android/launcher3/views/BaseDragLayer.java @@ -551,25 +551,21 @@ public abstract class BaseDragLayer @Override public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) { - if (Utilities.ATLEAST_Q) { - Insets gestureInsets = insets.getMandatorySystemGestureInsets(); - int gestureInsetBottom = gestureInsets.bottom; - Insets imeInset = Utilities.ATLEAST_R - ? insets.getInsets(WindowInsets.Type.ime()) - : Insets.NONE; - DeviceProfile dp = mActivity.getDeviceProfile(); - if (dp.isTaskbarPresent) { - // Ignore taskbar gesture insets to avoid interfering with TouchControllers. - gestureInsetBottom = ResourceUtils.getNavbarSize( - ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()); - } - mSystemGestureRegion.set( - Math.max(gestureInsets.left, imeInset.left), - Math.max(gestureInsets.top, imeInset.top), - Math.max(gestureInsets.right, imeInset.right), - Math.max(gestureInsetBottom, imeInset.bottom) - ); + Insets gestureInsets = insets.getMandatorySystemGestureInsets(); + int gestureInsetBottom = gestureInsets.bottom; + Insets imeInset = insets.getInsets(WindowInsets.Type.ime()); + DeviceProfile dp = mActivity.getDeviceProfile(); + if (dp.isTaskbarPresent) { + // Ignore taskbar gesture insets to avoid interfering with TouchControllers. + gestureInsetBottom = ResourceUtils.getNavbarSize( + ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()); } + mSystemGestureRegion.set( + Math.max(gestureInsets.left, imeInset.left), + Math.max(gestureInsets.top, imeInset.top), + Math.max(gestureInsets.right, imeInset.right), + Math.max(gestureInsetBottom, imeInset.bottom) + ); return super.dispatchApplyWindowInsets(insets); } } diff --git a/src/com/android/launcher3/views/ClipIconView.java b/src/com/android/launcher3/views/ClipIconView.java index 7737adb905..5d3fa9bc4e 100644 --- a/src/com/android/launcher3/views/ClipIconView.java +++ b/src/com/android/launcher3/views/ClipIconView.java @@ -25,7 +25,6 @@ import static java.lang.Math.max; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; @@ -36,7 +35,6 @@ import android.graphics.RectF; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; -import android.os.Build; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup.MarginLayoutParams; @@ -55,7 +53,6 @@ import com.android.launcher3.graphics.IconShape; * Supports springing just the foreground layer. * Supports clipping the icon to/from its icon shape. */ -@TargetApi(Build.VERSION_CODES.Q) public class ClipIconView extends View implements ClipPathView { private static final Rect sTmpRect = new Rect(); diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index 32c70a3120..f76b53b90d 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -24,14 +24,12 @@ import static com.android.launcher3.util.Executors.MODEL_EXECUTOR; import static com.android.launcher3.views.IconLabelDotView.setIconAndDotVisible; import android.animation.Animator; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.Drawable; -import android.os.Build; import android.os.CancellationSignal; import android.util.AttributeSet; import android.util.Log; @@ -67,7 +65,6 @@ import java.util.function.Supplier; /** * A view that is created to look like another view with the purpose of creating fluid animations. */ -@TargetApi(Build.VERSION_CODES.Q) public class FloatingIconView extends FrameLayout implements Animator.AnimatorListener, OnGlobalLayoutListener, FloatingView { diff --git a/src/com/android/launcher3/views/FloatingSurfaceView.java b/src/com/android/launcher3/views/FloatingSurfaceView.java index bfb75f0022..76b6fdebad 100644 --- a/src/com/android/launcher3/views/FloatingSurfaceView.java +++ b/src/com/android/launcher3/views/FloatingSurfaceView.java @@ -18,14 +18,12 @@ package com.android.launcher3.views; import static com.android.launcher3.views.FloatingIconView.getLocationBoundsForView; import static com.android.launcher3.views.IconLabelDotView.setIconAndDotVisible; -import android.annotation.TargetApi; import android.content.Context; import android.graphics.Canvas; import android.graphics.Picture; import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.SurfaceHolder; @@ -47,7 +45,6 @@ import com.android.launcher3.util.window.RefreshRateTracker; * Similar to {@link FloatingIconView} but displays a surface with the targetIcon. It then passes * the surfaceHandle to the {@link GestureNavContract}. */ -@TargetApi(Build.VERSION_CODES.R) public class FloatingSurfaceView extends AbstractFloatingView implements OnGlobalLayoutListener, Insettable, SurfaceHolder.Callback2 { diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index c0b24fa9f4..8408cc760d 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -30,7 +30,6 @@ import android.graphics.Paint; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; -import android.os.Build; import android.util.AttributeSet; import android.util.Log; import android.util.Property; @@ -40,7 +39,6 @@ import android.view.ViewConfiguration; import android.view.WindowInsets; import android.widget.TextView; -import androidx.annotation.RequiresApi; import androidx.recyclerview.widget.RecyclerView; import com.android.launcher3.FastScrollRecyclerView; @@ -352,26 +350,21 @@ public class RecyclerViewFastScroller extends View { float r = getScrollThumbRadius(); mThumbBounds.set(-halfW, 0, halfW, mThumbHeight); canvas.drawRoundRect(mThumbBounds, r, r, mThumbPaint); - if (Utilities.ATLEAST_Q) { - mThumbBounds.roundOut(SYSTEM_GESTURE_EXCLUSION_RECT.get(0)); - // swiping very close to the thumb area (not just within it's bound) - // will also prevent back gesture - SYSTEM_GESTURE_EXCLUSION_RECT.get(0).offset(mThumbDrawOffset.x, mThumbDrawOffset.y); - if (Utilities.ATLEAST_Q && mSystemGestureInsets != null) { - SYSTEM_GESTURE_EXCLUSION_RECT.get(0).left = - SYSTEM_GESTURE_EXCLUSION_RECT.get(0).right - mSystemGestureInsets.right; - } - setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT); + mThumbBounds.roundOut(SYSTEM_GESTURE_EXCLUSION_RECT.get(0)); + // swiping very close to the thumb area (not just within it's bound) + // will also prevent back gesture + SYSTEM_GESTURE_EXCLUSION_RECT.get(0).offset(mThumbDrawOffset.x, mThumbDrawOffset.y); + if (mSystemGestureInsets != null) { + SYSTEM_GESTURE_EXCLUSION_RECT.get(0).left = + SYSTEM_GESTURE_EXCLUSION_RECT.get(0).right - mSystemGestureInsets.right; } + setSystemGestureExclusionRects(SYSTEM_GESTURE_EXCLUSION_RECT); canvas.restoreToCount(saveCount); } @Override - @RequiresApi(Build.VERSION_CODES.Q) public WindowInsets onApplyWindowInsets(WindowInsets insets) { - if (Utilities.ATLEAST_Q) { - mSystemGestureInsets = insets.getSystemGestureInsets(); - } + mSystemGestureInsets = insets.getSystemGestureInsets(); return super.onApplyWindowInsets(insets); } diff --git a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java index 80b1cdd83c..4f5d31160a 100644 --- a/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java +++ b/src/com/android/launcher3/widget/AddItemWidgetsBottomSheet.java @@ -16,8 +16,6 @@ package com.android.launcher3.widget; -import static com.android.launcher3.Utilities.ATLEAST_R; - import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Insets; @@ -153,17 +151,10 @@ public class AddItemWidgetsBottomSheet extends AbstractSlideInView private int getNavBarScrimHeight(WindowInsets insets) { if (mDisableNavBarScrim) { return 0; - } else if (Utilities.ATLEAST_Q) { - return insets.getTappableElementInsets().bottom; } else { - return insets.getStableInsetBottom(); + return insets.getTappableElementInsets().bottom; } } diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java index e0de269eed..e77ec12e18 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetHostView.java @@ -16,11 +16,9 @@ package com.android.launcher3.widget; -import android.annotation.TargetApi; import android.appwidget.AppWidgetProviderInfo; import android.content.Context; import android.graphics.Rect; -import android.os.Build; import android.os.Handler; import android.os.Parcelable; import android.os.SystemClock; @@ -44,7 +42,6 @@ import com.android.launcher3.CheckLongPressHelper; import com.android.launcher3.Flags; import com.android.launcher3.Launcher; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.LauncherAppWidgetInfo; @@ -105,7 +102,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView setDefaultFocusHighlightEnabled(false); } - if (Utilities.ATLEAST_Q && Themes.getAttrBoolean(mLauncher, R.attr.isWorkspaceDarkText)) { + if (Themes.getAttrBoolean(mLauncher, R.attr.isWorkspaceDarkText)) { setOnLightBackground(true); } mColorExtractor = new LocalColorExtractor(); // no-op @@ -131,10 +128,9 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView } @Override - @TargetApi(Build.VERSION_CODES.Q) public void setAppWidget(int appWidgetId, AppWidgetProviderInfo info) { super.setAppWidget(appWidgetId, info); - if (!mTrackingWidgetUpdate && Utilities.ATLEAST_Q) { + if (!mTrackingWidgetUpdate) { mTrackingWidgetUpdate = true; Trace.beginAsyncSection(TRACE_METHOD_NAME + info.provider, appWidgetId); Log.i(TAG, "App widget created with id: " + appWidgetId); @@ -142,9 +138,8 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView } @Override - @TargetApi(Build.VERSION_CODES.Q) public void updateAppWidget(RemoteViews remoteViews) { - if (mTrackingWidgetUpdate && remoteViews != null && Utilities.ATLEAST_Q) { + if (mTrackingWidgetUpdate && remoteViews != null) { Log.i(TAG, "App widget with id: " + getAppWidgetId() + " loaded"); Trace.endAsyncSection( TRACE_METHOD_NAME + getAppWidgetInfo().provider, getAppWidgetId()); @@ -288,8 +283,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView super.onLayout(changed, left, top, right, bottom); mIsScrollable = checkScrollableRecursively(this); - if (!mIsInDragMode && getTag() instanceof LauncherAppWidgetInfo) { - LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) getTag(); + if (!mIsInDragMode && getTag() instanceof LauncherAppWidgetInfo info) { mTempRect.set(left, top, right, bottom); mColorExtractor.setWorkspaceLocation(mTempRect, (View) getParent(), info.screenId); } @@ -425,8 +419,7 @@ public class LauncherAppWidgetHostView extends BaseLauncherAppWidgetHostView @Override protected boolean shouldAllowDirectClick() { - if (getTag() instanceof ItemInfo) { - ItemInfo item = (ItemInfo) getTag(); + if (getTag() instanceof ItemInfo item) { return item.spanX == 1 && item.spanY == 1; } return false; diff --git a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java index ef51d152c7..3e4fd8caa8 100644 --- a/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java +++ b/src/com/android/launcher3/widget/LauncherAppWidgetProviderInfo.java @@ -15,7 +15,6 @@ import android.os.UserHandle; import com.android.launcher3.DeviceProfile; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; -import com.android.launcher3.Utilities; import com.android.launcher3.icons.ComponentWithLabelAndIcon; import com.android.launcher3.icons.IconCache; import com.android.launcher3.model.data.LauncherAppWidgetInfo; @@ -206,11 +205,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo } public int getWidgetFeatures() { - if (Utilities.ATLEAST_P) { - return widgetFeatures; - } else { - return 0; - } + return widgetFeatures; } public boolean isReconfigurable() {