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

Commit 74b3b88d authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Adds logging for signal controller set changes

We log whenever the set of MobileSignalControllers is mutated in any
way.

Test: Manually verified that I see log statements in logcat
Bug: 234146317
Change-Id: I5cad06f6bfb45d846f24fafa2fc4a5188475fbd3
parent 0414846b
Loading
Loading
Loading
Loading
+26 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;


import javax.inject.Inject;
import javax.inject.Inject;


@@ -937,6 +938,12 @@ public class NetworkControllerImpl extends BroadcastReceiver
                        : lhs.getSimSlotIndex() - rhs.getSimSlotIndex();
                        : lhs.getSimSlotIndex() - rhs.getSimSlotIndex();
            }
            }
        });
        });
        Log.i(
                TAG,
                String.format(
                        Locale.US,
                        "Subscriptions changed: %s",
                        createSubscriptionChangeStatement(mCurrentSubscriptions, subscriptions)));
        mCurrentSubscriptions = subscriptions;
        mCurrentSubscriptions = subscriptions;


        SparseArray<MobileSignalController> cachedControllers =
        SparseArray<MobileSignalController> cachedControllers =
@@ -1474,4 +1481,23 @@ public class NetworkControllerImpl extends BroadcastReceiver
     * get created will also run on the BG Looper.
     * get created will also run on the BG Looper.
     */
     */
    private final Runnable mRegisterListeners = () -> registerListeners();
    private final Runnable mRegisterListeners = () -> registerListeners();

    /** Returns a logging statement for the given old and new list of {@link SubscriptionInfo} */
    private static String createSubscriptionChangeStatement(
            final @Nullable List<SubscriptionInfo> oldSubscriptions,
            final @Nullable List<SubscriptionInfo> newSubscriptions) {
        return String.format(
                Locale.US,
                "old=%s, new=%s",
                toSubscriptionIds(oldSubscriptions),
                toSubscriptionIds(newSubscriptions));
    }

    /** Returns to a list of subscription IDs for the given list of {@link SubscriptionInfo} */
    @Nullable
    private static List<Integer> toSubscriptionIds(
            final @Nullable List<SubscriptionInfo> subscriptions) {
        return subscriptions != null ? subscriptions.stream().map(
                SubscriptionInfo::getSubscriptionId).collect(Collectors.toList()) : null;
    }
}
}