Merge "Revert "Revert "Synchronizing loader preload to avoid launcher getting stuck in loading state,""" into ub-launcher3-master
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index f508eab..d1ac936 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java b/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java
index e39430d..bf55bd6 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/EdgeSwipeController.java
@@ -24,6 +24,7 @@
import static com.android.quickstep.TouchInteractionService.EDGE_NAV_BAR;
import android.graphics.Rect;
+import android.metrics.LogMaker;
import android.view.MotionEvent;
import com.android.launcher3.DeviceProfile;
@@ -34,6 +35,40 @@
import com.android.launcher3.util.VerticalSwipeController;
import com.android.quickstep.RecentsView;
+class EventLogTags {
+ private EventLogTags() {
+ } // don't instantiate
+
+ /** 524292 sysui_multi_action (content|4) */
+ public static final int SYSUI_MULTI_ACTION = 524292;
+
+ public static void writeSysuiMultiAction(Object[] content) {
+ android.util.EventLog.writeEvent(SYSUI_MULTI_ACTION, content);
+ }
+}
+
+class MetricsLogger {
+ private static MetricsLogger sMetricsLogger;
+
+ private static MetricsLogger getLogger() {
+ if (sMetricsLogger == null) {
+ sMetricsLogger = new MetricsLogger();
+ }
+ return sMetricsLogger;
+ }
+
+ protected void saveLog(Object[] rep) {
+ EventLogTags.writeSysuiMultiAction(rep);
+ }
+
+ public void write(LogMaker content) {
+ if (content.getType() == 0/*MetricsEvent.TYPE_UNKNOWN*/) {
+ content.setType(4/*MetricsEvent.TYPE_ACTION*/);
+ }
+ saveLog(content.serialize());
+ }
+}
+
/**
* Extension of {@link VerticalSwipeController} to go from NORMAL to OVERVIEW.
*/
@@ -42,6 +77,8 @@
private static final Rect sTempRect = new Rect();
+ private final MetricsLogger mMetricsLogger = new MetricsLogger();
+
public EdgeSwipeController(Launcher l) {
super(l, NORMAL, OVERVIEW, l.getDeviceProfile().isVerticalBarLayout()
? HORIZONTAL : VERTICAL);
@@ -70,6 +107,17 @@
@Override
protected void onTransitionComplete(boolean wasFling, boolean stateChanged) {
+ if (stateChanged && mToState instanceof OverviewState) {
+ // Mimic ActivityMetricsLogger.logAppTransitionMultiEvents() logging for
+ // "Recents" activity for app transition tests.
+ final LogMaker builder = new LogMaker(761/*APP_TRANSITION*/);
+ builder.setPackageName("com.android.systemui");
+ builder.addTaggedData(871/*FIELD_CLASS_NAME*/,
+ "com.android.systemui.recents.RecentsActivity");
+ builder.addTaggedData(319/*APP_TRANSITION_DELAY_MS*/,
+ 0/* zero time */);
+ mMetricsLogger.write(builder);
+ }
// TODO: Log something
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
index b4f40c2..92b38fe 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,12 +16,11 @@
package com.android.launcher3.uioverrides;
-import android.content.pm.PackageManager;
+import static com.android.launcher3.LauncherState.NORMAL;
+
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PointF;
-import android.os.Bundle;
-import android.view.View;
import android.view.View.AccessibilityDelegate;
import com.android.launcher3.Launcher;
@@ -29,6 +28,7 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.graphics.BitmapRenderer;
import com.android.launcher3.util.TouchController;
+import com.android.quickstep.OverviewInteractionState;
import com.android.quickstep.RecentsView;
import com.android.systemui.shared.recents.view.RecentsTransition;
@@ -68,6 +68,11 @@
OptionsPopupView.show(launcher, touchPoint.x, touchPoint.y);
}
+ public static void onLauncherStateOrFocusChanged(Launcher launcher) {
+ OverviewInteractionState.setBackButtonVisible(launcher, !launcher.isInState(NORMAL)
+ || !launcher.hasWindowFocus());
+ }
+
public static Bitmap createFromRenderer(int width, int height, boolean forceSoftwareRenderer,
BitmapRenderer renderer) {
if (USE_HARDWARE_BITMAP && !forceSoftwareRenderer) {
diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
new file mode 100644
index 0000000..9be12bd
--- /dev/null
+++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 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.quickstep;
+
+import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_HIDE_BACK_BUTTON;
+
+import android.content.Context;
+import android.os.RemoteException;
+import android.util.Log;
+
+import com.android.systemui.shared.recents.ISystemUiProxy;
+
+/**
+ * Sets overview interaction flags, such as:
+ *
+ * - FLAG_DISABLE_QUICK_SCRUB
+ * - FLAG_DISABLE_SWIPE_UP
+ * - FLAG_HIDE_BACK_BUTTON
+ * - FLAG_SHOW_OVERVIEW_BUTTON
+ *
+ * @see com.android.systemui.shared.system.NavigationBarCompat.InteractionType and associated flags.
+ */
+public class OverviewInteractionState {
+
+ private static final String TAG = "OverviewFlags";
+
+ private static int sFlags;
+
+ public static void setBackButtonVisible(Context context, boolean visible) {
+ updateOverviewInteractionFlag(context, FLAG_HIDE_BACK_BUTTON, !visible);
+ }
+
+ private static void updateOverviewInteractionFlag(Context context, int flag, boolean enabled) {
+ if (enabled) {
+ sFlags |= flag;
+ } else {
+ sFlags &= ~flag;
+ }
+
+ ISystemUiProxy systemUiProxy = RecentsModel.getInstance(context).getSystemUiProxy();
+ if (systemUiProxy == null) {
+ Log.w(TAG, "Unable to update overview interaction flags; not bound to service");
+ return;
+ }
+ try {
+ systemUiProxy.setInteractionState(sFlags);
+ } catch (RemoteException e) {
+ Log.w(TAG, "Unable to update overview interaction flags", e);
+ }
+ }
+}
diff --git a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
index d09daed..bbd90cb 100644
--- a/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
+++ b/quickstep/src/com/android/quickstep/WindowTransformSwipeHandler.java
@@ -33,6 +33,7 @@
import android.annotation.TargetApi;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.Context;
+import android.content.pm.ActivityInfo;
import android.content.res.Resources;
import android.graphics.Matrix;
import android.graphics.Point;
@@ -280,6 +281,10 @@
mWasLauncherAlreadyVisible = alreadyOnHome;
mLauncher = launcher;
+ // For the duration of the gesture, lock the screen orientation to ensure that we do not
+ // rotate mid-quickscrub
+ mLauncher.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
+
LauncherState startState = mLauncher.getStateManager().getState();
if (startState.disableRestore) {
startState = mLauncher.getStateManager().getRestState();
@@ -616,6 +621,9 @@
mLauncherTransitionController = null;
mLauncherLayoutListener.setHandler(null);
mLauncherLayoutListener.close(false);
+
+ // Restore the requested orientation to the user preference after the gesture has ended
+ mLauncher.updateRequestedOrientation();
}
public void layoutListenerClosed() {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 7905ed0..b4093b7 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -371,11 +371,7 @@
// For handling default keys
setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);
- // On large interfaces, or on devices that a user has specifically enabled screen rotation,
- // we want the screen to auto-rotate based on the current orientation
- setRequestedOrientation(mRotationEnabled
- ? SCREEN_ORIENTATION_UNSPECIFIED : SCREEN_ORIENTATION_NOSENSOR);
-
+ updateRequestedOrientation();
setContentView(mLauncherView);
getRootView().dispatchInsets();
@@ -398,6 +394,13 @@
TraceHelper.endSection("Launcher-onCreate");
}
+ public void updateRequestedOrientation() {
+ // On large interfaces, or on devices that a user has specifically enabled screen rotation,
+ // we want the screen to auto-rotate based on the current orientation
+ setRequestedOrientation(mRotationEnabled
+ ? SCREEN_ORIENTATION_UNSPECIFIED : SCREEN_ORIENTATION_NOSENSOR);
+ }
+
@Override
public void onConfigurationChanged(Configuration newConfig) {
int diff = newConfig.diff(mOldConfig);
@@ -855,6 +858,12 @@
}
}
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+ mStateManager.onWindowFocusChanged();
+ }
+
public interface LauncherOverlay {
/**
diff --git a/src/com/android/launcher3/LauncherStateManager.java b/src/com/android/launcher3/LauncherStateManager.java
index 6050d15..e0b84bf 100644
--- a/src/com/android/launcher3/LauncherStateManager.java
+++ b/src/com/android/launcher3/LauncherStateManager.java
@@ -303,6 +303,12 @@
if (state == NORMAL) {
setRestState(null);
}
+
+ UiFactory.onLauncherStateOrFocusChanged(mLauncher);
+ }
+
+ public void onWindowFocusChanged() {
+ UiFactory.onLauncherStateOrFocusChanged(mLauncher);
}
public LauncherState getLastState() {
diff --git a/src/com/android/launcher3/util/VerticalSwipeController.java b/src/com/android/launcher3/util/VerticalSwipeController.java
index 735fb2f..a647378 100644
--- a/src/com/android/launcher3/util/VerticalSwipeController.java
+++ b/src/com/android/launcher3/util/VerticalSwipeController.java
@@ -62,7 +62,7 @@
private boolean mNoIntercept;
private AnimatorPlaybackController mCurrentAnimation;
- private LauncherState mToState;
+ protected LauncherState mToState;
private float mStartProgress;
// Ratio of transition process [0, 1] to drag displacement (px)
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
index 744125e..64a29ea 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java
@@ -16,6 +16,7 @@
package com.android.launcher3.uioverrides;
+import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.LauncherState.OVERVIEW;
import android.graphics.Bitmap;
@@ -61,4 +62,6 @@
}
public static void resetOverview(Launcher launcher) { }
+
+ public static void onLauncherStateOrFocusChanged(Launcher launcher) { }
}