Merge "Query the uid process state in opChanged instead of relying on callbacks." into main
diff --git a/camera/camera_platform.aconfig b/camera/camera_platform.aconfig
index 968b28f..2feebb4 100644
--- a/camera/camera_platform.aconfig
+++ b/camera/camera_platform.aconfig
@@ -246,3 +246,13 @@
purpose: PURPOSE_FEATURE
}
}
+
+flag {
+ namespace: "camera_platform"
+ name: "query_process_state"
+ description: "In opChanged, query the process state from AM instead of relying on mUidPolicy"
+ bug: "378016494"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 20b78b7..df94478 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -4550,6 +4550,17 @@
return OK;
}
+int32_t CameraService::getUidProcessState(int32_t uid) {
+ const auto& activityManager = getActivityManager();
+ int32_t procState = ActivityManager::PROCESS_STATE_NONEXISTENT;
+ if (activityManager != nullptr) {
+ procState = activityManager->getUidProcessState(uid, toString16(kServiceName));
+ } else {
+ ALOGE("%s: getActivityManager returned nullptr.", __FUNCTION__);
+ }
+ return procState;
+}
+
void CameraService::BasicClient::opChanged(int32_t op, const String16&) {
ATRACE_CALL();
if (mAppOpsManager == nullptr) {
@@ -4606,12 +4617,9 @@
[&](const auto& attr) {
uid = static_cast<uid_t>(attr.uid);
});
- const auto& activityManager = getActivityManager();
- if (activityManager != nullptr) {
- procState = activityManager->getUidProcessState(uid, toString16(kServiceName));
- } else {
- ALOGD("%s: getActivityManager returned nullptr.", __FUNCTION__);
- }
+ procState = getUidProcessState(uid);
+ } else if (flags::query_process_state()) {
+ procState = getUidProcessState(getClientUid());
} else {
procState = sCameraService->mUidPolicy->getProcState(getClientUid());
}
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 7e82401..9c75ede 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -691,6 +691,8 @@
return activityManager;
}
+ static int32_t getUidProcessState(int32_t uid);
+
/**
* Typesafe version of device status, containing both the HAL-layer and the service interface-
* layer values.