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

Commit 5898ac47 authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Adding screen recording function.

Screen recording can be launched via long press on screenshot in
the global actions menu if the local feature flag is enabled.
Otherwise, long press on screenshot will also trigger a screenshot.

Demo videos: https://drive.google.com/open?id=1oJzfzJb8aGXSUqn4CZ_Yn7qWmJ2dvRd5

Test: manual
Change-Id: I373d38ad86291ff6f26f7dca3195001bd8f5ee16
Bug: 111395687
Bug: 118826991
parent c1513cd4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public class FeatureFlagUtils {
    public static final String PERSIST_PREFIX = "persist." + FFLAG_OVERRIDE_PREFIX;
    public static final String HEARING_AID_SETTINGS = "settings_bluetooth_hearing_aid";
    public static final String EMERGENCY_DIAL_SHORTCUTS = "settings_emergency_dial_shortcuts";
    public static final String SCREENRECORD_LONG_PRESS = "settings_screenrecord_long_press";

    private static final Map<String, String> DEFAULT_FLAGS;
    static {
@@ -50,6 +51,7 @@ public class FeatureFlagUtils {
        DEFAULT_FLAGS.put(HEARING_AID_SETTINGS, "false");
        DEFAULT_FLAGS.put(EMERGENCY_DIAL_SHORTCUTS, "true");
        DEFAULT_FLAGS.put("settings_network_and_internet_v2", "false");
        DEFAULT_FLAGS.put(SCREENRECORD_LONG_PRESS, "false");
    }

    /**
+52 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * 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 com.android.internal.util;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

/**
 * Helper class to initiate a screen recording
 */
public class ScreenRecordHelper {
    private static final String SYSUI_PACKAGE = "com.android.systemui";
    private static final String SYSUI_SCREENRECORD_LAUNCHER =
            "com.android.systemui.screenrecord.ScreenRecordDialog";

    private final Context mContext;

    /**
     * Create a new ScreenRecordHelper for the given context
     * @param context
     */
    public ScreenRecordHelper(Context context) {
        mContext = context;
    }

    /**
     * Show dialog of screen recording options to user.
     */
    public void launchRecordPrompt() {
        final ComponentName launcherComponent = new ComponentName(SYSUI_PACKAGE,
                SYSUI_SCREENRECORD_LAUNCHER);
        final Intent intent = new Intent();
        intent.setComponent(launcherComponent);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(intent);
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -136,6 +136,10 @@
    <!-- Screen Capturing -->
    <uses-permission android:name="android.permission.MANAGE_MEDIA_PROJECTION" />

    <!-- Screen Recording -->
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

    <!-- Assist -->
    <uses-permission android:name="android.permission.ACCESS_VOICE_INTERACTION_SERVICE" />

@@ -267,6 +271,10 @@
            </intent-filter>
        </receiver>

        <activity android:name=".screenrecord.ScreenRecordDialog"
            android:theme="@style/ScreenRecord" />
        <service android:name=".screenrecord.RecordingService" />

        <receiver android:name=".SysuiRestartReceiver"
            android:exported="false">
            <intent-filter>
+41 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clipChildren="false"
              android:clipToPadding="false"
              android:gravity="top"
              android:orientation="vertical">

    <Space
        android:layout_width="match_parent"
        android:layout_height="10dp"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@android:color/white">
        <CheckBox
            android:id="@+id/checkbox_mic"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/screenrecord_mic_label"/>
        <CheckBox
            android:id="@+id/checkbox_taps"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/screenrecord_taps_label"/>
        <Button
            android:id="@+id/record_button"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="@string/screenrecord_start_label"
        />
    </LinearLayout>

    <Space
        android:layout_width="match_parent"
        android:layout_height="10dp"/>

</LinearLayout>
+33 −0
Original line number Diff line number Diff line
@@ -185,6 +185,39 @@
    <string name="screenshot_failed_to_capture_text">Taking screenshots isn\'t allowed by the app or
        your organization</string>

    <!-- Notification title displayed for screen recording [CHAR LIMIT=50]-->
    <string name="screenrecord_name">Screen Recording</string>
    <!-- Description of the screen recording notification channel [CHAR LIMIT=NONE]-->
    <string name="screenrecord_channel_description">Ongoing notification for a screen record session</string>
    <!-- Label for the button to begin screen recording [CHAR LIMIT=NONE]-->
    <string name="screenrecord_start_label">Start Recording</string>
    <!-- Label for the checkbox to enable microphone input during screen recording [CHAR LIMIT=NONE]-->
    <string name="screenrecord_mic_label">Record voiceover</string>
    <!-- Label for the checkbox to enable showing location of touches during screen recording [CHAR LIMIT=NONE]-->
    <string name="screenrecord_taps_label">Show taps</string>
    <!-- Label for notification action to stop and save the screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_stop_label">Stop</string>
    <!-- Label for notification action to pause screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_pause_label">Pause</string>
    <!-- Label for notification action to resume screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_resume_label">Resume</string>
    <!-- Label for notification action to cancel and discard screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_cancel_label">Cancel</string>
    <!-- Label for notification action to share screen recording [CHAR LIMIT=35] -->
    <string name="screenrecord_share_label">Share</string>
    <!-- Label for notification action to delete a screen recording file [CHAR LIMIT=35] -->
    <string name="screenrecord_delete_label">Delete</string>
    <!-- A toast message shown after successfully canceling a screen recording [CHAR LIMIT=NONE] -->
    <string name="screenrecord_cancel_success">Screen recording canceled</string>
    <!-- Notification text shown after saving a screen recording to prompt the user to view it [CHAR LIMIT=100] -->
    <string name="screenrecord_save_message">Screen recording saved, tap to view</string>
    <!-- A toast message shown after successfully deleting a screen recording [CHAR LIMIT=NONE] -->
    <string name="screenrecord_delete_description">Screen recording deleted</string>
    <!-- A toast message shown when there is an error deleting a screen recording [CHAR LIMIT=NONE] -->
    <string name="screenrecord_delete_error">Error deleting screen recording</string>
    <!-- A toast message shown when the screen recording cannot be started due to insufficient permissions [CHAR LIMIT=NONE] -->
    <string name="screenrecord_permission_error">Failed to get permissions</string>

    <!-- Title for the USB function chooser in UsbPreferenceActivity. [CHAR LIMIT=30] -->
    <string name="usb_preference_title">USB file transfer options</string>
    <!-- Label for the MTP USB function in UsbPreferenceActivity. [CHAR LIMIT=50] -->
Loading