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

Commit bc661bfc authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove unused keyguard code"

parents ad597c31 2a016160
Loading
Loading
Loading
Loading
+0 −47
Original line number Diff line number Diff line
@@ -86,8 +86,6 @@ import android.util.Log;
import android.util.SparseArray;
import android.util.SparseBooleanArray;

import androidx.lifecycle.Observer;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.util.LatencyTracker;
@@ -109,7 +107,6 @@ import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.Assert;
import com.android.systemui.util.RingerModeTracker;

import com.google.android.collect.Lists;

@@ -146,7 +143,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private static final boolean DEBUG_ACTIVE_UNLOCK = Build.IS_DEBUGGABLE;
    private static final boolean DEBUG_SPEW = false;
    private static final int BIOMETRIC_LOCKOUT_RESET_DELAY_MS = 600;
    private int mNumActiveUnlockTriggers = 0;

    private static final String ACTION_FACE_UNLOCK_STARTED
            = "com.android.facelock.FACE_UNLOCK_STARTED";
@@ -157,7 +153,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private static final int MSG_TIME_UPDATE = 301;
    private static final int MSG_BATTERY_UPDATE = 302;
    private static final int MSG_SIM_STATE_CHANGE = 304;
    private static final int MSG_RINGER_MODE_CHANGED = 305;
    private static final int MSG_PHONE_STATE_CHANGED = 306;
    private static final int MSG_DEVICE_PROVISIONED = 308;
    private static final int MSG_DPM_STATE_CHANGED = 309;
@@ -313,7 +308,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    private TrustManager mTrustManager;
    private UserManager mUserManager;
    private KeyguardBypassController mKeyguardBypassController;
    private RingerModeTracker mRingerModeTracker;
    private int mFingerprintRunningState = BIOMETRIC_STATE_STOPPED;
    private int mFaceRunningState = BIOMETRIC_STATE_STOPPED;
    private boolean mIsFaceAuthUserRequested;
@@ -362,13 +356,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    private final Handler mHandler;

    private final Observer<Integer> mRingerModeObserver = new Observer<Integer>() {
        @Override
        public void onChanged(Integer ringer) {
            mHandler.obtainMessage(MSG_RINGER_MODE_CHANGED, ringer, 0).sendToTarget();
        }
    };

    private SparseBooleanArray mBiometricEnabledForUser = new SparseBooleanArray();
    private BiometricManager mBiometricManager;
    private IBiometricEnabledOnKeyguardCallback mBiometricEnabledCallback =
@@ -1808,10 +1795,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mFaceRunningState = BIOMETRIC_STATE_STOPPED;
    }

    private void registerRingerTracker() {
        mRingerModeTracker.getRingerMode().observeForever(mRingerModeObserver);
    }

    @VisibleForTesting
    @Inject
    protected KeyguardUpdateMonitor(
@@ -1819,7 +1802,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            @Main Looper mainLooper,
            BroadcastDispatcher broadcastDispatcher,
            DumpManager dumpManager,
            RingerModeTracker ringerModeTracker,
            @Background Executor backgroundExecutor,
            @Main Executor mainExecutor,
            StatusBarStateController statusBarStateController,
@@ -1837,7 +1819,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mBroadcastDispatcher = broadcastDispatcher;
        mInteractionJankMonitor = interactionJankMonitor;
        mLatencyTracker = latencyTracker;
        mRingerModeTracker = ringerModeTracker;
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(mStatusBarStateControllerListener);
        mStatusBarState = mStatusBarStateController.getState();
@@ -1862,9 +1843,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
                    case MSG_SIM_STATE_CHANGE:
                        handleSimStateChange(msg.arg1, msg.arg2, (int) msg.obj);
                        break;
                    case MSG_RINGER_MODE_CHANGED:
                        handleRingerModeChange(msg.arg1);
                        break;
                    case MSG_PHONE_STATE_CHANGED:
                        handlePhoneStateChanged((String) msg.obj);
                        break;
@@ -2006,8 +1984,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            }
        });

        mHandler.post(this::registerRingerTracker);

        final IntentFilter allUserFilter = new IntentFilter();
        allUserFilter.addAction(Intent.ACTION_USER_INFO_CHANGED);
        allUserFilter.addAction(AlarmManager.ACTION_NEXT_ALARM_CLOCK_CHANGED);
