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

Commit 0be36f0c authored by Charles Chen's avatar Charles Chen Committed by Android (Google) Code Review
Browse files

Merge "[hotword] vqds enabling by build flag" into udc-qpr-dev

parents 284bd4bf 724654cd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SharedMemory;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.ArraySet;
import android.util.Log;
@@ -131,6 +132,9 @@ public class VoiceInteractionService extends Service {
    @EnabledSince(targetSdkVersion = Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
    static final long MULTIPLE_ACTIVE_HOTWORD_DETECTORS = 193232191L;

    private static final boolean SYSPROP_VISUAL_QUERY_SERVICE_ENABLED =
            SystemProperties.getBoolean("ro.hotword.visual_query_service_enabled", false);

    IVoiceInteractionService mInterface = new IVoiceInteractionService.Stub() {
        @Override
        public void ready() {
@@ -947,6 +951,10 @@ public class VoiceInteractionService extends Service {
        Objects.requireNonNull(executor);
        Objects.requireNonNull(callback);

        if (!SYSPROP_VISUAL_QUERY_SERVICE_ENABLED) {
            throw new IllegalStateException("VisualQueryDetectionService is not enabled on this "
                    + "system. Please set ro.hotword.visual_query_service_enabled to true.");
        }
        if (mSystemService == null) {
            throw new IllegalStateException("Not available until onReady() is called");
        }
+7 −2
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPH
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__KEYPHRASE_TRIGGER;
import static com.android.internal.util.FrameworkStatsLog.HOTWORD_DETECTOR_KEYPHRASE_TRIGGERED__RESULT__SERVICE_CRASH;

import android.app.AppOpsManager;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.compat.annotation.ChangeId;
import android.compat.annotation.Disabled;
import android.content.ComponentName;
@@ -50,6 +50,7 @@ import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SharedMemory;
import android.os.SystemProperties;
import android.provider.DeviceConfig;
import android.service.voice.HotwordDetectionService;
import android.service.voice.HotwordDetectionServiceFailure;
@@ -114,6 +115,9 @@ final class HotwordDetectionConnection {
    private static final long RESET_DEBUG_HOTWORD_LOGGING_TIMEOUT_MILLIS = 60 * 60 * 1000; // 1 hour
    private static final int MAX_ISOLATED_PROCESS_NUMBER = 10;

    private static final boolean SYSPROP_VISUAL_QUERY_SERVICE_ENABLED =
            SystemProperties.getBoolean("ro.hotword.visual_query_service_enabled", false);

    /**
     * Indicates the {@link HotwordDetectionService} is created.
     */
@@ -680,7 +684,8 @@ final class HotwordDetectionConnection {
            mIntent = intent;
            mDetectionServiceType = detectionServiceType;
            int flags = bindInstantServiceAllowed ? Context.BIND_ALLOW_INSTANT : 0;
            if (mVisualQueryDetectionComponentName != null
            if (SYSPROP_VISUAL_QUERY_SERVICE_ENABLED
                    && mVisualQueryDetectionComponentName != null
                    && mHotwordDetectionComponentName != null) {
                flags |= Context.BIND_SHARED_ISOLATED_PROCESS;
            }
+5 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SharedMemory;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.service.voice.HotwordDetector;
import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback;
@@ -96,6 +97,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne

    /** The delay time for retrying to request DirectActions. */
    private static final long REQUEST_DIRECT_ACTIONS_RETRY_TIME_MS = 200;
    private static final boolean SYSPROP_VISUAL_QUERY_SERVICE_ENABLED =
            SystemProperties.getBoolean("ro.hotword.visual_query_service_enabled", false);

    final boolean mValid;

@@ -715,7 +718,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        } else {
            verifyDetectorForVisualQueryDetectionLocked(sharedMemory);
        }
        if (!verifyProcessSharingLocked()) {
        if (SYSPROP_VISUAL_QUERY_SERVICE_ENABLED && !verifyProcessSharingLocked()) {
            Slog.w(TAG, "Sandboxed detection service not in shared isolated process");
            throw new IllegalStateException("VisualQueryDetectionService or HotworDetectionService "
                    + "not in a shared isolated process. Please make sure to set "
@@ -914,6 +917,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        if (hotwordInfo == null || visualQueryInfo == null) {
            return true;
        }
        // Enforce shared isolated option is used when VisualQueryDetectionservice is enabled
        return (hotwordInfo.flags & ServiceInfo.FLAG_ALLOW_SHARED_ISOLATED_PROCESS) != 0
                && (visualQueryInfo.flags & ServiceInfo.FLAG_ALLOW_SHARED_ISOLATED_PROCESS) != 0;
    }