diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java index f389df097d7d2..5ea1c0b4ce852 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java @@ -17,13 +17,11 @@ package com.android.systemui.recents; import android.annotation.Nullable; -import android.app.trust.TrustManager; import android.content.Context; import android.os.Handler; import android.os.RemoteException; import android.util.Log; -import com.android.systemui.Dependency; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.shared.recents.IOverviewProxy; import com.android.systemui.statusbar.phone.CentralSurfaces; @@ -44,23 +42,20 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { @Nullable private final Lazy> mCentralSurfacesOptionalLazy; - private Context mContext; private Handler mHandler; - private TrustManager mTrustManager; - private OverviewProxyService mOverviewProxyService; + private final OverviewProxyService mOverviewProxyService; @SuppressWarnings("OptionalUsedAsFieldOrParameterType") @Inject - public OverviewProxyRecentsImpl(Lazy> centralSurfacesOptionalLazy) { + public OverviewProxyRecentsImpl(Lazy> centralSurfacesOptionalLazy, + OverviewProxyService overviewProxyService) { mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; + mOverviewProxyService = overviewProxyService; } @Override public void onStart(Context context) { - mContext = context; mHandler = new Handler(); - mTrustManager = (TrustManager) context.getSystemService(Context.TRUST_SERVICE); - mOverviewProxyService = Dependency.get(OverviewProxyService.class); } @Override @@ -69,12 +64,9 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { if (overviewProxy != null) { try { overviewProxy.onOverviewShown(triggeredFromAltTab); - return; } catch (RemoteException e) { Log.e(TAG, "Failed to send overview show event to launcher.", e); } - } else { - // Do nothing } } @@ -84,12 +76,9 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { if (overviewProxy != null) { try { overviewProxy.onOverviewHidden(triggeredFromAltTab, triggeredFromHomeKey); - return; } catch (RemoteException e) { Log.e(TAG, "Failed to send overview hide event to launcher.", e); } - } else { - // Do nothing } } @@ -112,16 +101,13 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation { final Optional centralSurfacesOptional = mCentralSurfacesOptionalLazy.get(); if (centralSurfacesOptional.map(CentralSurfaces::isKeyguardShowing).orElse(false)) { - centralSurfacesOptional.get().executeRunnableDismissingKeyguard(() -> { - mHandler.post(toggleRecents); - }, null, true /* dismissShade */, false /* afterKeyguardGone */, - true /* deferred */); + centralSurfacesOptional.get().executeRunnableDismissingKeyguard( + () -> mHandler.post(toggleRecents), null, true /* dismissShade */, + false /* afterKeyguardGone */, + true /* deferred */); } else { toggleRecents.run(); } - return; - } else { - // Do nothing } } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java index c272602e33879..06c80a1ca57d1 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java +++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java @@ -49,7 +49,6 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.navigationbar.NavigationBarView; @@ -74,26 +73,28 @@ public class ScreenPinningRequest implements View.OnClickListener, private final AccessibilityManager mAccessibilityService; private final WindowManager mWindowManager; - private final OverviewProxyService mOverviewProxyService; + private final BroadcastDispatcher mBroadcastDispatcher; private RequestWindowView mRequestWindow; private int mNavBarMode; - // Id of task to be pinned or locked. + /** ID of task to be pinned or locked. */ private int taskId; @Inject public ScreenPinningRequest( Context context, - Lazy> centralSurfacesOptionalLazy) { + Lazy> centralSurfacesOptionalLazy, + NavigationModeController navigationModeController, + BroadcastDispatcher broadcastDispatcher) { mContext = context; mCentralSurfacesOptionalLazy = centralSurfacesOptionalLazy; mAccessibilityService = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - mOverviewProxyService = Dependency.get(OverviewProxyService.class); - mNavBarMode = Dependency.get(NavigationModeController.class).addListener(this); + mNavBarMode = navigationModeController.addListener(this); + mBroadcastDispatcher = broadcastDispatcher; } public void clearPrompt() { @@ -172,13 +173,10 @@ public class ScreenPinningRequest implements View.OnClickListener, private static final int OFFSET_DP = 96; private final ColorDrawable mColor = new ColorDrawable(0); - private ValueAnimator mColorAnim; private ViewGroup mLayout; - private boolean mShowCancel; - private final BroadcastDispatcher mBroadcastDispatcher = - Dependency.get(BroadcastDispatcher.class); + private final boolean mShowCancel; - public RequestWindowView(Context context, boolean showCancel) { + private RequestWindowView(Context context, boolean showCancel) { super(context); setClickable(true); setOnClickListener(ScreenPinningRequest.this); @@ -213,16 +211,16 @@ public class ScreenPinningRequest implements View.OnClickListener, .setInterpolator(new DecelerateInterpolator()) .start(); - mColorAnim = ValueAnimator.ofObject(new ArgbEvaluator(), 0, bgColor); - mColorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { + ValueAnimator colorAnim = ValueAnimator.ofObject(new ArgbEvaluator(), 0, bgColor); + colorAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { final int c = (Integer) animation.getAnimatedValue(); mColor.setColor(c); } }); - mColorAnim.setDuration(1000); - mColorAnim.start(); + colorAnim.setDuration(1000); + colorAnim.start(); } else { mColor.setColor(bgColor); } @@ -382,5 +380,4 @@ public class ScreenPinningRequest implements View.OnClickListener, } }; } - }