Do not fail Recognition on MODE_IGNORED for preflight

Recognition will fail upon attempting to open the microphone, if it is
accessed.

Bug: 197465285
Test: manual
Change-Id: I83f1ae30295caf576eb7a6f0191313cb789f1d52
This commit is contained in:
Nate Myren
2021-09-10 13:36:22 -07:00
parent c72d4fc175
commit 922e104be4

View File

@@ -115,7 +115,7 @@ public abstract class RecognitionService extends Service {
@NonNull AttributionSource attributionSource) {
try {
if (mCurrentCallback == null) {
boolean preflightPermissionCheckPassed = checkPermissionForPreflight(
boolean preflightPermissionCheckPassed = checkPermissionForPreflightNotHardDenied(
attributionSource);
if (preflightPermissionCheckPassed) {
if (DBG) {
@@ -470,10 +470,11 @@ public abstract class RecognitionService extends Service {
return mStartedDataDelivery;
}
private boolean checkPermissionForPreflight(AttributionSource attributionSource) {
return PermissionChecker.checkPermissionForPreflight(RecognitionService.this,
Manifest.permission.RECORD_AUDIO, attributionSource)
== PermissionChecker.PERMISSION_GRANTED;
private boolean checkPermissionForPreflightNotHardDenied(AttributionSource attributionSource) {
int result = PermissionChecker.checkPermissionForPreflight(RecognitionService.this,
Manifest.permission.RECORD_AUDIO, attributionSource);
return result == PermissionChecker.PERMISSION_GRANTED
|| result == PermissionChecker.PERMISSION_SOFT_DENIED;
}
void finishDataDelivery() {