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

Unverified Commit 06124fc4 authored by Ido Ben-Hur's avatar Ido Ben-Hur Committed by Michael Bestas
Browse files

Screenrecord: Add an option to use HEVC

Chose the profiles that best fit the ones we have in H.264 by spec

Change-Id: I153858bee5b3cce1e4cac4f86f44586a272de6ab
parent 21ca0fac
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -149,7 +149,7 @@ public class RecordingServiceTest extends SysuiTestCase {
    @Test
    public void testLogStartFullScreenRecording() {
        Intent startIntent = RecordingService.getStartIntent(mContext, 0, 0, false, null, false,
                false);
                false, false);
        mRecordingService.onStartCommand(startIntent, 0, 0);

        verify(mUiEventLogger, times(1)).log(Events.ScreenRecordEvent.SCREEN_RECORD_START);
@@ -160,7 +160,7 @@ public class RecordingServiceTest extends SysuiTestCase {
        MediaProjectionCaptureTarget target =
                new MediaProjectionCaptureTarget(new LaunchCookie(), 12345);
        Intent startIntent = RecordingService.getStartIntent(mContext, 0, 0, false, target, false,
                false);
                false, false);
        mRecordingService.onStartCommand(startIntent, 0, 0);

        verify(mUiEventLogger, times(1)).log(Events.ScreenRecordEvent.SCREEN_RECORD_START);
@@ -194,7 +194,7 @@ public class RecordingServiceTest extends SysuiTestCase {
        doThrow(new RuntimeException("fail")).when(mScreenMediaRecorder).start();

        Intent startIntent = RecordingService.getStartIntent(mContext, 0, 0, false, null, false,
                false);
                false, false);
        mRecordingService.onStartCommand(startIntent, 0, 0);

        assertUpdateState(false);
@@ -319,7 +319,8 @@ public class RecordingServiceTest extends SysuiTestCase {
    @Test
        public void testSecondaryDisplayRecording() throws IOException {
        Intent startIntent =
                RecordingService.getStartIntent(mContext, 0, 0, false, 200, null, false, false);
                RecordingService.getStartIntent(mContext, 0, 0, false, 200, null, false, false,
                        false);
        assertEquals(startIntent.getIntExtra("extra_displayId", -1), 200);
    }

+10 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24"
    android:tint="?attr/colorControlNormal">
  <path
      android:fillColor="@android:color/white"
      android:pathData="M3,15V9H4.5V11H5.5V9H7V15H5.5V12.5H4.5V15ZM8,15V9H11.5V10.5H9.5V11H11.5V12.5H9.5V13.5H11.5V15ZM13,15 L12,9H13.5L14.25,13.5L15,9H16.5L15.5,15ZM18,15Q17.575,15 17.288,14.712Q17,14.425 17,14V10Q17,9.575 17.288,9.287Q17.575,9 18,9H20Q20.425,9 20.712,9.287Q21,9.575 21,10V11H19.5V10.5H18.5V13.5H19.5V13H21V14Q21,14.425 20.712,14.712Q20.425,15 20,15Z"/>
</vector>
+47 −0
Original line number Diff line number Diff line
@@ -226,4 +226,51 @@
            style="@style/ScreenRecord.Switch"
            android:importantForAccessibility="yes" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/show_hevc"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        android:layout_marginTop="@dimen/screenrecord_option_padding">
        <ImageView
            android:layout_width="@dimen/screenrecord_option_icon_size"
            android:layout_height="@dimen/screenrecord_option_icon_size"
            android:src="@drawable/ic_hevc"
            android:tint="?android:attr/textColorSecondary"
            android:layout_marginRight="@dimen/screenrecord_option_padding"
            android:importantForAccessibility="no"/>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:minHeight="48dp"
            android:layout_weight="1"
            android:orientation="vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="@*android:string/config_bodyFontFamily"
                android:text="@string/screenrecord_hevc_switch_label"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textColor="?android:attr/textColorPrimary"
                android:contentDescription="@string/screenrecord_hevc_switch_label"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:importantForAccessibility="no"
                android:fontFamily="@*android:string/config_bodyFontFamily"
                android:text="@string/screenrecord_hevc_switch_summary"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="?android:textColorSecondary"/>
        </LinearLayout>

        <Switch
            android:layout_width="wrap_content"
            android:minWidth="48dp"
            android:layout_height="48dp"
            android:id="@+id/screenrecord_hevc_switch"
            android:contentDescription="@string/screenrecord_hevc_switch_label"
            style="@style/ScreenRecord.Switch"
            android:importantForAccessibility="yes" />
    </LinearLayout>
</LinearLayout>
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
@@ -124,4 +124,6 @@
    <string name="screenrecord_longer_timeout_switch_summary">Limit recording size to 15 GB</string>
    <string name="screenrecord_skip_time_label">Skip timer</string>
    <string name="screenrecord_skip_time_summary">Remove the 3 second wait</string>
    <string name="screenrecord_hevc_switch_label">HEVC encoding</string>
    <string name="screenrecord_hevc_switch_summary">Use the more efficient HEVC encoder</string>
</resources>
+15 −4
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
    private static final String EXTRA_STOP_REASON = "extra_stopReason";
    private static final String EXTRA_LOW_QUALITY = "extra_lowQuality";
    private static final String EXTRA_LONGER_DURATION = "extra_longerDuration";
    private final static String EXTRA_HEVC = "extra_HEVC";

    protected static final String ACTION_START = "com.android.systemui.screenrecord.START";
    protected static final String ACTION_SHOW_START_NOTIF =
@@ -114,6 +115,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList

    private boolean mLowQuality;
    private boolean mLongerDuration;
    private boolean mHEVC;

    @Inject
    public RecordingService(ScreenRecordUxController controller, @LongRunning Executor executor,
@@ -146,7 +148,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
    public static Intent getStartIntent(Context context, int resultCode,
            int audioSource, boolean showTaps,
            @Nullable MediaProjectionCaptureTarget captureTarget,
            boolean lowQuality, boolean longerDuration) {
            boolean lowQuality, boolean longerDuration, boolean hevc) {
        return new Intent(context, RecordingService.class)
                .setAction(ACTION_START)
                .putExtra(EXTRA_RESULT_CODE, resultCode)
@@ -154,7 +156,8 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
                .putExtra(EXTRA_SHOW_TAPS, showTaps)
                .putExtra(EXTRA_CAPTURE_TARGET, captureTarget)
                .putExtra(EXTRA_LOW_QUALITY, lowQuality)
                .putExtra(EXTRA_LONGER_DURATION, longerDuration);
                .putExtra(EXTRA_LONGER_DURATION, longerDuration)
                .putExtra(EXTRA_HEVC, hevc);
    }

    /**
@@ -177,9 +180,9 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
            boolean showTaps,
            int displayId,
            @Nullable MediaProjectionCaptureTarget captureTarget,
            boolean lowQuality, boolean longerDuration) {
            boolean lowQuality, boolean longerDuration, boolean hevc) {
        return getStartIntent(context, resultCode, audioSource, showTaps, captureTarget,
                lowQuality, longerDuration)
                lowQuality, longerDuration, hevc)
                .putExtra(EXTRA_DISPLAY_ID, displayId);
    }

@@ -211,6 +214,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
                mShowTaps = intent.getBooleanExtra(EXTRA_SHOW_TAPS, false);
                mLowQuality = intent.getBooleanExtra(EXTRA_LOW_QUALITY, false);
                mLongerDuration = intent.getBooleanExtra(EXTRA_LONGER_DURATION, false);
                mHEVC = intent.getBooleanExtra(EXTRA_HEVC, true);

                MediaProjectionCaptureTarget captureTarget =
                        intent.getParcelableExtra(EXTRA_CAPTURE_TARGET,
@@ -234,6 +238,7 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
                );
                setLowQuality(mLowQuality);
                setLongerDuration(mLongerDuration);
                setHEVC(mHEVC);

                if (startRecording()) {
                    updateState(true);
@@ -610,6 +615,12 @@ public class RecordingService extends Service implements ScreenMediaRecorderList
        }
    }

    private void setHEVC(boolean hevc) {
        if (getRecorder() != null) {
            getRecorder().setHEVC(hevc);
        }
    }

    /**
     * Get an intent to stop the recording service.
     * @param context Context from the requesting activity
Loading