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

Commit d0aa8a37 authored by Winson Chung's avatar Winson Chung
Browse files

Fixing issue with screen-pinning for secondary users.

- Proxy the screen pinning request to the SystemUI for the primary user.

Bug: 19395305
Change-Id: I6252d4ee05b2bea4e76b2a4d0b903e2866fffa76
parent a9b33ddf
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import android.view.View;
import com.android.systemui.R;
import com.android.systemui.RecentsComponent;
import com.android.systemui.SystemUI;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.recents.misc.Console;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoadPlan;
@@ -53,6 +54,7 @@ import com.android.systemui.recents.views.TaskStackView;
import com.android.systemui.recents.views.TaskStackViewLayoutAlgorithm;
import com.android.systemui.recents.views.TaskViewHeader;
import com.android.systemui.recents.views.TaskViewTransform;
import com.android.systemui.statusbar.phone.PhoneStatusBar;

import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -79,6 +81,8 @@ public class Recents extends SystemUI
    // Owner proxy events
    final public static String ACTION_PROXY_NOTIFY_RECENTS_VISIBLITY_TO_OWNER =
            "action_notify_recents_visibility_change";
    final public static String ACTION_PROXY_SCREEN_PINNING_REQUEST_TO_OWNER =
            "action_screen_pinning_request";

    final public static String ACTION_START_ENTER_ANIMATION = "action_start_enter_animation";
    final public static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity";
@@ -148,6 +152,9 @@ public class Recents extends SystemUI
                case ACTION_PROXY_NOTIFY_RECENTS_VISIBLITY_TO_OWNER:
                    visibilityChanged(intent.getBooleanExtra(EXTRA_RECENTS_VISIBILITY, false));
                    break;
                case ACTION_PROXY_SCREEN_PINNING_REQUEST_TO_OWNER:
                    onStartScreenPinning(context);
                    break;
            }
        }
    }
@@ -234,6 +241,7 @@ public class Recents extends SystemUI
            mProxyBroadcastReceiver = new RecentsOwnerEventProxyReceiver();
            IntentFilter filter = new IntentFilter();
            filter.addAction(Recents.ACTION_PROXY_NOTIFY_RECENTS_VISIBLITY_TO_OWNER);
            filter.addAction(Recents.ACTION_PROXY_SCREEN_PINNING_REQUEST_TO_OWNER);
            mContext.registerReceiverAsUser(mProxyBroadcastReceiver, UserHandle.CURRENT, filter,
                    null, mHandler);
        }
@@ -801,6 +809,27 @@ public class Recents extends SystemUI
        }
    }

    /** Notifies the status bar to trigger screen pinning. */
    @ProxyFromAnyToPrimaryUser
    public static void startScreenPinning(Context context, SystemServicesProxy ssp) {
        if (ssp.isForegroundUserOwner()) {
            onStartScreenPinning(context);
        } else {
            Intent intent = createLocalBroadcastIntent(context,
                    ACTION_PROXY_SCREEN_PINNING_REQUEST_TO_OWNER);
            context.sendBroadcastAsUser(intent, UserHandle.OWNER);
        }
    }
    static void onStartScreenPinning(Context context) {
        // For the primary user, the context for the SystemUI component is the SystemUIApplication
        SystemUIApplication app = (SystemUIApplication)
                getInstanceAndStartIfNeeded(context).mContext;
        PhoneStatusBar statusBar = app.getComponent(PhoneStatusBar.class);
        if (statusBar != null) {
            statusBar.showScreenPinningRequest(false);
        }
    }

    /**
     * Returns the preloaded load plan and invalidates it.
     */
+3 −7
Original line number Diff line number Diff line
@@ -85,8 +85,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    // Runnables to finish the Recents activity
    FinishRecentsRunnable mFinishLaunchHomeRunnable;

    private PhoneStatusBar mStatusBar;

    /**
     * A common Runnable to finish Recents either by calling finish() (with a custom animation) or
     * launching Home with some ActivityOptions.  Generally we always launch home when we exit
@@ -381,8 +379,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        mEmptyViewStub = (ViewStub) findViewById(R.id.empty_view_stub);
        mDebugOverlayStub = (ViewStub) findViewById(R.id.debug_overlay_stub);
        mScrimViews = new SystemBarScrimViews(this, mConfig);
        mStatusBar = ((SystemUIApplication) getApplication())
                .getComponent(PhoneStatusBar.class);
        inflateDebugOverlay();

        // Bind the search app widget when we first start up
@@ -650,9 +646,9 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView

    @Override
    public void onScreenPinningRequest() {
        if (mStatusBar != null) {
            mStatusBar.showScreenPinningRequest(false);
        }
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        SystemServicesProxy ssp = loader.getSystemServicesProxy();
        Recents.startScreenPinning(this, ssp);
    }

    /**** RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks Implementation ****/