Loading packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java +7 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading @@ -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() { Loading packages/SystemUI/src/com/android/systemui/screenrecord/RecordingController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; } /** Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -49,6 +50,8 @@ public class ScreenRecordTileTest extends SysuiTestCase { @Mock private RecordingController mController; @Mock private ActivityStarter mActivityStarter; @Mock private QSTileHost mHost; private TestableLooper mTestableLooper; Loading @@ -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 Loading @@ -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 Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java +7 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 Loading Loading @@ -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() { Loading
packages/SystemUI/src/com/android/systemui/screenrecord/RecordingController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; } /** Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -49,6 +50,8 @@ public class ScreenRecordTileTest extends SysuiTestCase { @Mock private RecordingController mController; @Mock private ActivityStarter mActivityStarter; @Mock private QSTileHost mHost; private TestableLooper mTestableLooper; Loading @@ -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 Loading @@ -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 Loading