@@ -2750,12 +2726,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        Assert.isMainThread();
        updateFingerprintListeningState(BIOMETRIC_ACTION_UPDATE);
        updateSecondaryLockscreenRequirement(userId);
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onDevicePolicyManagerStateChanged();
            }
        }
    }

    /**
@@ -2833,21 +2803,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        }
    }

    /**
     * Handle {@link #MSG_RINGER_MODE_CHANGED}
     */
    private void handleRingerModeChange(int mode) {
        Assert.isMainThread();
        if (DEBUG) Log.d(TAG, "handleRingerModeChange(" + mode + ")");
        mRingMode = mode;
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onRingerModeChanged(mode);
            }
        }
    }

    /**
     * Handle {@link #MSG_TIME_UPDATE}
     */
@@ -3235,7 +3190,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        // Notify listener of the current state
        callback.onRefreshBatteryInfo(mBatteryStatus);
        callback.onTimeChanged();
        callback.onRingerModeChanged(mRingMode);
        callback.onPhoneStateChanged(mPhoneState);
        callback.onRefreshCarrierInfo();
        callback.onClockVisibilityChanged();
@@ -3546,7 +3500,6 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

        mBroadcastDispatcher.unregisterReceiver(mBroadcastReceiver);
        mBroadcastDispatcher.unregisterReceiver(mBroadcastAllReceiver);
        mRingerModeTracker.getRingerMode().removeObserver(mRingerModeObserver);

        mLockPatternUtils.unregisterStrongAuthTracker(mStrongAuthTracker);
        mTrustManager.unregisterTrustListener(this);
+3 −26
Original line number Diff line number Diff line
@@ -15,10 +15,7 @@
 */
package com.android.keyguard;

import android.app.admin.DevicePolicyManager;
import android.graphics.Bitmap;
import android.hardware.biometrics.BiometricSourceType;
import android.media.AudioManager;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.view.WindowManagerPolicyConstants;
@@ -69,13 +66,6 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onRefreshCarrierInfo() { }

    /**
     * Called when the ringer mode changes.
     * @param state the current ringer state, as defined in
     * {@link AudioManager#RINGER_MODE_CHANGED_ACTION}
     */
    public void onRingerModeChanged(int state) { }

    /**
     * Called when the phone state changes. String will be one of:
     * {@link TelephonyManager#EXTRA_STATE_IDLE}
@@ -123,12 +113,6 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onDeviceProvisioned() { }

    /**
     * Called when the device policy changes.
     * See {@link DevicePolicyManager#ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED}
     */
    public void onDevicePolicyManagerStateChanged() { }

    /**
     * Called when the user change begins.
     */
