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

Commit d8b1d63f authored by Winson's avatar Winson
Browse files

Fixing issue with exit animation due to incorrect visibility state.

- This CL ensures that only Recents updates the SysUI visibility state
  for itself, ensuring that the visibility state reflects the state in
  Recents, and allows us to skip unnecessary work to close system
  dialogs when it is not required.

Bug: 26390248
Change-Id: Ib6301a8300cc3da6da75fcbbceceb0e1da3beab4
parent 982dcf3e
Loading
Loading
Loading
Loading
+20 −8
Original line number Original line Diff line number Diff line
@@ -77,6 +77,7 @@ import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.recents.views.ViewAnimation;
import com.android.systemui.recents.views.ViewAnimation;
import com.android.systemui.statusbar.BaseStatusBar;


import java.util.ArrayList;
import java.util.ArrayList;


@@ -298,12 +299,23 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
     */
     */
    void dismissRecentsToHome(boolean animated) {
    void dismissRecentsToHome(boolean animated) {
        if (animated) {
        if (animated) {
            ReferenceCountedTrigger exitTrigger = new ReferenceCountedTrigger(null,
            ReferenceCountedTrigger exitTrigger = new ReferenceCountedTrigger();
                    mFinishLaunchHomeRunnable, null);
            exitTrigger.increment();
            exitTrigger.addLastDecrementRunnable(mFinishLaunchHomeRunnable);
            exitTrigger.addLastDecrementRunnable(new Runnable() {
                @Override
                public void run() {
                    Recents.getSystemServices().sendCloseSystemWindows(
                            BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
                }
            });
            mRecentsView.startExitToHomeAnimation(
            mRecentsView.startExitToHomeAnimation(
                    new ViewAnimation.TaskViewExitContext(exitTrigger));
                    new ViewAnimation.TaskViewExitContext(exitTrigger));
            exitTrigger.decrement();
        } else {
        } else {
            mFinishLaunchHomeRunnable.run();
            mFinishLaunchHomeRunnable.run();
            Recents.getSystemServices().sendCloseSystemWindows(
                    BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
        }
        }
    }
    }


@@ -343,7 +355,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);
        EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);


        // Initialize the widget host (the host id is static and does not change)
        // Initialize the widget host (the host id is static and does not change)
        if (!RecentsDebugFlags.Static.DisableSearchBar) {
        if (RecentsDebugFlags.Static.EnableSearchBar) {
            mAppWidgetHost = new RecentsAppWidgetHost(this, RecentsAppWidgetHost.HOST_ID);
            mAppWidgetHost = new RecentsAppWidgetHost(this, RecentsAppWidgetHost.HOST_ID);
        }
        }
        mPackageMonitor = new RecentsPackageMonitor();
        mPackageMonitor = new RecentsPackageMonitor();
@@ -368,14 +380,14 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent);
        mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent);


        // Bind the search app widget when we first start up
        // Bind the search app widget when we first start up
        if (!RecentsDebugFlags.Static.DisableSearchBar) {
        if (RecentsDebugFlags.Static.EnableSearchBar) {
            mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost);
            mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost);
        }
        }


        // Register the broadcast receiver to handle messages when the screen is turned off
        // Register the broadcast receiver to handle messages when the screen is turned off
        IntentFilter filter = new IntentFilter();
        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        filter.addAction(Intent.ACTION_SCREEN_OFF);
        if (!RecentsDebugFlags.Static.DisableSearchBar) {
        if (RecentsDebugFlags.Static.EnableSearchBar) {
            filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
            filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
        }
        }
        registerReceiver(mSystemBroadcastReceiver, filter);
        registerReceiver(mSystemBroadcastReceiver, filter);
@@ -475,7 +487,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        mPackageMonitor.unregister();
        mPackageMonitor.unregister();


        // Stop listening for widget package changes if there was one bound
        // Stop listening for widget package changes if there was one bound
        if (!RecentsDebugFlags.Static.DisableSearchBar) {
        if (RecentsDebugFlags.Static.EnableSearchBar) {
            mAppWidgetHost.stopListening();
            mAppWidgetHost.stopListening();
        }
        }


