[SurfaceFlinger] Allow root to capture screen.
If adb is running in root, then uid is AID_ROOT and capture screen will fail.
This patch allows root to capture screen.
BUG: 132777517
Test: adb shell screencap -d 0 -p /sdcard/test.png produces a valid screenshot
Change-Id: Ib6eaad2dffa7a68f4b1fce548814f0c2f172c3fd
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 4d885fb..3d71267 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -5100,7 +5100,7 @@
case CAPTURE_SCREEN_BY_ID: {
IPCThreadState* ipc = IPCThreadState::self();
const int uid = ipc->getCallingUid();
- if ((uid == AID_GRAPHICS) || (uid == AID_SYSTEM) || (uid == AID_SHELL)) {
+ if (uid == AID_ROOT || uid == AID_GRAPHICS || uid == AID_SYSTEM || uid == AID_SHELL) {
return OK;
}
return PERMISSION_DENIED;