Loading core/api/system-current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -7001,6 +7001,7 @@ package android.os { public abstract static class BugreportManager.BugreportCallback { public abstract static class BugreportManager.BugreportCallback { ctor public BugreportManager.BugreportCallback(); ctor public BugreportManager.BugreportCallback(); method public void onEarlyReportFinished(); method public void onError(int); method public void onError(int); method public void onFinished(); method public void onFinished(); method public void onProgress(@FloatRange(from=0.0f, to=100.0f) float); method public void onProgress(@FloatRange(from=0.0f, to=100.0f) float); Loading core/java/android/os/BugreportManager.java +8 −14 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.SystemService; import android.app.ActivityManager; import android.app.ActivityManager; import android.content.Context; import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.Handler; import android.util.Log; import android.util.Log; import android.widget.Toast; import android.widget.Toast; Loading @@ -52,8 +51,6 @@ import java.util.concurrent.Executor; public final class BugreportManager { public final class BugreportManager { private static final String TAG = "BugreportManager"; private static final String TAG = "BugreportManager"; private static final String INTENT_UI_INTENSIVE_BUGREPORT_DUMPS_FINISHED = "com.android.internal.intent.action.UI_INTENSIVE_BUGREPORT_DUMPS_FINISHED"; private final Context mContext; private final Context mContext; private final IDumpstate mBinder; private final IDumpstate mBinder; Loading Loading @@ -126,6 +123,12 @@ public final class BugreportManager { * Called when taking bugreport finishes successfully. * Called when taking bugreport finishes successfully. */ */ public void onFinished() {} public void onFinished() {} /** * Called when it is ready for calling app to show UI, showing any extra UI before this * callback can interfere with bugreport generation. */ public void onEarlyReportFinished() {} } } /** /** Loading Loading @@ -288,21 +291,12 @@ public final class BugreportManager { } } @Override @Override public void onUiIntensiveBugreportDumpsFinished(String callingPackage) public void onUiIntensiveBugreportDumpsFinished() throws RemoteException { throws RemoteException { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { mExecutor.execute(() -> { mExecutor.execute(() -> { // Send intent to let calling app to show UI safely without interfering with mCallback.onEarlyReportFinished(); // the bugreport/screenshot generation. // TODO(b/154298410): When S is ready for API change, add a method in // BugreportCallback so we can just call the callback instead of using // broadcast. Intent intent = new Intent(INTENT_UI_INTENSIVE_BUGREPORT_DUMPS_FINISHED); intent.setPackage(callingPackage); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(intent, android.Manifest.permission.DUMP); }); }); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -118,6 +118,7 @@ public class BugreportManagerTest { // Wifi bugreports should not receive any progress. // Wifi bugreports should not receive any progress. assertThat(callback.hasReceivedProgress()).isFalse(); assertThat(callback.hasReceivedProgress()).isFalse(); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(callback.hasEarlyReportFinished()).isTrue(); assertFdsAreClosed(mBugreportFd); assertFdsAreClosed(mBugreportFd); } } Loading @@ -135,6 +136,7 @@ public class BugreportManagerTest { // Interactive bugreports show progress updates. // Interactive bugreports show progress updates. assertThat(callback.hasReceivedProgress()).isTrue(); assertThat(callback.hasReceivedProgress()).isTrue(); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(callback.hasEarlyReportFinished()).isTrue(); assertFdsAreClosed(mBugreportFd); assertFdsAreClosed(mBugreportFd); } } Loading Loading @@ -246,6 +248,7 @@ public class BugreportManagerTest { private int mErrorCode = -1; private int mErrorCode = -1; private boolean mSuccess = false; private boolean mSuccess = false; private boolean mReceivedProgress = false; private boolean mReceivedProgress = false; private boolean mEarlyReportFinished = false; private final Object mLock = new Object(); private final Object mLock = new Object(); @Override @Override Loading @@ -271,6 +274,13 @@ public class BugreportManagerTest { } } } } @Override public void onEarlyReportFinished() { synchronized (mLock) { mEarlyReportFinished = true; } } /* Indicates completion; and ended up with a success or error. */ /* Indicates completion; and ended up with a success or error. */ public boolean isDone() { public boolean isDone() { synchronized (mLock) { synchronized (mLock) { Loading @@ -295,6 +305,12 @@ public class BugreportManagerTest { return mReceivedProgress; return mReceivedProgress; } } } } public boolean hasEarlyReportFinished() { synchronized (mLock) { return mEarlyReportFinished; } } } } public static BugreportManager getBugreportManager() { public static BugreportManager getBugreportManager() { Loading packages/Shell/src/com/android/shell/BugreportProgressService.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -378,6 +378,9 @@ public class BugreportProgressService extends Service { } } } } @Override public void onEarlyReportFinished() {} /** /** * Reads bugreport id and links it to the bugreport info to track a bugreport that is in * Reads bugreport id and links it to the bugreport info to track a bugreport that is in * process. id is incremented in the dumpstate code. * process. id is incremented in the dumpstate code. Loading services/core/java/com/android/server/os/BugreportManagerServiceImpl.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -297,9 +297,8 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub { } } @Override @Override public void onUiIntensiveBugreportDumpsFinished(String callingPackage) public void onUiIntensiveBugreportDumpsFinished() throws RemoteException { throws RemoteException { mListener.onUiIntensiveBugreportDumpsFinished(); mListener.onUiIntensiveBugreportDumpsFinished(callingPackage); } } @Override @Override Loading Loading
core/api/system-current.txt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -7001,6 +7001,7 @@ package android.os { public abstract static class BugreportManager.BugreportCallback { public abstract static class BugreportManager.BugreportCallback { ctor public BugreportManager.BugreportCallback(); ctor public BugreportManager.BugreportCallback(); method public void onEarlyReportFinished(); method public void onError(int); method public void onError(int); method public void onFinished(); method public void onFinished(); method public void onProgress(@FloatRange(from=0.0f, to=100.0f) float); method public void onProgress(@FloatRange(from=0.0f, to=100.0f) float); Loading
core/java/android/os/BugreportManager.java +8 −14 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,6 @@ import android.annotation.SystemApi; import android.annotation.SystemService; import android.annotation.SystemService; import android.app.ActivityManager; import android.app.ActivityManager; import android.content.Context; import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.Handler; import android.util.Log; import android.util.Log; import android.widget.Toast; import android.widget.Toast; Loading @@ -52,8 +51,6 @@ import java.util.concurrent.Executor; public final class BugreportManager { public final class BugreportManager { private static final String TAG = "BugreportManager"; private static final String TAG = "BugreportManager"; private static final String INTENT_UI_INTENSIVE_BUGREPORT_DUMPS_FINISHED = "com.android.internal.intent.action.UI_INTENSIVE_BUGREPORT_DUMPS_FINISHED"; private final Context mContext; private final Context mContext; private final IDumpstate mBinder; private final IDumpstate mBinder; Loading Loading @@ -126,6 +123,12 @@ public final class BugreportManager { * Called when taking bugreport finishes successfully. * Called when taking bugreport finishes successfully. */ */ public void onFinished() {} public void onFinished() {} /** * Called when it is ready for calling app to show UI, showing any extra UI before this * callback can interfere with bugreport generation. */ public void onEarlyReportFinished() {} } } /** /** Loading Loading @@ -288,21 +291,12 @@ public final class BugreportManager { } } @Override @Override public void onUiIntensiveBugreportDumpsFinished(String callingPackage) public void onUiIntensiveBugreportDumpsFinished() throws RemoteException { throws RemoteException { final long identity = Binder.clearCallingIdentity(); final long identity = Binder.clearCallingIdentity(); try { try { mExecutor.execute(() -> { mExecutor.execute(() -> { // Send intent to let calling app to show UI safely without interfering with mCallback.onEarlyReportFinished(); // the bugreport/screenshot generation. // TODO(b/154298410): When S is ready for API change, add a method in // BugreportCallback so we can just call the callback instead of using // broadcast. Intent intent = new Intent(INTENT_UI_INTENSIVE_BUGREPORT_DUMPS_FINISHED); intent.setPackage(callingPackage); intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND); intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); mContext.sendBroadcast(intent, android.Manifest.permission.DUMP); }); }); } finally { } finally { Binder.restoreCallingIdentity(identity); Binder.restoreCallingIdentity(identity); Loading
core/tests/bugreports/src/com/android/os/bugreports/tests/BugreportManagerTest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -118,6 +118,7 @@ public class BugreportManagerTest { // Wifi bugreports should not receive any progress. // Wifi bugreports should not receive any progress. assertThat(callback.hasReceivedProgress()).isFalse(); assertThat(callback.hasReceivedProgress()).isFalse(); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(callback.hasEarlyReportFinished()).isTrue(); assertFdsAreClosed(mBugreportFd); assertFdsAreClosed(mBugreportFd); } } Loading @@ -135,6 +136,7 @@ public class BugreportManagerTest { // Interactive bugreports show progress updates. // Interactive bugreports show progress updates. assertThat(callback.hasReceivedProgress()).isTrue(); assertThat(callback.hasReceivedProgress()).isTrue(); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(mBugreportFile.length()).isGreaterThan(0L); assertThat(callback.hasEarlyReportFinished()).isTrue(); assertFdsAreClosed(mBugreportFd); assertFdsAreClosed(mBugreportFd); } } Loading Loading @@ -246,6 +248,7 @@ public class BugreportManagerTest { private int mErrorCode = -1; private int mErrorCode = -1; private boolean mSuccess = false; private boolean mSuccess = false; private boolean mReceivedProgress = false; private boolean mReceivedProgress = false; private boolean mEarlyReportFinished = false; private final Object mLock = new Object(); private final Object mLock = new Object(); @Override @Override Loading @@ -271,6 +274,13 @@ public class BugreportManagerTest { } } } } @Override public void onEarlyReportFinished() { synchronized (mLock) { mEarlyReportFinished = true; } } /* Indicates completion; and ended up with a success or error. */ /* Indicates completion; and ended up with a success or error. */ public boolean isDone() { public boolean isDone() { synchronized (mLock) { synchronized (mLock) { Loading @@ -295,6 +305,12 @@ public class BugreportManagerTest { return mReceivedProgress; return mReceivedProgress; } } } } public boolean hasEarlyReportFinished() { synchronized (mLock) { return mEarlyReportFinished; } } } } public static BugreportManager getBugreportManager() { public static BugreportManager getBugreportManager() { Loading
packages/Shell/src/com/android/shell/BugreportProgressService.java +3 −0 Original line number Original line Diff line number Diff line Loading @@ -378,6 +378,9 @@ public class BugreportProgressService extends Service { } } } } @Override public void onEarlyReportFinished() {} /** /** * Reads bugreport id and links it to the bugreport info to track a bugreport that is in * Reads bugreport id and links it to the bugreport info to track a bugreport that is in * process. id is incremented in the dumpstate code. * process. id is incremented in the dumpstate code. Loading
services/core/java/com/android/server/os/BugreportManagerServiceImpl.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -297,9 +297,8 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub { } } @Override @Override public void onUiIntensiveBugreportDumpsFinished(String callingPackage) public void onUiIntensiveBugreportDumpsFinished() throws RemoteException { throws RemoteException { mListener.onUiIntensiveBugreportDumpsFinished(); mListener.onUiIntensiveBugreportDumpsFinished(callingPackage); } } @Override @Override Loading