Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 925c8dec authored by Paul Chang's avatar Paul Chang
Browse files

Pass value to indicate screenshot is requested or not in Bugreporting API

BUG: 149525300
Test: Build pass
Change-Id: Ic307879bd80fe125cade37d8a53aaf718aebea2c
parent c7a08b57
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -157,20 +157,20 @@ public final class BugreportManager {
            Preconditions.checkNotNull(executor);
            Preconditions.checkNotNull(callback);

            boolean validScreenshotFd = screenshotFd != null;
            boolean isScreenshotRequested = 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,
                    validScreenshotFd);
                    isScreenshotRequested);
            // Note: mBinder can get callingUid from the binder transaction.
            mBinder.startBugreport(-1 /* callingUid */,
                    mContext.getOpPackageName(),
                    bugreportFd.getFileDescriptor(),
                    screenshotFd.getFileDescriptor(),
                    params.getMode(), dsListener);
                    params.getMode(), dsListener, isScreenshotRequested);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        } catch (FileNotFoundException e) {
@@ -225,13 +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;
        private final boolean mIsScreenshotRequested;

        DumpstateListener(Executor executor, BugreportCallback callback,
                boolean validScreenshotFd) {
                boolean isScreenshotRequested) {
            mExecutor = executor;
            mCallback = callback;
            mValidScreenshotFd = validScreenshotFd;
            mIsScreenshotRequested = isScreenshotRequested;
        }

        @Override
@@ -272,7 +272,7 @@ public final class BugreportManager {

        @Override
        public void onScreenshotTaken(boolean success) throws RemoteException {
            if (!mValidScreenshotFd) {
            if (!mIsScreenshotRequested) {
                return;
            }

+4 −4
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub {
    @RequiresPermission(android.Manifest.permission.DUMP)
    public void startBugreport(int callingUidUnused, String callingPackage,
            FileDescriptor bugreportFd, FileDescriptor screenshotFd,
            int bugreportMode, IDumpstateListener listener) {
            int bugreportMode, IDumpstateListener listener, boolean isScreenshotRequested) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, "startBugreport");
        Objects.requireNonNull(callingPackage);
        Objects.requireNonNull(bugreportFd);
@@ -88,7 +88,7 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub {
        }
        synchronized (mLock) {
            startBugreportLocked(callingUid, callingPackage, bugreportFd, screenshotFd,
                    bugreportMode, listener);
                    bugreportMode, listener, isScreenshotRequested);
        }
    }

@@ -145,7 +145,7 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub {
    @GuardedBy("mLock")
    private void startBugreportLocked(int callingUid, String callingPackage,
            FileDescriptor bugreportFd, FileDescriptor screenshotFd,
            int bugreportMode, IDumpstateListener listener) {
            int bugreportMode, IDumpstateListener listener, boolean isScreenshotRequested) {
        if (isDumpstateBinderServiceRunningLocked()) {
            Slog.w(TAG, "'dumpstate' is already running. Cannot start a new bugreport"
                    + " while another one is currently in progress.");
@@ -165,7 +165,7 @@ class BugreportManagerServiceImpl extends IDumpstate.Stub {
        IDumpstateListener myListener = new DumpstateListener(listener, ds);
        try {
            ds.startBugreport(callingUid, callingPackage,
                    bugreportFd, screenshotFd, bugreportMode, myListener);
                    bugreportFd, screenshotFd, bugreportMode, myListener, isScreenshotRequested);
        } catch (RemoteException e) {
            // bugreportd service is already started now. We need to kill it to manage the
            // lifecycle correctly. If we don't subsequent callers will get