Merge "profcollectd: Avoid hard-coding Betterbug name" am: adcff13790

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1746775

Change-Id: I18ba4c340edf0de8cff4835fa3ef754b086e21c1
This commit is contained in:
Treehugger Robot
2021-07-28 12:31:34 +00:00
committed by Automerger Merge Worker
3 changed files with 39 additions and 3 deletions

View File

@@ -4310,6 +4310,15 @@
<!-- The package name for the default bug report handler app from power menu short press. This app must be allowlisted. --> <!-- 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> <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 <!-- 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 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 if no android.account.Account with this name exists. A null string will be used if the

View File

@@ -3876,6 +3876,11 @@
<java-symbol type="bool" name="config_bugReportHandlerEnabled" /> <java-symbol type="bool" name="config_bugReportHandlerEnabled" />
<java-symbol type="string" name="config_defaultBugReportHandlerApp" /> <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" /> <java-symbol type="string" name="usb_device_resolve_prompt_warn" />
<!-- For Accessibility system actions --> <!-- For Accessibility system actions -->

View File

@@ -37,6 +37,7 @@ import android.os.UserManager;
import android.provider.DeviceConfig; import android.provider.DeviceConfig;
import android.util.Log; import android.util.Log;
import com.android.internal.R;
import com.android.server.IoThread; import com.android.server.IoThread;
import com.android.server.LocalServices; import com.android.server.LocalServices;
import com.android.server.SystemService; import com.android.server.SystemService;
@@ -305,8 +306,15 @@ public final class ProfcollectForwardingService extends SystemService {
return; return;
} }
if (!getUploaderEnabledConfig(getContext())) {
return;
}
new Thread(() -> { new Thread(() -> {
try { try {
Context context = getContext();
final String uploaderPkg = getUploaderPackageName(context);
final String uploaderAction = getUploaderActionName(context);
String reportUuid = mIProfcollect.report(); String reportUuid = mIProfcollect.report();
final int profileId = getBBProfileId(); final int profileId = getBBProfileId();
@@ -320,13 +328,12 @@ public final class ProfcollectForwardingService extends SystemService {
} }
Intent uploadIntent = Intent uploadIntent =
new Intent("com.google.android.apps.betterbug.intent.action.UPLOAD_PROFILE") new Intent(uploaderAction)
.setPackage("com.google.android.apps.internal.betterbug") .setPackage(uploaderPkg)
.putExtra("EXTRA_DESTINATION", "PROFCOLLECT") .putExtra("EXTRA_DESTINATION", "PROFCOLLECT")
.putExtra("EXTRA_PACKAGE_NAME", getContext().getPackageName()) .putExtra("EXTRA_PACKAGE_NAME", getContext().getPackageName())
.putExtra("EXTRA_PROFILE_PATH", reportPath) .putExtra("EXTRA_PROFILE_PATH", reportPath)
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
Context context = getContext();
List<ResolveInfo> receivers = List<ResolveInfo> receivers =
context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0); context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0);
@@ -359,4 +366,19 @@ public final class ProfcollectForwardingService extends SystemService {
} }
return UserHandle.USER_SYSTEM; 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);
}
} }