MediaPlayer: Use uid_t for uids
Test: Power manager shows correct uids
Bug: 32713790
Change-Id: Iddf8de5705319ec17c68787efc11e342779660c5
diff --git a/media/utils/BatteryNotifier.cpp b/media/utils/BatteryNotifier.cpp
index 7a7321f..09bc042 100644
--- a/media/utils/BatteryNotifier.cpp
+++ b/media/utils/BatteryNotifier.cpp
@@ -38,7 +38,7 @@
}
}
-void BatteryNotifier::noteStartVideo(int uid) {
+void BatteryNotifier::noteStartVideo(uid_t uid) {
Mutex::Autolock _l(mLock);
sp<IBatteryStats> batteryService = getBatteryService_l();
if (mVideoRefCounts[uid] == 0 && batteryService != nullptr) {
@@ -47,7 +47,7 @@
mVideoRefCounts[uid]++;
}
-void BatteryNotifier::noteStopVideo(int uid) {
+void BatteryNotifier::noteStopVideo(uid_t uid) {
Mutex::Autolock _l(mLock);
if (mVideoRefCounts.find(uid) == mVideoRefCounts.end()) {
ALOGW("%s: video refcount is broken for uid(%d).", __FUNCTION__, (int)uid);
@@ -74,7 +74,7 @@
}
}
-void BatteryNotifier::noteStartAudio(int uid) {
+void BatteryNotifier::noteStartAudio(uid_t uid) {
Mutex::Autolock _l(mLock);
sp<IBatteryStats> batteryService = getBatteryService_l();
if (mAudioRefCounts[uid] == 0 && batteryService != nullptr) {
@@ -83,7 +83,7 @@
mAudioRefCounts[uid]++;
}
-void BatteryNotifier::noteStopAudio(int uid) {
+void BatteryNotifier::noteStopAudio(uid_t uid) {
Mutex::Autolock _l(mLock);
if (mAudioRefCounts.find(uid) == mAudioRefCounts.end()) {
ALOGW("%s: audio refcount is broken for uid(%d).", __FUNCTION__, (int)uid);
@@ -110,11 +110,11 @@
}
}
-void BatteryNotifier::noteFlashlightOn(const String8& id, int uid) {
+void BatteryNotifier::noteFlashlightOn(const String8& id, uid_t uid) {
Mutex::Autolock _l(mLock);
sp<IBatteryStats> batteryService = getBatteryService_l();
- std::pair<String8, int> k = std::make_pair(id, uid);
+ std::pair<String8, uid_t> k = std::make_pair(id, uid);
if (!mFlashlightState[k]) {
mFlashlightState[k] = true;
if (batteryService != nullptr) {
@@ -123,11 +123,11 @@
}
}
-void BatteryNotifier::noteFlashlightOff(const String8& id, int uid) {
+void BatteryNotifier::noteFlashlightOff(const String8& id, uid_t uid) {
Mutex::Autolock _l(mLock);
sp<IBatteryStats> batteryService = getBatteryService_l();
- std::pair<String8, int> k = std::make_pair(id, uid);
+ std::pair<String8, uid_t> k = std::make_pair(id, uid);
if (mFlashlightState[k]) {
mFlashlightState[k] = false;
if (batteryService != nullptr) {
@@ -145,10 +145,10 @@
}
}
-void BatteryNotifier::noteStartCamera(const String8& id, int uid) {
+void BatteryNotifier::noteStartCamera(const String8& id, uid_t uid) {
Mutex::Autolock _l(mLock);
sp<IBatteryStats> batteryService = getBatteryService_l();
- std::pair<String8, int> k = std::make_pair(id, uid);
+ std::pair<String8, uid_t> k = std::make_pair(id, uid);
if (!mCameraState[k]) {
mCameraState[k] = true;
if (batteryService != nullptr) {
@@ -157,10 +157,10 @@
}
}
-void BatteryNotifier::noteStopCamera(const String8& id, int uid) {
+void BatteryNotifier::noteStopCamera(const String8& id, uid_t uid) {
Mutex::Autolock _l(mLock);
sp<IBatteryStats> batteryService = getBatteryService_l();
- std::pair<String8, int> k = std::make_pair(id, uid);
+ std::pair<String8, uid_t> k = std::make_pair(id, uid);
if (mCameraState[k]) {
mCameraState[k] = false;
if (batteryService != nullptr) {
@@ -211,7 +211,7 @@
// Notify start now if mediaserver or audioserver is already started.
// 1) mediaserver and audioserver is started before batterystats service
// 2) batterystats server may have crashed.
- std::map<int, int>::iterator it = mVideoRefCounts.begin();
+ std::map<uid_t, int>::iterator it = mVideoRefCounts.begin();
for (; it != mVideoRefCounts.end(); ++it) {
mBatteryStatService->noteStartVideo(it->first);
}
diff --git a/media/utils/include/mediautils/BatteryNotifier.h b/media/utils/include/mediautils/BatteryNotifier.h
index 2ba4c76..a4e42ad 100644
--- a/media/utils/include/mediautils/BatteryNotifier.h
+++ b/media/utils/include/mediautils/BatteryNotifier.h
@@ -37,17 +37,17 @@
public:
~BatteryNotifier();
- void noteStartVideo(int uid);
- void noteStopVideo(int uid);
+ void noteStartVideo(uid_t uid);
+ void noteStopVideo(uid_t uid);
void noteResetVideo();
- void noteStartAudio(int uid);
- void noteStopAudio(int uid);
+ void noteStartAudio(uid_t uid);
+ void noteStopAudio(uid_t uid);
void noteResetAudio();
- void noteFlashlightOn(const String8& id, int uid);
- void noteFlashlightOff(const String8& id, int uid);
+ void noteFlashlightOn(const String8& id, uid_t uid);
+ void noteFlashlightOff(const String8& id, uid_t uid);
void noteResetFlashlight();
- void noteStartCamera(const String8& id, int uid);
- void noteStopCamera(const String8& id, int uid);
+ void noteStartCamera(const String8& id, uid_t uid);
+ void noteStopCamera(const String8& id, uid_t uid);
void noteResetCamera();
private:
@@ -58,10 +58,10 @@
};
Mutex mLock;
- std::map<int, int> mVideoRefCounts;
- std::map<int, int> mAudioRefCounts;
- std::map<std::pair<String8, int>, bool> mFlashlightState;
- std::map<std::pair<String8, int>, bool> mCameraState;
+ std::map<uid_t, int> mVideoRefCounts;
+ std::map<uid_t, int> mAudioRefCounts;
+ std::map<std::pair<String8, uid_t>, bool> mFlashlightState;
+ std::map<std::pair<String8, uid_t>, bool> mCameraState;
sp<IBatteryStats> mBatteryStatService;
sp<DeathNotifier> mDeathNotifier;