/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.appium.java_client.android;

import static java.util.Optional.ofNullable;

import com.google.common.collect.ImmutableMap;

import io.appium.java_client.screenrecording.BaseStartScreenRecordingOptions;

import java.time.Duration;
import java.util.Map;

public class AndroidStartScreenRecordingOptions
        extends BaseStartScreenRecordingOptions<AndroidStartScreenRecordingOptions> {
    private Integer bitRate;
    private String videoSize;

    public static AndroidStartScreenRecordingOptions startScreenRecordingOptions() {
        return new AndroidStartScreenRecordingOptions();
    }

    /**
     * The video bit rate for the video, in megabits per second.
     * The default value is 4. You can increase the bit rate to improve video quality,
     * but doing so results in larger movie files.
     * The value of 5000000 equals to 5Mb/sec.
     *
     * @param bitRate The actual bit rate (Mb/s).
     * @return self instance for chaining.
     */
    public AndroidStartScreenRecordingOptions withBitRate(int bitRate) {
        this.bitRate = bitRate;
        return this;
    }
    
    /**
     * The video size of the generated media file. The format is WIDTHxHEIGHT.
     * The default value is the device's native display resolution (if supported),
     * 1280x720 if not. For best results,
     * use a size supported by your device's Advanced Video Coding (AVC) encoder.
     *
     * @param videoSize The actual video size: WIDTHxHEIGHT.
     * @return self instance for chaining.
     */
    public AndroidStartScreenRecordingOptions withVideoSize(String videoSize) {
        this.videoSize = videoSize;
        return this;
    }

    /**
     * The maximum recording time. The default and maximum value is 180 seconds (3 minutes).
     * Setting values greater than this or less than zero will cause an exception. The minimum
     * time resolution unit is one second.
     *
     * @param timeLimit The actual time limit of the recorded video.
     * @return self instance for chaining.
     */
    @Override
    public AndroidStartScreenRecordingOptions withTimeLimit(Duration timeLimit) {
        return super.withTimeLimit(timeLimit);
    }

    @Override
    public Map<String, Object> build() {
        final ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
        builder.putAll(super.build());
        ofNullable(bitRate).map(x -> builder.put("bitRate", x));
        ofNullable(videoSize).map(x -> builder.put("videoSize", x));
        return builder.build();
    }
}

@@ -1122,16 +1122,56 @@
 deoSize;
+%0A    private Boolean isBugReportEnabled;
 %0A%0A    pu
@@ -1415,17 +1415,127 @@
 lue is 4
-.
+000000 (4 Mb/s) for Android API level below 27%0A     * and 20000000 (20 Mb/s) for API level 27 and above.%0A     *
  You can
@@ -1638,55 +1638,8 @@
 es.%0A
-     * The value of 5000000 equals to 5Mb/sec.%0A
     
@@ -2428,32 +2428,469 @@
 rn this;%0A    %7D%0A%0A
+    /**%0A     * Makes the recorder to display an additional information on the video overlay,%0A     * such as a timestamp, that is helpful in videos captured to illustrate bugs.%0A     * This option is only supported since API level 27 (Android P).%0A     *%0A     * @return self instance for chaining.%0A     */%0A    public AndroidStartScreenRecordingOptions enableBugReport() %7B%0A        this.isBugReportEnabled = true;%0A        return this;%0A    %7D%0A%0A
     /**%0A     * T
@@ -3625,32 +3625,32 @@
 %22bitRate%22, x));%0A
-
         ofNullab
@@ -3694,32 +3694,110 @@
 ideoSize%22, x));%0A
+        ofNullable(isBugReportEnabled).map(x -%3E builder.put(%22bugReport%22, x));%0A
         return b

Add bugreport option to Android screen recorder (#852)