diff options
| author | 2021-04-28 11:25:10 +0000 | |
|---|---|---|
| committer | 2021-04-28 11:25:10 +0000 | |
| commit | 07dba930dde90d2392765a9707638258a4b86f3e (patch) | |
| tree | f19a1facb1367e7da7ec78ec032e040f57813523 | |
| parent | ba2767ef4a32986be5863d1d0aa50b20a039bced (diff) | |
| parent | c8fc6f2a1ed07efad32ba1831c12f41fbbb3191d (diff) | |
Merge "profcollect: attempt to upload reports if BetterBug is available" am: c01d2f4258 am: a21c2bc3a9 am: c8fc6f2a1e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1689209
Change-Id: Iecec4d0df333caf07a209e4f0c3ea3e8bdd07341
| -rw-r--r-- | services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java index 1208eccc69eb..75432cd8661f 100644 --- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java @@ -23,6 +23,7 @@ import android.app.job.JobService; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ResolveInfo; import android.os.Handler; import android.os.IBinder.DeathRecipient; 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.ActivityTaskManagerInternal; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; @@ -297,24 +301,20 @@ public final class ProfcollectForwardingService extends SystemService { return; } - final boolean uploadReport = - DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PROFCOLLECT_NATIVE_BOOT, - "upload_report", false); - new Thread(() -> { try { 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; } - 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 = new Intent("com.google.android.apps.betterbug.intent.action.UPLOAD_PROFILE") .setPackage("com.google.android.apps.internal.betterbug") @@ -323,9 +323,15 @@ public final class ProfcollectForwardingService extends SystemService { .putExtra("EXTRA_PROFILE_PATH", reportPath) .addFlags(Intent.FLAG_RECEIVER_FOREGROUND); 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); } catch (RemoteException e) { Log.e(LOG_TAG, e.getMessage()); |