Merge "profcollectd: Avoid hard-coding Betterbug name"
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 -->
|
||||
|
||||
@@ -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;
|
||||
@@ -305,8 +306,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();
|
||||
@@ -320,13 +328,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);
|
||||
@@ -359,4 +366,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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user