Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c00d9a4 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge changes I423d6df4,I7b8a079b

* changes:
  Piping animation signal to onboarding.
  Expose call to start screen pinning on a task.
parents e715ce13 8ae17be8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -30,6 +30,11 @@ interface ISystemUiProxy {
    GraphicBufferCompat screenshot(in Rect sourceCrop, int width, int height, int minLayer,
            int maxLayer, boolean useIdentityTransform, int rotation);

    /**
     * Begins screen pinning on the provided {@param taskId}.
     */
    void startScreenPinning(int taskId);

    /**
     * Called when the overview service has started the recents animation.
     */
+20 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.OverviewProxyService.OverviewProxyListener;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.shared.recents.ISystemUiProxy;
import com.android.systemui.shared.system.GraphicBufferCompat;
import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.CallbackController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceProvisionedListener;
@@ -67,6 +68,7 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
    private int mConnectionBackoffAttempts;

    private ISystemUiProxy mSysUiProxy = new ISystemUiProxy.Stub() {

        public GraphicBufferCompat screenshot(Rect sourceCrop, int width, int height, int minLayer,
                int maxLayer, boolean useIdentityTransform, int rotation) {
            long token = Binder.clearCallingIdentity();
@@ -78,10 +80,27 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
            }
        }

        public void startScreenPinning(int taskId) {
            long token = Binder.clearCallingIdentity();
            try {
                mHandler.post(() -> {
                    StatusBar statusBar = ((SystemUIApplication) mContext).getComponent(
                            StatusBar.class);
                    if (statusBar != null) {
                        statusBar.showScreenPinningRequest(taskId, false /* allowCancel */);
                    }
                });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
        }

        public void onRecentsAnimationStarted() {
            long token = Binder.clearCallingIdentity();
            try {
                mHandler.post(() -> {
                    notifyRecentsAnimationStarted();
                });
            } finally {
                Binder.restoreCallingIdentity(token);
            }
+13 −19
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ public class SwipeUpOnboarding {
    private final RippleDrawable mLightRipple;

    private boolean mTaskListenerRegistered;
    private ComponentName mLauncherComponent;
    private boolean mLayoutAttachedToWindow;
    private boolean mBackgroundIsLight;

@@ -91,18 +90,10 @@ public class SwipeUpOnboarding {
                } else {
                    Prefs.putInt(mContext, Prefs.Key.NUM_APPS_LAUNCHED, numAppsLaunched);
                }
            } else {
                String runningPackage = info.topActivity.getPackageName();
                // TODO: use callback from the overview proxy service to handle this case
                if (runningPackage.equals(mLauncherComponent.getPackageName())
                        && activityType == ACTIVITY_TYPE_RECENTS) {
                    Prefs.putBoolean(mContext, Prefs.Key.HAS_SWIPED_UP_FOR_RECENTS, true);
                    onDisconnectedFromLauncher();
            } else {
                hide(false);
            }
        }
        }
    };

    private final View.OnAttachStateChangeListener mOnAttachStateChangeListener
@@ -127,8 +118,8 @@ public class SwipeUpOnboarding {
        final Resources res = context.getResources();
        mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mLayout = LayoutInflater.from(mContext).inflate(R.layout.recents_swipe_up_onboarding, null);
        mTextView = (TextView) mLayout.findViewById(R.id.onboarding_text);
        mDismissView = (ImageView) mLayout.findViewById(R.id.dismiss);
        mTextView = mLayout.findViewById(R.id.onboarding_text);
        mDismissView = mLayout.findViewById(R.id.dismiss);
        mDarkBackgroundColor = res.getColor(android.R.color.background_dark);
        mLightBackgroundColor = res.getColor(android.R.color.background_light);
        mDarkContentColor = res.getColor(R.color.primary_text_default_material_light);
@@ -149,13 +140,7 @@ public class SwipeUpOnboarding {
        }
    }

    public void onConnectedToLauncher(ComponentName launcherComponent) {
        // TODO: re-enable this once we have the proper callback for when a swipe up was performed.
        final boolean disableOnboarding = true;
        if (disableOnboarding) {
            return;
        }
        mLauncherComponent = launcherComponent;
    public void onConnectedToLauncher() {
        boolean alreadyLearnedSwipeUpForRecents = Prefs.getBoolean(mContext,
                Prefs.Key.HAS_SWIPED_UP_FOR_RECENTS, false);
        if (!mTaskListenerRegistered && !alreadyLearnedSwipeUpForRecents) {
@@ -164,6 +149,15 @@ public class SwipeUpOnboarding {
        }
    }

    public void onRecentsAnimationStarted() {
        boolean alreadyLearnedSwipeUpForRecents = Prefs.getBoolean(mContext,
                Prefs.Key.HAS_SWIPED_UP_FOR_RECENTS, false);
        if (!alreadyLearnedSwipeUpForRecents) {
            Prefs.putBoolean(mContext, Prefs.Key.HAS_SWIPED_UP_FOR_RECENTS, true);
            onDisconnectedFromLauncher();
        }
    }

    public void onDisconnectedFromLauncher() {
        if (mTaskListenerRegistered) {
            ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mTaskListener);
+4 −1
Original line number Diff line number Diff line
@@ -218,6 +218,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        @Override
        public void onRecentsAnimationStarted() {
            mRecentsAnimationStarted = true;
            if (mSwipeUpOnboarding != null) {
                mSwipeUpOnboarding.onRecentsAnimationStarted();
            }
        }
    };

@@ -887,7 +890,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav

    private void setUpSwipeUpOnboarding(boolean connectedToOverviewProxy) {
        if (connectedToOverviewProxy) {
            mSwipeUpOnboarding.onConnectedToLauncher(mOverviewProxyService.getLauncherComponent());
            mSwipeUpOnboarding.onConnectedToLauncher();
        } else {
            mSwipeUpOnboarding.onDisconnectedFromLauncher();
        }