Merge "Fix null pointer exception" into tm-qpr-dev am: 56b94f24fc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19992917

Change-Id: Ie193edfa86d717d127197a19eea92ab3e3dbca3b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Vincent Wang
2022-09-22 03:13:25 +00:00
committed by Automerger Merge Worker

View File

@@ -350,18 +350,14 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
@Override @Override
public void onTryAgainPressed(long requestId) { public void onTryAgainPressed(long requestId) {
if (mReceiver == null) { final IBiometricSysuiReceiver receiver = getCurrentReceiver(requestId);
Log.e(TAG, "onTryAgainPressed: Receiver is null"); if (receiver == null) {
return; Log.w(TAG, "Skip onTryAgainPressed");
}
if (requestId != mCurrentDialog.getRequestId()) {
Log.w(TAG, "requestId doesn't match, skip onTryAgainPressed");
return; return;
} }
try { try {
mReceiver.onTryAgainPressed(); receiver.onTryAgainPressed();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "RemoteException when handling try again", e); Log.e(TAG, "RemoteException when handling try again", e);
} }
@@ -369,18 +365,14 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
@Override @Override
public void onDeviceCredentialPressed(long requestId) { public void onDeviceCredentialPressed(long requestId) {
if (mReceiver == null) { final IBiometricSysuiReceiver receiver = getCurrentReceiver(requestId);
Log.e(TAG, "onDeviceCredentialPressed: Receiver is null"); if (receiver == null) {
return; Log.w(TAG, "Skip onDeviceCredentialPressed");
}
if (requestId != mCurrentDialog.getRequestId()) {
Log.w(TAG, "requestId doesn't match, skip onDeviceCredentialPressed");
return; return;
} }
try { try {
mReceiver.onDeviceCredentialPressed(); receiver.onDeviceCredentialPressed();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "RemoteException when handling credential button", e); Log.e(TAG, "RemoteException when handling credential button", e);
} }
@@ -388,18 +380,14 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
@Override @Override
public void onSystemEvent(int event, long requestId) { public void onSystemEvent(int event, long requestId) {
if (mReceiver == null) { final IBiometricSysuiReceiver receiver = getCurrentReceiver(requestId);
Log.e(TAG, "onSystemEvent(" + event + "): Receiver is null"); if (receiver == null) {
return; Log.w(TAG, "Skip onSystemEvent");
}
if (requestId != mCurrentDialog.getRequestId()) {
Log.w(TAG, "requestId doesn't match, skip onSystemEvent");
return; return;
} }
try { try {
mReceiver.onSystemEvent(event); receiver.onSystemEvent(event);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "RemoteException when sending system event", e); Log.e(TAG, "RemoteException when sending system event", e);
} }
@@ -407,23 +395,46 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
@Override @Override
public void onDialogAnimatedIn(long requestId) { public void onDialogAnimatedIn(long requestId) {
if (mReceiver == null) { final IBiometricSysuiReceiver receiver = getCurrentReceiver(requestId);
Log.e(TAG, "onDialogAnimatedIn: Receiver is null"); if (receiver == null) {
return; Log.w(TAG, "Skip onDialogAnimatedIn");
}
if (requestId != mCurrentDialog.getRequestId()) {
Log.w(TAG, "requestId doesn't match, skip onDialogAnimatedIn");
return; return;
} }
try { try {
mReceiver.onDialogAnimatedIn(); receiver.onDialogAnimatedIn();
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "RemoteException when sending onDialogAnimatedIn", e); Log.e(TAG, "RemoteException when sending onDialogAnimatedIn", e);
} }
} }
@Nullable
private IBiometricSysuiReceiver getCurrentReceiver(long requestId) {
if (!isRequestIdValid(requestId)) {
return null;
}
if (mReceiver == null) {
Log.w(TAG, "getCurrentReceiver: Receiver is null");
}
return mReceiver;
}
private boolean isRequestIdValid(long requestId) {
if (mCurrentDialog == null) {
Log.w(TAG, "shouldNotifyReceiver: dialog already gone");
return false;
}
if (requestId != mCurrentDialog.getRequestId()) {
Log.w(TAG, "shouldNotifyReceiver: requestId doesn't match");
return false;
}
return true;
}
@Override @Override
public void onDismissed(@DismissedReason int reason, public void onDismissed(@DismissedReason int reason,
@Nullable byte[] credentialAttestation, long requestId) { @Nullable byte[] credentialAttestation, long requestId) {