From d407190b3691b8b404143281840b805ee21d7f8f Mon Sep 17 00:00:00 2001 From: Steven Thomas Date: Tue, 24 Mar 2020 16:02:53 -0700 Subject: Add frame rate flexibility token Add support for temporarily relaxing frame rate restrictions in surface flinger. This is used by CTS tests to get a consistent device state while running frame rate tests. Bug: 148033900 Test: - On a Pixel 4, I turned the brightness down and covered the ambient light sensor, causing the display manager to set a frame rate restriction. I ran the frame rate CTS test without these CLs applied, and confirmed the test failed because surface flinger couldn't switch frame rates, as expected. Then I ran the tests with the CLs applied, and confirmed the tests pass. - I confirmed that, without adopting shell permission identity, the CTS test is denied the request to acquire a frame rate flexibility token. So normal apps won't be able to access this. Change-Id: I6685edc4bc07c7888b79a9dd72a90f56b74e7604 --- libs/gui/ISurfaceComposer.cpp | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'libs/gui/ISurfaceComposer.cpp') diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp index 8d79cf8723..bd4d62c4f7 100644 --- a/libs/gui/ISurfaceComposer.cpp +++ b/libs/gui/ISurfaceComposer.cpp @@ -1145,6 +1145,42 @@ public: ALOGE("setFrameRate: failed to transact: %s (%d)", strerror(-err), err); return err; } + + return reply.readInt32(); + } + + virtual status_t acquireFrameRateFlexibilityToken(sp* outToken) { + if (!outToken) return BAD_VALUE; + + Parcel data, reply; + status_t err = data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); + if (err != NO_ERROR) { + ALOGE("acquireFrameRateFlexibilityToken: failed writing interface token: %s (%d)", + strerror(-err), -err); + return err; + } + + err = remote()->transact(BnSurfaceComposer::ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN, data, + &reply); + if (err != NO_ERROR) { + ALOGE("acquireFrameRateFlexibilityToken: failed to transact: %s (%d)", strerror(-err), + err); + return err; + } + + err = reply.readInt32(); + if (err != NO_ERROR) { + ALOGE("acquireFrameRateFlexibilityToken: call failed: %s (%d)", strerror(-err), err); + return err; + } + + err = reply.readStrongBinder(outToken); + if (err != NO_ERROR) { + ALOGE("acquireFrameRateFlexibilityToken: failed reading binder token: %s (%d)", + strerror(-err), err); + return err; + } + return NO_ERROR; } }; @@ -1945,6 +1981,16 @@ status_t BnSurfaceComposer::onTransact( reply->writeInt32(result); return NO_ERROR; } + case ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN: { + CHECK_INTERFACE(ISurfaceComposer, data, reply); + sp token; + status_t result = acquireFrameRateFlexibilityToken(&token); + reply->writeInt32(result); + if (result == NO_ERROR) { + reply->writeStrongBinder(token); + } + return NO_ERROR; + } default: { return BBinder::onTransact(code, data, reply, flags); } -- cgit v1.2.3-59-g8ed1b