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

Commit 5bb61ba0 authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge changes from topic "activity-starter" into udc-dev

* changes:
  Add ActivityStarterImpl
  Add use_new_activity_starter feature flag
  Remove centralsurfaces activitystarter invocations
parents 53026af5 f3fc361a
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -102,6 +102,33 @@ public interface ActivityStarter {
    void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
            boolean afterKeyguardGone, @Nullable String customMessage);

    /** Starts an activity and dismisses keyguard. */
    void startActivityDismissingKeyguard(Intent intent,
            boolean onlyProvisioned,
            boolean dismissShade,
            boolean disallowEnterPictureInPictureWhileLaunching,
            Callback callback,
            int flags,
            @Nullable ActivityLaunchAnimator.Controller animationController,
            UserHandle userHandle);

    /** Execute a runnable after dismissing keyguard. */
    void executeRunnableDismissingKeyguard(Runnable runnable,
            Runnable cancelAction,
            boolean dismissShade,
            boolean afterKeyguardGone,
            boolean deferred);

    /** Execute a runnable after dismissing keyguard. */
    void executeRunnableDismissingKeyguard(
            Runnable runnable,
            Runnable cancelAction,
            boolean dismissShade,
            boolean afterKeyguardGone,
            boolean deferred,
            boolean willAnimateOnKeyguard,
            @Nullable String customMessage);

    interface Callback {
        void onActivityStarted(int resultCode);
    }
+41 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ import javax.inject.Inject;
/**
 * Single common instance of ActivityStarter that can be gotten and referenced from anywhere, but
 * delegates to an actual implementation (CentralSurfaces).
 *
 * @deprecated Migrating to ActivityStarterImpl
 */
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
@SysUISingleton
@@ -91,6 +93,14 @@ public class ActivityStarterDelegate implements ActivityStarter {
                starter -> starter.startActivity(intent, dismissShade));
    }

    @Override
    public void startActivity(Intent intent,
            boolean dismissShade,
            @Nullable ActivityLaunchAnimator.Controller animationController) {
        mActualStarterOptionalLazy.get().ifPresent(
                starter -> starter.startActivity(intent, dismissShade, animationController));
    }

    @Override
    public void startActivity(Intent intent, boolean dismissShade,
            @Nullable ActivityLaunchAnimator.Controller animationController,
@@ -177,4 +187,35 @@ public class ActivityStarterDelegate implements ActivityStarter {
                starter -> starter.dismissKeyguardThenExecute(action, cancel, afterKeyguardGone,
                        customMessage));
    }

    @Override
    public void startActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned,
            boolean dismissShade, boolean disallowEnterPictureInPictureWhileLaunching,
            Callback callback, int flags,
            @Nullable ActivityLaunchAnimator.Controller animationController,
            UserHandle userHandle) {
        mActualStarterOptionalLazy.get().ifPresent(
                starter -> starter.startActivityDismissingKeyguard(intent, onlyProvisioned,
                        dismissShade, disallowEnterPictureInPictureWhileLaunching, callback,
                        flags, animationController, userHandle));
    }

    @Override
    public void executeRunnableDismissingKeyguard(Runnable runnable,
            Runnable cancelAction, boolean dismissShade,
            boolean afterKeyguardGone, boolean deferred) {
        mActualStarterOptionalLazy.get().ifPresent(
                starter -> starter.executeRunnableDismissingKeyguard(runnable, cancelAction,
                        dismissShade, afterKeyguardGone, deferred));
    }

    @Override
    public void executeRunnableDismissingKeyguard(Runnable runnable, Runnable cancelAction,
            boolean dismissShade, boolean afterKeyguardGone, boolean deferred,
            boolean willAnimateOnKeyguard, @Nullable String customMessage) {
        mActualStarterOptionalLazy.get().ifPresent(
                starter -> starter.executeRunnableDismissingKeyguard(runnable, cancelAction,
                        dismissShade, afterKeyguardGone, deferred, willAnimateOnKeyguard,
                        customMessage));
    }
}
+8 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.dagger;

import com.android.systemui.ActivityStarterDelegate;
import com.android.systemui.classifier.FalsingManagerProxy;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.globalactions.GlobalActionsComponent;
import com.android.systemui.globalactions.GlobalActionsImpl;
import com.android.systemui.plugins.ActivityStarter;
@@ -28,6 +30,7 @@ import com.android.systemui.plugins.PluginDependencyProvider;
import com.android.systemui.plugins.VolumeDialogController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.phone.ActivityStarterImpl;
import com.android.systemui.statusbar.phone.DarkIconDispatcherImpl;
import com.android.systemui.volume.VolumeDialogControllerImpl;

@@ -46,7 +49,11 @@ public abstract class PluginModule {
    /** */
    @Provides
    static ActivityStarter provideActivityStarter(ActivityStarterDelegate delegate,
            PluginDependencyProvider dependencyProvider) {
            PluginDependencyProvider dependencyProvider, ActivityStarterImpl activityStarterImpl,
            FeatureFlags featureFlags) {
        if (featureFlags.isEnabled(Flags.USE_NEW_ACTIVITY_STARTER)) {
            return activityStarterImpl;
        }
        dependencyProvider.allowPluginDependency(ActivityStarter.class, delegate);
        return delegate;
    }
+4 −0
Original line number Diff line number Diff line
@@ -675,4 +675,8 @@ object Flags {
    @JvmField
    val ADVANCED_VPN_ENABLED = unreleasedFlag(2800, name = "AdvancedVpn__enable_feature",
            namespace = "vpn", teamfood = true)

    // TODO(b/278761837): Tracking Bug
    @JvmField
    val USE_NEW_ACTIVITY_STARTER = unreleasedFlag(2801, name = "use_new_activity_starter")
}
+7 −4
Original line number Diff line number Diff line
@@ -23,15 +23,16 @@ import android.os.RemoteException;
import android.util.Log;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.shared.recents.IOverviewProxy;
import com.android.systemui.statusbar.phone.CentralSurfaces;

import dagger.Lazy;

import java.util.Optional;

import javax.inject.Inject;

import dagger.Lazy;

/**
 * An implementation of the Recents interface which proxies to the OverviewProxyService.
 */
@@ -44,13 +45,15 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation {

    private Handler mHandler;
    private final OverviewProxyService mOverviewProxyService;
    private final ActivityStarter mActivityStarter;

    @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
    @Inject
    public OverviewProxyRecentsImpl(Lazy<Optional<CentralSurfaces>> centralSurfacesOptionalLazy,
            OverviewProxyService overviewProxyService) {
            OverviewProxyService overviewProxyService, ActivityStarter activityStarter) {
        mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy;
        mOverviewProxyService = overviewProxyService;
        mActivityStarter = activityStarter;
    }

    @Override
@@ -101,7 +104,7 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation {
            final Optional<CentralSurfaces> centralSurfacesOptional =
                    mCentralSurfacesOptionalLazy.get();
            if (centralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) {
                centralSurfacesOptional.get().executeRunnableDismissingKeyguard(
                mActivityStarter.executeRunnableDismissingKeyguard(
                        () -> mHandler.post(toggleRecents), null, true /* dismissShade */,
                        false /* afterKeyguardGone */,
                        true /* deferred */);
Loading