summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Greg Kaiser <gkaiser@google.com> 2016-08-25 22:06:08 -0700
committer Greg Kaiser <gkaiser@google.com> 2016-08-25 23:18:16 -0700
commit5817ce0c13c4d190845b0cc74a4232cc845c31e3 (patch)
treeb626dbd4d3e293fe5346a1f7eca0a43410ab34f2
parentf8d61675ac755a5110193e796e35e2e2a364387c (diff)
ContextHubService: Hack in Google vendor value
To workaround b/30808791 without changing the NanoApp API, we make the assumption that if the most significant byte of our four-byte app ID is a lower-case 'L', then this is a Google Nanoapp and thus we should use "Googl" for our vendor ID, and set the most significant four bytes of our eight byte app ID accordingly. Bug: 30922112 Change-Id: I155dff58cdda1ef36a68e6d25df1e9059b1252f1
-rw-r--r--core/java/android/hardware/location/ContextHubService.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/java/android/hardware/location/ContextHubService.java b/core/java/android/hardware/location/ContextHubService.java
index a699b687918b..eea2387d7dea 100644
--- a/core/java/android/hardware/location/ContextHubService.java
+++ b/core/java/android/hardware/location/ContextHubService.java
@@ -162,6 +162,28 @@ public class ContextHubService extends IContextHubService.Stub {
msgHeader[HEADER_FIELD_MSG_TYPE] = MSG_LOAD_NANO_APP;
long appId = app.getAppId();
+ // TODO(b/30808791): Remove this hack when the NanoApp API is fixed.
+ // Due to a bug in the NanoApp API, only the least significant four
+ // bytes of the app ID can be stored. The most significant five
+ // bytes of a normal app ID are the "vendor", and thus the most
+ // significant of the bytes we have is the least significant byte
+ // of the vendor. In the case that byte is the ASCII value for
+ // lower-case 'L', we assume the vendor is supposed to be "Googl"
+ // and fill in the four most significant bytes accordingly.
+ if ((appId >> 32) != 0) {
+ // We're unlikely to notice this warning, but at least
+ // we can avoid running our hack logic.
+ Log.w(TAG, "Code has not been updated since API fix.");
+ } else {
+ // Note: Lower-case 'L', not the number 1.
+ if (((appId >> 24) & 0xFF) == (long)'l') {
+ // Assume we're a Google nanoapp.
+ appId |= ((long)'G') << 56;
+ appId |= ((long)'o') << 48;
+ appId |= ((long)'o') << 40;
+ appId |= ((long)'g') << 32;
+ }
+ }
msgHeader[HEADER_FIELD_LOAD_APP_ID_LO] = (int)(appId & 0xFFFFFFFF);
msgHeader[HEADER_FIELD_LOAD_APP_ID_HI] = (int)((appId >> 32) & 0xFFFFFFFF);