diff options
| author | 2022-01-25 16:10:47 -0500 | |
|---|---|---|
| committer | 2022-01-25 16:22:25 -0500 | |
| commit | d084d11bad4a0af048fd1a9e8d04d1231339230a (patch) | |
| tree | a450420cab3aacc3588018e0f5aa3502ec93a706 | |
| parent | 35216e0275a4a743bbeb7f1c02969174c89946c1 (diff) | |
More low-hanging Dependency#get calls.
Bug: 138786270
Test: manual
Change-Id: I147dbf27bfdaa2e4f78ac18e8dbf2713da0fdd73
7 files changed, 46 insertions, 34 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index fd37b3509a4e..21edb2478c79 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -52,7 +52,6 @@ import android.widget.LinearLayout; import android.widget.ScrollView; import com.android.internal.annotations.VisibleForTesting; -import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; import com.android.systemui.keyguard.WakefulnessLifecycle; @@ -106,7 +105,7 @@ public class AuthContainerView extends LinearLayout private final float mTranslationY; - @VisibleForTesting final WakefulnessLifecycle mWakefulnessLifecycle; + private final WakefulnessLifecycle mWakefulnessLifecycle; @VisibleForTesting @ContainerState int mContainerState = STATE_UNKNOWN; @@ -187,10 +186,12 @@ public class AuthContainerView extends LinearLayout public AuthContainerView build(int[] sensorIds, boolean credentialAllowed, @Nullable List<FingerprintSensorPropertiesInternal> fpProps, - @Nullable List<FaceSensorPropertiesInternal> faceProps) { + @Nullable List<FaceSensorPropertiesInternal> faceProps, + WakefulnessLifecycle wakefulnessLifecycle) { mConfig.mSensorIds = sensorIds; mConfig.mCredentialAllowed = credentialAllowed; - return new AuthContainerView(mConfig, new Injector(), fpProps, faceProps); + return new AuthContainerView( + mConfig, new Injector(), fpProps, faceProps, wakefulnessLifecycle); } } @@ -276,7 +277,8 @@ public class AuthContainerView extends LinearLayout @VisibleForTesting AuthContainerView(Config config, Injector injector, @Nullable List<FingerprintSensorPropertiesInternal> fpProps, - @Nullable List<FaceSensorPropertiesInternal> faceProps) { + @Nullable List<FaceSensorPropertiesInternal> faceProps, + WakefulnessLifecycle wakefulnessLifecycle) { super(config.mContext); mConfig = config; @@ -289,7 +291,7 @@ public class AuthContainerView extends LinearLayout mHandler = new Handler(Looper.getMainLooper()); mWindowManager = mContext.getSystemService(WindowManager.class); - mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class); + mWakefulnessLifecycle = wakefulnessLifecycle; mTranslationY = getResources() .getDimension(R.dimen.biometric_dialog_animation_translation_offset); diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java index 2b12f67acd5b..f833c2ad433b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java @@ -63,6 +63,7 @@ import com.android.systemui.assist.ui.DisplayUtils; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.doze.DozeReceiver; +import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.util.concurrency.Execution; @@ -130,6 +131,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser; private SensorPrivacyManager mSensorPrivacyManager; + private final WakefulnessLifecycle mWakefulnessLifecycle; private class BiometricTaskStackListener extends TaskStackListener { @Override @@ -479,9 +481,11 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba Provider<UdfpsController> udfpsControllerFactory, Provider<SidefpsController> sidefpsControllerFactory, @NonNull DisplayManager displayManager, + WakefulnessLifecycle wakefulnessLifecycle, @Main Handler handler) { super(context); mExecution = execution; + mWakefulnessLifecycle = wakefulnessLifecycle; mHandler = handler; mCommandQueue = commandQueue; mActivityTaskManager = activityTaskManager; @@ -788,7 +792,8 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba skipAnimation, operationId, requestId, - multiSensorConfig); + multiSensorConfig, + mWakefulnessLifecycle); if (newDialog == null) { Log.e(TAG, "Unsupported type configuration"); @@ -868,7 +873,8 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba protected AuthDialog buildDialog(PromptInfo promptInfo, boolean requireConfirmation, int userId, int[] sensorIds, boolean credentialAllowed, String opPackageName, boolean skipIntro, long operationId, long requestId, - @BiometricMultiSensorMode int multiSensorConfig) { + @BiometricMultiSensorMode int multiSensorConfig, + WakefulnessLifecycle wakefulnessLifecycle) { return new AuthContainerView.Builder(mContext) .setCallback(this) .setPromptInfo(promptInfo) @@ -879,7 +885,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba .setOperationId(operationId) .setRequestId(requestId) .setMultiSensorConfig(multiSensorConfig) - .build(sensorIds, credentialAllowed, mFpProps, mFaceProps); + .build(sensorIds, credentialAllowed, mFpProps, mFaceProps, wakefulnessLifecycle); } /** diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java index ad4a2f4c24b1..dbd641bffe7e 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java @@ -58,7 +58,6 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage; import com.android.settingslib.Utils; import com.android.settingslib.fuelgauge.BatterySaverUtils; import com.android.settingslib.utils.PowerUtil; -import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.SystemUIApplication; import com.android.systemui.dagger.SysUISingleton; @@ -421,7 +420,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(url)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - Dependency.get(ActivityStarter.class).startActivity(helpIntent, + mActivityStarter.startActivity(helpIntent, true /* dismissShade */, resultCode -> { mHighTempDialog = null; }); @@ -456,7 +455,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { new Intent(Intent.ACTION_VIEW) .setData(Uri.parse(url)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - Dependency.get(ActivityStarter.class).startActivity(helpIntent, + mActivityStarter.startActivity(helpIntent, true /* dismissShade */, resultCode -> { mThermalShutdownDialog = null; }); @@ -516,7 +515,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { helpIntent.setClassName("com.android.settings", "com.android.settings.HelpTrampoline"); helpIntent.putExtra(Intent.EXTRA_TEXT, contextString); - Dependency.get(ActivityStarter.class).startActivity(helpIntent, + mActivityStarter.startActivity(helpIntent, true /* dismissShade */, resultCode -> { mUsbHighTempDialog = null; }); diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java index 37a0f5949e16..642af593c211 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java @@ -43,7 +43,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.settingslib.fuelgauge.Estimate; import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.CoreStartable; -import com.android.systemui.Dependency; import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; @@ -80,13 +79,13 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks { @VisibleForTesting final Receiver mReceiver = new Receiver(); - private PowerManager mPowerManager; - private WarningsUI mWarnings; + private final PowerManager mPowerManager; + private final WarningsUI mWarnings; private InattentiveSleepWarningView mOverlayView; private final Configuration mLastConfiguration = new Configuration(); private int mPlugType = 0; private int mInvalidCharger = 0; - private EnhancedEstimates mEnhancedEstimates; + private final EnhancedEstimates mEnhancedEstimates; private Future mLastShowWarningTask; private boolean mEnableSkinTemperatureWarning; private boolean mEnableUsbTemperatureAlarm; @@ -113,18 +112,20 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks { @Inject public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher, - CommandQueue commandQueue, Lazy<Optional<StatusBar>> statusBarOptionalLazy) { + CommandQueue commandQueue, Lazy<Optional<StatusBar>> statusBarOptionalLazy, + WarningsUI warningsUI, EnhancedEstimates enhancedEstimates, + PowerManager powerManager) { super(context); mBroadcastDispatcher = broadcastDispatcher; mCommandQueue = commandQueue; mStatusBarOptionalLazy = statusBarOptionalLazy; + mWarnings = warningsUI; + mEnhancedEstimates = enhancedEstimates; + mPowerManager = powerManager; } public void start() { - mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE); mScreenOffTime = mPowerManager.isScreenOn() ? -1 : SystemClock.elapsedRealtime(); - mWarnings = Dependency.get(WarningsUI.class); - mEnhancedEstimates = Dependency.get(EnhancedEstimates.class); mLastConfiguration.setTo(mContext.getResources().getConfiguration()); ContentObserver obs = new ContentObserver(mHandler) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java index 0b399cf118b0..ae1268d48af9 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.java @@ -56,6 +56,7 @@ import android.widget.ImageView; import android.widget.ScrollView; import com.android.systemui.SysuiTestCase; +import com.android.systemui.keyguard.WakefulnessLifecycle; import org.junit.Before; import org.junit.Test; @@ -75,6 +76,7 @@ public class AuthContainerViewTest extends SysuiTestCase { private @Mock AuthDialogCallback mCallback; private @Mock UserManager mUserManager; + private @Mock WakefulnessLifecycle mWakefulnessLifecycle; @Before public void setup() { @@ -263,15 +265,17 @@ public class AuthContainerViewTest extends SysuiTestCase { componentInfo, FingerprintSensorProperties.TYPE_REAR, false /* resetLockoutRequiresHardwareAuthToken */)); - mAuthContainer = new TestableAuthContainer(config, fpProps, null /* faceProps */); + mAuthContainer = new TestableAuthContainer(config, fpProps, null /* faceProps */, + mWakefulnessLifecycle); } private class TestableAuthContainer extends AuthContainerView { TestableAuthContainer(AuthContainerView.Config config, @Nullable List<FingerprintSensorPropertiesInternal> fpProps, - @Nullable List<FaceSensorPropertiesInternal> faceProps) { + @Nullable List<FaceSensorPropertiesInternal> faceProps, + WakefulnessLifecycle wakefulnessLifecycle) { - super(config, new MockInjector(), fpProps, faceProps); + super(config, new MockInjector(), fpProps, faceProps, wakefulnessLifecycle); } @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java index 08c77146d34c..786f54782598 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthControllerTest.java @@ -69,6 +69,7 @@ import androidx.test.filters.SmallTest; import com.android.internal.R; import com.android.systemui.SysuiTestCase; +import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.util.concurrency.Execution; import com.android.systemui.util.concurrency.FakeExecution; @@ -117,6 +118,8 @@ public class AuthControllerTest extends SysuiTestCase { private SidefpsController mSidefpsController; @Mock private DisplayManager mDisplayManager; + @Mock + private WakefulnessLifecycle mWakefulnessLifecycle; @Captor ArgumentCaptor<IFingerprintAuthenticatorsRegisteredCallback> mAuthenticatorsRegisteredCaptor; @Captor @@ -677,14 +680,15 @@ public class AuthControllerTest extends SysuiTestCase { Provider<SidefpsController> sidefpsControllerFactory) { super(context, execution, commandQueue, activityTaskManager, windowManager, fingerprintManager, faceManager, udfpsControllerFactory, - sidefpsControllerFactory, mDisplayManager, mHandler); + sidefpsControllerFactory, mDisplayManager, mWakefulnessLifecycle, mHandler); } @Override protected AuthDialog buildDialog(PromptInfo promptInfo, boolean requireConfirmation, int userId, int[] sensorIds, boolean credentialAllowed, String opPackageName, boolean skipIntro, long operationId, long requestId, - @BiometricManager.BiometricMultiSensorMode int multiSensorConfig) { + @BiometricManager.BiometricMultiSensorMode int multiSensorConfig, + WakefulnessLifecycle wakefulnessLifecycle) { mLastBiometricPromptInfo = promptInfo; diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java index e73e5ff49dd2..721809c83cd8 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java @@ -28,7 +28,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.BroadcastReceiver; -import android.content.Context; import android.content.IntentFilter; import android.os.BatteryManager; import android.os.Handler; @@ -81,9 +80,9 @@ public class PowerUITest extends SysuiTestCase { private static final int OLD_BATTERY_LEVEL_10 = 10; private static final long VERY_BELOW_SEVERE_HYBRID_THRESHOLD = TimeUnit.MINUTES.toMillis(15); public static final int BATTERY_LEVEL_10 = 10; - private WarningsUI mMockWarnings; + @Mock private WarningsUI mMockWarnings; private PowerUI mPowerUI; - private EnhancedEstimates mEnhancedEstimates; + @Mock private EnhancedEstimates mEnhancedEstimates; @Mock private PowerManager mPowerManager; @Mock private IThermalService mThermalServiceMock; private IThermalEventListener mUsbThermalEventListener; @@ -96,13 +95,9 @@ public class PowerUITest extends SysuiTestCase { @Before public void setup() { MockitoAnnotations.initMocks(this); - mMockWarnings = mDependency.injectMockDependency(WarningsUI.class); - mEnhancedEstimates = mDependency.injectMockDependency(EnhancedEstimates.class); when(mStatusBarOptionalLazy.get()).thenReturn(Optional.of(mStatusBar)); - mContext.addMockSystemService(Context.POWER_SERVICE, mPowerManager); - createPowerUi(); mSkinThermalEventListener = mPowerUI.new SkinThermalEventListener(); mUsbThermalEventListener = mPowerUI.new UsbThermalEventListener(); @@ -690,7 +685,8 @@ public class PowerUITest extends SysuiTestCase { private void createPowerUi() { mPowerUI = new PowerUI( - mContext, mBroadcastDispatcher, mCommandQueue, mStatusBarOptionalLazy); + mContext, mBroadcastDispatcher, mCommandQueue, mStatusBarOptionalLazy, + mMockWarnings, mEnhancedEstimates, mPowerManager); mPowerUI.mThermalService = mThermalServiceMock; } |