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

Commit 9b55151a authored by Eugene Susla's avatar Eugene Susla
Browse files

Fix CDM logcat spam when device is nearby

Bug: 181344542
Test: presubmit

Change-Id: Ie8aa35db3f878e4ea4d57b696b87d4d45e25f00b
parent 34385615
Loading
Loading
Loading
Loading
+5 −15
Original line number Original line Diff line number Diff line
@@ -1205,8 +1205,6 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        }
        }


        public void schedule() {
        public void schedule() {
            Slog.d(LOG_TAG,
                    "TriggerDeviceDisappearedRunnable.schedule(address = " + mAddress + ")");
            mMainHandler.removeCallbacks(this);
            mMainHandler.removeCallbacks(this);
            mMainHandler.postDelayed(this, this, DEVICE_DISAPPEARED_TIMEOUT_MS);
            mMainHandler.postDelayed(this, this, DEVICE_DISAPPEARED_TIMEOUT_MS);
        }
        }
@@ -1244,8 +1242,6 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
    }
    }


    private void onDeviceNearby(String address) {
    private void onDeviceNearby(String address) {
        Slog.i(LOG_TAG, "onDeviceNearby(address = " + address + ")");

        Date timestamp = new Date();
        Date timestamp = new Date();
        Date oldTimestamp = mDevicesLastNearby.put(address, timestamp);
        Date oldTimestamp = mDevicesLastNearby.put(address, timestamp);


@@ -1259,13 +1255,11 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        boolean justAppeared = oldTimestamp == null
        boolean justAppeared = oldTimestamp == null
                || timestamp.getTime() - oldTimestamp.getTime() >= DEVICE_DISAPPEARED_TIMEOUT_MS;
                || timestamp.getTime() - oldTimestamp.getTime() >= DEVICE_DISAPPEARED_TIMEOUT_MS;
        if (justAppeared) {
        if (justAppeared) {
            Slog.i(LOG_TAG, "onDeviceNearby(justAppeared, address = " + address + ")");
            for (Association association : getAllAssociations(address)) {
            for (Association association : getAllAssociations(address)) {
                if (association.isNotifyOnDeviceNearby()) {
                if (association.isNotifyOnDeviceNearby()) {
                    if (DEBUG) {
                    Slog.i(LOG_TAG,
                        Slog.i(LOG_TAG, "Device " + address
                            "Sending onDeviceAppeared to " + association.getPackageName() + ")");
                                + " managed by " + association.getPackageName()
                                + " is nearby on " + timestamp);
                    }
                    getDeviceListenerServiceConnector(association).run(
                    getDeviceListenerServiceConnector(association).run(
                            service -> service.onDeviceAppeared(association.getDeviceMacAddress()));
                            service -> service.onDeviceAppeared(association.getDeviceMacAddress()));
                }
                }
@@ -1279,12 +1273,8 @@ public class CompanionDeviceManagerService extends SystemService implements Bind
        boolean hasDeviceListeners = false;
        boolean hasDeviceListeners = false;
        for (Association association : getAllAssociations(address)) {
        for (Association association : getAllAssociations(address)) {
            if (association.isNotifyOnDeviceNearby()) {
            if (association.isNotifyOnDeviceNearby()) {
                if (DEBUG) {
                Slog.i(LOG_TAG,
                    Slog.i(LOG_TAG, "Device " + address
                        "Sending onDeviceDisappeared to " + association.getPackageName() + ")");
                            + " managed by " + association.getPackageName()
                            + " disappeared; last seen on " + mDevicesLastNearby.get(address));
                }

                getDeviceListenerServiceConnector(association).run(
                getDeviceListenerServiceConnector(association).run(
                        service -> service.onDeviceDisappeared(address));
                        service -> service.onDeviceDisappeared(address));
                hasDeviceListeners = true;
                hasDeviceListeners = true;