diff options
| author | 2019-09-25 17:54:19 -0400 | |
|---|---|---|
| committer | 2019-09-27 16:40:47 -0400 | |
| commit | 898e1bbff398d5a306dd6ec58bd7e501d31d5e4c (patch) | |
| tree | 50afc33ea632bacdfa513dd97a45372ccec964e5 | |
| parent | 4bec4b2fd9e246476be840dc1f751e4cdc861a8d (diff) | |
Remove calls to Dependency.get(FalsingManager.class)
This removes all calls except one, which is used in a View.
Bug: 136279712
Test: atest SystemUITests
Change-Id: Ibadb81a41a4d23208842a99fa89436fd34b7a8a0
9 files changed, 92 insertions, 44 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 720074b0ad73..47d911df90a9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -2752,7 +2752,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private void checkIsHandlerThread() { if (!mHandler.getLooper().isCurrentThread()) { - Log.wtf(TAG, "must call on mHandler's thread " + Log.wtfStack(TAG, "must call on mHandler's thread " + mHandler.getLooper().getThread() + ", not " + Thread.currentThread()); } } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java index 0fa80aca97fb..d9b4297f2ae2 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java @@ -18,6 +18,8 @@ package com.android.systemui; import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.power.PowerUI; +import com.android.systemui.recents.Recents; +import com.android.systemui.recents.RecentsModule; import dagger.Binds; import dagger.Module; @@ -27,7 +29,7 @@ import dagger.multibindings.IntoMap; /** * SystemUI objects that are injectable should go here. */ -@Module +@Module(includes = {RecentsModule.class}) public abstract class SystemUIBinder { /** Inject into KeyguardViewMediator. */ @Binds @@ -40,4 +42,10 @@ public abstract class SystemUIBinder { @IntoMap @ClassKey(PowerUI.class) public abstract SystemUI bindPowerUI(PowerUI sysui); + + /** Inject into StatusBar. */ + @Binds + @IntoMap + @ClassKey(Recents.class) + public abstract SystemUI bindRecents(Recents sysui); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java index 0fc4fe72bd54..a1b4a93c454a 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java +++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java @@ -21,25 +21,30 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.provider.Settings; -import com.android.systemui.R; import com.android.systemui.SystemUI; import com.android.systemui.statusbar.CommandQueue; import java.io.FileDescriptor; import java.io.PrintWriter; +import javax.inject.Inject; + /** * A proxy to a Recents implementation. */ public class Recents extends SystemUI implements CommandQueue.Callbacks { - private RecentsImplementation mImpl; + private final RecentsImplementation mImpl; + + @Inject + public Recents(RecentsImplementation impl) { + mImpl = impl; + } @Override public void start() { getComponent(CommandQueue.class).addCallback(this); putComponent(Recents.class, this); - mImpl = createRecentsImplementationFromConfig(); mImpl.onStart(mContext, this); } @@ -139,28 +144,6 @@ public class Recents extends SystemUI implements CommandQueue.Callbacks { (Settings.Secure.getInt(cr, Settings.Secure.USER_SETUP_COMPLETE, 0) != 0); } - /** - * @return The recents implementation from the config. - */ - private RecentsImplementation createRecentsImplementationFromConfig() { - final String clsName = mContext.getString(R.string.config_recentsComponent); - if (clsName == null || clsName.length() == 0) { - throw new RuntimeException("No recents component configured", null); - } - Class<?> cls = null; - try { - cls = mContext.getClassLoader().loadClass(clsName); - } catch (Throwable t) { - throw new RuntimeException("Error loading recents component: " + clsName, t); - } - try { - RecentsImplementation impl = (RecentsImplementation) cls.newInstance(); - return impl; - } catch (Throwable t) { - throw new RuntimeException("Error creating recents component: " + clsName, t); - } - } - @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { mImpl.dump(pw); diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsModule.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsModule.java new file mode 100644 index 000000000000..55552850890f --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsModule.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.recents; + +import android.content.Context; + +import com.android.systemui.R; + +import dagger.Module; +import dagger.Provides; + +/** + * Dagger injection module for {@link RecentsImplementation} + */ +@Module +public class RecentsModule { + /** + * @return The {@link RecentsImplementation} from the config. + */ + @Provides + public RecentsImplementation provideRecentsImpl(Context context) { + final String clsName = context.getString(R.string.config_recentsComponent); + if (clsName == null || clsName.length() == 0) { + throw new RuntimeException("No recents component configured", null); + } + Class<?> cls = null; + try { + cls = context.getClassLoader().loadClass(clsName); + } catch (Throwable t) { + throw new RuntimeException("Error loading recents component: " + clsName, t); + } + try { + RecentsImplementation impl = (RecentsImplementation) cls.newInstance(); + return impl; + } catch (Throwable t) { + throw new RuntimeException("Error creating recents component: " + clsName, t); + } + } +} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt index a70dc7c0ec5d..e516af590e34 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/PulseExpansionHandler.kt @@ -27,7 +27,6 @@ import android.os.SystemClock import android.view.MotionEvent import android.view.VelocityTracker import android.view.ViewConfiguration -import com.android.systemui.Dependency import com.android.systemui.Gefingerpoken import com.android.systemui.Interpolators @@ -58,7 +57,8 @@ constructor( private val bypassController: KeyguardBypassController, private val headsUpManager: HeadsUpManagerPhone, private val roundnessManager: NotificationRoundnessManager, - private val statusBarStateController: StatusBarStateController + private val statusBarStateController: StatusBarStateController, + private val falsingManager: FalsingManager ) : Gefingerpoken { companion object { private val RUBBERBAND_FACTOR_STATIC = 0.25f @@ -99,7 +99,6 @@ constructor( private val mTemp2 = IntArray(2) private var mDraggedFarEnough: Boolean = false private var mStartingChild: ExpandableView? = null - private val mFalsingManager: FalsingManager private var mPulsing: Boolean = false var isWakingToShadeLocked: Boolean = false private set @@ -109,7 +108,7 @@ constructor( private var velocityTracker: VelocityTracker? = null private val isFalseTouch: Boolean - get() = mFalsingManager.isFalseTouch + get() = falsingManager.isFalseTouch var qsExpanded: Boolean = false var pulseExpandAbortListener: Runnable? = null var bouncerShowing: Boolean = false @@ -118,7 +117,6 @@ constructor( mMinDragDistance = context.resources.getDimensionPixelSize( R.dimen.keyguard_drag_down_min_distance) mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat() - mFalsingManager = Dependency.get(FalsingManager::class.java) mPowerManager = context.getSystemService(PowerManager::class.java) } @@ -151,7 +149,7 @@ constructor( MotionEvent.ACTION_MOVE -> { val h = y - mInitialTouchY if (h > mTouchSlop && h > Math.abs(x - mInitialTouchX)) { - mFalsingManager.onStartExpandingFromPulse() + falsingManager.onStartExpandingFromPulse() isExpanding = true captureStartingChild(mInitialTouchX, mInitialTouchY) mInitialTouchY = y @@ -192,7 +190,7 @@ constructor( velocityTracker!!.computeCurrentVelocity(1000 /* units */) val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000 && statusBarStateController.state != StatusBarState.SHADE - if (!mFalsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) { + if (!falsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) { finishExpansion() } else { cancelExpansion() @@ -297,7 +295,7 @@ constructor( private fun cancelExpansion() { isExpanding = false - mFalsingManager.onExpansionFromPulseStopped() + falsingManager.onExpansionFromPulseStopped() if (mStartingChild != null) { reset(mStartingChild!!) mStartingChild = null diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java index 8d7325118139..a817f54e77ca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ActivatableNotificationView.java @@ -180,6 +180,10 @@ public abstract class ActivatableNotificationView extends ExpandableOutlineView initDimens(); } + public FalsingManager getFalsingManager() { + return mFalsingManager; + } + private void updateColors() { mNormalColor = mContext.getColor(R.color.notification_material_background_color); mTintedRippleColor = mContext.getColor( diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java index 0f6ce2153488..9f4b026b3d38 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java @@ -74,7 +74,6 @@ import com.android.internal.widget.CachingIconView; import com.android.systemui.Dependency; import com.android.systemui.Interpolators; import com.android.systemui.R; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin; import com.android.systemui.plugins.statusbar.NotificationMenuRowPlugin.MenuItem; @@ -221,7 +220,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView private ViewStub mGutsStub; private boolean mIsSystemChildExpanded; private boolean mIsPinned; - private FalsingManager mFalsingManager; private boolean mExpandAnimationRunning; private AboveShelfChangedListener mAboveShelfChangedListener; private HeadsUpManager mHeadsUpManager; @@ -1636,7 +1634,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView public ExpandableNotificationRow(Context context, AttributeSet attrs) { super(context, attrs); - mFalsingManager = Dependency.get(FalsingManager.class); // TODO: inject into a controller. mNotificationInflater = new NotificationContentInflater(this); mMenuRow = new NotificationMenuRow(mContext); mImageResolver = new NotificationInlineImageResolver(context, @@ -2208,7 +2205,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView * @param allowChildExpansion whether a call to this method allows expanding children */ public void setUserExpanded(boolean userExpanded, boolean allowChildExpansion) { - mFalsingManager.setNotificationExpanded(); + getFalsingManager().setNotificationExpanded(); if (mIsSummaryWithChildren && !shouldShowPublic() && allowChildExpansion && !mChildrenContainer.showingAsLowPriority()) { final boolean wasExpanded = mGroupManager.isGroupExpanded(mStatusBarNotification); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 81501615ae2f..5fc2d9beab89 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -396,6 +396,8 @@ public class StatusBar extends SystemUI implements DemoMode, boolean mAllowNotificationLongPress; @Inject protected NotifPipelineInitializer mNotifPipelineInitializer; + @Inject + protected FalsingManager mFalsingManager; @VisibleForTesting BroadcastDispatcher mBroadcastDispatcher; @@ -587,7 +589,6 @@ public class StatusBar extends SystemUI implements DemoMode, } }; private boolean mNoAnimationOnNextBarModeChange; - protected FalsingManager mFalsingManager; private final SysuiStatusBarStateController mStatusBarStateController = (SysuiStatusBarStateController) Dependency.get(StatusBarStateController.class); @@ -719,7 +720,6 @@ public class StatusBar extends SystemUI implements DemoMode, mRecents = getComponent(Recents.class); mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); - mFalsingManager = Dependency.get(FalsingManager.class); // Connect in to the status bar manager service mCommandQueue = getComponent(CommandQueue.class); @@ -2448,7 +2448,7 @@ public class StatusBar extends SystemUI implements DemoMode, mKeyguardUpdateMonitor.dump(fd, pw, args); } - Dependency.get(FalsingManager.class).dump(pw); + mFalsingManager.dump(pw); FalsingLog.dump(pw); pw.println("SharedPreferences:"); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java index b5ef716904df..f1da4e8a2905 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/NotificationPanelViewTest.java @@ -41,6 +41,7 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SystemUIFactory; import com.android.systemui.SysuiTestCase; import com.android.systemui.doze.DozeLog; +import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.plugins.PluginManager; @@ -130,9 +131,13 @@ public class NotificationPanelViewTest extends SysuiTestCase { mock(HeadsUpManagerPhone.class), new StatusBarStateControllerImpl(), mKeyguardBypassController); - PulseExpansionHandler expansionHandler = new PulseExpansionHandler(mContext, coordinator, + PulseExpansionHandler expansionHandler = new PulseExpansionHandler( + mContext, + coordinator, mKeyguardBypassController, mHeadsUpManager, - mock(NotificationRoundnessManager.class), mStatusBarStateController); + mock(NotificationRoundnessManager.class), + mStatusBarStateController, + new FalsingManagerFake()); mNotificationPanelView = new TestableNotificationPanelView(coordinator, expansionHandler, mKeyguardBypassController); mNotificationPanelView.setHeadsUpManager(mHeadsUpManager); |