@@ -656,8 +668,8 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        ReferenceCountedTrigger t = new ReferenceCountedTrigger();
        ReferenceCountedTrigger t = new ReferenceCountedTrigger();
        ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t);
        ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t);
        ctx.postAnimationTrigger.increment();
        ctx.postAnimationTrigger.increment();
        if (RecentsDebugFlags.Static.EnableSearchBar) {
            if (mSearchWidgetInfo != null) {
            if (mSearchWidgetInfo != null) {
            if (!RecentsDebugFlags.Static.DisableSearchBar) {
                ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
                ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
                    @Override
                    @Override
                    public void run() {
                    public void run() {
+2 −2
Original line number Original line Diff line number Diff line
@@ -32,8 +32,8 @@ public class RecentsDebugFlags implements TunerService.Tunable {
    public static class Static {
    public static class Static {
        // Enables debug drawing for the transition thumbnail
        // Enables debug drawing for the transition thumbnail
        public static final boolean EnableTransitionThumbnailDebugMode = false;
        public static final boolean EnableTransitionThumbnailDebugMode = false;
        // This disables the search bar integration
        // This enables the search bar integration
        public static final boolean DisableSearchBar = true;
        public static final boolean EnableSearchBar = false;
        // This disables the bitmap and icon caches
        // This disables the bitmap and icon caches
        public static final boolean DisableBackgroundCache = false;
        public static final boolean DisableBackgroundCache = false;
        // Enables the simulated task affiliations
        // Enables the simulated task affiliations
+17 −4
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.recents;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.ActivityOptions;
import android.app.ITaskStackListener;
import android.app.ITaskStackListener;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
@@ -60,6 +61,7 @@ import com.android.systemui.recents.views.TaskStackLayoutAlgorithm;
import com.android.systemui.recents.views.TaskStackView;
import com.android.systemui.recents.views.TaskStackView;
import com.android.systemui.recents.views.TaskViewHeader;
import com.android.systemui.recents.views.TaskViewHeader;
import com.android.systemui.recents.views.TaskViewTransform;
import com.android.systemui.recents.views.TaskViewTransform;
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.phone.PhoneStatusBar;
import com.android.systemui.statusbar.phone.PhoneStatusBar;


import java.util.ArrayList;
import java.util.ArrayList;
@@ -364,6 +366,9 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements


                // Otherwise, start the recents activity
                // Otherwise, start the recents activity
                startRecentsActivity(topTask, isTopTaskHome.value, true /* animate */);
                startRecentsActivity(topTask, isTopTaskHome.value, true /* animate */);

                // Only close the other system windows if we are actually showing recents
                ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
                mLastToggleTime = SystemClock.elapsedRealtime();
                mLastToggleTime = SystemClock.elapsedRealtime();
            }
            }
        } catch (ActivityNotFoundException e) {
        } catch (ActivityNotFoundException e) {
@@ -578,7 +583,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        // Update the configuration for the current state
        // Update the configuration for the current state
        config.update(windowRect);
        config.update(windowRect);


        if (!RecentsDebugFlags.Static.DisableSearchBar && tryAndBindSearchWidget) {
        if (RecentsDebugFlags.Static.EnableSearchBar && tryAndBindSearchWidget) {
            // Try and pre-emptively bind the search widget on startup to ensure that we
            // Try and pre-emptively bind the search widget on startup to ensure that we
            // have the right thumbnail bounds to animate to.
            // have the right thumbnail bounds to animate to.
            // Note: We have to reload the widget id before we get the task stack bounds below
            // Note: We have to reload the widget id before we get the task stack bounds below
@@ -854,11 +859,19 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
        if (!useThumbnailTransition) {
        if (!useThumbnailTransition) {
            // If there is no thumbnail transition, but is launching from home into recents, then
            // If there is no thumbnail transition, but is launching from home into recents, then
            // use a quick home transition and do the animation from home
            // use a quick home transition and do the animation from home
            if (!RecentsDebugFlags.Static.DisableSearchBar && hasRecentTasks) {
            if (hasRecentTasks) {
                SystemServicesProxy ssp = Recents.getSystemServices();
                SystemServicesProxy ssp = Recents.getSystemServices();
                String homeActivityPackage = ssp.getHomeActivityPackageName();
                String homeActivityPackage = ssp.getHomeActivityPackageName();
                String searchWidgetPackage = Prefs.getString(mContext,
                String searchWidgetPackage = null;
                if (RecentsDebugFlags.Static.EnableSearchBar) {
                    searchWidgetPackage = Prefs.getString(mContext,
                            Prefs.Key.OVERVIEW_SEARCH_APP_WIDGET_PACKAGE, null);
                            Prefs.Key.OVERVIEW_SEARCH_APP_WIDGET_PACKAGE, null);
                } else {
                    AppWidgetProviderInfo searchWidgetInfo = ssp.resolveSearchAppWidget();
                    if (searchWidgetInfo != null) {
                        searchWidgetPackage = searchWidgetInfo.provider.getPackageName();
                    }
                }


                // Determine whether we are coming from a search owned home activity
                // Determine whether we are coming from a search owned home activity
                boolean fromSearchHome = (homeActivityPackage != null) &&
                boolean fromSearchHome = (homeActivityPackage != null) &&
+15 −2
Original line number Original line Diff line number Diff line
@@ -68,6 +68,7 @@ import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.statusbar.BaseStatusBar;


import java.io.IOException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ArrayList;
@@ -501,6 +502,18 @@ public class SystemServicesProxy {
        });
        });
    }
    }


    /**
     * Sends a message to close other system windows.
     */
    public void sendCloseSystemWindows(String reason) {
        if (ActivityManagerNative.isSystemReady()) {
            try {
                ActivityManagerNative.getDefault().closeSystemDialogs(reason);
            } catch (RemoteException e) {
            }
        }
    }

    /**
    /**
     * Returns the activity info for a given component name.
     * Returns the activity info for a given component name.
     *
     *
@@ -638,7 +651,7 @@ public class SystemServicesProxy {
        if (mPm == null) return null;
        if (mPm == null) return null;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return null;
        if (RecentsDebugFlags.Static.EnableSystemServicesProxy) return null;


        ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
        ArrayList<ResolveInfo> homeActivities = new ArrayList<>();
        ComponentName defaultHomeActivity = mPm.getHomeActivities(homeActivities);
        ComponentName defaultHomeActivity = mPm.getHomeActivities(homeActivities);
        if (defaultHomeActivity != null) {
        if (defaultHomeActivity != null) {
            return defaultHomeActivity.getPackageName();
            return defaultHomeActivity.getPackageName();
@@ -726,7 +739,7 @@ public class SystemServicesProxy {
    /**
    /**
     * Returns the first Recents widget from the same package as the global assist activity.
     * Returns the first Recents widget from the same package as the global assist activity.
     */
     */
    private AppWidgetProviderInfo resolveSearchAppWidget() {
    public AppWidgetProviderInfo resolveSearchAppWidget() {
        if (mAssistComponent == null) return null;
        if (mAssistComponent == null) return null;
        List<AppWidgetProviderInfo> widgets = mAwm.getInstalledProviders(
        List<AppWidgetProviderInfo> widgets = mAwm.getInstalledProviders(
                AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX);
                AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX);
+2 −2
Original line number Original line Diff line number Diff line
@@ -317,7 +317,7 @@ public class RecentsView extends FrameLayout {
     * Hides the task stack and shows the empty view.
     * Hides the task stack and shows the empty view.
     */
     */
    public void showEmptyView() {
    public void showEmptyView() {
        if (!RecentsDebugFlags.Static.DisableSearchBar && (mSearchBar != null)) {
        if (RecentsDebugFlags.Static.EnableSearchBar && (mSearchBar != null)) {
            mSearchBar.setVisibility(View.INVISIBLE);
            mSearchBar.setVisibility(View.INVISIBLE);
        }
        }
        mTaskStackView.setVisibility(View.INVISIBLE);
        mTaskStackView.setVisibility(View.INVISIBLE);
@@ -332,7 +332,7 @@ public class RecentsView extends FrameLayout {
    public void hideEmptyView() {
    public void hideEmptyView() {
        mEmptyView.setVisibility(View.INVISIBLE);
        mEmptyView.setVisibility(View.INVISIBLE);
        mTaskStackView.setVisibility(View.VISIBLE);
        mTaskStackView.setVisibility(View.VISIBLE);
        if (!RecentsDebugFlags.Static.DisableSearchBar && (mSearchBar != null)) {
        if (RecentsDebugFlags.Static.EnableSearchBar && (mSearchBar != null)) {
            mSearchBar.setVisibility(View.VISIBLE);
            mSearchBar.setVisibility(View.VISIBLE);
        }
        }
        mTaskStackView.bringToFront();
        mTaskStackView.bringToFront();
Loading