diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 7d88f051fb..ce3cd52898 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -21,6 +21,8 @@ import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEAS import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED; import static com.android.app.animation.Interpolators.EMPHASIZED; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.PENDING_SPLIT_SELECT_INFO; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE; import static com.android.launcher3.LauncherSettings.Animation.DEFAULT_NO_ICON; import static com.android.launcher3.LauncherSettings.Animation.VIEW_BACKGROUND; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT; diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 189db21085..79b831e117 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -32,6 +32,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.Px; +import com.android.launcher3.LauncherConstants.ActivityCodes; import com.android.launcher3.accessibility.DragViewStateAnnouncer; import com.android.launcher3.celllayout.CellLayoutLayoutParams; import com.android.launcher3.celllayout.CellPosMapper.CellPos; @@ -270,7 +271,7 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O .startConfigActivity( mLauncher, mWidgetView.getAppWidgetId(), - Launcher.REQUEST_RECONFIGURE_APPWIDGET); + ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET); }); if (!hasSeenReconfigurableWidgetEducationTip()) { post(() -> { diff --git a/src/com/android/launcher3/DropTargetHandler.kt b/src/com/android/launcher3/DropTargetHandler.kt index 6560e16b52..9e2f364dde 100644 --- a/src/com/android/launcher3/DropTargetHandler.kt +++ b/src/com/android/launcher3/DropTargetHandler.kt @@ -3,6 +3,7 @@ package com.android.launcher3 import android.content.ComponentName import android.view.View import com.android.launcher3.DropTarget.DragObject +import com.android.launcher3.LauncherConstants.ActivityCodes import com.android.launcher3.SecondaryDropTarget.DeferredOnComplete import com.android.launcher3.dragndrop.DragLayer import com.android.launcher3.logging.StatsLogManager.LauncherEvent @@ -45,7 +46,7 @@ class DropTargetHandler(launcher: Launcher) { mLauncher.appWidgetHolder.startConfigActivity( mLauncher, widgetId, - Launcher.REQUEST_RECONFIGURE_APPWIDGET + ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET ) } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 7d6204594d..7de4de2671 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -33,6 +33,28 @@ import static com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FAC import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WIDGET_TRANSITION; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; import static com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_BIND_APPWIDGET; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_BIND_PENDING_APPWIDGET; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_CREATE_APPWIDGET; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_CREATE_SHORTCUT; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_PICK_APPWIDGET; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE_CURRENT_SCREEN_IDS; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE_PENDING_ACTIVITY_RESULT; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE_PENDING_REQUEST_ARGS; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE_PENDING_REQUEST_CODE; +import static com.android.launcher3.LauncherConstants.SavedInstanceKeys.RUNTIME_STATE_WIDGET_PANEL; +import static com.android.launcher3.LauncherConstants.TraceEvents.COLD_STARTUP_TRACE_COOKIE; +import static com.android.launcher3.LauncherConstants.TraceEvents.COLD_STARTUP_TRACE_METHOD_NAME; +import static com.android.launcher3.LauncherConstants.TraceEvents.DISPLAY_ALL_APPS_TRACE_COOKIE; +import static com.android.launcher3.LauncherConstants.TraceEvents.DISPLAY_ALL_APPS_TRACE_METHOD_NAME; +import static com.android.launcher3.LauncherConstants.TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME; +import static com.android.launcher3.LauncherConstants.TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE; +import static com.android.launcher3.LauncherConstants.TraceEvents.ON_CREATE_EVT; +import static com.android.launcher3.LauncherConstants.TraceEvents.ON_NEW_INTENT_EVT; +import static com.android.launcher3.LauncherConstants.TraceEvents.ON_RESUME_EVT; +import static com.android.launcher3.LauncherConstants.TraceEvents.ON_START_EVT; import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_DESKTOP; import static com.android.launcher3.LauncherSettings.Favorites.ITEM_TYPE_APPLICATION; import static com.android.launcher3.LauncherState.ALL_APPS; @@ -267,15 +289,6 @@ public class Launcher extends StatefulActivity static final boolean DEBUG_STRICT_MODE = false; - private static final int REQUEST_CREATE_SHORTCUT = 1; - private static final int REQUEST_CREATE_APPWIDGET = 5; - - private static final int REQUEST_PICK_APPWIDGET = 9; - - private static final int REQUEST_BIND_APPWIDGET = 11; - public static final int REQUEST_BIND_PENDING_APPWIDGET = 12; - public static final int REQUEST_RECONFIGURE_APPWIDGET = 13; - private static final float BOUNCE_ANIMATION_TENSION = 1.3f; /** @@ -284,30 +297,9 @@ public class Launcher extends StatefulActivity */ protected static final int REQUEST_LAST = 100; - // Type: int - protected static final String RUNTIME_STATE = "launcher.state"; - // Type: PendingRequestArgs - private static final String RUNTIME_STATE_PENDING_REQUEST_ARGS = "launcher.request_args"; - // Type: int - private static final String RUNTIME_STATE_PENDING_REQUEST_CODE = "launcher.request_code"; - // Type: ActivityResultInfo - private static final String RUNTIME_STATE_PENDING_ACTIVITY_RESULT = "launcher.activity_result"; - // Type: SparseArray - private static final String RUNTIME_STATE_WIDGET_PANEL = "launcher.widget_panel"; - // Type int[] - private static final String RUNTIME_STATE_CURRENT_SCREEN_IDS = "launcher.current_screen_ids"; - - // Type PendingSplitSelectInfo - protected static final String PENDING_SPLIT_SELECT_INFO = "launcher.pending_split_select_info"; - public static final String INTENT_ACTION_ALL_APPS_TOGGLE = "launcher.intent_action_all_apps_toggle"; - public static final String ON_CREATE_EVT = "Launcher.onCreate"; - public static final String ON_START_EVT = "Launcher.onStart"; - public static final String ON_RESUME_EVT = "Launcher.onResume"; - public static final String ON_NEW_INTENT_EVT = "Launcher.onNewIntent"; - private static boolean sIsNewProcess = true; private StateManager mStateManager; @@ -319,13 +311,6 @@ public class Launcher extends StatefulActivity private static final int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; @Thunk @VisibleForTesting public static final int NEW_APPS_ANIMATION_DELAY = 500; - private static final String DISPLAY_WORKSPACE_TRACE_METHOD_NAME = "DisplayWorkspaceFirstFrame"; - public static final String DISPLAY_ALL_APPS_TRACE_METHOD_NAME = "DisplayAllApps"; - public static final int DISPLAY_WORKSPACE_TRACE_COOKIE = 0; - public static final int DISPLAY_ALL_APPS_TRACE_COOKIE = 1; - private static final String COLD_STARTUP_TRACE_METHOD_NAME = "LauncherColdStartup"; - public static final int COLD_STARTUP_TRACE_COOKIE = 2; - private static final FloatProperty> WORKSPACE_WIDGET_SCALE = WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION); private static final FloatProperty HOTSEAT_WIDGET_SCALE = @@ -2806,10 +2791,8 @@ public class Launcher extends StatefulActivity Map packageUserKeytoUidMap) { mModelCallbacks.bindAllApplications(apps, flags, packageUserKeytoUidMap); if (Utilities.ATLEAST_S) { - Trace.endAsyncSection( - Launcher.DISPLAY_ALL_APPS_TRACE_METHOD_NAME, - Launcher.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/LauncherConstants.java b/src/com/android/launcher3/LauncherConstants.java new file mode 100644 index 0000000000..1abfeb902f --- /dev/null +++ b/src/com/android/launcher3/LauncherConstants.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3; + +public class LauncherConstants { + + /** + * Trace events to visualize using Systrace tool. + */ + public static class TraceEvents { + + public static final String DISPLAY_ALL_APPS_TRACE_METHOD_NAME = "DisplayAllApps"; + public static final int DISPLAY_WORKSPACE_TRACE_COOKIE = 0; + public static final int DISPLAY_ALL_APPS_TRACE_COOKIE = 1; + public static final int COLD_STARTUP_TRACE_COOKIE = 2; + public static final String ON_CREATE_EVT = "Launcher.onCreate"; + public static final String ON_START_EVT = "Launcher.onStart"; + public static final String ON_RESUME_EVT = "Launcher.onResume"; + public static final String ON_NEW_INTENT_EVT = "Launcher.onNewIntent"; + static final String DISPLAY_WORKSPACE_TRACE_METHOD_NAME = "DisplayWorkspaceFirstFrame"; + static final String COLD_STARTUP_TRACE_METHOD_NAME = "LauncherColdStartup"; + } + + /** + * This are the different codes the Launcher can receive when a new Launcher Intent is created. + */ + public static class ActivityCodes { + + public static final int REQUEST_BIND_PENDING_APPWIDGET = 12; + public static final int REQUEST_RECONFIGURE_APPWIDGET = 13; + static final int REQUEST_CREATE_SHORTCUT = 1; + static final int REQUEST_CREATE_APPWIDGET = 5; + static final int REQUEST_PICK_APPWIDGET = 9; + static final int REQUEST_BIND_APPWIDGET = 11; + } + + /** + * Keys used to get the saved values of the previous Activity instance. + */ + public static class SavedInstanceKeys { + + // Type: int + public static final String RUNTIME_STATE = "launcher.state"; + // Type PendingSplitSelectInfo + public static final String PENDING_SPLIT_SELECT_INFO = "launcher.pending_split_select_info"; + // Type: PendingRequestArgs + static final String RUNTIME_STATE_PENDING_REQUEST_ARGS = "launcher.request_args"; + // Type: int + static final String RUNTIME_STATE_PENDING_REQUEST_CODE = "launcher.request_code"; + // Type: ActivityResultInfo + static final String RUNTIME_STATE_PENDING_ACTIVITY_RESULT = "launcher.activity_result"; + // Type: SparseArray + static final String RUNTIME_STATE_WIDGET_PANEL = "launcher.widget_panel"; + // Type int[] + static final String RUNTIME_STATE_CURRENT_SCREEN_IDS = "launcher.current_screen_ids"; + } +} diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 8c12547bb5..db328290c4 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -15,8 +15,8 @@ */ package com.android.launcher3.touch; -import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET; -import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_BIND_PENDING_APPWIDGET; +import static com.android.launcher3.LauncherConstants.ActivityCodes.REQUEST_RECONFIGURE_APPWIDGET; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_FOLDER_OPEN; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_BY_PUBLISHER; import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_DISABLED_LOCKED_USER;