summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Erin Yan <yiranyan@google.com> 2019-09-04 11:55:30 -0700
committer Erin Yan <yiranyan@google.com> 2019-09-06 01:52:12 +0000
commit5eb60a2c0df5169cbf77c96caa8167ae86c89ed2 (patch)
tree526ca3eb74183da23caf50fb87d303218b5a3bdc
parentb1af47bec8dd6d771478705e4b03d5c1d45d13dc (diff)
Make unlock dialog exit if the person taps outside of the dialog
Bug: 136049501 Test: Manually on IHU Change-Id: Iabbca72bf65b5e93aafd53296d77a88ccaaf5dfd Merged-in: Iabbca72bf65b5e93aafd53296d77a88ccaaf5dfd (cherry picked from commit fe3efb667fd3ceafda97a28d6f4673960114c369)
-rw-r--r--packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml3
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java39
-rw-r--r--packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java19
3 files changed, 44 insertions, 17 deletions
diff --git a/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml b/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml
index 2d9901c30d02..9df78f1378b1 100644
--- a/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml
+++ b/packages/CarSystemUI/res/layout/trust_agent_unlock_dialog.xml
@@ -16,12 +16,13 @@
-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/layout"
+ android:id="@+id/unlock_dialog_parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
+ android:id="@+id/unlock_dialog"
android:layout_width="@dimen/unlock_dialog_width"
android:layout_height="wrap_content"
android:gravity="center"
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
index 013c63b834ff..ec72ee74f59a 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/CarTrustAgentUnlockDialogHelper.java
@@ -52,7 +52,7 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
* Not using Dialog because context passed from {@link FullscreenUserSwitcher} is not an
* activity.
*/
- private final View mUnlockDialog;
+ private final View mUnlockDialogLayout;
private final TextView mUnlockingText;
private final Button mButton;
private final IntentFilter mFilter;
@@ -70,14 +70,25 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
mParams.packageName = mContext.getPackageName();
mParams.setTitle(mContext.getString(R.string.unlock_dialog_title));
- mUnlockDialog = LayoutInflater.from(mContext).inflate(
+ mUnlockDialogLayout = LayoutInflater.from(mContext).inflate(
R.layout.trust_agent_unlock_dialog, null);
- mUnlockDialog.setLayoutParams(mParams);
+ mUnlockDialogLayout.setLayoutParams(mParams);
- mUnlockingText = mUnlockDialog.findViewById(R.id.unlocking_text);
- mButton = mUnlockDialog.findViewById(R.id.enter_pin_button);
+ View dialogParent = mUnlockDialogLayout.findViewById(R.id.unlock_dialog_parent);
+ dialogParent.setOnTouchListener((v, event)-> {
+ hideUnlockDialog(/* dismissUserSwitcher= */ false);
+ return true;
+ });
+ View unlockDialog = mUnlockDialogLayout.findViewById(R.id.unlock_dialog);
+ unlockDialog.setOnTouchListener((v, event) -> {
+ // If the person taps inside the unlock dialog, the touch event will be intercepted here
+ // and the dialog will not exit
+ return true;
+ });
+ mUnlockingText = mUnlockDialogLayout.findViewById(R.id.unlocking_text);
+ mButton = mUnlockDialogLayout.findViewById(R.id.enter_pin_button);
mButton.setOnClickListener(v -> {
- hideUnlockDialog(/* notifyOnHideListener= */true);
+ hideUnlockDialog(/* dismissUserSwitcher= */true);
// TODO(b/138250105) Stop unlock advertising
});
@@ -133,7 +144,7 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
if (!mUserManager.isUserUnlocked(uid)) {
logd("Showed unlock dialog for user: " + uid + " after " + delayMillis
+ " delay.");
- mWindowManager.addView(mUnlockDialog, mParams);
+ mWindowManager.addView(mUnlockDialogLayout, mParams);
}
}, delayMillis);
}
@@ -142,22 +153,22 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
private void setUid(int uid) {
mUid = uid;
- TextView userName = mUnlockDialog.findViewById(R.id.user_name);
+ TextView userName = mUnlockDialogLayout.findViewById(R.id.user_name);
userName.setText(mUserManager.getUserInfo(mUid).name);
- ImageView avatar = mUnlockDialog.findViewById(R.id.avatar);
+ ImageView avatar = mUnlockDialogLayout.findViewById(R.id.avatar);
avatar.setImageBitmap(mUserManager.getUserIcon(mUid));
setButtonText();
}
- private void hideUnlockDialog(boolean notifyOnHideListener) {
+ private void hideUnlockDialog(boolean dismissUserSwitcher) {
if (!mIsDialogShowing) {
return;
}
- mWindowManager.removeView(mUnlockDialog);
+ mWindowManager.removeView(mUnlockDialogLayout);
logd("Receiver unregistered");
mContext.unregisterReceiver(this);
- if (notifyOnHideListener && mOnHideListener != null) {
- mOnHideListener.onHide();
+ if (mOnHideListener != null) {
+ mOnHideListener.onHide(dismissUserSwitcher);
}
mIsDialogShowing = false;
}
@@ -240,6 +251,6 @@ class CarTrustAgentUnlockDialogHelper extends BroadcastReceiver{
* Listener used to notify when the dialog is hidden
*/
interface OnHideListener {
- void onHide();
+ void onHide(boolean dismissUserSwitcher);
}
}
diff --git a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index 7cd6adbb3952..0f7c1ee8ea7e 100644
--- a/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/CarSystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -34,6 +34,7 @@ import android.view.ViewStub;
import androidx.recyclerview.widget.GridLayoutManager;
import com.android.systemui.R;
+import com.android.systemui.statusbar.car.CarTrustAgentUnlockDialogHelper.OnHideListener;
import com.android.systemui.statusbar.car.UserGridRecyclerView.UserRecord;
/**
@@ -116,7 +117,7 @@ public class FullscreenUserSwitcher {
// Show unlock dialog for initial user
if (hasTrustedDevice(initialUser)) {
mUnlockDialogHelper.showUnlockDialogAfterDelay(initialUser,
- () -> dismissUserSwitcher());
+ mOnHideListener);
}
}
@@ -162,7 +163,7 @@ public class FullscreenUserSwitcher {
private void onUserSelected(UserGridRecyclerView.UserRecord record) {
mSelectedUser = record;
if (hasTrustedDevice(record.mInfo.id)) {
- mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, () -> dismissUserSwitcher());
+ mUnlockDialogHelper.showUnlockDialog(record.mInfo.id, mOnHideListener);
return;
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
@@ -202,4 +203,18 @@ public class FullscreenUserSwitcher {
private boolean hasTrustedDevice(int uid) {
return !mEnrollmentManager.getEnrolledDeviceInfoForUser(uid).isEmpty();
}
+
+ private OnHideListener mOnHideListener = new OnHideListener() {
+ @Override
+ public void onHide(boolean dismissUserSwitcher) {
+ if (dismissUserSwitcher) {
+ dismissUserSwitcher();
+ } else {
+ // Re-draw the parent view, otherwise the unlock dialog will not be removed from
+ // the screen immediately.
+ mParent.invalidate();
+ }
+
+ }
+ };
}