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

Commit 28aa27c5 authored by Evan Laird's avatar Evan Laird
Browse files

[Sb] Don't add NetworkControllerImpl as a demo mode callback

This class is already unused in the display of networking icons in the
status bar and quick settings. Furthermore, there is an infinite loop
bug that gets triggered if using `-e slot N`, where N > 1, in a demo
command.

Until we can fully remove the class, we can just remove it as a demo
mode listener.

Test: manual via demo mode
Test: adb shell -n dumpsys activity service com.android.systemui/.dump.SystemUIAuxiliaryDumpService and check for
NetworkControllerImpl as a listener
Bug: 336357360
Flag: NONE

Change-Id: I743fb7555e04738e8da51951fb3cf7ec75bf6cb3
parent 0fc10250
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,15 @@ public interface DemoMode extends DemoModeCommandReceiver {
        return NO_COMMANDS;
    }

    /** Something simple enough to be recognizable in dumpsys logs */
    default String logName() {
        if (this.getClass().isAnonymousClass()) {
            return getClass().getName();
        } else {
            return getClass().getSimpleName();
        }
    }

    String ACTION_DEMO = "com.android.systemui.demo";

    String EXTRA_COMMAND = "command";
+10 −12
Original line number Diff line number Diff line
@@ -25,12 +25,12 @@ import android.os.UserHandle
import android.util.Log
import com.android.systemui.Dumpable
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import com.android.systemui.demomode.DemoMode.ACTION_DEMO
import com.android.systemui.dump.DumpManager
import com.android.systemui.statusbar.policy.CallbackController
import com.android.systemui.util.Assert
import com.android.systemui.util.settings.GlobalSettings
import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow
import java.io.PrintWriter
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
@@ -209,20 +209,18 @@ constructor(
        pw.println("DemoModeController state -")
        pw.println("  isInDemoMode=$isInDemoMode")
        pw.println("  isDemoModeAllowed=$isAvailable")
        pw.print("  receivers=[")
        val copy: List<DemoModeCommandReceiver>
        val copy: List<DemoMode>
        synchronized(this) { copy = receivers.toList() }
        copy.forEach { recv -> pw.print(" ${recv.javaClass.simpleName}") }
        pw.println(" ]")

        // List of all receivers
        pw.println("  receivers=[${copy.joinToString(", ") { it.logName() }}]")

        // Print out the map of COMMAND -> list of receivers for that command
        pw.println("  receiverMap= [")
        receiverMap.keys.forEach { command ->
            pw.print("    $command : [")
            val recvs =
                receiverMap[command]!!
                    .map { receiver -> receiver.javaClass.simpleName }
                    .joinToString(",")
            pw.println("$recvs ]")
        receiverMap.entries.forEach { (comm, recv) ->
            pw.println("    $comm : [${recv.joinToString(", ") {it.logName()}}]")
        }
        pw.println(" ]")
    }

    private val tracker =
+10 −4
Original line number Diff line number Diff line
@@ -83,6 +83,10 @@ import com.android.systemui.statusbar.policy.DeviceProvisionedController.DeviceP
import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.CarrierConfigTracker;

import dalvik.annotation.optimization.NeverCompile;

import kotlin.Unit;

import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -97,9 +101,6 @@ import java.util.stream.Collectors;

import javax.inject.Inject;

import dalvik.annotation.optimization.NeverCompile;
import kotlin.Unit;

/** Platform implementation of the network controller. **/
@SysUISingleton
public class NetworkControllerImpl extends BroadcastReceiver
@@ -464,7 +465,10 @@ public class NetworkControllerImpl extends BroadcastReceiver
            });
        };

        mDemoModeController.addCallback(this);
        // TODO(b/336357360): Until we can remove this class entirely, disable its handling of ALL
        // demo mode commands, due to the fact that the mobile command handler has an infinite
        // loop bug if you use any slot other than 1.
        // mDemoModeController.addCallback(this);

        mDumpManager.registerNormalDumpable(TAG, this);
    }
@@ -1317,6 +1321,8 @@ public class NetworkControllerImpl extends BroadcastReceiver
            int carrierId = TextUtils.isEmpty(carrierIdString) ? 0
                    : Integer.parseInt(carrierIdString);
            // Ensure we have enough sim slots
            // TODO(b/336357360): This is the origination of the infinite loop bug, for those
            // following along at home.
            List<SubscriptionInfo> subs = new ArrayList<>();
            while (mMobileSignalControllers.size() <= slot) {
                int nextSlot = mMobileSignalControllers.size();