Prompt to unlock if player is tapped on lockscreen
Fixes: 151336738
Test: manual
Change-Id: I416281f6d6b2926a15ca0d8bee18f78d4b6035e7
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
index 8dcf528..683c793 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java
@@ -57,7 +57,6 @@
import com.android.settingslib.media.MediaDevice;
import com.android.settingslib.media.MediaOutputSliceConstants;
import com.android.settingslib.widget.AdaptiveIcon;
-import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.qs.QSMediaBrowser;
@@ -75,6 +74,7 @@
@Nullable private final LocalMediaManager mLocalMediaManager;
private final Executor mForegroundExecutor;
protected final Executor mBackgroundExecutor;
+ private final ActivityStarter mActivityStarter;
private Context mContext;
protected LinearLayout mMediaNotifView;
@@ -178,10 +178,12 @@
* @param actionIds resource IDs for action buttons in the layout
* @param foregroundExecutor foreground executor
* @param backgroundExecutor background executor, used for processing artwork
+ * @param activityStarter activity starter
*/
public MediaControlPanel(Context context, ViewGroup parent,
@Nullable LocalMediaManager routeManager, @LayoutRes int layoutId, int[] actionIds,
- Executor foregroundExecutor, Executor backgroundExecutor) {
+ Executor foregroundExecutor, Executor backgroundExecutor,
+ ActivityStarter activityStarter) {
mContext = context;
LayoutInflater inflater = LayoutInflater.from(mContext);
mMediaNotifView = (LinearLayout) inflater.inflate(layoutId, parent, false);
@@ -195,6 +197,7 @@
mActionIds = actionIds;
mForegroundExecutor = foregroundExecutor;
mBackgroundExecutor = backgroundExecutor;
+ mActivityStarter = activityStarter;
}
/**
@@ -267,13 +270,7 @@
// Click action
if (contentIntent != null) {
mMediaNotifView.setOnClickListener(v -> {
- try {
- contentIntent.send();
- // Also close shade
- mContext.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
- } catch (PendingIntent.CanceledException e) {
- Log.e(TAG, "Pending intent was canceled", e);
- }
+ mActivityStarter.postStartActivityDismissingKeyguard(contentIntent);
});
}
@@ -287,7 +284,6 @@
if (mSeamless != null && mLocalMediaManager != null) {
mSeamless.setVisibility(View.VISIBLE);
updateDevice(mLocalMediaManager.getCurrentConnectedDevice());
- ActivityStarter mActivityStarter = Dependency.get(ActivityStarter.class);
mSeamless.setOnClickListener(v -> {
final Intent intent = new Intent()
.setAction(MediaOutputSliceConstants.ACTION_MEDIA_OUTPUT)
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
index 9e574a1..e76cd51 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSMediaPlayer.java
@@ -41,6 +41,7 @@
import com.android.systemui.media.MediaControlPanel;
import com.android.systemui.media.SeekBarObserver;
import com.android.systemui.media.SeekBarViewModel;
+import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.util.concurrency.DelayableExecutor;
import java.util.concurrent.Executor;
@@ -75,11 +76,13 @@
* @param routeManager Provides information about device
* @param foregroundExecutor
* @param backgroundExecutor
+ * @param activityStarter
*/
public QSMediaPlayer(Context context, ViewGroup parent, LocalMediaManager routeManager,
- Executor foregroundExecutor, DelayableExecutor backgroundExecutor) {
+ Executor foregroundExecutor, DelayableExecutor backgroundExecutor,
+ ActivityStarter activityStarter) {
super(context, parent, routeManager, R.layout.qs_media_panel, QS_ACTION_IDS,
- foregroundExecutor, backgroundExecutor);
+ foregroundExecutor, backgroundExecutor, activityStarter);
mParent = (QSPanel) parent;
mForegroundExecutor = foregroundExecutor;
mBackgroundExecutor = backgroundExecutor;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
index 1252008..c7ce1af 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
@@ -65,6 +65,7 @@
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.media.MediaControlPanel;
+import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.DetailAdapter;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.qs.QSTileView;
@@ -114,6 +115,7 @@
private final Executor mForegroundExecutor;
private final DelayableExecutor mBackgroundExecutor;
private boolean mUpdateCarousel = false;
+ private ActivityStarter mActivityStarter;
protected boolean mExpanded;
protected boolean mListening;
@@ -158,7 +160,8 @@
QSLogger qsLogger,
@Main Executor foregroundExecutor,
@Background DelayableExecutor backgroundExecutor,
- @Nullable LocalBluetoothManager localBluetoothManager
+ @Nullable LocalBluetoothManager localBluetoothManager,
+ ActivityStarter activityStarter
) {
super(context, attrs);
mContext = context;
@@ -168,6 +171,7 @@
mBackgroundExecutor = backgroundExecutor;
mLocalBluetoothManager = localBluetoothManager;
mBroadcastDispatcher = broadcastDispatcher;
+ mActivityStarter = activityStarter;
setOrientation(VERTICAL);
@@ -284,7 +288,7 @@
imm, notif.getPackageName());
player = new QSMediaPlayer(mContext, this, routeManager, mForegroundExecutor,
- mBackgroundExecutor);
+ mBackgroundExecutor, mActivityStarter);
player.setListening(mListening);
if (player.isPlaying()) {
mMediaCarousel.addView(player.getView(), 0, lp); // add in front
@@ -341,7 +345,7 @@
Log.d(TAG, "adding track from browser: " + desc + ", " + component);
QSMediaPlayer player = new QSMediaPlayer(mContext, QSPanel.this,
- null, mForegroundExecutor, mBackgroundExecutor);
+ null, mForegroundExecutor, mBackgroundExecutor, mActivityStarter);
String pkgName = component.getPackageName();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
index 89b36da..f77ff8c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSMediaPlayer.java
@@ -29,6 +29,7 @@
import com.android.systemui.R;
import com.android.systemui.media.MediaControlPanel;
+import com.android.systemui.plugins.ActivityStarter;
import java.util.concurrent.Executor;
@@ -48,11 +49,12 @@
* @param parent
* @param foregroundExecutor
* @param backgroundExecutor
+ * @param activityStarter
*/
public QuickQSMediaPlayer(Context context, ViewGroup parent, Executor foregroundExecutor,
- Executor backgroundExecutor) {
+ Executor backgroundExecutor, ActivityStarter activityStarter) {
super(context, parent, null, R.layout.qqs_media_panel, QQS_ACTION_IDS,
- foregroundExecutor, backgroundExecutor);
+ foregroundExecutor, backgroundExecutor, activityStarter);
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
index 2169677..becf9da 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QuickQSPanel.java
@@ -34,6 +34,7 @@
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
+import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.QSTile;
import com.android.systemui.plugins.qs.QSTile.SignalState;
import com.android.systemui.plugins.qs.QSTile.State;
@@ -84,10 +85,11 @@
QSLogger qsLogger,
@Main Executor foregroundExecutor,
@Background DelayableExecutor backgroundExecutor,
- @Nullable LocalBluetoothManager localBluetoothManager
+ @Nullable LocalBluetoothManager localBluetoothManager,
+ ActivityStarter activityStarter
) {
super(context, attrs, dumpManager, broadcastDispatcher, qsLogger,
- foregroundExecutor, backgroundExecutor, localBluetoothManager);
+ foregroundExecutor, backgroundExecutor, localBluetoothManager, activityStarter);
if (mFooter != null) {
removeView(mFooter.getView());
}
@@ -107,7 +109,7 @@
int marginSize = (int) mContext.getResources().getDimension(R.dimen.qqs_media_spacing);
mMediaPlayer = new QuickQSMediaPlayer(mContext, mHorizontalLinearLayout,
- foregroundExecutor, backgroundExecutor);
+ foregroundExecutor, backgroundExecutor, activityStarter);
LayoutParams lp2 = new LayoutParams(0, LayoutParams.MATCH_PARENT, 1);
lp2.setMarginEnd(marginSize);
lp2.setMarginStart(0);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.java
index 9112b65..9a32b1d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSPanelTest.java
@@ -39,6 +39,7 @@
import com.android.systemui.SysuiTestCase;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dump.DumpManager;
+import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.qs.QSTileView;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.qs.logging.QSLogger;
@@ -88,6 +89,8 @@
private DelayableExecutor mBackgroundExecutor;
@Mock
private LocalBluetoothManager mLocalBluetoothManager;
+ @Mock
+ private ActivityStarter mActivityStarter;
@Before
public void setup() throws Exception {
@@ -98,7 +101,7 @@
mMetricsLogger = mDependency.injectMockDependency(MetricsLogger.class);
mQsPanel = new QSPanel(mContext, null, mDumpManager, mBroadcastDispatcher,
mQSLogger, mForegroundExecutor, mBackgroundExecutor,
- mLocalBluetoothManager);
+ mLocalBluetoothManager, mActivityStarter);
// Provides a parent with non-zero size for QSPanel
mParentView = new FrameLayout(mContext);
mParentView.addView(mQsPanel);