@@ -168,14 +152,7 @@ public class KeyguardUpdateMonitorCallback {
    public void onEmergencyCallAction() { }

    /**
     * Called when the transport background changes.
     * @param bitmap
     */
    public void onSetBackground(Bitmap bitmap) {
    }

    /**
     * Called when the device has started waking up.
     * Called when the device has started waking up and after biometric states are updated.
     *
     * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
     */
@@ -183,7 +160,8 @@ public class KeyguardUpdateMonitorCallback {
    public void onStartedWakingUp() { }

    /**
     * Called when the device has started going to sleep.
     * Called when the device has started going to sleep and after biometric recognized
     * states are reset.
     * @param why see {@link #onFinishedGoingToSleep(int)}
     *
     * @deprecated use {@link com.android.systemui.keyguard.WakefulnessLifecycle}.
@@ -304,7 +282,6 @@ public class KeyguardUpdateMonitorCallback {
     */
    public void onTrustAgentErrorMessage(CharSequence message) { }


    /**
     * Called when a value of logout enabled is change.
     */
+1 −37
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
@@ -58,7 +57,6 @@ import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.fingerprint.FingerprintManager;
import android.media.AudioManager;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.os.Handler;
@@ -74,9 +72,6 @@ import android.testing.AndroidTestingRunner;
import android.testing.TestableContext;
import android.testing.TestableLooper;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;

import com.android.dx.mockito.inline.extended.ExtendedMockito;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.telephony.TelephonyIntents;
@@ -92,7 +87,6 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.RingerModeTracker;

import org.junit.After;
import org.junit.Assert;
@@ -101,7 +95,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoSession;
@@ -161,10 +154,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    @Mock
    private TelephonyManager mTelephonyManager;
    @Mock
    private RingerModeTracker mRingerModeTracker;
    @Mock
    private LiveData<Integer> mRingerModeLiveData;
    @Mock
    private StatusBarStateController mStatusBarStateController;
    @Mock
    private AuthController mAuthController;
@@ -242,8 +231,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        mSpiedContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
        mSpiedContext.addMockSystemService(TelephonyManager.class, mTelephonyManager);

        when(mRingerModeTracker.getRingerMode()).thenReturn(mRingerModeLiveData);

        mMockitoSession = ExtendedMockito.mockitoSession()
                .spyStatic(SubscriptionManager.class).startMocking();
        ExtendedMockito.doReturn(SubscriptionManager.INVALID_SUBSCRIPTION_ID)
@@ -865,29 +852,6 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        assertThat(mKeyguardUpdateMonitor.getSecondaryLockscreenRequirement(user)).isNull();
    }

    @Test
    public void testRingerModeChange() {
        ArgumentCaptor<Observer<Integer>> captor = ArgumentCaptor.forClass(Observer.class);
        verify(mRingerModeLiveData).observeForever(captor.capture());
        Observer<Integer> observer = captor.getValue();

        KeyguardUpdateMonitorCallback callback = mock(KeyguardUpdateMonitorCallback.class);

        mKeyguardUpdateMonitor.registerCallback(callback);

        observer.onChanged(AudioManager.RINGER_MODE_NORMAL);
        observer.onChanged(AudioManager.RINGER_MODE_SILENT);
        observer.onChanged(AudioManager.RINGER_MODE_VIBRATE);

        mTestableLooper.processAllMessages();

        InOrder orderVerify = inOrder(callback);
        orderVerify.verify(callback).onRingerModeChanged(anyInt()); // Initial update on register
        orderVerify.verify(callback).onRingerModeChanged(AudioManager.RINGER_MODE_NORMAL);
        orderVerify.verify(callback).onRingerModeChanged(AudioManager.RINGER_MODE_SILENT);
        orderVerify.verify(callback).onRingerModeChanged(AudioManager.RINGER_MODE_VIBRATE);
    }

    @Test
    public void testRegisterAuthControllerCallback() {
        assertThat(mKeyguardUpdateMonitor.isUdfpsEnrolled()).isFalse();
@@ -1120,7 +1084,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
            super(context,
                    TestableLooper.get(KeyguardUpdateMonitorTest.this).getLooper(),
                    mBroadcastDispatcher, mDumpManager,
                    mRingerModeTracker, mBackgroundExecutor, mMainExecutor,
                    mBackgroundExecutor, mMainExecutor,
                    mStatusBarStateController, mLockPatternUtils,
                    mAuthController, mTelephonyListenerManager,
                    mInteractionJankMonitor, mLatencyTracker);
+1 −1
Original line number Diff line number Diff line
@@ -754,7 +754,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {

        // WHEN asked to update the indication area
        mController.setVisible(true);
        int runTasks = mExecutor.runAllReady();
        mExecutor.runAllReady();

        // THEN the owner info should be hidden
        verifyHideIndication(INDICATION_TYPE_OWNER_INFO);