diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-02-17 19:13:13 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2021-02-17 19:13:13 +0000 |
| commit | d271b73c5e281c4e219619ced10c262de7291890 (patch) | |
| tree | 3d8023f63a7b3d9335277e0cd8bfd1bc5e84354c /core/java | |
| parent | 197e2169b130817738519e51bf92fe2571973561 (diff) | |
| parent | ab42e66b4c27253a6a45c3ce70bd798694d44631 (diff) | |
Merge "Enforce nanoapp permissions for ContextHub APIs" into sc-dev
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/hardware/location/ContextHubManager.java | 12 | ||||
| -rw-r--r-- | core/java/android/hardware/location/IContextHubService.aidl | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/core/java/android/hardware/location/ContextHubManager.java b/core/java/android/hardware/location/ContextHubManager.java index ebb3021bf083..a65f36b14f13 100644 --- a/core/java/android/hardware/location/ContextHubManager.java +++ b/core/java/android/hardware/location/ContextHubManager.java @@ -24,6 +24,7 @@ import android.annotation.RequiresPermission; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.SystemService; +import android.app.ActivityThread; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; @@ -849,9 +850,18 @@ public final class ContextHubManager { attributionTag = context.getAttributionTag(); } + // Workaround for old APIs not providing a context + String packageName; + if (context != null) { + packageName = context.getPackageName(); + } else { + packageName = ActivityThread.currentPackageName(); + } + IContextHubClient clientProxy; try { - clientProxy = mService.createClient(hubInfo.getId(), clientInterface, attributionTag); + clientProxy = mService.createClient( + hubInfo.getId(), clientInterface, attributionTag, packageName); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/hardware/location/IContextHubService.aidl b/core/java/android/hardware/location/IContextHubService.aidl index 4961195a3017..92882c4f93bb 100644 --- a/core/java/android/hardware/location/IContextHubService.aidl +++ b/core/java/android/hardware/location/IContextHubService.aidl @@ -60,7 +60,8 @@ interface IContextHubService { // Creates a client to send and receive messages IContextHubClient createClient( - int contextHubId, in IContextHubClientCallback client, in String attributionTag); + int contextHubId, in IContextHubClientCallback client, in String attributionTag, + in String packageName); // Creates a PendingIntent-based client to send and receive messages IContextHubClient createPendingIntentClient( |
