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

Commit 80bc2f6a authored by Paul Chang's avatar Paul Chang Committed by Android (Google) Code Review
Browse files

Merge "Take screenshot only when screenshot is requested" into rvc-dev

parents da8418c0 f59c2b7a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -84,7 +84,8 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,
                                                android::base::unique_fd bugreport_fd,
                                                android::base::unique_fd screenshot_fd,
                                                int bugreport_mode,
                                                const sp<IDumpstateListener>& listener) {
                                                const sp<IDumpstateListener>& listener,
                                                bool is_screenshot_requested) {
    MYLOGI("startBugreport() with mode: %d\n", bugreport_mode);

    // Ensure there is only one bugreport in progress at a time.
@@ -118,7 +119,7 @@ binder::Status DumpstateService::startBugreport(int32_t calling_uid,

    std::unique_ptr<Dumpstate::DumpOptions> options = std::make_unique<Dumpstate::DumpOptions>();
    options->Initialize(static_cast<Dumpstate::BugreportMode>(bugreport_mode), bugreport_fd,
                        screenshot_fd);
                        screenshot_fd, is_screenshot_requested);

    if (bugreport_fd.get() == -1 || (options->do_screenshot && screenshot_fd.get() == -1)) {
        MYLOGE("Invalid filedescriptor");
+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ class DumpstateService : public BinderService<DumpstateService>, public BnDumpst
    binder::Status startBugreport(int32_t calling_uid, const std::string& calling_package,
                                  android::base::unique_fd bugreport_fd,
                                  android::base::unique_fd screenshot_fd, int bugreport_mode,
                                  const sp<IDumpstateListener>& listener) override;
                                  const sp<IDumpstateListener>& listener,
                                  bool is_screenshot_requested) override;

    // No-op
    binder::Status cancelBugreport();
+3 −1
Original line number Diff line number Diff line
@@ -64,10 +64,12 @@ interface IDumpstate {
     * @param screenshotFd the file to which screenshot should be written
     * @param bugreportMode the mode that specifies other run time options; must be one of above
     * @param listener callback for updates; optional
     * @param isScreenshotRequested indicates screenshot is requested or not
     */
    void startBugreport(int callingUid, @utf8InCpp String callingPackage,
                        FileDescriptor bugreportFd, FileDescriptor screenshotFd,
                        int bugreportMode, IDumpstateListener listener);
                        int bugreportMode, IDumpstateListener listener,
                        boolean isScreenshotRequested);

    /*
     * Cancels the bugreport currently in progress.
+8 −6
Original line number Diff line number Diff line
@@ -2249,20 +2249,21 @@ static inline const char* ModeToString(Dumpstate::BugreportMode mode) {
    }
}

static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOptions* options) {
static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOptions* options,
                               bool is_screenshot_requested) {
    // Modify com.android.shell.BugreportProgressService#isDefaultScreenshotRequired as well for
    // default system screenshots.
    options->bugreport_mode = ModeToString(mode);
    switch (mode) {
        case Dumpstate::BugreportMode::BUGREPORT_FULL:
            options->do_screenshot = true;
            options->do_screenshot = is_screenshot_requested;
            options->dumpstate_hal_mode = DumpstateMode::FULL;
            break;
        case Dumpstate::BugreportMode::BUGREPORT_INTERACTIVE:
            // Currently, the dumpstate binder is only used by Shell to update progress.
            options->do_start_service = true;
            options->do_progress_updates = true;
            options->do_screenshot = true;
            options->do_screenshot = is_screenshot_requested;
            options->dumpstate_hal_mode = DumpstateMode::INTERACTIVE;
            break;
        case Dumpstate::BugreportMode::BUGREPORT_REMOTE:
@@ -2275,7 +2276,7 @@ static void SetOptionsFromMode(Dumpstate::BugreportMode mode, Dumpstate::DumpOpt
            options->do_start_service = true;
            options->do_progress_updates = true;
            options->do_zip_file = true;
            options->do_screenshot = true;
            options->do_screenshot = is_screenshot_requested;
            options->dumpstate_hal_mode = DumpstateMode::WEAR;
            break;
        // TODO(b/148168577) rename TELEPHONY everywhere to CONNECTIVITY.
@@ -2312,7 +2313,8 @@ static void LogDumpOptions(const Dumpstate::DumpOptions& options) {

void Dumpstate::DumpOptions::Initialize(BugreportMode bugreport_mode,
                                        const android::base::unique_fd& bugreport_fd_in,
                                        const android::base::unique_fd& screenshot_fd_in) {
                                        const android::base::unique_fd& screenshot_fd_in,
                                        bool is_screenshot_requested) {
    // In the new API world, date is always added; output is always a zip file.
    // TODO(111441001): remove these options once they are obsolete.
    do_add_date = true;
@@ -2322,7 +2324,7 @@ void Dumpstate::DumpOptions::Initialize(BugreportMode bugreport_mode,
    bugreport_fd.reset(dup(bugreport_fd_in.get()));
    screenshot_fd.reset(dup(screenshot_fd_in.get()));

    SetOptionsFromMode(bugreport_mode, this);
    SetOptionsFromMode(bugreport_mode, this, is_screenshot_requested);
}

Dumpstate::RunStatus Dumpstate::DumpOptions::Initialize(int argc, char* argv[]) {
+2 −1
Original line number Diff line number Diff line
@@ -390,7 +390,8 @@ class Dumpstate {

        /* Initializes options from the requested mode. */
        void Initialize(BugreportMode bugreport_mode, const android::base::unique_fd& bugreport_fd,
                        const android::base::unique_fd& screenshot_fd);
                        const android::base::unique_fd& screenshot_fd,
                        bool is_screenshot_requested);

        /* Returns true if the options set so far are consistent. */
        bool ValidateOptions() const;
Loading