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

Commit 90f4380b authored by Marvin Ramin's avatar Marvin Ramin
Browse files

Simplify ProxyManager#displayBelongsToCaller

Bug: 399840253
Test: presubmit
Flag: EXEMPT refactor
Change-Id: I1c761e004626e202f7cc71420aa26322768045e5
parent 92b95d68
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.accessibilityservice.AccessibilityServiceInfo;
import android.accessibilityservice.AccessibilityTrace;
import android.accessibilityservice.IAccessibilityServiceClient;
import android.annotation.NonNull;
import android.companion.virtual.VirtualDevice;
import android.companion.virtual.VirtualDeviceManager;
import android.content.ComponentName;
import android.content.Context;
@@ -378,21 +377,12 @@ public class ProxyManager {

    /** Returns true if the display belongs to one of the caller's virtual devices. */
    public boolean displayBelongsToCaller(int callingUid, int proxyDisplayId) {
        final VirtualDeviceManager vdm = mContext.getSystemService(VirtualDeviceManager.class);
        final VirtualDeviceManagerInternal localVdm = getLocalVdm();
        if (vdm == null || localVdm == null) {
        if (localVdm == null) {
            return false;
        }
        final List<VirtualDevice> virtualDevices = vdm.getVirtualDevices();
        for (VirtualDevice device : virtualDevices) {
            if (localVdm.getDisplayIdsForDevice(device.getDeviceId()).contains(proxyDisplayId)) {
                final int ownerUid = localVdm.getDeviceOwnerUid(device.getDeviceId());
                if (callingUid == ownerUid) {
                    return true;
                }
            }
        }
        return false;
        int deviceId = localVdm.getDeviceIdForDisplayId(proxyDisplayId);
        return callingUid == localVdm.getDeviceOwnerUid(deviceId);
    }

    /**