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

Commit d084d11b authored by Dave Mankoff's avatar Dave Mankoff
Browse files

More low-hanging Dependency#get calls.

Bug: 138786270
Test: manual
Change-Id: I147dbf27bfdaa2e4f78ac18e8dbf2713da0fdd73
parent 35216e02
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.ScrollView;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -106,7 +105,7 @@ public class AuthContainerView extends LinearLayout


    private final float mTranslationY;
    private final float mTranslationY;


    @VisibleForTesting final WakefulnessLifecycle mWakefulnessLifecycle;
    private final WakefulnessLifecycle mWakefulnessLifecycle;


    @VisibleForTesting @ContainerState int mContainerState = STATE_UNKNOWN;
    @VisibleForTesting @ContainerState int mContainerState = STATE_UNKNOWN;


@@ -187,10 +186,12 @@ public class AuthContainerView extends LinearLayout


        public AuthContainerView build(int[] sensorIds, boolean credentialAllowed,
        public AuthContainerView build(int[] sensorIds, boolean credentialAllowed,
                @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
                @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
                @Nullable List<FaceSensorPropertiesInternal> faceProps) {
                @Nullable List<FaceSensorPropertiesInternal> faceProps,
                WakefulnessLifecycle wakefulnessLifecycle) {
            mConfig.mSensorIds = sensorIds;
            mConfig.mSensorIds = sensorIds;
            mConfig.mCredentialAllowed = credentialAllowed;
            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
    @VisibleForTesting
    AuthContainerView(Config config, Injector injector,
    AuthContainerView(Config config, Injector injector,
            @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
            @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
            @Nullable List<FaceSensorPropertiesInternal> faceProps) {
            @Nullable List<FaceSensorPropertiesInternal> faceProps,
            WakefulnessLifecycle wakefulnessLifecycle) {
        super(config.mContext);
        super(config.mContext);


        mConfig = config;
        mConfig = config;
@@ -289,7 +291,7 @@ public class AuthContainerView extends LinearLayout


        mHandler = new Handler(Looper.getMainLooper());
        mHandler = new Handler(Looper.getMainLooper());
        mWindowManager = mContext.getSystemService(WindowManager.class);
        mWindowManager = mContext.getSystemService(WindowManager.class);
        mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
        mWakefulnessLifecycle = wakefulnessLifecycle;


        mTranslationY = getResources()
        mTranslationY = getResources()
                .getDimension(R.dimen.biometric_dialog_animation_translation_offset);
                .getDimension(R.dimen.biometric_dialog_animation_translation_offset);
+9 −3
Original line number Original line Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.systemui.assist.ui.DisplayUtils;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.doze.DozeReceiver;
import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.util.concurrency.Execution;
import com.android.systemui.util.concurrency.Execution;


@@ -130,6 +131,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba


    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;
    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;
    private SensorPrivacyManager mSensorPrivacyManager;
    private SensorPrivacyManager mSensorPrivacyManager;
    private final WakefulnessLifecycle mWakefulnessLifecycle;


    private class BiometricTaskStackListener extends TaskStackListener {
    private class BiometricTaskStackListener extends TaskStackListener {
        @Override
        @Override
@@ -479,9 +481,11 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
            Provider<UdfpsController> udfpsControllerFactory,
            Provider<UdfpsController> udfpsControllerFactory,
            Provider<SidefpsController> sidefpsControllerFactory,
            Provider<SidefpsController> sidefpsControllerFactory,
            @NonNull DisplayManager displayManager,
            @NonNull DisplayManager displayManager,
            WakefulnessLifecycle wakefulnessLifecycle,
            @Main Handler handler) {
            @Main Handler handler) {
        super(context);
        super(context);
        mExecution = execution;
        mExecution = execution;
        mWakefulnessLifecycle = wakefulnessLifecycle;
        mHandler = handler;
        mHandler = handler;
        mCommandQueue = commandQueue;
        mCommandQueue = commandQueue;
        mActivityTaskManager = activityTaskManager;
        mActivityTaskManager = activityTaskManager;
@@ -788,7 +792,8 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
                skipAnimation,
                skipAnimation,
                operationId,
                operationId,
                requestId,
                requestId,
                multiSensorConfig);
                multiSensorConfig,
                mWakefulnessLifecycle);


        if (newDialog == null) {
        if (newDialog == null) {
            Log.e(TAG, "Unsupported type configuration");
            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,
    protected AuthDialog buildDialog(PromptInfo promptInfo, boolean requireConfirmation,
            int userId, int[] sensorIds, boolean credentialAllowed, String opPackageName,
            int userId, int[] sensorIds, boolean credentialAllowed, String opPackageName,
            boolean skipIntro, long operationId, long requestId,
            boolean skipIntro, long operationId, long requestId,
            @BiometricMultiSensorMode int multiSensorConfig) {
            @BiometricMultiSensorMode int multiSensorConfig,
            WakefulnessLifecycle wakefulnessLifecycle) {
        return new AuthContainerView.Builder(mContext)
        return new AuthContainerView.Builder(mContext)
                .setCallback(this)
                .setCallback(this)
                .setPromptInfo(promptInfo)
                .setPromptInfo(promptInfo)
@@ -879,7 +885,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
                .setOperationId(operationId)
                .setOperationId(operationId)
                .setRequestId(requestId)
                .setRequestId(requestId)
                .setMultiSensorConfig(multiSensorConfig)
                .setMultiSensorConfig(multiSensorConfig)
                .build(sensorIds, credentialAllowed, mFpProps, mFaceProps);
                .build(sensorIds, credentialAllowed, mFpProps, mFaceProps, wakefulnessLifecycle);
    }
    }


    /**
    /**
+3 −4
Original line number Original line Diff line number Diff line
@@ -58,7 +58,6 @@ import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.settingslib.Utils;
import com.android.settingslib.Utils;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
import com.android.settingslib.fuelgauge.BatterySaverUtils;
import com.android.settingslib.utils.PowerUtil;
import com.android.settingslib.utils.PowerUtil;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.SysUISingleton;
@@ -421,7 +420,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                                    new Intent(Intent.ACTION_VIEW)
                                    new Intent(Intent.ACTION_VIEW)
                                            .setData(Uri.parse(url))
                                            .setData(Uri.parse(url))
                                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            Dependency.get(ActivityStarter.class).startActivity(helpIntent,
                            mActivityStarter.startActivity(helpIntent,
                                    true /* dismissShade */, resultCode -> {
                                    true /* dismissShade */, resultCode -> {
                                        mHighTempDialog = null;
                                        mHighTempDialog = null;
                                    });
                                    });
@@ -456,7 +455,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                                    new Intent(Intent.ACTION_VIEW)
                                    new Intent(Intent.ACTION_VIEW)
                                            .setData(Uri.parse(url))
                                            .setData(Uri.parse(url))
                                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                            .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                            Dependency.get(ActivityStarter.class).startActivity(helpIntent,
                            mActivityStarter.startActivity(helpIntent,
                                    true /* dismissShade */, resultCode -> {
                                    true /* dismissShade */, resultCode -> {
                                        mThermalShutdownDialog = null;
                                        mThermalShutdownDialog = null;
                                    });
                                    });
@@ -516,7 +515,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
                    helpIntent.setClassName("com.android.settings",
                    helpIntent.setClassName("com.android.settings",
                            "com.android.settings.HelpTrampoline");
                            "com.android.settings.HelpTrampoline");
                    helpIntent.putExtra(Intent.EXTRA_TEXT, contextString);
                    helpIntent.putExtra(Intent.EXTRA_TEXT, contextString);
                    Dependency.get(ActivityStarter.class).startActivity(helpIntent,
                    mActivityStarter.startActivity(helpIntent,
                            true /* dismissShade */, resultCode -> {
                            true /* dismissShade */, resultCode -> {
                                mUsbHighTempDialog = null;
                                mUsbHighTempDialog = null;
                            });
                            });
+9 −8
Original line number Original line Diff line number Diff line
@@ -43,7 +43,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.settingslib.fuelgauge.Estimate;
import com.android.settingslib.fuelgauge.Estimate;
import com.android.settingslib.utils.ThreadUtils;
import com.android.settingslib.utils.ThreadUtils;
import com.android.systemui.CoreStartable;
import com.android.systemui.CoreStartable;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.SysUISingleton;
@@ -80,13 +79,13 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks {
    @VisibleForTesting
    @VisibleForTesting
    final Receiver mReceiver = new Receiver();
    final Receiver mReceiver = new Receiver();


    private PowerManager mPowerManager;
    private final PowerManager mPowerManager;
    private WarningsUI mWarnings;
    private final WarningsUI mWarnings;
    private InattentiveSleepWarningView mOverlayView;
    private InattentiveSleepWarningView mOverlayView;
    private final Configuration mLastConfiguration = new Configuration();
    private final Configuration mLastConfiguration = new Configuration();
    private int mPlugType = 0;
    private int mPlugType = 0;
    private int mInvalidCharger = 0;
    private int mInvalidCharger = 0;
    private EnhancedEstimates mEnhancedEstimates;
    private final EnhancedEstimates mEnhancedEstimates;
    private Future mLastShowWarningTask;
    private Future mLastShowWarningTask;
    private boolean mEnableSkinTemperatureWarning;
    private boolean mEnableSkinTemperatureWarning;
    private boolean mEnableUsbTemperatureAlarm;
    private boolean mEnableUsbTemperatureAlarm;
@@ -113,18 +112,20 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks {


    @Inject
    @Inject
    public PowerUI(Context context, BroadcastDispatcher broadcastDispatcher,
    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);
        super(context);
        mBroadcastDispatcher = broadcastDispatcher;
        mBroadcastDispatcher = broadcastDispatcher;
        mCommandQueue = commandQueue;
        mCommandQueue = commandQueue;
        mStatusBarOptionalLazy = statusBarOptionalLazy;
        mStatusBarOptionalLazy = statusBarOptionalLazy;
        mWarnings = warningsUI;
        mEnhancedEstimates = enhancedEstimates;
        mPowerManager = powerManager;
    }
    }


    public void start() {
    public void start() {
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mScreenOffTime = mPowerManager.isScreenOn() ? -1 : SystemClock.elapsedRealtime();
        mScreenOffTime = mPowerManager.isScreenOn() ? -1 : SystemClock.elapsedRealtime();
        mWarnings = Dependency.get(WarningsUI.class);
        mEnhancedEstimates = Dependency.get(EnhancedEstimates.class);
        mLastConfiguration.setTo(mContext.getResources().getConfiguration());
        mLastConfiguration.setTo(mContext.getResources().getConfiguration());


        ContentObserver obs = new ContentObserver(mHandler) {
        ContentObserver obs = new ContentObserver(mHandler) {
+7 −3
Original line number Original line Diff line number Diff line
@@ -56,6 +56,7 @@ import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.ScrollView;


import com.android.systemui.SysuiTestCase;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.keyguard.WakefulnessLifecycle;


import org.junit.Before;
import org.junit.Before;
import org.junit.Test;
import org.junit.Test;
@@ -75,6 +76,7 @@ public class AuthContainerViewTest extends SysuiTestCase {


    private @Mock AuthDialogCallback mCallback;
    private @Mock AuthDialogCallback mCallback;
    private @Mock UserManager mUserManager;
    private @Mock UserManager mUserManager;
    private @Mock WakefulnessLifecycle mWakefulnessLifecycle;


    @Before
    @Before
    public void setup() {
    public void setup() {
@@ -263,15 +265,17 @@ public class AuthContainerViewTest extends SysuiTestCase {
                componentInfo,
                componentInfo,
                FingerprintSensorProperties.TYPE_REAR,
                FingerprintSensorProperties.TYPE_REAR,
                false /* resetLockoutRequiresHardwareAuthToken */));
                false /* resetLockoutRequiresHardwareAuthToken */));
        mAuthContainer = new TestableAuthContainer(config, fpProps, null /* faceProps */);
        mAuthContainer = new TestableAuthContainer(config, fpProps, null /* faceProps */,
                mWakefulnessLifecycle);
    }
    }


    private class TestableAuthContainer extends AuthContainerView {
    private class TestableAuthContainer extends AuthContainerView {
        TestableAuthContainer(AuthContainerView.Config config,
        TestableAuthContainer(AuthContainerView.Config config,
                @Nullable List<FingerprintSensorPropertiesInternal> fpProps,
                @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
        @Override
Loading