Sensor: Make getId() more varied
Apps from different developers will now receive a different
ID for the same dynamic sensor. Additionally, all apps
will now receive a different/new ID for the same dynamic
sensor after a factory reset.
Bug: 28775590, 29547335
Change-Id: I368655b0e4bdc16736a7fd163ea3f7dad2886b3b
diff --git a/include/gui/Sensor.h b/include/gui/Sensor.h
index 3f60741..094fd16 100644
--- a/include/gui/Sensor.h
+++ b/include/gui/Sensor.h
@@ -89,7 +89,14 @@
bool isDynamicSensor() const;
bool hasAdditionalInfo() const;
int32_t getReportingMode() const;
+
+ // Note that after setId() has been called, getUuid() no longer
+ // returns the UUID.
+ // TODO(b/29547335): Remove getUuid(), add getUuidIndex(), and
+ // make sure setId() doesn't change the UuidIndex.
const uuid_t& getUuid() const;
+ int32_t getId() const;
+ void setId(int32_t id);
// LightFlattenable protocol
inline bool isFixedSize() const { return false; }
@@ -116,6 +123,9 @@
int32_t mRequiredAppOp;
int32_t mMaxDelay;
uint32_t mFlags;
+ // TODO(b/29547335): Get rid of this field and replace with an index.
+ // The index will be into a separate global vector of UUIDs.
+ // Also add an mId field (and change flatten/unflatten appropriately).
uuid_t mUuid;
static void flattenString8(void*& buffer, size_t& size, const String8& string8);
static bool unflattenString8(void const*& buffer, size_t& size, String8& outputString8);