Merge "profcollect: attempt to upload reports if BetterBug is available" am: c01d2f4258
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1689209 Change-Id: I4dc9cc1c28b095395ba03634ede9bb1b28c172ba
This commit is contained in:
@@ -23,6 +23,7 @@ import android.app.job.JobService;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder.DeathRecipient;
|
import android.os.IBinder.DeathRecipient;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@@ -42,6 +43,9 @@ import com.android.server.wm.ActivityMetricsLaunchObserver;
|
|||||||
import com.android.server.wm.ActivityMetricsLaunchObserverRegistry;
|
import com.android.server.wm.ActivityMetricsLaunchObserverRegistry;
|
||||||
import com.android.server.wm.ActivityTaskManagerInternal;
|
import com.android.server.wm.ActivityTaskManagerInternal;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -297,24 +301,20 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean uploadReport =
|
|
||||||
DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PROFCOLLECT_NATIVE_BOOT,
|
|
||||||
"upload_report", false);
|
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
String reportUuid = mIProfcollect.report();
|
String reportUuid = mIProfcollect.report();
|
||||||
|
|
||||||
if (!uploadReport) {
|
final int profileId = getBBProfileId();
|
||||||
|
String reportDir = "/data/user/" + profileId
|
||||||
|
+ "/com.google.android.apps.internal.betterbug/cache/";
|
||||||
|
String reportPath = reportDir + reportUuid + ".zip";
|
||||||
|
|
||||||
|
if (!Files.exists(Paths.get(reportDir))) {
|
||||||
|
Log.i(LOG_TAG, "Destination directory does not exist, abort upload.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int profileId = getBBProfileId();
|
|
||||||
mIProfcollect.copy_report_to_bb(profileId, reportUuid);
|
|
||||||
String reportPath =
|
|
||||||
"/data/user/" + profileId
|
|
||||||
+ "/com.google.android.apps.internal.betterbug/cache/"
|
|
||||||
+ reportUuid + ".zip";
|
|
||||||
Intent uploadIntent =
|
Intent uploadIntent =
|
||||||
new Intent("com.google.android.apps.betterbug.intent.action.UPLOAD_PROFILE")
|
new Intent("com.google.android.apps.betterbug.intent.action.UPLOAD_PROFILE")
|
||||||
.setPackage("com.google.android.apps.internal.betterbug")
|
.setPackage("com.google.android.apps.internal.betterbug")
|
||||||
@@ -323,9 +323,15 @@ public final class ProfcollectForwardingService extends SystemService {
|
|||||||
.putExtra("EXTRA_PROFILE_PATH", reportPath)
|
.putExtra("EXTRA_PROFILE_PATH", reportPath)
|
||||||
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0) != null) {
|
|
||||||
context.sendBroadcast(uploadIntent);
|
List<ResolveInfo> receivers =
|
||||||
|
context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0);
|
||||||
|
if (receivers == null || receivers.isEmpty()) {
|
||||||
|
Log.i(LOG_TAG, "No one to receive upload intent, abort upload.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
mIProfcollect.copy_report_to_bb(profileId, reportUuid);
|
||||||
|
context.sendBroadcast(uploadIntent);
|
||||||
mIProfcollect.delete_report(reportUuid);
|
mIProfcollect.delete_report(reportUuid);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(LOG_TAG, e.getMessage());
|
Log.e(LOG_TAG, e.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user