summaryrefslogtreecommitdiffstats
path: root/media/lib
diff options
context:
space:
mode:
Diffstat (limited to 'media/lib')
-rw-r--r--media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java b/media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java
index 701c39c..e2df77c 100644
--- a/media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java
+++ b/media/lib/java/com/android/media/remotedisplay/RemoteDisplayProvider.java
@@ -16,6 +16,7 @@
package com.android.media.remotedisplay;
+import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
@@ -27,6 +28,7 @@ import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
+import android.provider.Settings;
import android.util.ArrayMap;
import java.util.Collection;
@@ -95,6 +97,7 @@ public abstract class RemoteDisplayProvider {
private static final int MSG_SET_VOLUME = 5;
private static final int MSG_ADJUST_VOLUME = 6;
+ private final Context mContext;
private final ProviderStub mStub;
private final ProviderHandler mHandler;
private final ArrayMap<String, RemoteDisplay> mDisplays =
@@ -102,6 +105,8 @@ public abstract class RemoteDisplayProvider {
private IRemoteDisplayCallback mCallback;
private int mDiscoveryMode = DISCOVERY_MODE_NONE;
+ private PendingIntent mSettingsPendingIntent;
+
/**
* The {@link Intent} that must be declared as handled by the service.
* Put this in your manifest.
@@ -140,11 +145,19 @@ public abstract class RemoteDisplayProvider {
* @param context The application context for the remote display provider.
*/
public RemoteDisplayProvider(Context context) {
+ mContext = context;
mStub = new ProviderStub();
mHandler = new ProviderHandler(context.getMainLooper());
}
/**
+ * Gets the context of the remote display provider.
+ */
+ public final Context getContext() {
+ return mContext;
+ }
+
+ /**
* Gets the Binder associated with the provider.
* <p>
* This is intended to be used for the onBind() method of a service that implements
@@ -261,11 +274,29 @@ public abstract class RemoteDisplayProvider {
* Finds the remote display with the specified id, returns null if not found.
*
* @param id Id of the remote display.
+ * @return The display, or null if none.
*/
public RemoteDisplay findRemoteDisplay(String id) {
return mDisplays.get(id);
}
+ /**
+ * Gets a pending intent to launch the remote display settings activity.
+ *
+ * @return A pending intent to launch the settings activity.
+ */
+ public PendingIntent getSettingsPendingIntent() {
+ 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;
+ }
+
void setCallback(IRemoteDisplayCallback callback) {
mCallback = callback;
publishState();