diff options
author | Philip P. Moltmann <moltmann@google.com> | 2020-01-10 08:53:43 -0800 |
---|---|---|
committer | Philip P. Moltmann <moltmann@google.com> | 2020-02-08 22:53:43 +0000 |
commit | 9c5226fe363245e454d715cc4009ac9a80de5b6a (patch) | |
tree | 88f66be06917b639c0545ef39da437c722979227 /services/voiceinteraction | |
parent | a540e1eea92091dcdf1a3a9ef1af2a78017497e1 (diff) |
Activity start: Send featureId from context->AppOpsManager
The expected usage pattern for noteOp is to get the
Context#getOpPackageName() and Context#getFeatureId() in the calling app
and the call
noteOp(callingPackageName, Binder.getCallingUid(), callingFeatureId)
As the featureId parameter is new this parameter has to been piped all
through from the ...Manager classes running in the app all way deep into
the bowels of the system server.
There is a special featureId==null for the "default" feature. This is
used in two cases:
- In case the system server (packageName == null || packageName ==
"android") makes a call
- In the case there is no caller. In this case I left annotations in the
code to make clear that the default feature is used
Raw binder interfaces (defined in AIDL files) are not supposed to be
used by apps. Still historically this has happened and we ended up with
@UnsupportedAppUsage tags in these files. Also AIDL does not support
two methods with the same name but different parameters. I.e. in the
case when I had to add a paramater to a method tagged as UnsupportedAppUsage I
- created a new method ...WithFeature with the additional paramter
- set a maxTargetSDK for the old method and mention the public API to
use in the deprecation method
This is really not pretty. Once there is no more app using the old
internal API this hack can be removed.
Additionally this change removed all internal calls to
AppOpsService.noteOperation and AppOpsService.checkOperation and
replaces them with the public API equivalent. This sometimes means to
move the resolution of the mAppOpsManager to be lazy.
Exempt-From-Owner-Approval:: Just piping through arguments
Bug: 136595429
Test: atest --test-mapping frameworks/base/services/core/java/com/android/server/am/
atest CtsAppOpsTestCases added test to cover activity start
atest WmTests
Change-Id: Ic7056b492cb1c9a79158e6c2b4864898a0eb5b2a
Diffstat (limited to 'services/voiceinteraction')
2 files changed, 17 insertions, 15 deletions
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java index d5eec332cda0..8378d8ed9f68 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java @@ -747,7 +747,8 @@ public class VoiceInteractionManagerService extends SystemService { } @Override - public int startVoiceActivity(IBinder token, Intent intent, String resolvedType) { + public int startVoiceActivity(IBinder token, Intent intent, String resolvedType, + String callingFeatureId) { synchronized (this) { if (mImpl == null) { Slog.w(TAG, "startVoiceActivity without running voice interaction service"); @@ -757,8 +758,8 @@ public class VoiceInteractionManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final long caller = Binder.clearCallingIdentity(); try { - return mImpl.startVoiceActivityLocked(callingPid, callingUid, token, - intent, resolvedType); + return mImpl.startVoiceActivityLocked(callingFeatureId, callingPid, callingUid, + token, intent, resolvedType); } finally { Binder.restoreCallingIdentity(caller); } @@ -766,7 +767,8 @@ public class VoiceInteractionManagerService extends SystemService { } @Override - public int startAssistantActivity(IBinder token, Intent intent, String resolvedType) { + public int startAssistantActivity(IBinder token, Intent intent, String resolvedType, + String callingFeatureId) { synchronized (this) { if (mImpl == null) { Slog.w(TAG, "startAssistantActivity without running voice interaction service"); @@ -776,8 +778,8 @@ public class VoiceInteractionManagerService extends SystemService { final int callingUid = Binder.getCallingUid(); final long caller = Binder.clearCallingIdentity(); try { - return mImpl.startAssistantActivityLocked(callingPid, callingUid, token, - intent, resolvedType); + return mImpl.startAssistantActivityLocked(callingFeatureId, callingPid, + callingUid, token, intent, resolvedType); } finally { Binder.restoreCallingIdentity(caller); } diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java index a1210cfce26d..a62b03ca82e4 100644 --- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java +++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java @@ -216,8 +216,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne return true; } - public int startVoiceActivityLocked(int callingPid, int callingUid, IBinder token, - Intent intent, String resolvedType) { + public int startVoiceActivityLocked(@Nullable String callingFeatureId, int callingPid, + int callingUid, IBinder token, Intent intent, String resolvedType) { try { if (mActiveSession == null || token != mActiveSession.mToken) { Slog.w(TAG, "startVoiceActivity does not match active session"); @@ -230,16 +230,16 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne intent = new Intent(intent); intent.addCategory(Intent.CATEGORY_VOICE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); - return mAtm.startVoiceActivity(mComponent.getPackageName(), callingPid, callingUid, - intent, resolvedType, mActiveSession.mSession, mActiveSession.mInteractor, - 0, null, null, mUser); + return mAtm.startVoiceActivity(mComponent.getPackageName(), callingFeatureId, + callingPid, callingUid, intent, resolvedType, mActiveSession.mSession, + mActiveSession.mInteractor, 0, null, null, mUser); } catch (RemoteException e) { throw new IllegalStateException("Unexpected remote error", e); } } - public int startAssistantActivityLocked(int callingPid, int callingUid, IBinder token, - Intent intent, String resolvedType) { + public int startAssistantActivityLocked(@Nullable String callingFeatureId, int callingPid, + int callingUid, IBinder token, Intent intent, String resolvedType) { try { if (mActiveSession == null || token != mActiveSession.mToken) { Slog.w(TAG, "startAssistantActivity does not match active session"); @@ -253,8 +253,8 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final ActivityOptions options = ActivityOptions.makeBasic(); options.setLaunchActivityType(ACTIVITY_TYPE_ASSISTANT); - return mAtm.startAssistantActivity(mComponent.getPackageName(), callingPid, callingUid, - intent, resolvedType, options.toBundle(), mUser); + return mAtm.startAssistantActivity(mComponent.getPackageName(), callingFeatureId, + callingPid, callingUid, intent, resolvedType, options.toBundle(), mUser); } catch (RemoteException e) { throw new IllegalStateException("Unexpected remote error", e); } |