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

Commit e27f1644 authored by Rios Kao's avatar Rios Kao Committed by Automerger Merge Worker
Browse files

Merge "correct sequence about granting permission of SoundTriggerTestApp" into...

Merge "correct sequence about granting permission of SoundTriggerTestApp" into tm-dev am: f10600c7

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

Change-Id: I0aa3174fed77aa4b32215b34674024858d4b365c
parents 15975b90 f10600c7
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -97,13 +97,8 @@ public class SoundTriggerTestActivity extends Activity implements SoundTriggerTe

        setVolumeControlStream(AudioManager.STREAM_MUSIC);

        // Make sure that the service is started, so even if our activity goes down, we'll still
        // have a request for it to run.
        startService(new Intent(getBaseContext(), SoundTriggerTestService.class));

        // Bind to SoundTriggerTestService.
        Intent intent = new Intent(this, SoundTriggerTestService.class);
        bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
        requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO},
                AUDIO_PERMISSIONS_REQUEST);
    }

    @Override
@@ -267,6 +262,9 @@ public class SoundTriggerTestActivity extends Activity implements SoundTriggerTe

    public synchronized void onCaptureAudioCheckboxClicked(View v) {
        // See if we have the right permissions
        if (mService == null) {
            Log.e(TAG, "Can't set capture audio: not bound to SoundTriggerTestService");
        } else {
            if (!mService.hasMicrophonePermission()) {
                requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO},
                        AUDIO_PERMISSIONS_REQUEST);
@@ -275,6 +273,7 @@ public class SoundTriggerTestActivity extends Activity implements SoundTriggerTe
                mService.setCaptureAudio(mSelectedModelUuid, mCaptureAudioCheckBox.isChecked());
            }
        }
    }

    @Override
    public synchronized void onRequestPermissionsResult(int requestCode, String permissions[],
@@ -283,8 +282,15 @@ public class SoundTriggerTestActivity extends Activity implements SoundTriggerTe
            if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
                // Make sure that the check box is set to false.
                mCaptureAudioCheckBox.setChecked(false);
            } else {
                // After granted Record_Audio permission, start and bind the service.
                // so we can run that sound trigger capability,
                // even if our activity goes down, we'll still have a request for it to run.
                startService(new Intent(getBaseContext(), SoundTriggerTestService.class));
                // Bind to SoundTriggerTestService.
                Intent intent = new Intent(this, SoundTriggerTestService.class);
                bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
            }
            mService.setCaptureAudio(mSelectedModelUuid, mCaptureAudioCheckBox.isChecked());
        }
    }