Change fps listener permission to allow systemui to use it.

Require READ_FRAME_BUFFER permission instead of ACCESS_SURFACE_FLINGER,
so that systemui is allowed to listen to FPS measurements.

Strictly speaking, the fps listener does not require as strict of
permissions as screenshots because there's no on-screen content, but
systemui is already requesting this permission, and we probably don't
want arbitrary apps to backdoor into this api.

Bug: 174956756
Test: end to end integration test to check that systemui does not crash
when registering the listener.

Change-Id: I9149618950988250ae2649ac5242d5165b5037db
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 31b253c..292fd1c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4945,8 +4945,6 @@
         case GET_DISPLAYED_CONTENT_SAMPLE:
         case NOTIFY_POWER_BOOST:
         case SET_GLOBAL_SHADOW_SETTINGS:
-        case ADD_FPS_LISTENER:
-        case REMOVE_FPS_LISTENER:
         case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: {
             // ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN is used by CTS tests, which acquire the
             // necessary permission dynamically. Don't use the permission cache for this check.
@@ -5009,6 +5007,8 @@
             // This is not sensitive information, so should not require permission control.
             return OK;
         }
+        case ADD_FPS_LISTENER:
+        case REMOVE_FPS_LISTENER:
         case ADD_REGION_SAMPLING_LISTENER:
         case REMOVE_REGION_SAMPLING_LISTENER: {
             // codes that require permission check