Merge changes I2598cce2,I64525b73

* changes:
  Remove icon vertical padding from small dialog height calculation
  Dismiss the BiometricPrompt upon Intent.ACTION_CLOSE_SYSTEM_DIALOGS
This commit is contained in:
Kevin Chyn
2019-11-06 01:26:35 +00:00
committed by Android (Google) Code Review
3 changed files with 48 additions and 1 deletions

View File

@@ -298,7 +298,10 @@ public abstract class AuthBiometricView extends LinearLayout {
.getDimension(R.dimen.biometric_dialog_icon_padding);
mIconView.setY(getHeight() - mIconView.getHeight() - iconPadding);
final int newHeight = mIconView.getHeight() + 2 * (int) iconPadding;
// Subtract the vertical padding from the new height since it's only used to create
// extra space between the other elements, and not part of the actual icon.
final int newHeight = mIconView.getHeight() + 2 * (int) iconPadding
- mIconView.getPaddingTop() - mIconView.getPaddingBottom();
mPanelController.updateForContentDimensions(mMediumWidth, newHeight,
0 /* animateDurationMs */);

View File

@@ -23,7 +23,10 @@ import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.TaskStackListener;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.hardware.biometrics.Authenticator;
@@ -85,6 +88,28 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
}
}
@VisibleForTesting
final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (mCurrentDialog != null
&& Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
Log.w(TAG, "ACTION_CLOSE_SYSTEM_DIALOGS received");
mCurrentDialog.dismissWithoutCallback(true /* animate */);
mCurrentDialog = null;
try {
if (mReceiver != null) {
mReceiver.onDialogDismissed(BiometricPrompt.DISMISSED_REASON_USER_CANCEL);
mReceiver = null;
}
} catch (RemoteException e) {
Log.e(TAG, "Remote exception", e);
}
}
}
};
private final Runnable mTaskStackChangedRunnable = () -> {
if (mCurrentDialog != null) {
try {
@@ -204,6 +229,11 @@ public class AuthController extends SystemUI implements CommandQueue.Callbacks,
super(context);
mCommandQueue = commandQueue;
mInjector = injector;
IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
context.registerReceiver(mBroadcastReceiver, filter);
}
@Override

View File

@@ -35,6 +35,7 @@ import android.app.ActivityManager;
import android.app.IActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.hardware.biometrics.Authenticator;
@@ -403,6 +404,19 @@ public class AuthControllerTest extends SysuiTestCase {
mAuthController.onDeviceCredentialPressed();
}
@Test
public void testActionCloseSystemDialogs_dismissesDialogIfShowing() throws Exception {
showDialog(Authenticator.TYPE_BIOMETRIC, BiometricPrompt.TYPE_FACE);
Intent intent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
mAuthController.mBroadcastReceiver.onReceive(mContext, intent);
waitForIdleSync();
assertNull(mAuthController.mCurrentDialog);
assertNull(mAuthController.mReceiver);
verify(mDialog1).dismissWithoutCallback(true /* animate */);
verify(mReceiver).onDialogDismissed(eq(BiometricPrompt.DISMISSED_REASON_USER_CANCEL));
}
// Helpers
private void showDialog(int authenticators, int biometricModality) {