Search in sources :

Example 46 with WifiDisplay

use of android.hardware.display.WifiDisplay in project android_frameworks_base by ParanoidAndroid.

the class WifiDisplayController method handleScanFinished.

private void handleScanFinished() {
    final int count = mAvailableWifiDisplayPeers.size();
    final WifiDisplay[] displays = WifiDisplay.CREATOR.newArray(count);
    for (int i = 0; i < count; i++) {
        WifiP2pDevice device = mAvailableWifiDisplayPeers.get(i);
        displays[i] = createWifiDisplay(device);
        updateDesiredDevice(device);
    }
    mHandler.post(new Runnable() {

        @Override
        public void run() {
            mListener.onScanFinished(displays);
        }
    });
}
Also used : WifiP2pDevice(android.net.wifi.p2p.WifiP2pDevice) WifiDisplay(android.hardware.display.WifiDisplay)

Example 47 with WifiDisplay

use of android.hardware.display.WifiDisplay in project platform_frameworks_base by android.

the class MediaRouter method selectRouteStatic.

static void selectRouteStatic(int types, @NonNull RouteInfo route, boolean explicit) {
    Log.v(TAG, "Selecting route: " + route);
    assert (route != null);
    final RouteInfo oldRoute = sStatic.mSelectedRoute;
    if (oldRoute == route)
        return;
    if (!route.matchesTypes(types)) {
        Log.w(TAG, "selectRoute ignored; cannot select route with supported types " + typesToString(route.getSupportedTypes()) + " into route types " + typesToString(types));
        return;
    }
    final RouteInfo btRoute = sStatic.mBluetoothA2dpRoute;
    if (btRoute != null && (types & ROUTE_TYPE_LIVE_AUDIO) != 0 && (route == btRoute || route == sStatic.mDefaultAudioVideo)) {
        try {
            sStatic.mAudioService.setBluetoothA2dpOn(route == btRoute);
        } catch (RemoteException e) {
            Log.e(TAG, "Error changing Bluetooth A2DP state", e);
        }
    }
    final WifiDisplay activeDisplay = sStatic.mDisplayService.getWifiDisplayStatus().getActiveDisplay();
    final boolean oldRouteHasAddress = oldRoute != null && oldRoute.mDeviceAddress != null;
    final boolean newRouteHasAddress = route.mDeviceAddress != null;
    if (activeDisplay != null || oldRouteHasAddress || newRouteHasAddress) {
        if (newRouteHasAddress && !matchesDeviceAddress(activeDisplay, route)) {
            if (sStatic.mCanConfigureWifiDisplays) {
                sStatic.mDisplayService.connectWifiDisplay(route.mDeviceAddress);
            } else {
                Log.e(TAG, "Cannot connect to wifi displays because this process " + "is not allowed to do so.");
            }
        } else if (activeDisplay != null && !newRouteHasAddress) {
            sStatic.mDisplayService.disconnectWifiDisplay();
        }
    }
    sStatic.setSelectedRoute(route, explicit);
    if (oldRoute != null) {
        dispatchRouteUnselected(types & oldRoute.getSupportedTypes(), oldRoute);
        if (oldRoute.resolveStatusCode()) {
            dispatchRouteChanged(oldRoute);
        }
    }
    if (route != null) {
        if (route.resolveStatusCode()) {
            dispatchRouteChanged(route);
        }
        dispatchRouteSelected(types & route.getSupportedTypes(), route);
    }
    // The behavior of active scans may depend on the currently selected route.
    sStatic.updateDiscoveryRequest();
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay) RemoteException(android.os.RemoteException)

Example 48 with WifiDisplay

use of android.hardware.display.WifiDisplay in project platform_frameworks_base by android.

the class PersistentDataStore method dump.

