Improvements to Bugreporting API.
- Show a toast to indicate screenshot is taken. BUG:149525300 Test: Flash and press bug report shortcut and check the toast Change-Id: Ib210c8855d2b588b51f883e32070c8b748ea4e3f Merged-In: Ib210c8855d2b588b51f883e32070c8b748ea4e3f
This commit is contained in:
@@ -27,8 +27,10 @@ import android.annotation.SystemService;
|
|||||||
import android.annotation.TestApi;
|
import android.annotation.TestApi;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import com.android.internal.R;
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
|
|
||||||
import libcore.io.IoUtils;
|
import libcore.io.IoUtils;
|
||||||
@@ -155,12 +157,14 @@ public final class BugreportManager {
|
|||||||
Preconditions.checkNotNull(executor);
|
Preconditions.checkNotNull(executor);
|
||||||
Preconditions.checkNotNull(callback);
|
Preconditions.checkNotNull(callback);
|
||||||
|
|
||||||
|
boolean validScreenshotFd = screenshotFd != null;
|
||||||
if (screenshotFd == null) {
|
if (screenshotFd == null) {
|
||||||
// Binder needs a valid File Descriptor to be passed
|
// Binder needs a valid File Descriptor to be passed
|
||||||
screenshotFd = ParcelFileDescriptor.open(new File("/dev/null"),
|
screenshotFd = ParcelFileDescriptor.open(new File("/dev/null"),
|
||||||
ParcelFileDescriptor.MODE_READ_ONLY);
|
ParcelFileDescriptor.MODE_READ_ONLY);
|
||||||
}
|
}
|
||||||
DumpstateListener dsListener = new DumpstateListener(executor, callback);
|
DumpstateListener dsListener = new DumpstateListener(executor, callback,
|
||||||
|
validScreenshotFd);
|
||||||
// Note: mBinder can get callingUid from the binder transaction.
|
// Note: mBinder can get callingUid from the binder transaction.
|
||||||
mBinder.startBugreport(-1 /* callingUid */,
|
mBinder.startBugreport(-1 /* callingUid */,
|
||||||
mContext.getOpPackageName(),
|
mContext.getOpPackageName(),
|
||||||
@@ -221,10 +225,13 @@ public final class BugreportManager {
|
|||||||
private final class DumpstateListener extends IDumpstateListener.Stub {
|
private final class DumpstateListener extends IDumpstateListener.Stub {
|
||||||
private final Executor mExecutor;
|
private final Executor mExecutor;
|
||||||
private final BugreportCallback mCallback;
|
private final BugreportCallback mCallback;
|
||||||
|
private final boolean mValidScreenshotFd;
|
||||||
|
|
||||||
DumpstateListener(Executor executor, BugreportCallback callback) {
|
DumpstateListener(Executor executor, BugreportCallback callback,
|
||||||
|
boolean validScreenshotFd) {
|
||||||
mExecutor = executor;
|
mExecutor = executor;
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
|
mValidScreenshotFd = validScreenshotFd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -262,5 +269,20 @@ public final class BugreportManager {
|
|||||||
Binder.restoreCallingIdentity(identity);
|
Binder.restoreCallingIdentity(identity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScreenshotTaken(boolean success) throws RemoteException {
|
||||||
|
if (!mValidScreenshotFd) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handler mainThreadHandler = new Handler(Looper.getMainLooper());
|
||||||
|
mainThreadHandler.post(
|
||||||
|
() -> {
|
||||||
|
int message = success ? R.string.bugreport_screenshot_success_toast
|
||||||
|
: R.string.bugreport_screenshot_failure_toast;
|
||||||
|
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -584,6 +584,12 @@
|
|||||||
<!-- Format for build summary info [CHAR LIMIT=NONE] -->
|
<!-- Format for build summary info [CHAR LIMIT=NONE] -->
|
||||||
<string name="bugreport_status" translatable="false">%s (%s)</string>
|
<string name="bugreport_status" translatable="false">%s (%s)</string>
|
||||||
|
|
||||||
|
<!-- Toast for taking screenshot with bugreport successfully. [CHAR_LIMIT=100] -->
|
||||||
|
<string name="bugreport_screenshot_success_toast">Screenshot taken with bug report</string>
|
||||||
|
|
||||||
|
<!-- Toast for failed to take screenshot with bugreport. [CHAR_LIMIT=100] -->
|
||||||
|
<string name="bugreport_screenshot_failure_toast">Failed to take screenshot with bug report</string>
|
||||||
|
|
||||||
<!-- label for item that enables silent mode in phone options dialog -->
|
<!-- label for item that enables silent mode in phone options dialog -->
|
||||||
<string name="global_action_toggle_silent_mode">Silent mode</string>
|
<string name="global_action_toggle_silent_mode">Silent mode</string>
|
||||||
|
|
||||||
|
|||||||
@@ -1789,6 +1789,8 @@
|
|||||||
<java-symbol type="string" name="bugreport_option_full_title" />
|
<java-symbol type="string" name="bugreport_option_full_title" />
|
||||||
<java-symbol type="string" name="bugreport_option_interactive_summary" />
|
<java-symbol type="string" name="bugreport_option_interactive_summary" />
|
||||||
<java-symbol type="string" name="bugreport_option_interactive_title" />
|
<java-symbol type="string" name="bugreport_option_interactive_title" />
|
||||||
|
<java-symbol type="string" name="bugreport_screenshot_failure_toast" />
|
||||||
|
<java-symbol type="string" name="bugreport_screenshot_success_toast" />
|
||||||
<java-symbol type="string" name="bugreport_status" />
|
<java-symbol type="string" name="bugreport_status" />
|
||||||
<java-symbol type="string" name="bugreport_title" />
|
<java-symbol type="string" name="bugreport_title" />
|
||||||
<java-symbol type="string" name="faceunlock_multiple_failures" />
|
<java-symbol type="string" name="faceunlock_multiple_failures" />
|
||||||
|
|||||||
@@ -275,6 +275,11 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub {
|
|||||||
mListener.onFinished();
|
mListener.onFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScreenshotTaken(boolean success) throws RemoteException {
|
||||||
|
mListener.onScreenshotTaken(success);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void binderDied() {
|
public void binderDied() {
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
|||||||
Reference in New Issue
Block a user