Skip to content

Commit e83f771

Browse files
jmtriviAndroid (Google) Code Review
authored andcommitted
Merge "Bug 5300223 RemoteControlClient uses PendingIntent"
2 parents d8c8251 + 6e920e6 commit e83f771

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

api/current.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10870,8 +10870,8 @@ package android.media {
1087010870
}
1087110871

1087210872
public class RemoteControlClient {
10873-
ctor public RemoteControlClient(android.content.ComponentName);
10874-
ctor public RemoteControlClient(android.content.ComponentName, android.os.Looper);
10873+
ctor public RemoteControlClient(android.app.PendingIntent);
10874+
ctor public RemoteControlClient(android.app.PendingIntent, android.os.Looper);
1087510875
method public android.media.RemoteControlClient.MetadataEditor editMetadata(boolean);
1087610876
method public void setPlaybackState(int);
1087710877
method public void setTransportControlFlags(int);

media/java/android/media/RemoteControlClient.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package android.media;
1818

19+
import android.app.PendingIntent;
1920
import android.content.ComponentName;
21+
import android.content.Intent;
2022
import android.graphics.Bitmap;
2123
import android.graphics.Canvas;
2224
import android.graphics.Paint;
@@ -203,6 +205,8 @@ public class RemoteControlClient
203205
public final static int FLAG_INFORMATION_REQUEST_ALBUM_ART = 1 << 3;
204206

205207
/**
208+
* @hide
209+
* TODO remove after modifying known (internal) media apps using this API
206210
* Class constructor.
207211
* @param mediaButtonEventReceiver The receiver for the media button events. It needs to have
208212
* been registered with {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)}
@@ -226,6 +230,8 @@ public RemoteControlClient(ComponentName mediaButtonEventReceiver) {
226230
}
227231

228232
/**
233+
* @hide
234+
* TODO remove after modifying known (internal) media apps using this API
229235
* Class constructor for a remote control client whose internal event handling
230236
* happens on a user-provided Looper.
231237
* @param mediaButtonEventReceiver The receiver for the media button events. It needs to have
@@ -242,6 +248,56 @@ public RemoteControlClient(ComponentName mediaButtonEventReceiver, Looper looper
242248
mEventHandler = new EventHandler(this, looper);
243249
}
244250

251+
/**
252+
* Class constructor.
253+
* @param mediaButtonIntent The intent that will be sent for the media button events sent
254+
* by remote controls.
255+
* This intent needs to have been constructed with the {@link Intent#ACTION_MEDIA_BUTTON}
256+
* action, and have a component that will handle the intent (set with
257+
* {@link Intent#setComponent(ComponentName)}) registered with
258+
* {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)}
259+
* before this new RemoteControlClient can itself be registered with
260+
* {@link AudioManager#registerRemoteControlClient(RemoteControlClient)}.
261+
* @see AudioManager#registerMediaButtonEventReceiver(ComponentName)
262+
* @see AudioManager#registerRemoteControlClient(RemoteControlClient)
263+
*/
264+
public RemoteControlClient(PendingIntent mediaButtonIntent) {
265+
// TODO implement using PendingIntent instead of ComponentName
266+
mRcEventReceiver = null;
267+
268+
Looper looper;
269+
if ((looper = Looper.myLooper()) != null) {
270+
mEventHandler = new EventHandler(this, looper);
271+
} else if ((looper = Looper.getMainLooper()) != null) {
272+
mEventHandler = new EventHandler(this, looper);
273+
} else {
274+
mEventHandler = null;
275+
Log.e(TAG, "RemoteControlClient() couldn't find main application thread");
276+
}
277+
}
278+
279+
/**
280+
* Class constructor for a remote control client whose internal event handling
281+
* happens on a user-provided Looper.
282+
* @param mediaButtonIntent The intent that will be sent for the media button events sent
283+
* by remote controls.
284+
* This intent needs to have been constructed with the {@link Intent#ACTION_MEDIA_BUTTON}
285+
* action, and have a component that will handle the intent (set with
286+
* {@link Intent#setComponent(ComponentName)}) registered with
287+
* {@link AudioManager#registerMediaButtonEventReceiver(ComponentName)}
288+
* before this new RemoteControlClient can itself be registered with
289+
* {@link AudioManager#registerRemoteControlClient(RemoteControlClient)}.
290+
* @param looper The Looper running the event loop.
291+
* @see AudioManager#registerMediaButtonEventReceiver(ComponentName)
292+
* @see AudioManager#registerRemoteControlClient(RemoteControlClient)
293+
*/
294+
public RemoteControlClient(PendingIntent mediaButtonIntent, Looper looper) {
295+
// TODO implement using PendingIntent instead of ComponentName
296+
mRcEventReceiver = null;
297+
298+
mEventHandler = new EventHandler(this, looper);
299+
}
300+
245301
private static final int[] METADATA_KEYS_TYPE_STRING = {
246302
MediaMetadataRetriever.METADATA_KEY_ALBUM,
247303
MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST,

0 commit comments

Comments
 (0)