public void dump(PrintWriter pw) {
    pw.println("PersistentDataStore");
    pw.println("  mLoaded=" + mLoaded);
    pw.println("  mDirty=" + mDirty);
    pw.println("  RememberedWifiDisplays:");
    int i = 0;
    for (WifiDisplay display : mRememberedWifiDisplays) {
        pw.println("    " + i++ + ": " + display);
    }
    pw.println("  DisplayStates:");
    i = 0;
    for (Map.Entry<String, DisplayState> entry : mDisplayStates.entrySet()) {
        pw.println("    " + i++ + ": " + entry.getKey());
        entry.getValue().dump(pw, "      ");
    }
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay) HashMap(java.util.HashMap) Map(java.util.Map)

Example 49 with WifiDisplay

use of android.hardware.display.WifiDisplay in project platform_frameworks_base by android.

the class PersistentDataStore method applyWifiDisplayAliases.

public WifiDisplay[] applyWifiDisplayAliases(WifiDisplay[] displays) {
    WifiDisplay[] results = displays;
    if (results != null) {
        int count = displays.length;
        for (int i = 0; i < count; i++) {
            WifiDisplay result = applyWifiDisplayAlias(displays[i]);
            if (result != displays[i]) {
                if (results == displays) {
                    results = new WifiDisplay[count];
                    System.arraycopy(displays, 0, results, 0, count);
                }
                results[i] = result;
            }
        }
    }
    return results;
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay)

Example 50 with WifiDisplay

use of android.hardware.display.WifiDisplay in project platform_frameworks_base by android.

the class WifiDisplayAdapter method fixRememberedDisplayNamesFromAvailableDisplaysLocked.

private void fixRememberedDisplayNamesFromAvailableDisplaysLocked() {
    // It may happen that a display name has changed since it was remembered.
    // Consult the list of available displays and update the name if needed.
    // We don't do anything special for the active display here.  The display
    // controller will send a separate event when it needs to be updates.
    boolean changed = false;
    for (int i = 0; i < mRememberedDisplays.length; i++) {
        WifiDisplay rememberedDisplay = mRememberedDisplays[i];
        WifiDisplay availableDisplay = findAvailableDisplayLocked(rememberedDisplay.getDeviceAddress());
        if (availableDisplay != null && !rememberedDisplay.equals(availableDisplay)) {
            if (DEBUG) {
                Slog.d(TAG, "fixRememberedDisplayNamesFromAvailableDisplaysLocked: " + "updating remembered display to " + availableDisplay);
            }
            mRememberedDisplays[i] = availableDisplay;
            changed |= mPersistentDataStore.rememberWifiDisplay(availableDisplay);
        }
    }
    if (changed) {
        mPersistentDataStore.saveIfNeeded();
    }
}
Also used : WifiDisplay(android.hardware.display.WifiDisplay)

Aggregations

WifiDisplay (android.hardware.display.WifiDisplay)77 WifiP2pDevice (android.net.wifi.p2p.WifiP2pDevice)12 Surface (android.view.Surface)12 HashMap (java.util.HashMap)10 Map (java.util.Map)10 WpsInfo (android.net.wifi.WpsInfo)6 WifiP2pConfig (android.net.wifi.p2p.WifiP2pConfig)6 ActionListener (android.net.wifi.p2p.WifiP2pManager.ActionListener)6 GroupInfoListener (android.net.wifi.p2p.WifiP2pManager.GroupInfoListener)6 PeerListListener (android.net.wifi.p2p.WifiP2pManager.PeerListListener)6 RemoteException (android.os.RemoteException)6 Inet4Address (java.net.Inet4Address)6 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)6 ArrayList (java.util.ArrayList)5 RemoteDisplay (android.media.RemoteDisplay)3 StackTraceElement (java.lang.StackTraceElement)3 WifiDisplayStatus (android.hardware.display.WifiDisplayStatus)1 MediaRouter (android.media.MediaRouter)1 RouteInfo (android.media.MediaRouter.RouteInfo)1 PreferenceScreen (android.support.v7.preference.PreferenceScreen)1