Java 类android.net.wifi.p2p.WifiP2pManager.GroupInfoListener 实例源码

项目:SPF    文件:WifiDirectMiddleware.java   
@Override
public void onConnectionInfoAvailable(final WifiP2pInfo info) {
    if (mGroupActor != null) {
        return;
    }
    WfdLog.d(TAG, "connection info available");
    if (!info.groupFormed) {
        createGroup();
        return;
    }
    WfdLog.d(TAG, "group formed");
    if (info.isGroupOwner) {
        instantiateGroupOwner();
    } else {
        mManager.requestGroupInfo(mChannel, new GroupInfoListener() {
            @Override
            public void onGroupInfoAvailable(WifiP2pGroup arg0) {
                if (arg0 == null) {
                    // happens when the go goes away and the
                    // framework does not have time to update the
                    // connection loss
                    return;
                }
                WifiP2pDevice groupOwnerDevice = arg0.getOwner();
                Integer destPort = mPorts.get(groupOwnerDevice.deviceAddress);
                if (destPort == null) {
                    Log.e(TAG, "null destPort for group owner");
                    mManager.removeGroup(mChannel, null);
                }
                instantiateGroupClient(info.groupOwnerAddress, destPort);
            }
        });
    }
}