Merge "More low-hanging Dependency#get calls."

This commit is contained in:
TreeHugger Robot
2022-01-26 16:51:41 +00:00
committed by Android (Google) Code Review
7 changed files with 46 additions and 34 deletions

View File

@@ -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);

View File

@@ -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);
}
/**

View File

@@ -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;
});

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
}