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

Commit 24b8aabd authored by Cedric Ho's avatar Cedric Ho Committed by Android Git Automerger
Browse files

am 9d80c98a: am 768623d2: am d9b0c913: am 782def77: am 80cf2210: Add...

am 9d80c98a: am 768623d2: am d9b0c913: am 782def77: am 80cf2210: Add config_forceVoiceInteractionServicePackage to allow a device to config its VoiceInteractionService package and ignore the regular setting.

* commit '9d80c98a':
  Add config_forceVoiceInteractionServicePackage to allow a device to config its VoiceInteractionService package and ignore the regular setting.
parents 30246293 9d80c98a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2142,8 +2142,9 @@
    <!-- Keyguard component -->
    <string name="config_keyguardComponent" translatable="false">com.android.systemui/com.android.systemui.keyguard.KeyguardService</string>

    <!-- This config is used to force VoiceInteractionService to start on certain low ram devices. -->
    <bool name="config_forceEnableVoiceInteractionService">false</bool>
    <!-- This config is used to force VoiceInteractionService to start on certain low ram devices.
         It declares the package name of VoiceInteractionService that should be started. -->
    <string translatable="false" name="config_forceVoiceInteractionServicePackage"></string>

    <!-- This config is ued to determine whether animations are allowed in low power mode. -->
    <bool name="config_allowAnimationsInLowPowerMode">false</bool>
+1 −1
Original line number Diff line number Diff line
@@ -280,7 +280,6 @@
  <java-symbol type="bool" name="config_enableScreenshotChord" />
  <java-symbol type="bool" name="config_bluetooth_default_profiles" />
  <java-symbol type="bool" name="config_enableWifiDisplay" />
  <java-symbol type="bool" name="config_forceEnableVoiceInteractionService" />
  <java-symbol type="bool" name="config_allowAnimationsInLowPowerMode" />
  <java-symbol type="bool" name="config_useDevInputEventForAudioJack" />
  <java-symbol type="bool" name="config_safe_media_volume_enabled" />
@@ -560,6 +559,7 @@
  <java-symbol type="string" name="chooseActivity" />
  <java-symbol type="string" name="config_default_dns_server" />
  <java-symbol type="string" name="config_ethernet_iface_regex" />
  <java-symbol type="string" name="config_forceVoiceInteractionServicePackage" />
  <java-symbol type="string" name="config_mms_user_agent" />
  <java-symbol type="string" name="config_mms_user_agent_profile_url" />
  <java-symbol type="string" name="config_ntpServer" />
+24 −6
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ public class VoiceInteractionManagerService extends SystemService {
                // the user to have the default voice interaction service enabled.
                // Note that we don't do this for low-RAM devices, since we aren't
                // supporting voice interaction services there.
                curInteractorInfo = findAvailInteractor(userHandle, curRecognizer);
                curInteractorInfo = findAvailInteractor(userHandle, curRecognizer.getPackageName());
                if (curInteractorInfo != null) {
                    // Looks good!  We'll apply this one.  To make it happen, we clear the
                    // recognizer so that we don't think we have anything set and will
@@ -162,6 +162,18 @@ public class VoiceInteractionManagerService extends SystemService {
                }
            }

            // If forceInteractorPackage exists, try to apply the interactor from this package if
            // possible and ignore the regular interactor setting.
            String forceInteractorPackage =
                    getForceVoiceInteractionServicePackage(mContext.getResources());
            if (forceInteractorPackage != null) {
                curInteractorInfo = findAvailInteractor(userHandle, forceInteractorPackage);
                if (curInteractorInfo != null) {
                    // We'll apply this one. Clear the recognizer and re-apply the settings.
                    curRecognizer = null;
                }
            }

            // If we are on a svelte device, make sure an interactor is not currently
            // enabled; if it is, turn it off.
            if (!mEnableService && curInteractorStr != null) {
@@ -225,8 +237,14 @@ public class VoiceInteractionManagerService extends SystemService {

        private boolean shouldEnableService(Resources res) {
            // VoiceInteractionService should not be enabled on low ram devices unless it has the config flag.
            return !ActivityManager.isLowRamDeviceStatic()
                    || res.getBoolean(com.android.internal.R.bool.config_forceEnableVoiceInteractionService);
            return !ActivityManager.isLowRamDeviceStatic() ||
                    getForceVoiceInteractionServicePackage(res) != null;
        }

        private String getForceVoiceInteractionServicePackage(Resources res) {
            String interactorPackage =
                    res.getString(com.android.internal.R.string.config_forceVoiceInteractionServicePackage);
            return TextUtils.isEmpty(interactorPackage) ? null : interactorPackage;
        }

        public void systemRunning(boolean safeMode) {
@@ -279,7 +297,7 @@ public class VoiceInteractionManagerService extends SystemService {
            }
        }

        VoiceInteractionServiceInfo findAvailInteractor(int userHandle, ComponentName recognizer) {
        VoiceInteractionServiceInfo findAvailInteractor(int userHandle, String packageName) {
            List<ResolveInfo> available =
                    mContext.getPackageManager().queryIntentServicesAsUser(
                            new Intent(VoiceInteractionService.SERVICE_INTERFACE), 0, userHandle);
@@ -300,8 +318,8 @@ public class VoiceInteractionManagerService extends SystemService {
                            VoiceInteractionServiceInfo info = new VoiceInteractionServiceInfo(
                                    mContext.getPackageManager(), comp, userHandle);
                            if (info.getParseError() == null) {
                                if (recognizer == null || info.getServiceInfo().packageName.equals(
                                        recognizer.getPackageName())) {
                                if (packageName == null || info.getServiceInfo().packageName.equals(
                                        packageName)) {
                                    if (foundInfo == null) {
                                        foundInfo = info;
                                    } else {