Skip to content

Commit d055398

Browse files
committed
Added more loggging statements when saving a shared bugreport.
Test: manual verification Bug: 185426804 Change-Id: I81d513d305799ff797c2b3c9a4c039b23e45e619
1 parent ac7efff commit d055398

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/src/main/java/com/afwsamples/testdpc/DeviceAdminReceiver.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public void onBugreportShared(final Context context, Intent intent,
165165
final String bugreportFileHash) {
166166
Log.i(TAG, "Bugreport shared, hash: " + bugreportFileHash);
167167
final Uri bugreportUri = intent.getData();
168+
Log.i(TAG, "Bugreport URI: " + bugreportUri);
168169

169170
final PendingResult result = goAsync();
170171
new AsyncTask<Void, Void, String>() {
@@ -180,16 +181,20 @@ protected String doInBackground(Void... params) {
180181
in = new FileInputStream(mInputPfd.getFileDescriptor());
181182
outputBugreportFile = new File(context.getExternalFilesDir(null),
182183
bugreportUri.getLastPathSegment());
184+
Log.i(TAG, "Writing bugreport to " + outputBugreportFile);
183185
out = new FileOutputStream(outputBugreportFile);
184186
byte[] buffer = new byte[1024];
185187
int read;
188+
long totalRead = 0;
186189
while ((read = in.read(buffer)) != -1) {
190+
totalRead += read;
187191
out.write(buffer, 0, read);
188192
}
189193
in.close();
190194
out.close();
191195
message = context.getString(R.string.received_bugreport,
192-
outputBugreportFile.getPath(), bugreportFileHash);
196+
outputBugreportFile.getPath(), bugreportFileHash, totalRead);
197+
Log.i(TAG, message);
193198
} catch (IOException e) {
194199
Log.e(TAG, e.getMessage());
195200
message = context.getString(R.string.received_bugreport_failed_retrieval);

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@
632632
<!-- Remote bugreport -->
633633
<string name="bugreport_title">Bugreport</string>
634634
<string name="request_bugreport">Request bugreport</string>
635-
<string name="received_bugreport">Received bugreport %1$s hash: %2$s</string>
635+
<string name="received_bugreport">Received bugreport %1$s hash: %2$s bytes: %3$s</string>
636636
<string name="received_bugreport_failed_retrieval">Received bugreport file, but failed to retrieve it</string>
637637
<string name="bugreport_sharing_declined">User declined sharing bugreport</string>
638638
<string name="bugreport_failure_message">Bugreport request failed: %s</string>

0 commit comments

Comments
 (0)