Loading services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +10 −1 Original line number Diff line number Diff line Loading @@ -338,14 +338,16 @@ public abstract class ActivityTaskManagerInternal { private final @NonNull IBinder mAssistToken; private final @NonNull IBinder mShareableActivityToken; private final @NonNull IApplicationThread mAppThread; private final int mUid; public ActivityTokens(@NonNull IBinder activityToken, @NonNull IBinder assistToken, @NonNull IApplicationThread appThread, @NonNull IBinder shareableActivityToken) { @NonNull IBinder shareableActivityToken, int uid) { mActivityToken = activityToken; mAssistToken = assistToken; mAppThread = appThread; mShareableActivityToken = shareableActivityToken; mUid = uid; } /** Loading Loading @@ -375,6 +377,13 @@ public abstract class ActivityTaskManagerInternal { public @NonNull IApplicationThread getApplicationThread() { return mAppThread; } /** * @return The UID of the activity */ public int getUid() { return mUid; } } public abstract void sendActivityResult(int callingUid, IBinder activityToken, Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -5820,14 +5820,16 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { if (token == null && list.get(0).attachedToProcess()) { ActivityRecord topRecord = list.get(0); return new ActivityTokens(topRecord.token, topRecord.assistToken, topRecord.app.getThread(), topRecord.shareableActivityToken); topRecord.app.getThread(), topRecord.shareableActivityToken, topRecord.getUid()); } // find the expected Activity for (int i = 0; i < list.size(); i++) { ActivityRecord record = list.get(i); if (record.shareableActivityToken == token && record.attachedToProcess()) { return new ActivityTokens(record.token, record.assistToken, record.app.getThread(), record.shareableActivityToken); record.app.getThread(), record.shareableActivityToken, record.getUid()); } } return null; Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +5 −33 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.ShortcutServiceInternal; Loading Loading @@ -105,7 +104,6 @@ import com.android.server.pm.permission.LegacyPermissionManagerInternal; import com.android.server.soundtrigger.SoundTriggerInternal; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.ActivityTaskManagerInternal.ActivityTokens; import java.io.FileDescriptor; import java.io.PrintWriter; Loading @@ -128,7 +126,6 @@ public class VoiceInteractionManagerService extends SystemService { final ActivityManagerInternal mAmInternal; final ActivityTaskManagerInternal mAtmInternal; final UserManagerInternal mUserManagerInternal; final PackageManagerInternal mPackageManagerInternal; final ArrayMap<Integer, VoiceInteractionManagerServiceStub.SoundTriggerSession> mLoadedKeyphraseIds = new ArrayMap<>(); ShortcutServiceInternal mShortcutServiceInternal; Loading @@ -149,8 +146,6 @@ public class VoiceInteractionManagerService extends SystemService { LocalServices.getService(ActivityTaskManagerInternal.class)); mUserManagerInternal = Objects.requireNonNull( LocalServices.getService(UserManagerInternal.class)); mPackageManagerInternal = Objects.requireNonNull( LocalServices.getService(PackageManagerInternal.class)); LegacyPermissionManagerInternal permissionManagerInternal = LocalServices.getService( LegacyPermissionManagerInternal.class); Loading Loading @@ -374,21 +369,6 @@ public class VoiceInteractionManagerService extends SystemService { return new SoundTriggerSessionBinderProxy(session); } @GuardedBy("this") private void grantImplicitAccessLocked(int grantRecipientUid, @Nullable Intent intent) { if (mImpl == null) { Slog.w(TAG, "Cannot grant implicit access because mImpl is null."); return; } final int grantRecipientAppId = UserHandle.getAppId(grantRecipientUid); final int grantRecipientUserId = UserHandle.getUserId(grantRecipientUid); final int voiceInteractionUid = mImpl.mInfo.getServiceInfo().applicationInfo.uid; mPackageManagerInternal.grantImplicitAccess( grantRecipientUserId, intent, grantRecipientAppId, voiceInteractionUid, /* direct= */ true); } private IVoiceInteractionSoundTriggerSession createSoundTriggerSessionForSelfIdentity( IBinder client) { Identity identity = new Identity(); Loading Loading @@ -419,10 +399,11 @@ public class VoiceInteractionManagerService extends SystemService { @Override public void onShown() { synchronized (VoiceInteractionManagerServiceStub.this) { VoiceInteractionManagerServiceStub.this .grantImplicitAccessLocked(callingUid, if (mImpl != null) { mImpl.grantImplicitAccessLocked(callingUid, /* intent= */ null); } } mAtmInternal.onLocalVoiceInteractionStarted(token, mImpl.mActiveSession.mSession, mImpl.mActiveSession.mInteractor); Loading Loading @@ -995,7 +976,7 @@ public class VoiceInteractionManagerService extends SystemService { mContext.getPackageManager(), PackageManager.MATCH_ALL); if (activityInfo != null) { final int activityUid = activityInfo.applicationInfo.uid; grantImplicitAccessLocked(activityUid, intent); mImpl.grantImplicitAccessLocked(activityUid, intent); } else { Slog.w(TAG, "Cannot find ActivityInfo in startVoiceActivity."); } Loading Loading @@ -1039,15 +1020,6 @@ public class VoiceInteractionManagerService extends SystemService { } final long caller = Binder.clearCallingIdentity(); try { // Getting the UID corresponding to the taskId, and grant the visibility to it. final ActivityTokens tokens = mAtmInternal .getAttachedNonFinishingActivityForTask(taskId, /* token= */ null); final ComponentName componentName = mAtmInternal.getActivityName( tokens.getActivityToken()); grantImplicitAccessLocked(mPackageManagerInternal.getPackageUid( componentName.getPackageName(), PackageManager.MATCH_ALL, UserHandle.myUserId()), /* intent= */ null); mImpl.requestDirectActionsLocked(token, taskId, assistToken, cancellationCallback, resultCallback); } finally { Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +15 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ParceledListSlice; import android.content.pm.ServiceInfo; import android.hardware.soundtrigger.IRecognitionStatusCallback; Loading Loading @@ -80,6 +81,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Objects; class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConnection.Callback { final static String TAG = "VoiceInteractionServiceManager"; Loading @@ -100,6 +102,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne final ComponentName mComponent; final IActivityManager mAm; final IActivityTaskManager mAtm; final PackageManagerInternal mPackageManagerInternal; final VoiceInteractionServiceInfo mInfo; final ComponentName mSessionComponentName; final IWindowManager mIWindowManager; Loading Loading @@ -195,6 +198,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne mComponent = service; mAm = ActivityManager.getService(); mAtm = ActivityTaskManager.getService(); mPackageManagerInternal = Objects.requireNonNull( LocalServices.getService(PackageManagerInternal.class)); VoiceInteractionServiceInfo info; try { info = new VoiceInteractionServiceInfo(context.getPackageManager(), service, mUser); Loading Loading @@ -230,6 +235,15 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne Context.RECEIVER_EXPORTED); } public void grantImplicitAccessLocked(int grantRecipientUid, @Nullable Intent intent) { final int grantRecipientAppId = UserHandle.getAppId(grantRecipientUid); final int grantRecipientUserId = UserHandle.getUserId(grantRecipientUid); final int voiceInteractionUid = mInfo.getServiceInfo().applicationInfo.uid; mPackageManagerInternal.grantImplicitAccess( grantRecipientUserId, intent, grantRecipientAppId, voiceInteractionUid, /* direct= */ true); } public boolean showSessionLocked(Bundle args, int flags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken) { if (mActiveSession == null) { Loading Loading @@ -354,6 +368,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne VoiceInteractionManagerServiceImpl.this, token, taskId, assistToken, cancellationCallback, callback), REQUEST_DIRECT_ACTIONS_RETRY_TIME_MS); } else { grantImplicitAccessLocked(tokens.getUid(), /* intent= */ null); try { tokens.getApplicationThread().requestDirectActions(tokens.getActivityToken(), mActiveSession.mInteractor, cancellationCallback, callback); Loading Loading
services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +10 −1 Original line number Diff line number Diff line Loading @@ -338,14 +338,16 @@ public abstract class ActivityTaskManagerInternal { private final @NonNull IBinder mAssistToken; private final @NonNull IBinder mShareableActivityToken; private final @NonNull IApplicationThread mAppThread; private final int mUid; public ActivityTokens(@NonNull IBinder activityToken, @NonNull IBinder assistToken, @NonNull IApplicationThread appThread, @NonNull IBinder shareableActivityToken) { @NonNull IBinder shareableActivityToken, int uid) { mActivityToken = activityToken; mAssistToken = assistToken; mAppThread = appThread; mShareableActivityToken = shareableActivityToken; mUid = uid; } /** Loading Loading @@ -375,6 +377,13 @@ public abstract class ActivityTaskManagerInternal { public @NonNull IApplicationThread getApplicationThread() { return mAppThread; } /** * @return The UID of the activity */ public int getUid() { return mUid; } } public abstract void sendActivityResult(int callingUid, IBinder activityToken, Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −2 Original line number Diff line number Diff line Loading @@ -5820,14 +5820,16 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { if (token == null && list.get(0).attachedToProcess()) { ActivityRecord topRecord = list.get(0); return new ActivityTokens(topRecord.token, topRecord.assistToken, topRecord.app.getThread(), topRecord.shareableActivityToken); topRecord.app.getThread(), topRecord.shareableActivityToken, topRecord.getUid()); } // find the expected Activity for (int i = 0; i < list.size(); i++) { ActivityRecord record = list.get(i); if (record.shareableActivityToken == token && record.attachedToProcess()) { return new ActivityTokens(record.token, record.assistToken, record.app.getThread(), record.shareableActivityToken); record.app.getThread(), record.shareableActivityToken, record.getUid()); } } return null; Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +5 −33 Original line number Diff line number Diff line Loading @@ -35,7 +35,6 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.IPackageManager; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; import android.content.pm.ShortcutServiceInternal; Loading Loading @@ -105,7 +104,6 @@ import com.android.server.pm.permission.LegacyPermissionManagerInternal; import com.android.server.soundtrigger.SoundTriggerInternal; import com.android.server.utils.TimingsTraceAndSlog; import com.android.server.wm.ActivityTaskManagerInternal; import com.android.server.wm.ActivityTaskManagerInternal.ActivityTokens; import java.io.FileDescriptor; import java.io.PrintWriter; Loading @@ -128,7 +126,6 @@ public class VoiceInteractionManagerService extends SystemService { final ActivityManagerInternal mAmInternal; final ActivityTaskManagerInternal mAtmInternal; final UserManagerInternal mUserManagerInternal; final PackageManagerInternal mPackageManagerInternal; final ArrayMap<Integer, VoiceInteractionManagerServiceStub.SoundTriggerSession> mLoadedKeyphraseIds = new ArrayMap<>(); ShortcutServiceInternal mShortcutServiceInternal; Loading @@ -149,8 +146,6 @@ public class VoiceInteractionManagerService extends SystemService { LocalServices.getService(ActivityTaskManagerInternal.class)); mUserManagerInternal = Objects.requireNonNull( LocalServices.getService(UserManagerInternal.class)); mPackageManagerInternal = Objects.requireNonNull( LocalServices.getService(PackageManagerInternal.class)); LegacyPermissionManagerInternal permissionManagerInternal = LocalServices.getService( LegacyPermissionManagerInternal.class); Loading Loading @@ -374,21 +369,6 @@ public class VoiceInteractionManagerService extends SystemService { return new SoundTriggerSessionBinderProxy(session); } @GuardedBy("this") private void grantImplicitAccessLocked(int grantRecipientUid, @Nullable Intent intent) { if (mImpl == null) { Slog.w(TAG, "Cannot grant implicit access because mImpl is null."); return; } final int grantRecipientAppId = UserHandle.getAppId(grantRecipientUid); final int grantRecipientUserId = UserHandle.getUserId(grantRecipientUid); final int voiceInteractionUid = mImpl.mInfo.getServiceInfo().applicationInfo.uid; mPackageManagerInternal.grantImplicitAccess( grantRecipientUserId, intent, grantRecipientAppId, voiceInteractionUid, /* direct= */ true); } private IVoiceInteractionSoundTriggerSession createSoundTriggerSessionForSelfIdentity( IBinder client) { Identity identity = new Identity(); Loading Loading @@ -419,10 +399,11 @@ public class VoiceInteractionManagerService extends SystemService { @Override public void onShown() { synchronized (VoiceInteractionManagerServiceStub.this) { VoiceInteractionManagerServiceStub.this .grantImplicitAccessLocked(callingUid, if (mImpl != null) { mImpl.grantImplicitAccessLocked(callingUid, /* intent= */ null); } } mAtmInternal.onLocalVoiceInteractionStarted(token, mImpl.mActiveSession.mSession, mImpl.mActiveSession.mInteractor); Loading Loading @@ -995,7 +976,7 @@ public class VoiceInteractionManagerService extends SystemService { mContext.getPackageManager(), PackageManager.MATCH_ALL); if (activityInfo != null) { final int activityUid = activityInfo.applicationInfo.uid; grantImplicitAccessLocked(activityUid, intent); mImpl.grantImplicitAccessLocked(activityUid, intent); } else { Slog.w(TAG, "Cannot find ActivityInfo in startVoiceActivity."); } Loading Loading @@ -1039,15 +1020,6 @@ public class VoiceInteractionManagerService extends SystemService { } final long caller = Binder.clearCallingIdentity(); try { // Getting the UID corresponding to the taskId, and grant the visibility to it. final ActivityTokens tokens = mAtmInternal .getAttachedNonFinishingActivityForTask(taskId, /* token= */ null); final ComponentName componentName = mAtmInternal.getActivityName( tokens.getActivityToken()); grantImplicitAccessLocked(mPackageManagerInternal.getPackageUid( componentName.getPackageName(), PackageManager.MATCH_ALL, UserHandle.myUserId()), /* intent= */ null); mImpl.requestDirectActionsLocked(token, taskId, assistToken, cancellationCallback, resultCallback); } finally { Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +15 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.ParceledListSlice; import android.content.pm.ServiceInfo; import android.hardware.soundtrigger.IRecognitionStatusCallback; Loading Loading @@ -80,6 +81,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.Objects; class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConnection.Callback { final static String TAG = "VoiceInteractionServiceManager"; Loading @@ -100,6 +102,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne final ComponentName mComponent; final IActivityManager mAm; final IActivityTaskManager mAtm; final PackageManagerInternal mPackageManagerInternal; final VoiceInteractionServiceInfo mInfo; final ComponentName mSessionComponentName; final IWindowManager mIWindowManager; Loading Loading @@ -195,6 +198,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne mComponent = service; mAm = ActivityManager.getService(); mAtm = ActivityTaskManager.getService(); mPackageManagerInternal = Objects.requireNonNull( LocalServices.getService(PackageManagerInternal.class)); VoiceInteractionServiceInfo info; try { info = new VoiceInteractionServiceInfo(context.getPackageManager(), service, mUser); Loading Loading @@ -230,6 +235,15 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne Context.RECEIVER_EXPORTED); } public void grantImplicitAccessLocked(int grantRecipientUid, @Nullable Intent intent) { final int grantRecipientAppId = UserHandle.getAppId(grantRecipientUid); final int grantRecipientUserId = UserHandle.getUserId(grantRecipientUid); final int voiceInteractionUid = mInfo.getServiceInfo().applicationInfo.uid; mPackageManagerInternal.grantImplicitAccess( grantRecipientUserId, intent, grantRecipientAppId, voiceInteractionUid, /* direct= */ true); } public boolean showSessionLocked(Bundle args, int flags, IVoiceInteractionSessionShowCallback showCallback, IBinder activityToken) { if (mActiveSession == null) { Loading Loading @@ -354,6 +368,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne VoiceInteractionManagerServiceImpl.this, token, taskId, assistToken, cancellationCallback, callback), REQUEST_DIRECT_ACTIONS_RETRY_TIME_MS); } else { grantImplicitAccessLocked(tokens.getUid(), /* intent= */ null); try { tokens.getApplicationThread().requestDirectActions(tokens.getActivityToken(), mActiveSession.mInteractor, cancellationCallback, callback); Loading