1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.service.voice; 18 19 import android.annotation.Nullable; 20 import android.os.Bundle; 21 import android.os.IBinder; 22 23 import com.android.internal.annotations.Immutable; 24 25 /** 26 * @hide 27 * Private interface to the VoiceInteractionManagerService for use by ActivityManagerService. 28 */ 29 public abstract class VoiceInteractionManagerInternal { 30 31 /** 32 * Start a new voice interaction session when requested from within an activity 33 * by Activity.startLocalVoiceInteraction() 34 * @param callingActivity The binder token representing the calling activity. 35 * @param options 36 */ startLocalVoiceInteraction(IBinder callingActivity, Bundle options)37 public abstract void startLocalVoiceInteraction(IBinder callingActivity, Bundle options); 38 39 /** 40 * Returns whether the currently selected voice interaction service supports local voice 41 * interaction for launching from an Activity. 42 */ supportsLocalVoiceInteraction()43 public abstract boolean supportsLocalVoiceInteraction(); 44 stopLocalVoiceInteraction(IBinder callingActivity)45 public abstract void stopLocalVoiceInteraction(IBinder callingActivity); 46 47 /** 48 * Returns whether the given package is currently in an active session 49 */ hasActiveSession(String packageName)50 public abstract boolean hasActiveSession(String packageName); 51 52 /** 53 * Gets the identity of the currently active HotwordDetectionService. 54 * 55 * @see HotwordDetectionServiceIdentity 56 */ 57 @Nullable getHotwordDetectionServiceIdentity()58 public abstract HotwordDetectionServiceIdentity getHotwordDetectionServiceIdentity(); 59 60 /** 61 * Provides the uids of the currently active 62 * {@link android.service.voice.HotwordDetectionService} and its owning package. The 63 * HotwordDetectionService is an isolated service, so it has a separate uid. 64 */ 65 @Immutable 66 public static class HotwordDetectionServiceIdentity { 67 private final int mIsolatedUid; 68 private final int mOwnerUid; 69 HotwordDetectionServiceIdentity(int isolatedUid, int ownerUid)70 public HotwordDetectionServiceIdentity(int isolatedUid, int ownerUid) { 71 mIsolatedUid = isolatedUid; 72 mOwnerUid = ownerUid; 73 } 74 75 /** Gets the uid of the currently active isolated process hosting the service. */ getIsolatedUid()76 public int getIsolatedUid() { 77 return mIsolatedUid; 78 } 79 80 /** Gets the uid of the package that provides the HotwordDetectionService. */ getOwnerUid()81 public int getOwnerUid() { 82 return mOwnerUid; 83 } 84 } 85 }