Handle multi-user when disabling MediaMetrics service.
This logic was added in I740b4f5acb88821197e3c4023a4032babd48ec5a but
didn't work for multi-user. Some tests in CtsVoiceInteractionTestCases
where failing on Automotive (in a multi-user environment) because of
additional delays in the test trying to access the MediaMetrics service.
Real world impact: For any secondary user (NOT user 0), the first time
the hotword is spoken after the HotwordDetectionService process starts,
detection fails because the delay causes a timeout in detection. This is
not just a one-time occurrence, as the process may occasionally get
restarted.
Bug: 214488187
Test: `atest CtsVoiceInteractionTestCases` on a raven_car build
Change-Id: If5c721c9acfc78f1cbc35c3056adad95a4604f8b
diff --git a/media/libmediametrics/MediaMetricsItem.cpp b/media/libmediametrics/MediaMetricsItem.cpp
index 57fc49d..ecb248d 100644
--- a/media/libmediametrics/MediaMetricsItem.cpp
+++ b/media/libmediametrics/MediaMetricsItem.cpp
@@ -26,6 +26,7 @@
#include <unordered_map>
#include <binder/Parcel.h>
+#include <cutils/multiuser.h>
#include <cutils/properties.h>
#include <utils/Errors.h>
#include <utils/Log.h>
@@ -343,7 +344,8 @@
// now.
// TODO(b/190151205): Either allow the HotwordDetectionService to access MediaMetrics or
// make this disabling specific to that process.
- if (uid >= AID_ISOLATED_START && uid <= AID_ISOLATED_END) {
+ uid_t appid = multiuser_get_app_id(uid);
+ if (appid >= AID_ISOLATED_START && appid <= AID_ISOLATED_END) {
return false;
}
break;