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

Commit 33f8a600 authored by Yi Kong's avatar Yi Kong Committed by Android (Google) Code Review
Browse files

Merge "profcollect: disable some logging in forwarding service" into main

parents 1706fcfe a6aa6ab4
Loading
Loading
Loading
Loading
+29 −13
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ import java.util.concurrent.TimeUnit;
public final class ProfcollectForwardingService extends SystemService {
    public static final String LOG_TAG = "ProfcollectForwardingService";

    private static final boolean DEBUG = false;

    private static final String INTENT_UPLOAD_PROFILES =
            "com.android.server.profcollect.UPLOAD_PROFILES";
    private static final long BG_PROCESS_INTERVAL = TimeUnit.HOURS.toMillis(4); // every 4 hours.
@@ -99,22 +101,30 @@ public final class ProfcollectForwardingService extends SystemService {
            } else if (ACTION_BATTERY_OKAY.equals(intent.getAction())) {
                sIsBatteryLow = false;
            } else if (ACTION_SCREEN_ON.equals(intent.getAction())) {
                if (DEBUG) {
                    Log.d(LOG_TAG, "Received broadcast that the device became interactive, was "
                            + sIsInteractive);
                }
                sIsInteractive = true;
            } else if (ACTION_SCREEN_OFF.equals(intent.getAction())) {
                if (DEBUG) {
                    Log.d(LOG_TAG, "Received broadcast that the device became noninteractive, was "
                            + sIsInteractive);
                }
                sIsInteractive = false;
            } else if (INTENT_UPLOAD_PROFILES.equals(intent.getAction())) {
                if (DEBUG) {
                    Log.d(LOG_TAG, "Received broadcast to pack and upload reports");
                }
                createAndUploadReport(sSelfService);
            } else if (UsbManager.ACTION_USB_STATE.equals(intent.getAction())) {
                boolean isADB = intent.getBooleanExtra(UsbManager.USB_FUNCTION_ADB, false);
                if (isADB) {
                    boolean connected = intent.getBooleanExtra(UsbManager.USB_CONNECTED, false);
                    if (DEBUG) {
                        Log.d(LOG_TAG, "Received broadcast that ADB became " + connected
                                + ", was " + sAdbActive);
                    }
                    sAdbActive = connected;
                }
            }
@@ -141,7 +151,7 @@ public final class ProfcollectForwardingService extends SystemService {
        final String verityMode = SystemProperties.get("ro.boot.veritymode");
        sVerityEnforced = verityMode.equals("enforcing");
        if (!sVerityEnforced) {
            Log.d(LOG_TAG, "verity is not enforced: " + verityMode);
            Log.w(LOG_TAG, "verity is not enforced: " + verityMode);
        }

        mUploadEnabled =
@@ -177,21 +187,25 @@ public final class ProfcollectForwardingService extends SystemService {
            UsbManager usbManager = getContext().getSystemService(UsbManager.class);
            if (usbManager == null) {
                sAdbActive = false;
                Log.d(LOG_TAG, "USBManager is not ready");
                Log.w(LOG_TAG, "USBManager is not ready");
            } else {
                sAdbActive = ((usbManager.getCurrentFunctions() & UsbManager.FUNCTION_ADB) == 1);
                if (DEBUG) {
                    Log.d(LOG_TAG, "ADB is " + sAdbActive + " on system startup");
                }
            }

            PowerManager powerManager = getContext().getSystemService(PowerManager.class);
            if (powerManager == null) {
                sIsInteractive = true;
                Log.d(LOG_TAG, "PowerManager is not ready");
                Log.w(LOG_TAG, "PowerManager is not ready");
            } else {
                sIsInteractive = powerManager.isInteractive();
                if (DEBUG) {
                    Log.d(LOG_TAG, "Device is interactive " + sIsInteractive + " on system startup");
                }
            }
        }
        if (phase == PHASE_BOOT_COMPLETED) {
            if (sIProfcollect == null) {
                return;
@@ -458,7 +472,9 @@ public final class ProfcollectForwardingService extends SystemService {
        cm.registerAvailabilityCallback(new CameraManager.AvailabilityCallback() {
            @Override
            public void onCameraOpened(String cameraId, String packageId) {
                if (DEBUG) {
                    Log.d(LOG_TAG, "Received camera open event from: " + packageId);
                }
                // Skip face auth since it triggers way too often.
                if (packageId.startsWith("client.pid")) {
                    return;