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

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

Merge "Always show transient indication in AOD"

parents bea71a2f ff6628d4
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -19,14 +19,14 @@ package com.android.systemui.statusbar;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.app.admin.DevicePolicyManager;
import android.hardware.biometrics.BiometricSourceType;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.hardware.biometrics.BiometricSourceType;
import android.hardware.face.FaceManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.BatteryManager;
@@ -106,6 +106,7 @@ public class KeyguardIndicationController {

    private final DevicePolicyManager mDevicePolicyManager;
    private boolean mDozing;
    private float mDarkAmount;

    /**
     * Creates a new KeyguardIndicationController and registers callbacks.
@@ -298,6 +299,15 @@ public class KeyguardIndicationController {
        if (mVisible) {
            // Walk down a precedence-ordered list of what indication
            // should be shown based on user or device state
            if (mDozing) {
                if (!TextUtils.isEmpty(mTransientIndication)) {
                    mTextView.setTextColor(Color.WHITE);
                    mTextView.switchIndication(mTransientIndication);
                }
                updateAlphas();
                return;
            }

            KeyguardUpdateMonitor updateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
            int userId = KeyguardUpdateMonitor.getCurrentUser();
            String trustGrantedIndication = getTrustGrantedIndication();
@@ -335,6 +345,14 @@ public class KeyguardIndicationController {
        }
    }

    private void updateAlphas() {
        if (!TextUtils.isEmpty(mTransientIndication)) {
            mTextView.setAlpha(1f);
        } else {
            mTextView.setAlpha(1f - mDarkAmount);
        }
    }

    // animates textView - textView moves up and bounces down
    private void animateText(KeyguardIndicationTextView textView, String indication) {
        int yTranslation = mContext.getResources().getInteger(
@@ -492,6 +510,14 @@ public class KeyguardIndicationController {
        pw.println("  computePowerIndication(): " + computePowerIndication());
    }

    public void setDarkAmount(float darkAmount) {
        if (mDarkAmount == darkAmount) {
            return;
        }
        mDarkAmount = darkAmount;
        updateAlphas();
    }

    protected class BaseKeyguardCallback extends KeyguardUpdateMonitorCallback {
        public static final int HIDE_DELAY_MS = 5000;
        private int mLastSuccessiveErrorMessage = -1;
+1 −1
Original line number Diff line number Diff line
@@ -560,7 +560,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
            return;
        }
        mDarkAmount = darkAmount;
        mIndicationArea.setAlpha(1f - darkAmount);
        mIndicationController.setDarkAmount(darkAmount);
        mLockIcon.setDarkAmount(darkAmount);
    }

+28 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.systemui.statusbar;

import static com.google.common.truth.Truth.assertThat;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -28,6 +30,7 @@ import android.app.Instrumentation;
import android.app.admin.DevicePolicyManager;
import android.app.trust.TrustManager;
import android.content.Context;
import android.graphics.Color;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Looper;
import android.support.test.InstrumentationRegistry;
@@ -45,6 +48,8 @@ import com.android.systemui.util.wakelock.WakeLockFake;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -54,9 +59,13 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {

    private String mDisclosureWithOrganization;

    private DevicePolicyManager mDevicePolicyManager = mock(DevicePolicyManager.class);
    private ViewGroup mIndicationArea = mock(ViewGroup.class);
    private KeyguardIndicationTextView mDisclosure = mock(KeyguardIndicationTextView.class);
    @Mock
    private DevicePolicyManager mDevicePolicyManager;
    @Mock
    private ViewGroup mIndicationArea;
    @Mock
    private KeyguardIndicationTextView mDisclosure;
    private KeyguardIndicationTextView mTextView;

    private KeyguardIndicationController mController;
    private WakeLockFake mWakeLock;
@@ -64,7 +73,9 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {

    @Before
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mInstrumentation = InstrumentationRegistry.getInstrumentation();
        mTextView = new KeyguardIndicationTextView(mContext);

        mContext.addMockSystemService(Context.DEVICE_POLICY_SERVICE, mDevicePolicyManager);
        mContext.addMockSystemService(Context.TRUST_SERVICE, mock(TrustManager.class));
@@ -74,6 +85,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {

        when(mIndicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure))
                .thenReturn(mDisclosure);
        when(mIndicationArea.findViewById(R.id.keyguard_indication_text)).thenReturn(mTextView);

        mWakeLock = new WakeLockFake();
    }
@@ -189,4 +201,17 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase {
        });
        assertFalse("WakeLock expected: RELEASED, was: HELD", held[0]);
    }

    @Test
    public void transientIndication_visibleWhenDozing() {
        createController();

        mController.setVisible(true);
        mController.showTransientIndication("Test");
        mController.setDozing(true);

        assertThat(mTextView.getText()).isEqualTo("Test");
        assertThat(mTextView.getCurrentTextColor()).isEqualTo(Color.WHITE);
        assertThat(mTextView.getAlpha()).isEqualTo(1f);
    }
}