Merge "profcollect: Broadcast intent when a profile report is ready to upload" am: 096f175b7f

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

Change-Id: Ib99f51c22253a26b28f2f23565530a85c1a60e00
This commit is contained in:
Yi Kong
2021-03-24 18:31:28 +00:00
committed by Automerger Merge Worker

View File

@@ -295,10 +295,30 @@ public final class ProfcollectForwardingService extends SystemService {
return;
}
try {
mIProfcollect.report();
} catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage());
}
final boolean uploadReport =
DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PROFCOLLECT_NATIVE_BOOT,
"upload_report", false);
new Thread(() -> {
try {
String reportPath = mIProfcollect.report();
if (!uploadReport) {
return;
}
Intent uploadIntent =
new Intent("com.google.android.apps.betterbug.intent.action.UPLOAD_PROFILE")
.setPackage("com.google.android.apps.internal.betterbug")
.putExtra("EXTRA_DESTINATION", "PROFCOLLECT")
.putExtra("EXTRA_PACKAGE_NAME", getContext().getPackageName())
.putExtra("EXTRA_PROFILE_PATH", reportPath)
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
Context context = getContext();
if (context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0) != null) {
context.sendBroadcast(uploadIntent);
}
} catch (RemoteException e) {
Log.e(LOG_TAG, e.getMessage());
}
}).start();
}
}