Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 718cbd32 authored by Nate Myren's avatar Nate Myren
Browse files

Add sessions to RecognitionService before starting

In order for the handleAttributionContextCreation method to work
properly, sessions must be added to the map before calling
onStartListening. If the permission checks fail, then they can be
removed afterwards

Bug: 255108991
Test: manual
Change-Id: I2380600d6b9ee88c78ceb8a839563da5fefe1919
parent e93dca15
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -142,6 +142,10 @@ public abstract class RecognitionService extends Service {
                if (preflightPermissionCheckPassed) {
                    currentCallback = new Callback(listener, attributionSource);
                    sessionState = new SessionState(currentCallback);
                    mSessions.put(listener.asBinder(), sessionState);
                    if (DBG) {
                        Log.d(TAG, "Added a new session to the map, pending permission checks");
                    }
                    RecognitionService.this.onStartListening(intent, currentCallback);
                }

@@ -151,16 +155,12 @@ public abstract class RecognitionService extends Service {
                    if (preflightPermissionCheckPassed) {
                        // If start listening was attempted, cancel the callback.
                        RecognitionService.this.onCancel(currentCallback);
                        mSessions.remove(listener.asBinder());
                        finishDataDelivery(sessionState);
                        sessionState.reset();
                    }
                    Log.i(TAG, "#startListening received from a caller "
                            + "without permission " + Manifest.permission.RECORD_AUDIO + ".");
                } else {
                    if (DBG) {
                        Log.d(TAG, "Added a new session to the map.");
                    }
                    mSessions.put(listener.asBinder(), sessionState);
                }
            } else {
                listener.onError(SpeechRecognizer.ERROR_CLIENT);