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

Commit 3b8a900d authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Prompt to unlock when tapping tile" into rvc-dev

parents 64033711 f54cace3
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.Log;
import android.widget.Switch;

import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.qs.QSHost;
import com.android.systemui.qs.tileimpl.QSTileImpl;
@@ -37,14 +38,17 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
        implements RecordingController.RecordingStateChangeCallback {
    private static final String TAG = "ScreenRecordTile";
    private RecordingController mController;
    private ActivityStarter mActivityStarter;
    private long mMillisUntilFinished = 0;
    private Callback mCallback = new Callback();

    @Inject
    public ScreenRecordTile(QSHost host, RecordingController controller) {
    public ScreenRecordTile(QSHost host, RecordingController controller,
            ActivityStarter activityStarter) {
        super(host);
        mController = controller;
        mController.observe(this, mCallback);
        mActivityStarter = activityStarter;
    }

    @Override
@@ -115,7 +119,8 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
        Log.d(TAG, "Starting countdown");
        // Close QS, otherwise the permission dialog appears beneath it
        getHost().collapsePanels();
        mController.launchRecordPrompt();
        Intent intent = mController.getPromptIntent();
        mActivityStarter.postStartActivityDismissingKeyguard(intent, 0);
    }

    private void cancelCountdown() {
+3 −3
Original line number Diff line number Diff line
@@ -59,15 +59,15 @@ public class RecordingController
    }

    /**
     * Show dialog of screen recording options to user.
     * Get an intent to show screen recording options to the user.
     */
    public void launchRecordPrompt() {
    public Intent getPromptIntent() {
        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);
        return intent;
    }

    /**
+6 −2
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.qs.QSTileHost;
import com.android.systemui.screenrecord.RecordingController;

@@ -49,6 +50,8 @@ public class ScreenRecordTileTest extends SysuiTestCase {
    @Mock
    private RecordingController mController;
    @Mock
    private ActivityStarter mActivityStarter;
    @Mock
    private QSTileHost mHost;

    private TestableLooper mTestableLooper;
@@ -61,10 +64,11 @@ public class ScreenRecordTileTest extends SysuiTestCase {
        mTestableLooper = TestableLooper.get(this);
        mDependency.injectTestDependency(Dependency.BG_LOOPER, mTestableLooper.getLooper());
        mController = mDependency.injectMockDependency(RecordingController.class);
        mActivityStarter = mDependency.injectMockDependency(ActivityStarter.class);

        when(mHost.getContext()).thenReturn(mContext);

        mTile = new ScreenRecordTile(mHost, mController);
        mTile = new ScreenRecordTile(mHost, mController, mActivityStarter);
    }

    // Test that the tile is inactive and labeled correctly when the controller is neither starting
@@ -82,7 +86,7 @@ public class ScreenRecordTileTest extends SysuiTestCase {
                mContext.getString(R.string.quick_settings_screen_record_start)));

        mTile.handleClick();
        verify(mController, times(1)).launchRecordPrompt();
        verify(mController, times(1)).getPromptIntent();
    }

    // Test that the tile is active and labeled correctly when the controller is starting