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

Commit 858c55f7 authored by Steven Moreland's avatar Steven Moreland
Browse files

sf: avoid assumption remote binder is local

We are lucky that a test was passing a remote binder here and that I
happened to reorder elements in BpBinder, since this caused a crash,
where before, 'owner' was getting set to some random bits inside of a
BpBinder object.

Bug: 150904694
Test: move mTrackingUid around in BpBinder, then
    `atest CompositionSamplingListenerTest` passes

Change-Id: I552a669113844a6b7ceaba5a1197fd04ca7e18d5
parent 966d74c4
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -201,9 +201,10 @@ RegionSamplingThread::~RegionSamplingThread() {

void RegionSamplingThread::addListener(const Rect& samplingArea, const sp<IBinder>& stopLayerHandle,
                                       const sp<IRegionSamplingListener>& listener) {
    wp<Layer> stopLayer = stopLayerHandle != nullptr
            ? static_cast<Layer::Handle*>(stopLayerHandle.get())->owner
            : nullptr;
    wp<Layer> stopLayer;
    if (stopLayerHandle != nullptr && stopLayerHandle->localBinder() != nullptr) {
        stopLayer = static_cast<Layer::Handle*>(stopLayerHandle.get())->owner;
    }

    sp<IBinder> asBinder = IInterface::asBinder(listener);
    asBinder->linkToDeath(this);