Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6332b05 authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

SF backdoor for primary display hotplug

This is a backdoor for SurfaceFlinger which injects a hotplug
event for the primary display. This causes SF to deallocate and
reallocate the  display state including framebuffers. From the
user perspective this should look like a noop because HWC will
return the same display properties.

Bug: 167670568
Test: adb shell service call SurfaceFlinger 1037
Change-Id: Ie52aac67571ed41c1a796797b7d7c54bcbdd9bdc
parent 8ff31f2c
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -5035,9 +5035,9 @@ status_t SurfaceFlinger::CheckTransactCodeCredentials(uint32_t code) {
        code == IBinder::SYSPROPS_TRANSACTION) {
        return OK;
    }
    // Numbers from 1000 to 1036 are currently used for backdoors. The code
    // Numbers from 1000 to 1037 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 <= 1036) {
    if (code >= 1000 && code <= 1037) {
        ALOGV("Accessing SurfaceFlinger through backdoor code: %u", code);
        return OK;
    }
@@ -5379,6 +5379,23 @@ status_t SurfaceFlinger::onTransact(uint32_t code, const Parcel& data, Parcel* r
                }
                return NO_ERROR;
            }
            // Inject a hotplug connected event for the primary display. This will deallocate and
            // reallocate the display state including framebuffers.
            case 1037: {
                const auto token = getInternalDisplayToken();

                sp<DisplayDevice> display;
                {
                    Mutex::Autolock lock(mStateLock);
                    display = getDisplayDeviceLocked(token);
                }
                const auto hwcId =
                        getHwComposer().fromPhysicalDisplayId(PhysicalDisplayId(*display->getId()));

                onHotplugReceived(getBE().mComposerSequenceId, *hwcId, hal::Connection::CONNECTED);

                return NO_ERROR;
            }
        }
    }
    return err;