diff options
| author | 2020-03-24 16:02:53 -0700 | |
|---|---|---|
| committer | 2020-04-06 12:55:16 -0700 | |
| commit | d407190b3691b8b404143281840b805ee21d7f8f (patch) | |
| tree | 6f5ea79535e90f0c42940db76f4ef57d2b368c8d /libs/gui/ISurfaceComposer.cpp | |
| parent | 4e2936c2d1d9fa231da596c4288a612574a194e8 (diff) | |
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
Diffstat (limited to 'libs/gui/ISurfaceComposer.cpp')
| -rw-r--r-- | libs/gui/ISurfaceComposer.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
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<IBinder>* 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<IBinder> 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); } |