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

Commit af22baee authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Skip the VDM call if running on the default device.

The call is redundant and is causing a performance regression.

We still need to call VDM if the device id association is not
the defult device but in the vast majority of cases it will be
skipped.

Test: presubmit
Fix: 316962296
Change-Id: I9e95d53dcdaf5fe0992d5fa2ec18933d0c005a1c
parent 398be22e
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -407,7 +407,7 @@ public final class ActivityThread extends ClientTransactionHandler

    private int mLastSessionId;
    // Holds the value of the last reported device ID value from the server for the top activity.
    int mLastReportedDeviceId;
    int mLastReportedDeviceId = Context.DEVICE_ID_DEFAULT;
    final ArrayMap<IBinder, CreateServiceData> mServicesData = new ArrayMap<>();
    @UnsupportedAppUsage
    final ArrayMap<IBinder, Service> mServices = new ArrayMap<>();
@@ -4856,12 +4856,15 @@ public final class ActivityThread extends ClientTransactionHandler
            service.attach(context, this, data.info.name, data.token, app,
                    ActivityManager.getService());
            if (!service.isUiContext()) { // WindowProviderService is a UI Context.
                if (mLastReportedDeviceId == Context.DEVICE_ID_DEFAULT) {
                    service.updateDeviceId(mLastReportedDeviceId);
                } else {
                    VirtualDeviceManager vdm = context.getSystemService(VirtualDeviceManager.class);
                if (mLastReportedDeviceId == Context.DEVICE_ID_DEFAULT
                        || vdm.isValidVirtualDeviceId(mLastReportedDeviceId)) {
                    if (vdm != null && vdm.isValidVirtualDeviceId(mLastReportedDeviceId)) {
                        service.updateDeviceId(mLastReportedDeviceId);
                    }
                }
            }
            service.onCreate();
            mServicesData.put(data.token, data);
            mServices.put(data.token, service);