Loading core/java/android/service/voice/VoiceInteractionService.java +20 −1 Original line number Diff line number Diff line Loading @@ -387,7 +387,6 @@ public class VoiceInteractionService extends Service { VoiceInteractionService::onShutdownInternal, VoiceInteractionService.this)); }; private void onShutdownInternal() { onShutdown(); // Stop any active recognitions when shutting down. Loading Loading @@ -1025,6 +1024,26 @@ public class VoiceInteractionService extends Service { } } /** Set sandboxed detection training data egress op. * * <p> This method can be called by a preinstalled assistant to allow/disallow training data * egress from trusted process. * * @return whether was able to update sandboxed detection op successfully. * @throws SecurityException if assistant is not a preinstalled assistant. * * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_TRAINING_DATA_EGRESS_FROM_HDS) public boolean setSandboxedDetectionTrainingDataOp(int opMode) { Log.i(TAG, "Setting training data egress op-mode to " + opMode); try { return mSystemService.setSandboxedDetectionTrainingDataOp(opMode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Creates an {@link KeyphraseModelManager} to use for enrolling voice models outside of the * pre-bundled system voice models. Loading core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +10 −0 Original line number Diff line number Diff line Loading @@ -388,4 +388,14 @@ interface IVoiceInteractionManagerService { oneway void notifyActivityEventChanged( in IBinder activityToken, int type); /** * Sets the sandboxed detection training data egress op to provided op-mode. * Caller must be the active assistant and a preinstalled assistant. * * @param opMode app-op mode to set training data egress op to. * * @return whether was able to successfully set training data egress op. */ boolean setSandboxedDetectionTrainingDataOp(int opMode); } services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +42 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.role.OnRoleHoldersChangedListener; import android.app.role.RoleManager; import android.content.ComponentName; Loading Loading @@ -1565,6 +1566,33 @@ public class VoiceInteractionManagerService extends SystemService { } } @Override public boolean setSandboxedDetectionTrainingDataOp(int opMode) { synchronized (this) { enforceIsCallerPreinstalledAssistant(); if (mImpl == null) { Slog.w(TAG, "setSandboxedDetectionTrainingDataop without running" + " voice interaction service"); return false; } int callingUid = Binder.getCallingUid(); final long caller = Binder.clearCallingIdentity(); try { AppOpsManager appOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); appOpsManager.setUidMode( AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA, callingUid, opMode); } finally { Binder.restoreCallingIdentity(caller); } return true; } } //----------------- Model management APIs --------------------------------// @Override Loading Loading @@ -2219,6 +2247,13 @@ public class VoiceInteractionManagerService extends SystemService { } } private void enforceIsCallerPreinstalledAssistant() { if (!isCallerPreinstalledAssistant()) { throw new SecurityException("Caller is not the pre-installed assistant."); } } private void enforceCallerAllowedToEnrollVoiceModel() { if (isCallerHoldingPermission(Manifest.permission.KEYPHRASE_ENROLLMENT_APPLICATION)) { return; Loading @@ -2233,6 +2268,13 @@ public class VoiceInteractionManagerService extends SystemService { && mImpl.mInfo.getServiceInfo().applicationInfo.uid == Binder.getCallingUid(); } private boolean isCallerPreinstalledAssistant() { return mImpl != null && mImpl.mInfo.getServiceInfo().applicationInfo.uid == Binder.getCallingUid() && (mImpl.mInfo.getServiceInfo().applicationInfo.isSystemApp() || mImpl.mInfo.getServiceInfo().applicationInfo.isUpdatedSystemApp()); } private void setImplLocked(VoiceInteractionManagerServiceImpl impl) { mImpl = impl; mAtmInternal.notifyActiveVoiceInteractionServiceChanged( Loading Loading
core/java/android/service/voice/VoiceInteractionService.java +20 −1 Original line number Diff line number Diff line Loading @@ -387,7 +387,6 @@ public class VoiceInteractionService extends Service { VoiceInteractionService::onShutdownInternal, VoiceInteractionService.this)); }; private void onShutdownInternal() { onShutdown(); // Stop any active recognitions when shutting down. Loading Loading @@ -1025,6 +1024,26 @@ public class VoiceInteractionService extends Service { } } /** Set sandboxed detection training data egress op. * * <p> This method can be called by a preinstalled assistant to allow/disallow training data * egress from trusted process. * * @return whether was able to update sandboxed detection op successfully. * @throws SecurityException if assistant is not a preinstalled assistant. * * @hide */ @FlaggedApi(Flags.FLAG_ALLOW_TRAINING_DATA_EGRESS_FROM_HDS) public boolean setSandboxedDetectionTrainingDataOp(int opMode) { Log.i(TAG, "Setting training data egress op-mode to " + opMode); try { return mSystemService.setSandboxedDetectionTrainingDataOp(opMode); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Creates an {@link KeyphraseModelManager} to use for enrolling voice models outside of the * pre-bundled system voice models. Loading
core/java/com/android/internal/app/IVoiceInteractionManagerService.aidl +10 −0 Original line number Diff line number Diff line Loading @@ -388,4 +388,14 @@ interface IVoiceInteractionManagerService { oneway void notifyActivityEventChanged( in IBinder activityToken, int type); /** * Sets the sandboxed detection training data egress op to provided op-mode. * Caller must be the active assistant and a preinstalled assistant. * * @param opMode app-op mode to set training data egress op to. * * @return whether was able to successfully set training data egress op. */ boolean setSandboxedDetectionTrainingDataOp(int opMode); }
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +42 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import android.annotation.UserIdInt; import android.app.ActivityManager; import android.app.ActivityManagerInternal; import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.role.OnRoleHoldersChangedListener; import android.app.role.RoleManager; import android.content.ComponentName; Loading Loading @@ -1565,6 +1566,33 @@ public class VoiceInteractionManagerService extends SystemService { } } @Override public boolean setSandboxedDetectionTrainingDataOp(int opMode) { synchronized (this) { enforceIsCallerPreinstalledAssistant(); if (mImpl == null) { Slog.w(TAG, "setSandboxedDetectionTrainingDataop without running" + " voice interaction service"); return false; } int callingUid = Binder.getCallingUid(); final long caller = Binder.clearCallingIdentity(); try { AppOpsManager appOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); appOpsManager.setUidMode( AppOpsManager.OP_RECEIVE_SANDBOXED_DETECTION_TRAINING_DATA, callingUid, opMode); } finally { Binder.restoreCallingIdentity(caller); } return true; } } //----------------- Model management APIs --------------------------------// @Override Loading Loading @@ -2219,6 +2247,13 @@ public class VoiceInteractionManagerService extends SystemService { } } private void enforceIsCallerPreinstalledAssistant() { if (!isCallerPreinstalledAssistant()) { throw new SecurityException("Caller is not the pre-installed assistant."); } } private void enforceCallerAllowedToEnrollVoiceModel() { if (isCallerHoldingPermission(Manifest.permission.KEYPHRASE_ENROLLMENT_APPLICATION)) { return; Loading @@ -2233,6 +2268,13 @@ public class VoiceInteractionManagerService extends SystemService { && mImpl.mInfo.getServiceInfo().applicationInfo.uid == Binder.getCallingUid(); } private boolean isCallerPreinstalledAssistant() { return mImpl != null && mImpl.mInfo.getServiceInfo().applicationInfo.uid == Binder.getCallingUid() && (mImpl.mInfo.getServiceInfo().applicationInfo.isSystemApp() || mImpl.mInfo.getServiceInfo().applicationInfo.isUpdatedSystemApp()); } private void setImplLocked(VoiceInteractionManagerServiceImpl impl) { mImpl = impl; mAtmInternal.notifyActiveVoiceInteractionServiceChanged( Loading