aboutsummaryrefslogtreecommitdiff
path: root/TestMediaApp/src/com/android/car
diff options
context:
space:
mode:
Diffstat (limited to 'TestMediaApp/src/com/android/car')
-rw-r--r--TestMediaApp/src/com/android/car/media/testmediaapp/TmaBrowser.java13
-rw-r--r--TestMediaApp/src/com/android/car/media/testmediaapp/TmaForegroundService.java2
-rw-r--r--TestMediaApp/src/com/android/car/media/testmediaapp/TmaPlayer.java3
3 files changed, 15 insertions, 3 deletions
diff --git a/TestMediaApp/src/com/android/car/media/testmediaapp/TmaBrowser.java b/TestMediaApp/src/com/android/car/media/testmediaapp/TmaBrowser.java
index c187448..87161fd 100644
--- a/TestMediaApp/src/com/android/car/media/testmediaapp/TmaBrowser.java
+++ b/TestMediaApp/src/com/android/car/media/testmediaapp/TmaBrowser.java
@@ -19,7 +19,10 @@ import static com.android.car.media.testmediaapp.prefs.TmaEnumPrefs.TmaBrowseNod
import static com.android.car.media.testmediaapp.prefs.TmaEnumPrefs.TmaBrowseNodeType.QUEUE_ONLY;
import static com.android.car.media.testmediaapp.prefs.TmaEnumPrefs.TmaLoginEventOrder.PLAYBACK_STATE_UPDATE_FIRST;
+import android.app.PendingIntent;
+import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
@@ -31,6 +34,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.media.MediaBrowserServiceCompat;
+import androidx.media.session.MediaButtonReceiver;
import com.android.car.media.testmediaapp.loader.TmaLoader;
import com.android.car.media.testmediaapp.prefs.TmaEnumPrefs.TmaAccountType;
@@ -83,7 +87,14 @@ public class TmaBrowser extends MediaBrowserServiceCompat {
super.onCreate();
mPrefs = TmaPrefs.getInstance(this);
mHandler = new Handler();
- mSession = new MediaSessionCompat(this, MEDIA_SESSION_TAG);
+
+ ComponentName mbrComponent = MediaButtonReceiver.getMediaButtonReceiverComponent(this);
+ Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
+ mediaButtonIntent.setComponent(mbrComponent);
+ PendingIntent mbrIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent,
+ PendingIntent.FLAG_IMMUTABLE);
+
+ mSession = new MediaSessionCompat(this, MEDIA_SESSION_TAG, mbrComponent, mbrIntent);
setSessionToken(mSession.getSessionToken());
mLibrary = new TmaLibrary(new TmaLoader(this));
diff --git a/TestMediaApp/src/com/android/car/media/testmediaapp/TmaForegroundService.java b/TestMediaApp/src/com/android/car/media/testmediaapp/TmaForegroundService.java
index 6241455..594cbab 100644
--- a/TestMediaApp/src/com/android/car/media/testmediaapp/TmaForegroundService.java
+++ b/TestMediaApp/src/com/android/car/media/testmediaapp/TmaForegroundService.java
@@ -58,7 +58,7 @@ public class TmaForegroundService extends Service {
createNotificationChannel();
Intent notificationIntent = new Intent(this, TmaPrefsActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this,
- 0, notificationIntent, 0);
+ 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("Foreground Service")
.setSmallIcon(R.drawable.ic_app_icon)
diff --git a/TestMediaApp/src/com/android/car/media/testmediaapp/TmaPlayer.java b/TestMediaApp/src/com/android/car/media/testmediaapp/TmaPlayer.java
index 43cf3af..e75d028 100644
--- a/TestMediaApp/src/com/android/car/media/testmediaapp/TmaPlayer.java
+++ b/TestMediaApp/src/com/android/car/media/testmediaapp/TmaPlayer.java
@@ -103,7 +103,8 @@ public class TmaPlayer extends MediaSessionCompat.Callback {
Intent prefsIntent = new Intent();
prefsIntent.setClass(mBrowser, TmaPrefsActivity.class);
prefsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- PendingIntent pendingIntent = PendingIntent.getActivity(mBrowser, 0, prefsIntent, 0);
+ PendingIntent pendingIntent = PendingIntent.getActivity(mBrowser, 0, prefsIntent,
+ PendingIntent.FLAG_IMMUTABLE);
Bundle extras = new Bundle();
extras.putString(MediaKeys.ERROR_RESOLUTION_ACTION_LABEL, event.mActionLabel);