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

Commit 69abc0d7 authored by Yi Kong's avatar Yi Kong
Browse files

profcollect: Fix NPE when invoking UsbManager

The UsbManager may intermittently be unavailable following the
PHASE_SYSTEM_SERVICES_READY phase. In these instances, disregard
the issue and consider adb inactive.

Test: presubmit
Bug: 376302943
Change-Id: I62ac4ad8bb39759d8ebd9decff99b9d515830569
parent 7c8b795e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -144,6 +144,10 @@ public final class ProfcollectForwardingService extends SystemService {
    public void onBootPhase(int phase) {
        if (phase == PHASE_SYSTEM_SERVICES_READY) {
            UsbManager usbManager = getContext().getSystemService(UsbManager.class);
            if (usbManager == null) {
                mAdbActive = false;
                return;
            }
            mAdbActive = ((usbManager.getCurrentFunctions() & UsbManager.FUNCTION_ADB) == 1);
            Log.d(LOG_TAG, "ADB is " + mAdbActive + " on system startup");
        }