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.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.UserIdInt; 22 import android.os.Bundle; 23 import android.os.IBinder; 24 25 import com.android.internal.annotations.Immutable; 26 27 /** 28 * @hide 29 * Private interface to the VoiceInteractionManagerService for use by ActivityManagerService. 30 */ 31 public abstract class VoiceInteractionManagerInternal { 32 33 /** 34 * Start a new voice interaction session when requested from within an activity 35 * by Activity.startLocalVoiceInteraction() 36 * @param callingActivity The binder token representing the calling activity. 37 * @param attributionTag The attribution tag of the calling context or {@code null} for default 38 * attribution 39 * @param options A Bundle of private arguments to the current voice interaction service 40 */ startLocalVoiceInteraction(@onNull IBinder callingActivity, @Nullable String attributionTag, @Nullable Bundle options)41 public abstract void startLocalVoiceInteraction(@NonNull IBinder callingActivity, 42 @Nullable String attributionTag, @Nullable Bundle options); 43 44 /** 45 * Returns whether the currently selected voice interaction service supports local voice 46 * interaction for launching from an Activity. 47 */ supportsLocalVoiceInteraction()48 public abstract boolean supportsLocalVoiceInteraction(); 49 stopLocalVoiceInteraction(IBinder callingActivity)50 public abstract void stopLocalVoiceInteraction(IBinder callingActivity); 51 52 /** 53 * Returns whether the given package is currently in an active session 54 */ hasActiveSession(String packageName)55 public abstract boolean hasActiveSession(String packageName); 56 57 /** 58 * Returns the package name of the active session. 59 * 60 * @param callingVoiceInteractor the voice interactor binder from the calling VoiceInteractor. 61 */ getVoiceInteractorPackageName(IBinder callingVoiceInteractor)62 public abstract String getVoiceInteractorPackageName(IBinder callingVoiceInteractor); 63 64 /** 65 * Gets the identity of the currently active HotwordDetectionService. 66 * 67 * @see HotwordDetectionServiceIdentity 68 */ 69 @Nullable getHotwordDetectionServiceIdentity()70 public abstract HotwordDetectionServiceIdentity getHotwordDetectionServiceIdentity(); 71 72 /** 73 * Called by {@code UMS.convertPreCreatedUserIfPossible()} when a new user is not created from 74 * scratched, but converted from the pool of existing pre-created users. 75 */ 76 // TODO(b/226201975): remove method once RoleService supports pre-created users onPreCreatedUserConversion(@serIdInt int userId)77 public abstract void onPreCreatedUserConversion(@UserIdInt int userId); 78 79 /** 80 * Provides the uids of the currently active 81 * {@link android.service.voice.HotwordDetectionService} and its owning package. The 82 * HotwordDetectionService is an isolated service, so it has a separate uid. 83 */ 84 @Immutable 85 public static class HotwordDetectionServiceIdentity { 86 private final int mIsolatedUid; 87 private final int mOwnerUid; 88 HotwordDetectionServiceIdentity(int isolatedUid, int ownerUid)89 public HotwordDetectionServiceIdentity(int isolatedUid, int ownerUid) { 90 mIsolatedUid = isolatedUid; 91 mOwnerUid = ownerUid; 92 } 93 94 /** Gets the uid of the currently active isolated process hosting the service. */ getIsolatedUid()95 public int getIsolatedUid() { 96 return mIsolatedUid; 97 } 98 99 /** Gets the uid of the package that provides the HotwordDetectionService. */ getOwnerUid()100 public int getOwnerUid() { 101 return mOwnerUid; 102 } 103 } 104 } 105