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

Commit 4c2e705b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Validate HotwordDetectionService to be in the isolated process." into sc-dev am: f1ce6c68

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

Change-Id: I71cdfe1d66731121cfdff41516138b2fc3ef21a3
parents c9588d83 f1ce6c68
Loading
Loading
Loading
Loading
+22 −8
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.app.ActivityOptions;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.IActivityManager;
import android.app.IActivityManager;
import android.app.IActivityTaskManager;
import android.app.IActivityTaskManager;
import android.content.BroadcastReceiver;
import android.content.BroadcastReceiver;
@@ -35,7 +36,9 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.ServiceConnection;
import android.content.pm.IPackageManager;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
import android.hardware.soundtrigger.IRecognitionStatusCallback;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler;
@@ -167,12 +170,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        mSessionComponentName = new ComponentName(service.getPackageName(),
        mSessionComponentName = new ComponentName(service.getPackageName(),
                mInfo.getSessionService());
                mInfo.getSessionService());
        final String hotwordDetectionServiceName = mInfo.getHotwordDetectionService();
        final String hotwordDetectionServiceName = mInfo.getHotwordDetectionService();
        if (hotwordDetectionServiceName != null) {
        mHotwordDetectionComponentName = hotwordDetectionServiceName != null
            mHotwordDetectionComponentName = new ComponentName(service.getPackageName(),
                ? new ComponentName(service.getPackageName(), hotwordDetectionServiceName) : null;
                    hotwordDetectionServiceName);
        } else {
            mHotwordDetectionComponentName = null;
        }
        mIWindowManager = IWindowManager.Stub.asInterface(
        mIWindowManager = IWindowManager.Stub.asInterface(
                ServiceManager.getService(Context.WINDOW_SERVICE));
                ServiceManager.getService(Context.WINDOW_SERVICE));
        IntentFilter filter = new IntentFilter();
        IntentFilter filter = new IntentFilter();
@@ -456,8 +455,22 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
    }
    }


    boolean isIsolatedProcessLocked(ComponentName componentName) {
    boolean isIsolatedProcessLocked(ComponentName componentName) {
        // TODO : Need to make sure this component exists and is :isolated.
        IPackageManager pm = AppGlobals.getPackageManager();
        return true;
        try {
            ServiceInfo serviceInfo = pm.getServiceInfo(componentName,
                    PackageManager.GET_META_DATA
                            | PackageManager.MATCH_DIRECT_BOOT_AWARE
                            | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, mUser);
            if (serviceInfo != null) {
                return (serviceInfo.flags & ServiceInfo.FLAG_ISOLATED_PROCESS) != 0
                        && (serviceInfo.flags & ServiceInfo.FLAG_EXTERNAL_SERVICE) == 0;
            }
        } catch (RemoteException e) {
            if (DEBUG) {
                Slog.w(TAG, "isIsolatedProcess RemoteException : " + e);
            }
        }
        return false;
    }
    }


    public void dumpLocked(FileDescriptor fd, PrintWriter pw, String[] args) {
    public void dumpLocked(FileDescriptor fd, PrintWriter pw, String[] args) {
@@ -476,6 +489,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
        pw.println("  Service info:");
        pw.println("  Service info:");
        mInfo.getServiceInfo().dump(new PrintWriterPrinter(pw), "    ");
        mInfo.getServiceInfo().dump(new PrintWriterPrinter(pw), "    ");
        pw.print("  Recognition service="); pw.println(mInfo.getRecognitionService());
        pw.print("  Recognition service="); pw.println(mInfo.getRecognitionService());
        pw.print("  Hotword detection service="); pw.println(mInfo.getHotwordDetectionService());
        pw.print("  Settings activity="); pw.println(mInfo.getSettingsActivity());
        pw.print("  Settings activity="); pw.println(mInfo.getSettingsActivity());
        pw.print("  Supports assist="); pw.println(mInfo.getSupportsAssist());
        pw.print("  Supports assist="); pw.println(mInfo.getSupportsAssist());
        pw.print("  Supports launch from keyguard=");
        pw.print("  Supports launch from keyguard=");