Loading core/java/android/os/BugreportManager.java +25 −3 Original line number Diff line number Diff line Loading @@ -27,8 +27,10 @@ import android.annotation.SystemService; import android.annotation.TestApi; import android.app.ActivityManager; import android.content.Context; import android.os.Handler; import android.util.Log; import android.widget.Toast; import com.android.internal.R; import com.android.internal.util.Preconditions; import libcore.io.IoUtils; Loading Loading @@ -155,12 +157,14 @@ public final class BugreportManager { Preconditions.checkNotNull(executor); Preconditions.checkNotNull(callback); boolean validScreenshotFd = screenshotFd != null; if (screenshotFd == null) { // Binder needs a valid File Descriptor to be passed screenshotFd = ParcelFileDescriptor.open(new File("/dev/null"), 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. mBinder.startBugreport(-1 /* callingUid */, mContext.getOpPackageName(), Loading Loading @@ -221,10 +225,13 @@ public final class BugreportManager { private final class DumpstateListener extends IDumpstateListener.Stub { private final Executor mExecutor; private final BugreportCallback mCallback; private final boolean mValidScreenshotFd; DumpstateListener(Executor executor, BugreportCallback callback) { DumpstateListener(Executor executor, BugreportCallback callback, boolean validScreenshotFd) { mExecutor = executor; mCallback = callback; mValidScreenshotFd = validScreenshotFd; } @Override Loading Loading @@ -262,5 +269,20 @@ public final class BugreportManager { 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(); }); } } } core/res/res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -584,6 +584,12 @@ <!-- Format for build summary info [CHAR LIMIT=NONE] --> <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 --> <string name="global_action_toggle_silent_mode">Silent mode</string> Loading core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1789,6 +1789,8 @@ <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_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_title" /> <java-symbol type="string" name="faceunlock_multiple_failures" /> Loading services/core/java/com/android/server/os/BugreportManagerServiceImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,11 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub { mListener.onFinished(); } @Override public void onScreenshotTaken(boolean success) throws RemoteException { mListener.onScreenshotTaken(success); } @Override public void binderDied() { synchronized (mLock) { Loading Loading
core/java/android/os/BugreportManager.java +25 −3 Original line number Diff line number Diff line Loading @@ -27,8 +27,10 @@ import android.annotation.SystemService; import android.annotation.TestApi; import android.app.ActivityManager; import android.content.Context; import android.os.Handler; import android.util.Log; import android.widget.Toast; import com.android.internal.R; import com.android.internal.util.Preconditions; import libcore.io.IoUtils; Loading Loading @@ -155,12 +157,14 @@ public final class BugreportManager { Preconditions.checkNotNull(executor); Preconditions.checkNotNull(callback); boolean validScreenshotFd = screenshotFd != null; if (screenshotFd == null) { // Binder needs a valid File Descriptor to be passed screenshotFd = ParcelFileDescriptor.open(new File("/dev/null"), 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. mBinder.startBugreport(-1 /* callingUid */, mContext.getOpPackageName(), Loading Loading @@ -221,10 +225,13 @@ public final class BugreportManager { private final class DumpstateListener extends IDumpstateListener.Stub { private final Executor mExecutor; private final BugreportCallback mCallback; private final boolean mValidScreenshotFd; DumpstateListener(Executor executor, BugreportCallback callback) { DumpstateListener(Executor executor, BugreportCallback callback, boolean validScreenshotFd) { mExecutor = executor; mCallback = callback; mValidScreenshotFd = validScreenshotFd; } @Override Loading Loading @@ -262,5 +269,20 @@ public final class BugreportManager { 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(); }); } } }
core/res/res/values/strings.xml +6 −0 Original line number Diff line number Diff line Loading @@ -584,6 +584,12 @@ <!-- Format for build summary info [CHAR LIMIT=NONE] --> <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 --> <string name="global_action_toggle_silent_mode">Silent mode</string> Loading
core/res/res/values/symbols.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1789,6 +1789,8 @@ <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_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_title" /> <java-symbol type="string" name="faceunlock_multiple_failures" /> Loading
services/core/java/com/android/server/os/BugreportManagerServiceImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -275,6 +275,11 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub { mListener.onFinished(); } @Override public void onScreenshotTaken(boolean success) throws RemoteException { mListener.onScreenshotTaken(success); } @Override public void binderDied() { synchronized (mLock) { Loading