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

Commit aadc4e44 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add robustness for permissions errors to Surface APIs." into sc-dev am:...

Merge "Add robustness for permissions errors to Surface APIs." into sc-dev am: a3d681c3 am: b01eb768

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/14466581

Change-Id: Ie552643a3300ca0f3438057268e125cec26396ce
parents 58563c32 b01eb768
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1268,8 +1268,11 @@ int Surface::query(int what, int* value) const {
                if (err == NO_ERROR) {
                    return NO_ERROR;
                }
                if (composerService()->authenticateSurfaceTexture(
                        mGraphicBufferProducer)) {
                sp<ISurfaceComposer> surfaceComposer = composerService();
                if (surfaceComposer == nullptr) {
                    return -EPERM; // likely permissions error
                }
                if (surfaceComposer->authenticateSurfaceTexture(mGraphicBufferProducer)) {
                    *value = 1;
                } else {
                    *value = 0;
+8 −7
Original line number Diff line number Diff line
@@ -65,12 +65,12 @@ ComposerService::ComposerService()
    connectLocked();
}

void ComposerService::connectLocked() {
bool ComposerService::connectLocked() {
    const String16 name("SurfaceFlinger");
    while (getService(name, &mComposerService) != NO_ERROR) {
        usleep(250000);
    mComposerService = waitForService<ISurfaceComposer>(name);
    if (mComposerService == nullptr) {
        return false; // fatal error or permission problem
    }
    assert(mComposerService != nullptr);

    // Create the death listener.
    class DeathObserver : public IBinder::DeathRecipient {
@@ -86,16 +86,17 @@ void ComposerService::connectLocked() {

    mDeathObserver = new DeathObserver(*const_cast<ComposerService*>(this));
    IInterface::asBinder(mComposerService)->linkToDeath(mDeathObserver);
    return true;
}

/*static*/ sp<ISurfaceComposer> ComposerService::getComposerService() {
    ComposerService& instance = ComposerService::getInstance();
    Mutex::Autolock _l(instance.mLock);
    if (instance.mComposerService == nullptr) {
        ComposerService::getInstance().connectLocked();
        assert(instance.mComposerService != nullptr);
        if (ComposerService::getInstance().connectLocked()) {
            ALOGD("ComposerService reconnected");
        }
    }
    return instance.mComposerService;
}

+2 −3
Original line number Diff line number Diff line
@@ -45,13 +45,12 @@ class ComposerService : public Singleton<ComposerService>
    Mutex mLock;

    ComposerService();
    void connectLocked();
    bool connectLocked();
    void composerServiceDied();
    friend class Singleton<ComposerService>;
public:

    // Get a connection to the Composer Service.  This will block until
    // a connection is established.
    // a connection is established. Returns null if permission is denied.
    static sp<ISurfaceComposer> getComposerService();
};