SurfaceFlinger: add a backdoor to override DisplayManager policy

Added a new backdoor, for debugging purposes, to override DisplayManager
policy and allow SurfaceFlinger to freely switch refresh rates.

To override DisplayManager policy:
	adb shell service call SurfaceFlinger 1036 i32 1
To undo the override
	adb shell service call SurfaceFlinger 1036 i32 0

Bug: 152411921
Test: override policy by backdoor and observe dumpsys SurfaceFlinger
Change-Id: I14bb4722986f6df9100959eea66e5e3a3fa6f953
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 3264642..1c5b32c 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -4398,11 +4398,19 @@
 
     scheduler::RefreshRateConfigs::Policy policy = mRefreshRateConfigs->getDisplayManagerPolicy();
     StringAppendF(&result,
-                  "DesiredDisplayConfigSpecs: default config ID: %d"
+                  "DesiredDisplayConfigSpecs (DisplayManager): default config ID: %d"
                   ", min: %.2f Hz, max: %.2f Hz",
                   policy.defaultConfig.value(), policy.minRefreshRate, policy.maxRefreshRate);
     StringAppendF(&result, "(config override by backdoor: %s)\n\n",
                   mDebugDisplayConfigSetByBackdoor ? "yes" : "no");
+    scheduler::RefreshRateConfigs::Policy currentPolicy = mRefreshRateConfigs->getCurrentPolicy();
+    if (currentPolicy != policy) {
+        StringAppendF(&result,
+                      "DesiredDisplayConfigSpecs (Override): default config ID: %d"
+                      ", min: %.2f Hz, max: %.2f Hz\n\n",
+                      currentPolicy.defaultConfig.value(), currentPolicy.minRefreshRate,
+                      currentPolicy.maxRefreshRate);
+    }
 
     mScheduler->dump(mAppConnectionHandle, result);
     mScheduler->getPrimaryDispSync().dump(result);
@@ -4927,9 +4935,9 @@
         code == IBinder::SYSPROPS_TRANSACTION) {
         return OK;
     }
-    // Numbers from 1000 to 1034 are currently used for backdoors. The code
+    // Numbers from 1000 to 1036 are currently used for backdoors. The code
     // in onTransact verifies that the user is root, and has access to use SF.
-    if (code >= 1000 && code <= 1035) {
+    if (code >= 1000 && code <= 1036) {
         ALOGV("Accessing SurfaceFlinger through backdoor code: %u", code);
         return OK;
     }
@@ -5258,6 +5266,18 @@
                 }
                 return NO_ERROR;
             }
+            case 1036: {
+                if (data.readInt32() > 0) {
+                    status_t result =
+                            acquireFrameRateFlexibilityToken(&mDebugFrameRateFlexibilityToken);
+                    if (result != NO_ERROR) {
+                        return result;
+                    }
+                } else {
+                    mDebugFrameRateFlexibilityToken = nullptr;
+                }
+                return NO_ERROR;
+            }
         }
     }
     return err;