diff options
-rw-r--r-- | media/java/android/media/MediaRouter.java | 22 | ||||
-rw-r--r-- | services/java/com/android/server/display/WifiDisplayAdapter.java | 29 |
2 files changed, 35 insertions, 16 deletions
diff --git a/media/java/android/media/MediaRouter.java b/media/java/android/media/MediaRouter.java index 8e9384ee..82ed432 100644 --- a/media/java/android/media/MediaRouter.java +++ b/media/java/android/media/MediaRouter.java @@ -751,18 +751,10 @@ public class MediaRouter { RouteInfo.STATUS_AVAILABLE : RouteInfo.STATUS_CONNECTING); newRoute.mEnabled = available; - newRoute.mName = makeWifiDisplayName(display); + newRoute.mName = display.getFriendlyDisplayName(); return newRoute; } - static String makeWifiDisplayName(WifiDisplay display) { - String name = display.getDeviceAlias(); - if (TextUtils.isEmpty(name)) { - name = display.getDeviceName(); - } - return name; - } - private static void updateWifiDisplayRoute(RouteInfo route, WifiDisplay display, boolean available, WifiDisplayStatus wifiDisplayStatus) { final boolean isScanning = @@ -792,8 +784,8 @@ public class MediaRouter { } } - final String newName = makeWifiDisplayName(display); - if (route.getName().equals(newName)) { + final String newName = display.getFriendlyDisplayName(); + if (!route.getName().equals(newName)) { route.mName = newName; changed = true; } @@ -814,11 +806,11 @@ public class MediaRouter { } } - private static WifiDisplay findMatchingDisplay(WifiDisplay address, WifiDisplay[] displays) { + private static WifiDisplay findMatchingDisplay(WifiDisplay d, WifiDisplay[] displays) { for (int i = 0; i < displays.length; i++) { - final WifiDisplay d = displays[i]; - if (d.equals(address)) { - return d; + final WifiDisplay other = displays[i]; + if (d.getDeviceAddress().equals(other.getDeviceAddress())) { + return other; } } return null; diff --git a/services/java/com/android/server/display/WifiDisplayAdapter.java b/services/java/com/android/server/display/WifiDisplayAdapter.java index b2beb5e..3e541dd 100644 --- a/services/java/com/android/server/display/WifiDisplayAdapter.java +++ b/services/java/com/android/server/display/WifiDisplayAdapter.java @@ -50,6 +50,8 @@ import java.util.Arrays; final class WifiDisplayAdapter extends DisplayAdapter { private static final String TAG = "WifiDisplayAdapter"; + private static final boolean DEBUG = false; + private final PersistentDataStore mPersistentDataStore; private final boolean mSupportsProtectedBuffers; @@ -116,6 +118,10 @@ final class WifiDisplayAdapter extends DisplayAdapter { } public void requestScanLocked() { + if (DEBUG) { + Slog.d(TAG, "requestScanLocked"); + } + getHandler().post(new Runnable() { @Override public void run() { @@ -127,6 +133,10 @@ final class WifiDisplayAdapter extends DisplayAdapter { } public void requestConnectLocked(final String address, final boolean trusted) { + if (DEBUG) { + Slog.d(TAG, "requestConnectLocked: address=" + address + ", trusted=" + trusted); + } + if (!trusted) { synchronized (getSyncRoot()) { if (!isRememberedDisplayLocked(address)) { @@ -157,6 +167,10 @@ final class WifiDisplayAdapter extends DisplayAdapter { } public void requestDisconnectLocked() { + if (DEBUG) { + Slog.d(TAG, "requestDisconnectedLocked"); + } + getHandler().post(new Runnable() { @Override public void run() { @@ -168,9 +182,13 @@ final class WifiDisplayAdapter extends DisplayAdapter { } public void requestRenameLocked(String address, String alias) { + if (DEBUG) { + Slog.d(TAG, "requestRenameLocked: address=" + address + ", alias=" + alias); + } + if (alias != null) { alias = alias.trim(); - if (alias.isEmpty()) { + if (alias.isEmpty() || alias.equals(address)) { alias = null; } } @@ -183,6 +201,10 @@ final class WifiDisplayAdapter extends DisplayAdapter { } public void requestForgetLocked(String address) { + if (DEBUG) { + Slog.d(TAG, "requestForgetLocked: address=" + address); + } + if (mPersistentDataStore.forgetWifiDisplay(address)) { mPersistentDataStore.saveIfNeeded(); updateRememberedDisplaysLocked(); @@ -200,6 +222,10 @@ final class WifiDisplayAdapter extends DisplayAdapter { mFeatureState, mScanState, mActiveDisplayState, mActiveDisplay, mAvailableDisplays, mRememberedDisplays); } + + if (DEBUG) { + Slog.d(TAG, "getWifiDisplayStatusLocked: result=" + mCurrentStatus); + } return mCurrentStatus; } @@ -295,6 +321,7 @@ final class WifiDisplayAdapter extends DisplayAdapter { } } + @Override public void onScanFinished(WifiDisplay[] availableDisplays) { synchronized (getSyncRoot()) { availableDisplays = mPersistentDataStore.applyWifiDisplayAliases( |