Fields Summary |
---|
private static final int | MSG_SET_CALLBACK |
private static final int | MSG_SET_DISCOVERY_MODE |
private static final int | MSG_CONNECT |
private static final int | MSG_DISCONNECT |
private static final int | MSG_SET_VOLUME |
private static final int | MSG_ADJUST_VOLUME |
private final android.content.Context | mContext |
private final ProviderStub | mStub |
private final ProviderHandler | mHandler |
private final android.util.ArrayMap | mDisplays |
private android.media.IRemoteDisplayCallback | mCallback |
private int | mDiscoveryMode |
private android.app.PendingIntent | mSettingsPendingIntent |
public static final String | SERVICE_INTERFACEThe {@link Intent} that must be declared as handled by the service.
Put this in your manifest. |
public static final int | DISCOVERY_MODE_NONEDiscovery mode: Do not perform any discovery. |
public static final int | DISCOVERY_MODE_PASSIVEDiscovery mode: Passive or low-power periodic discovery.
This mode indicates that an application is interested in knowing whether there
are any remote displays paired or available but doesn't need the latest or
most detailed information. The provider may scan at a lower rate or rely on
knowledge of previously paired devices.
|
public static final int | DISCOVERY_MODE_ACTIVEDiscovery mode: Active discovery.
This mode indicates that the user is actively trying to connect to a route
and we should perform continuous scans. This mode may use significantly more
power but is intended to be short-lived.
|
Methods Summary |
---|
public void | addDisplay(RemoteDisplay display)Adds the specified remote display and notifies the system.
if (display == null || mDisplays.containsKey(display.getId())) {
throw new IllegalArgumentException("display");
}
mDisplays.put(display.getId(), display);
publishState();
|
public RemoteDisplay | findRemoteDisplay(java.lang.String id)Finds the remote display with the specified id, returns null if not found.
return mDisplays.get(id);
|
public android.os.IBinder | getBinder()Gets the Binder associated with the provider.
This is intended to be used for the onBind() method of a service that implements
a remote display provider service.
return mStub;
|
public final android.content.Context | getContext()Gets the context of the remote display provider.
return mContext;
|
public int | getDiscoveryMode()Gets the current discovery mode.
return mDiscoveryMode;
|
public java.util.Collection | getDisplays()Gets the current collection of displays.
return mDisplays.values();
|
public android.app.PendingIntent | getSettingsPendingIntent()Gets a pending intent to launch the remote display settings activity.
if (mSettingsPendingIntent == null) {
Intent settingsIntent = new Intent(Settings.ACTION_WIFI_DISPLAY_SETTINGS);
settingsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
| Intent.FLAG_ACTIVITY_CLEAR_TOP);
mSettingsPendingIntent = PendingIntent.getActivity(
mContext, 0, settingsIntent, 0, null);
}
return mSettingsPendingIntent;
|
public void | onAdjustVolume(RemoteDisplay display, int delta)Called when the system would like to adjust the volume of a display.
|
public void | onConnect(RemoteDisplay display)Called when the system would like to connect to a display.
|
public void | onDisconnect(RemoteDisplay display)Called when the system would like to disconnect from a display.
|
public void | onDiscoveryModeChanged(int mode)Called when the current discovery mode changes.
|
public void | onSetVolume(RemoteDisplay display, int volume)Called when the system would like to set the volume of a display.
|
void | publishState()
if (mCallback != null) {
RemoteDisplayState state = new RemoteDisplayState();
final int count = mDisplays.size();
for (int i = 0; i < count; i++) {
final RemoteDisplay display = mDisplays.valueAt(i);
state.displays.add(display.getInfo());
}
try {
mCallback.onStateChanged(state);
} catch (RemoteException ex) {
// system server died?
}
}
|
public void | removeDisplay(RemoteDisplay display)Removes the specified remote display and tells the system about it.
if (display == null || mDisplays.get(display.getId()) != display) {
throw new IllegalArgumentException("display");
}
mDisplays.remove(display.getId());
publishState();
|
void | setCallback(android.media.IRemoteDisplayCallback callback)
mCallback = callback;
publishState();
|
void | setDiscoveryMode(int mode)
if (mDiscoveryMode != mode) {
mDiscoveryMode = mode;
onDiscoveryModeChanged(mode);
}
|
public void | updateDisplay(RemoteDisplay display)Updates information about the specified remote display and notifies the system.
if (display == null || mDisplays.get(display.getId()) != display) {
throw new IllegalArgumentException("display");
}
publishState();
|