Merge "Add trust indicator to keyguard"

This commit is contained in:
Adrian Roos
2014-05-21 14:04:42 +00:00
committed by Android (Google) Code Review
6 changed files with 63 additions and 0 deletions

View File

@@ -213,6 +213,13 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
@Override
public void onTrustChanged(boolean enabled, int userId) {
mUserHasTrust.put(userId, enabled);
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
if (cb != null) {
cb.onTrustChanged(userId);
}
}
}
private boolean isTrustDisabled(int userId) {

View File

@@ -179,4 +179,9 @@ public class KeyguardUpdateMonitorCallback {
* {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT}.
*/
public void onScreenTurnedOff(int why) { }
/**
* Called when trust changes for a user.
*/
public void onTrustChanged(int userId) { }
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1007 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

View File

@@ -56,6 +56,7 @@
android:textAppearance="?android:attr/textAppearanceMedium"/>
<ImageView
android:id="@+id/lock_icon"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="bottom|center_horizontal"

View File

@@ -36,7 +36,11 @@ import android.view.accessibility.AccessibilityManager;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.R;
/**
@@ -52,10 +56,14 @@ public class KeyguardBottomAreaView extends FrameLayout
private SwipeAffordanceView mCameraButton;
private SwipeAffordanceView mPhoneButton;
private ImageView mLockIcon;
private PowerManager mPowerManager;
private ActivityStarter mActivityStarter;
private LockPatternUtils mLockPatternUtils;
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
public KeyguardBottomAreaView(Context context) {
super(context);
}
@@ -78,12 +86,17 @@ public class KeyguardBottomAreaView extends FrameLayout
super.onFinishInflate();
mCameraButton = (SwipeAffordanceView) findViewById(R.id.camera_button);
mPhoneButton = (SwipeAffordanceView) findViewById(R.id.phone_button);
mLockIcon = (ImageView) findViewById(R.id.lock_icon);
mCameraButton.setAffordanceListener(this);
mPhoneButton.setAffordanceListener(this);
mLockPatternUtils = new LockPatternUtils(getContext());
mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
KeyguardUpdateMonitor.getInstance(getContext()).registerCallback(mCallback);
watchForDevicePolicyChanges();
watchForAccessibilityChanges();
updateCameraVisibility();
updatePhoneVisibility();
updateTrust();
mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
}
@@ -185,4 +198,41 @@ public class KeyguardBottomAreaView extends FrameLayout
launchPhone();
}
}
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);
if (changedView == this && visibility == VISIBLE) {
updateTrust();
}
}
private void updateTrust() {
if (getVisibility() != VISIBLE) {
return;
}
int user = mLockPatternUtils.getCurrentUser();
boolean trust = !mLockPatternUtils.isSecure() ||
mKeyguardUpdateMonitor.getUserHasTrust(user);
int iconRes = trust ? R.drawable.ic_lock_open_24dp : R.drawable.ic_lock_24dp;
mLockIcon.setImageResource(iconRes);
}
final KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
@Override
public void onScreenTurnedOn() {
updateTrust();
}
@Override
public void onUserSwitchComplete(int userId) {
updateTrust();
}
@Override
public void onTrustChanged(int userId) {
updateTrust();
}
};
}