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

Commit f8f20df1 authored by Yi Kong's avatar Yi Kong
Browse files

profcollectd: Avoid hard-coding Betterbug name

Use vendor config file to provide the uploader package name and action
name, so that OEMs can implement their own uploaders.

Test: manual
Bug: 178561556
Bug: 183487233
Change-Id: Ib398f34825233db1b9a9f2e4da78c7ce35953164
Merged-In: Ib398f34825233db1b9a9f2e4da78c7ce35953164
(cherry picked from commit 2d17c284)
parent 05201409
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -4310,6 +4310,15 @@
    <!-- The package name for the default bug report handler app from power menu short press. This app must be allowlisted. -->
    <string name="config_defaultBugReportHandlerApp" translatable="false"></string>

    <!-- When true, enables the allowlisted app to upload profcollect reports. -->
    <bool name="config_profcollectReportUploaderEnabled">false</bool>

    <!-- The package name for the default profcollect report uploader app. This app must be allowlisted. -->
    <string name="config_defaultProfcollectReportUploaderApp" translatable="false"></string>

    <!-- The action name for the default profcollect report uploader app. -->
    <string name="config_defaultProfcollectReportUploaderAction" translatable="false"></string>

    <!-- The default value used for RawContacts.ACCOUNT_NAME when contacts are inserted without this
         column set. These contacts are stored locally on the device and will not be removed even
         if no android.account.Account with this name exists. A null string will be used if the
+5 −0
Original line number Diff line number Diff line
@@ -3876,6 +3876,11 @@
  <java-symbol type="bool" name="config_bugReportHandlerEnabled" />
  <java-symbol type="string" name="config_defaultBugReportHandlerApp" />

  <!-- For profcollect report uploader -->
  <java-symbol type="bool" name="config_profcollectReportUploaderEnabled" />
  <java-symbol type="string" name="config_defaultProfcollectReportUploaderApp" />
  <java-symbol type="string" name="config_defaultProfcollectReportUploaderAction" />

  <java-symbol type="string" name="usb_device_resolve_prompt_warn" />

  <!-- For Accessibility system actions -->
+25 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.UserManager;
import android.provider.DeviceConfig;
import android.util.Log;

import com.android.internal.R;
import com.android.server.IoThread;
import com.android.server.LocalServices;
import com.android.server.SystemService;
@@ -302,8 +303,15 @@ public final class ProfcollectForwardingService extends SystemService {
            return;
        }

        if (!getUploaderEnabledConfig(getContext())) {
            return;
        }

        new Thread(() -> {
            try {
                Context context = getContext();
                final String uploaderPkg = getUploaderPackageName(context);
                final String uploaderAction = getUploaderActionName(context);
                String reportUuid = mIProfcollect.report();

                final int profileId = getBBProfileId();
@@ -317,13 +325,12 @@ public final class ProfcollectForwardingService extends SystemService {
                }

                Intent uploadIntent =
                        new Intent("com.google.android.apps.betterbug.intent.action.UPLOAD_PROFILE")
                        .setPackage("com.google.android.apps.internal.betterbug")
                        new Intent(uploaderAction)
                        .setPackage(uploaderPkg)
                        .putExtra("EXTRA_DESTINATION", "PROFCOLLECT")
                        .putExtra("EXTRA_PACKAGE_NAME", getContext().getPackageName())
                        .putExtra("EXTRA_PROFILE_PATH", reportPath)
                        .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
                Context context = getContext();

                List<ResolveInfo> receivers =
                        context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0);
@@ -356,4 +363,19 @@ public final class ProfcollectForwardingService extends SystemService {
        }
        return UserHandle.USER_SYSTEM;
    }

    private boolean getUploaderEnabledConfig(Context context) {
        return context.getResources().getBoolean(
            R.bool.config_profcollectReportUploaderEnabled);
    }

    private String getUploaderPackageName(Context context) {
        return context.getResources().getString(
            R.string.config_defaultProfcollectReportUploaderApp);
    }

    private String getUploaderActionName(Context context) {
        return context.getResources().getString(
            R.string.config_defaultProfcollectReportUploaderAction);
    }
}