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

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

Merge "Should call deviceGone for all the association" into udc-dev am: 3dcb7560

parents 3190a114 3dcb7560
Loading
Loading
Loading
Loading
+7 −7
Original line number Original line Diff line number Diff line
@@ -346,31 +346,31 @@ public class CompanionApplicationController {
        // Make sure do not schedule rebind for the case ServiceConnector still gets callback after
        // Make sure do not schedule rebind for the case ServiceConnector still gets callback after
        // app is uninstalled.
        // app is uninstalled.
        boolean stillAssociated = false;
        boolean stillAssociated = false;
        // Make sure to clean up the state for all the associations
        // that associate with this package.
        boolean shouldScheduleRebind = false;


        for (AssociationInfo ai :
        for (AssociationInfo ai :
                mAssociationStore.getAssociationsForPackage(userId, packageName)) {
                mAssociationStore.getAssociationsForPackage(userId, packageName)) {
            final int associationId = ai.getId();
            final int associationId = ai.getId();
            stillAssociated = true;
            stillAssociated = true;

            if (ai.isSelfManaged()) {
            if (ai.isSelfManaged()) {
                // Do not rebind if primary one is died for selfManaged application.
                // Do not rebind if primary one is died for selfManaged application.
                if (isPrimary
                if (isPrimary
                        && mDevicePresenceMonitor.isDevicePresent(associationId)) {
                        && mDevicePresenceMonitor.isDevicePresent(associationId)) {
                    mDevicePresenceMonitor.onSelfManagedDeviceReporterBinderDied(associationId);
                    mDevicePresenceMonitor.onSelfManagedDeviceReporterBinderDied(associationId);
                    return false;
                    shouldScheduleRebind = false;
                }
                }
                // Do not rebind if both primary and secondary services are died for
                // Do not rebind if both primary and secondary services are died for
                // selfManaged application.
                // selfManaged application.
                if (!isCompanionApplicationBound(userId, packageName)) {
                shouldScheduleRebind = isCompanionApplicationBound(userId, packageName);
                    return false;
                }
            } else if (ai.isNotifyOnDeviceNearby()) {
            } else if (ai.isNotifyOnDeviceNearby()) {
                // Always rebind for non-selfManaged devices.
                // Always rebind for non-selfManaged devices.
                return true;
                shouldScheduleRebind = true;
            }
            }
        }
        }


        return stillAssociated;
        return stillAssociated && shouldScheduleRebind;
    }
    }


    private class CompanionServicesRegister extends PerUser<Map<String, List<ComponentName>>> {
    private class CompanionServicesRegister extends PerUser<Map<String, List<ComponentName>>> {
+12 −8
Original line number Original line Diff line number Diff line
@@ -232,11 +232,14 @@ public class CompanionDevicePresenceMonitor implements AssociationStore.OnChange
        }
        }


        final boolean alreadyPresent = isDevicePresent(newDeviceAssociationId);
        final boolean alreadyPresent = isDevicePresent(newDeviceAssociationId);
        if (DEBUG && alreadyPresent) Log.i(TAG, "Device is already present.");
        if (alreadyPresent) {
            Log.i(TAG, "Device" + "id (" + newDeviceAssociationId + ") already present.");
        }


        final boolean added = presentDevicesForSource.add(newDeviceAssociationId);
        final boolean added = presentDevicesForSource.add(newDeviceAssociationId);
        if (DEBUG && !added) {
        if (!added) {
            Log.w(TAG, "Association with id " + newDeviceAssociationId + " is ALREADY reported as "
            Log.w(TAG, "Association with id "
                    + newDeviceAssociationId + " is ALREADY reported as "
                    + "present by this source (" + sourceLoggingTag + ")");
                    + "present by this source (" + sourceLoggingTag + ")");
        }
        }


@@ -256,16 +259,17 @@ public class CompanionDevicePresenceMonitor implements AssociationStore.OnChange


        final boolean removed = presentDevicesForSource.remove(goneDeviceAssociationId);
        final boolean removed = presentDevicesForSource.remove(goneDeviceAssociationId);
        if (!removed) {
        if (!removed) {
            if (DEBUG) {
            Log.w(TAG, "Association with id " + goneDeviceAssociationId + " was NOT reported "
            Log.w(TAG, "Association with id " + goneDeviceAssociationId + " was NOT reported "
                    + "as present by this source (" + sourceLoggingTag + ")");
                    + "as present by this source (" + sourceLoggingTag + ")");
            }

            return;
            return;
        }
        }


        final boolean stillPresent = isDevicePresent(goneDeviceAssociationId);
        final boolean stillPresent = isDevicePresent(goneDeviceAssociationId);
        if (stillPresent) {
        if (stillPresent) {
            if (DEBUG) Log.i(TAG, "  Device is still present.");
            if (DEBUG) {
                Log.i(TAG, "  Device id (" + goneDeviceAssociationId + ") is still present.");
            }
            return;
            return;
        }
        }