diff options
author | Chong Zhang <chz@google.com> | 2013-05-03 15:55:36 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2013-08-23 16:02:09 -0700 |
commit | 1f3ecaae6303d5ee6c5ca8499262c9962f036365 (patch) | |
tree | 610f36b3c049710713e921c1aa10938fa250f1d2 /core | |
parent | 570cd0f4c06a6e3de2af348040415ff2fcff57a1 (diff) | |
download | frameworks_base-1f3ecaae6303d5ee6c5ca8499262c9962f036365.zip frameworks_base-1f3ecaae6303d5ee6c5ca8499262c9962f036365.tar.gz frameworks_base-1f3ecaae6303d5ee6c5ca8499262c9962f036365.tar.bz2 |
wifi-display: add certification options
When certification mode is enabled:
- Pass wfd session info to wifi display settings
- Allow sink to connect to source
- Add interface in display manager for pausing/resuming session
- Add interface in WifiP2pManager for setting lc, oc and starting
autonomous GO
Note that we're compliant regardless of certification mode, but
some confusing options (eg. allowing incoming connection from
sink) we want to hide when not being tested.
Bug: 9371882
Change-Id: Icc7dcae4e046453796cfa03f5f197055fabf234b
Diffstat (limited to 'core')
7 files changed, 204 insertions, 8 deletions
diff --git a/core/java/android/hardware/display/DisplayManager.java b/core/java/android/hardware/display/DisplayManager.java index 7d65736..0071865 100644 --- a/core/java/android/hardware/display/DisplayManager.java +++ b/core/java/android/hardware/display/DisplayManager.java @@ -325,6 +325,16 @@ public final class DisplayManager { mGlobal.connectWifiDisplay(deviceAddress); } + /** @hide */ + public void pauseWifiDisplay() { + mGlobal.pauseWifiDisplay(); + } + + /** @hide */ + public void resumeWifiDisplay() { + mGlobal.resumeWifiDisplay(); + } + /** * Disconnects from the current Wifi display. * The results are sent as a {@link #ACTION_WIFI_DISPLAY_STATUS_CHANGED} broadcast. diff --git a/core/java/android/hardware/display/DisplayManagerGlobal.java b/core/java/android/hardware/display/DisplayManagerGlobal.java index 10c14ff..936a086 100644 --- a/core/java/android/hardware/display/DisplayManagerGlobal.java +++ b/core/java/android/hardware/display/DisplayManagerGlobal.java @@ -287,6 +287,22 @@ public final class DisplayManagerGlobal { } } + public void pauseWifiDisplay() { + try { + mDm.pauseWifiDisplay(); + } catch (RemoteException ex) { + Log.e(TAG, "Failed to pause Wifi display.", ex); + } + } + + public void resumeWifiDisplay() { + try { + mDm.resumeWifiDisplay(); + } catch (RemoteException ex) { + Log.e(TAG, "Failed to resume Wifi display.", ex); + } + } + public void disconnectWifiDisplay() { try { mDm.disconnectWifiDisplay(); diff --git a/core/java/android/hardware/display/IDisplayManager.aidl b/core/java/android/hardware/display/IDisplayManager.aidl index afaf436..6b2c887 100644 --- a/core/java/android/hardware/display/IDisplayManager.aidl +++ b/core/java/android/hardware/display/IDisplayManager.aidl @@ -55,4 +55,10 @@ interface IDisplayManager { // No permissions required but must be same Uid as the creator. void releaseVirtualDisplay(in IBinder token); + + // Requires CONFIGURE_WIFI_DISPLAY permission. + void pauseWifiDisplay(); + + // Requires CONFIGURE_WIFI_DISPLAY permission. + void resumeWifiDisplay(); } diff --git a/core/java/android/hardware/display/WifiDisplaySessionInfo.java b/core/java/android/hardware/display/WifiDisplaySessionInfo.java new file mode 100644 index 0000000..33d2725 --- /dev/null +++ b/core/java/android/hardware/display/WifiDisplaySessionInfo.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.display; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * This class contains information regarding a wifi display session + * (such as session id, source ip address, etc.). This is needed for + * Wifi Display Certification process. + * <p> + * This object is immutable. + * </p> + * + * @hide + */ +public final class WifiDisplaySessionInfo implements Parcelable { + private final boolean mClient; + private final int mSessionId; + private final String mGroupId; + private final String mPassphrase; + private final String mIP; + + public static final Creator<WifiDisplaySessionInfo> CREATOR = + new Creator<WifiDisplaySessionInfo>() { + @Override + public WifiDisplaySessionInfo createFromParcel(Parcel in) { + boolean client = (in.readInt() != 0); + int session = in.readInt(); + String group = in.readString(); + String pp = in.readString(); + String ip = in.readString(); + + return new WifiDisplaySessionInfo(client, session, group, pp, ip); + } + + @Override + public WifiDisplaySessionInfo[] newArray(int size) { + return new WifiDisplaySessionInfo[size]; + } + }; + + public WifiDisplaySessionInfo() { + this(true, 0, "", "", ""); + } + + public WifiDisplaySessionInfo( + boolean client, int session, String group, String pp, String ip) { + mClient = client; + mSessionId = session; + mGroupId = group; + mPassphrase = pp; + mIP = ip; + } + + public boolean isClient() { + return mClient; + } + + public int getSessionId() { + return mSessionId; + } + + public String getGroupId() { + return mGroupId; + } + + public String getPassphrase() { + return mPassphrase; + } + + public String getIP() { + return mIP; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mClient ? 1 : 0); + dest.writeInt(mSessionId); + dest.writeString(mGroupId); + dest.writeString(mPassphrase); + dest.writeString(mIP); + } + + @Override + public int describeContents() { + return 0; + } + + // For debugging purposes only. + @Override + public String toString() { + return "WifiDisplaySessionInfo:" + +"\n Client/Owner: " + (mClient ? "Client":"Owner") + +"\n GroupId: " + mGroupId + +"\n Passphrase: " + mPassphrase + +"\n SessionId: " + mSessionId + +"\n IP Address: " + mIP + ; + } +} diff --git a/core/java/android/hardware/display/WifiDisplayStatus.java b/core/java/android/hardware/display/WifiDisplayStatus.java index 77acdc0..5216727 100644 --- a/core/java/android/hardware/display/WifiDisplayStatus.java +++ b/core/java/android/hardware/display/WifiDisplayStatus.java @@ -39,6 +39,9 @@ public final class WifiDisplayStatus implements Parcelable { private final WifiDisplay mActiveDisplay; private final WifiDisplay[] mDisplays; + /** Session info needed for Miracast Certification */ + private final WifiDisplaySessionInfo mSessionInfo; + /** Feature state: Wifi display is not available on this device. */ public static final int FEATURE_STATE_UNAVAILABLE = 0; /** Feature state: Wifi display is disabled, probably because Wifi is disabled. */ @@ -76,8 +79,11 @@ public final class WifiDisplayStatus implements Parcelable { displays[i] = WifiDisplay.CREATOR.createFromParcel(in); } + WifiDisplaySessionInfo sessionInfo = + WifiDisplaySessionInfo.CREATOR.createFromParcel(in); + return new WifiDisplayStatus(featureState, scanState, activeDisplayState, - activeDisplay, displays); + activeDisplay, displays, sessionInfo); } public WifiDisplayStatus[] newArray(int size) { @@ -87,11 +93,11 @@ public final class WifiDisplayStatus implements Parcelable { public WifiDisplayStatus() { this(FEATURE_STATE_UNAVAILABLE, SCAN_STATE_NOT_SCANNING, DISPLAY_STATE_NOT_CONNECTED, - null, WifiDisplay.EMPTY_ARRAY); + null, WifiDisplay.EMPTY_ARRAY, null); } - public WifiDisplayStatus(int featureState, int scanState, - int activeDisplayState, WifiDisplay activeDisplay, WifiDisplay[] displays) { + public WifiDisplayStatus(int featureState, int scanState, int activeDisplayState, + WifiDisplay activeDisplay, WifiDisplay[] displays, WifiDisplaySessionInfo sessionInfo) { if (displays == null) { throw new IllegalArgumentException("displays must not be null"); } @@ -101,6 +107,8 @@ public final class WifiDisplayStatus implements Parcelable { mActiveDisplayState = activeDisplayState; mActiveDisplay = activeDisplay; mDisplays = displays; + + mSessionInfo = (sessionInfo != null) ? sessionInfo : new WifiDisplaySessionInfo(); } /** @@ -144,13 +152,20 @@ public final class WifiDisplayStatus implements Parcelable { /** * Gets the list of Wifi displays, returns a combined list of all available - * Wifi displays as reported by the most recent scan, and all remembered + * Wifi displays as reported by the most recent scan, and all remembered * Wifi displays (not necessarily available at the time). */ public WifiDisplay[] getDisplays() { return mDisplays; } + /** + * Gets the Wifi display session info (required for certification only) + */ + public WifiDisplaySessionInfo getSessionInfo() { + return mSessionInfo; + } + @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mFeatureState); @@ -168,6 +183,8 @@ public final class WifiDisplayStatus implements Parcelable { for (WifiDisplay display : mDisplays) { display.writeToParcel(dest, flags); } + + mSessionInfo.writeToParcel(dest, flags); } @Override @@ -183,6 +200,7 @@ public final class WifiDisplayStatus implements Parcelable { + ", activeDisplayState=" + mActiveDisplayState + ", activeDisplay=" + mActiveDisplay + ", displays=" + Arrays.toString(mDisplays) + + ", sessionInfo=" + mSessionInfo + "}"; } } diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index b3309e1..0b51b8a 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5075,6 +5075,14 @@ public final class Settings { public static final String WIFI_DISPLAY_ON = "wifi_display_on"; /** + * Whether Wifi display certification mode is enabled/disabled + * 0=disabled. 1=enabled. + * @hide + */ + public static final String WIFI_DISPLAY_CERTIFICATION_ON = + "wifi_display_certification_on"; + + /** * Whether to notify the user of open networks. * <p> * If not connected and the scan results have an open network, we will diff --git a/core/jni/android_media_RemoteDisplay.cpp b/core/jni/android_media_RemoteDisplay.cpp index 80d13be..3fd8ed9 100644 --- a/core/jni/android_media_RemoteDisplay.cpp +++ b/core/jni/android_media_RemoteDisplay.cpp @@ -61,7 +61,7 @@ protected: public: virtual void onDisplayConnected(const sp<IGraphicBufferProducer>& bufferProducer, - uint32_t width, uint32_t height, uint32_t flags) { + uint32_t width, uint32_t height, uint32_t flags, uint32_t session) { JNIEnv* env = AndroidRuntime::getJNIEnv(); jobject surfaceObj = android_view_Surface_createFromIGraphicBufferProducer(env, bufferProducer); @@ -73,7 +73,7 @@ public: env->CallVoidMethod(mRemoteDisplayObjGlobal, gRemoteDisplayClassInfo.notifyDisplayConnected, - surfaceObj, width, height, flags); + surfaceObj, width, height, flags, session); env->DeleteLocalRef(surfaceObj); checkAndClearExceptionFromCallback(env, "notifyDisplayConnected"); } @@ -117,6 +117,14 @@ public: mDisplay->dispose(); } + void pause() { + mDisplay->pause(); + } + + void resume() { + mDisplay->resume(); + } + private: sp<IRemoteDisplay> mDisplay; sp<NativeRemoteDisplayClient> mClient; @@ -149,6 +157,16 @@ static jint nativeListen(JNIEnv* env, jobject remoteDisplayObj, jstring ifaceStr return reinterpret_cast<jint>(wrapper); } +static void nativePause(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { + NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr); + wrapper->pause(); +} + +static void nativeResume(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { + NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr); + wrapper->resume(); +} + static void nativeDispose(JNIEnv* env, jobject remoteDisplayObj, jint ptr) { NativeRemoteDisplay* wrapper = reinterpret_cast<NativeRemoteDisplay*>(ptr); delete wrapper; @@ -161,6 +179,10 @@ static JNINativeMethod gMethods[] = { (void*)nativeListen }, {"nativeDispose", "(I)V", (void*)nativeDispose }, + {"nativePause", "(I)V", + (void*)nativePause }, + {"nativeResume", "(I)V", + (void*)nativeResume }, }; int register_android_media_RemoteDisplay(JNIEnv* env) @@ -171,7 +193,7 @@ int register_android_media_RemoteDisplay(JNIEnv* env) jclass clazz = env->FindClass("android/media/RemoteDisplay"); gRemoteDisplayClassInfo.notifyDisplayConnected = env->GetMethodID(clazz, "notifyDisplayConnected", - "(Landroid/view/Surface;III)V"); + "(Landroid/view/Surface;IIII)V"); gRemoteDisplayClassInfo.notifyDisplayDisconnected = env->GetMethodID(clazz, "notifyDisplayDisconnected", "()V"); gRemoteDisplayClassInfo.notifyDisplayError = |