Merge "Revert^2 "[hotword] remove exemption for pixel devices"" into udc-dev am: 8e3c3bd264
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23260396 Change-Id: I2fa75ec3e8b8b4ccf813403a95566a6c5ac0e007 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -37,6 +37,7 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.PackageTagsList;
|
import android.os.PackageTagsList;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.service.voice.VoiceInteractionManagerInternal;
|
import android.service.voice.VoiceInteractionManagerInternal;
|
||||||
import android.service.voice.VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity;
|
import android.service.voice.VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity;
|
||||||
@@ -68,6 +69,8 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
|
|||||||
private static final String ACTIVITY_RECOGNITION_TAGS =
|
private static final String ACTIVITY_RECOGNITION_TAGS =
|
||||||
"android:activity_recognition_allow_listed_tags";
|
"android:activity_recognition_allow_listed_tags";
|
||||||
private static final String ACTIVITY_RECOGNITION_TAGS_SEPARATOR = ";";
|
private static final String ACTIVITY_RECOGNITION_TAGS_SEPARATOR = ";";
|
||||||
|
private static final boolean SYSPROP_HOTWORD_DETECTION_SERVICE_REQUIRED =
|
||||||
|
SystemProperties.getBoolean("ro.hotword.detection_service_required", false);
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private final Object mLock = new Object();
|
private final Object mLock = new Object();
|
||||||
@@ -199,10 +202,16 @@ public final class AppOpsPolicy implements AppOpsManagerInternal.CheckOpsDelegat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isHotwordDetectionServiceRequired(PackageManager pm) {
|
/**
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static boolean isHotwordDetectionServiceRequired(PackageManager pm) {
|
||||||
// The HotwordDetectionService APIs aren't ready yet for Auto or TV.
|
// The HotwordDetectionService APIs aren't ready yet for Auto or TV.
|
||||||
return !(pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
if (pm.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)
|
||||||
|| pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK));
|
|| pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return SYSPROP_HOTWORD_DETECTION_SERVICE_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ import com.android.internal.annotations.GuardedBy;
|
|||||||
import com.android.internal.app.IHotwordRecognitionStatusCallback;
|
import com.android.internal.app.IHotwordRecognitionStatusCallback;
|
||||||
import com.android.internal.infra.AndroidFuture;
|
import com.android.internal.infra.AndroidFuture;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
|
import com.android.server.policy.AppOpsPolicy;
|
||||||
import com.android.server.voiceinteraction.VoiceInteractionManagerServiceImpl.DetectorRemoteExceptionListener;
|
import com.android.server.voiceinteraction.VoiceInteractionManagerServiceImpl.DetectorRemoteExceptionListener;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
@@ -742,6 +743,7 @@ abstract class DetectorSession {
|
|||||||
void enforcePermissionsForDataDelivery() {
|
void enforcePermissionsForDataDelivery() {
|
||||||
Binder.withCleanCallingIdentity(() -> {
|
Binder.withCleanCallingIdentity(() -> {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
if (AppOpsPolicy.isHotwordDetectionServiceRequired(mContext.getPackageManager())) {
|
||||||
int result = PermissionChecker.checkPermissionForPreflight(
|
int result = PermissionChecker.checkPermissionForPreflight(
|
||||||
mContext, RECORD_AUDIO, /* pid */ -1, mVoiceInteractorIdentity.uid,
|
mContext, RECORD_AUDIO, /* pid */ -1, mVoiceInteractorIdentity.uid,
|
||||||
mVoiceInteractorIdentity.packageName);
|
mVoiceInteractorIdentity.packageName);
|
||||||
@@ -750,10 +752,15 @@ abstract class DetectorSession {
|
|||||||
"Failed to obtain permission RECORD_AUDIO for identity "
|
"Failed to obtain permission RECORD_AUDIO for identity "
|
||||||
+ mVoiceInteractorIdentity);
|
+ mVoiceInteractorIdentity);
|
||||||
}
|
}
|
||||||
int hotwordOp = AppOpsManager.strOpToOp(AppOpsManager.OPSTR_RECORD_AUDIO_HOTWORD);
|
int hotwordOp = AppOpsManager.strOpToOp(
|
||||||
|
AppOpsManager.OPSTR_RECORD_AUDIO_HOTWORD);
|
||||||
mAppOpsManager.noteOpNoThrow(hotwordOp,
|
mAppOpsManager.noteOpNoThrow(hotwordOp,
|
||||||
mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
|
mVoiceInteractorIdentity.uid, mVoiceInteractorIdentity.packageName,
|
||||||
mVoiceInteractorIdentity.attributionTag, HOTWORD_DETECTION_OP_MESSAGE);
|
mVoiceInteractorIdentity.attributionTag, HOTWORD_DETECTION_OP_MESSAGE);
|
||||||
|
} else {
|
||||||
|
enforcePermissionForDataDelivery(mContext, mVoiceInteractorIdentity,
|
||||||
|
RECORD_AUDIO, HOTWORD_DETECTION_OP_MESSAGE);
|
||||||
|
}
|
||||||
enforcePermissionForDataDelivery(mContext, mVoiceInteractorIdentity,
|
enforcePermissionForDataDelivery(mContext, mVoiceInteractorIdentity,
|
||||||
CAPTURE_AUDIO_HOTWORD, HOTWORD_DETECTION_OP_MESSAGE);
|
CAPTURE_AUDIO_HOTWORD, HOTWORD_DETECTION_OP_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user