Merge "Check permission for soundtrigger detection service" into rvc-dev am: 7714a18236
Change-Id: Ibb89e4820ca99151f0494c3149ee8079976db331
This commit is contained in:
@@ -443,6 +443,8 @@ public class SoundTriggerService extends SystemService {
|
|||||||
|
|
||||||
enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
|
enforceCallingPermission(Manifest.permission.MANAGE_SOUND_TRIGGER);
|
||||||
|
|
||||||
|
enforceDetectionPermissions(detectionService);
|
||||||
|
|
||||||
if (!isInitialized()) return STATUS_ERROR;
|
if (!isInitialized()) return STATUS_ERROR;
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Slog.i(TAG, "startRecognition(): id = " + soundModelId);
|
Slog.i(TAG, "startRecognition(): id = " + soundModelId);
|
||||||
@@ -1532,6 +1534,16 @@ public class SoundTriggerService extends SystemService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void enforceDetectionPermissions(ComponentName detectionService) {
|
||||||
|
PackageManager packageManager = mContext.getPackageManager();
|
||||||
|
String packageName = detectionService.getPackageName();
|
||||||
|
if (packageManager.checkPermission(Manifest.permission.CAPTURE_AUDIO_HOTWORD, packageName)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
throw new SecurityException(detectionService.getPackageName() + " does not have"
|
||||||
|
+ " permission " + Manifest.permission.CAPTURE_AUDIO_HOTWORD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================
|
//=================================================================
|
||||||
// For logging
|
// For logging
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user