Merge "profcollect: Copy report file to BetterBug's internal storage" am: 72468611b4 am: daa8551b98
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1652264 Change-Id: If4045eb995c2efc935abe19541a8c7dd7771497b
This commit is contained in:
@@ -30,6 +30,8 @@ import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.UpdateEngine;
|
||||
import android.os.UpdateEngineCallback;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -301,10 +303,18 @@ public final class ProfcollectForwardingService extends SystemService {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
String reportPath = mIProfcollect.report();
|
||||
String reportUuid = mIProfcollect.report();
|
||||
|
||||
if (!uploadReport) {
|
||||
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")
|
||||
@@ -316,9 +326,27 @@ public final class ProfcollectForwardingService extends SystemService {
|
||||
if (context.getPackageManager().queryBroadcastReceivers(uploadIntent, 0) != null) {
|
||||
context.sendBroadcast(uploadIntent);
|
||||
}
|
||||
mIProfcollect.delete_report(reportUuid);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get BetterBug's profile ID. It is the work profile ID, if it exists. Otherwise the system
|
||||
* user ID.
|
||||
*
|
||||
* @return BetterBug's profile ID.
|
||||
*/
|
||||
private int getBBProfileId() {
|
||||
UserManager userManager = UserManager.get(getContext());
|
||||
int[] profiles = userManager.getProfileIds(UserHandle.USER_SYSTEM, false);
|
||||
for (int p : profiles) {
|
||||
if (userManager.getUserInfo(p).isManagedProfile()) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return UserHandle.USER_SYSTEM;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user