Problems with Android O with WiFi Peer Discovery

I am developing an Android application that uses WiFi (Direct) to discover a service and discover / discover P2P connections.

My development concept is as follows: -

Android Studio 3.0 Beta 4
Build #AI-171.4304935, built on August 29, 2017
JRE: 1.8.0_152-release-915-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.11.6

My Gradle build: -

apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.research.wifi_direct"

        minSdkVersion 19
        targetSdkVersion 26

        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    buildTypes {

        debug {
            buildConfigField "String", "INSTANCE_NAME", "\"_vascodagama\""
            buildConfigField "String", "SERVICE_TYPE", "\"_presence._tcp\""
        }

        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:26.0.2'
    implementation 'com.android.support:recyclerview-v7:26.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    implementation 'com.yarolegovich:lovely-dialog:1.0.7'

    implementation 'io.realm:android-adapters:2.1.0'


    testImplementation 'junit:junit:4.12'

    androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.1', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
}

The devices I am testing include: -

Nexus 7 - Android 6.0.1
Nexus 9 - Android 7.1.1
Samsung Tablet - Android 4.4.1
Pixel - Android 8.0.0 

Service discovery works fine on all four devices.

However, the P2P Peers List is always empty in Pixel XLrunning Android 8.0.0. The other three devices sequentially detect each other, as well as other different devices around my office, for example. such as Samsung TV and my personal personal phones, etc.

The only thing I can come up with is something about Android Othat blocks P2P peer detection. I don’t see anything in “Whats New in Android O” to identify the culprit

- Android O? ? ?

, , .

https://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html https://developer.android.com/training/connect-devices-wirelessly/nsd-wifi-direct.html

- , , , "" WiFi, android.net.wifi.WifiManager.WifiLock . , , WiFiLock. ... use-permission android:name="android.permission.WAKE_LOCK".

UPDATE - 0001

, , , PEER_CHANGED, , , Android O Pixel XL Nexus

WiFiDirectBroadcastRcvr: android.net.wifi.p2p.PEERS_CHANGED<<<<<EXTRA DATA :: ------------------------START
WiFiDirectBroadcastRcvr: EXTRA DATA :: wifiP2pDeviceList 
                         Device: Nexus 7
                          deviceAddress: da:50:e6:7c:56:4e
                          primary type: 000A0050F2040005
                          secondary type: null
                          wps: 392
                          grpcapab: 0
                          devcapab: 37
                          status: 3
                          wfdInfo: WFD enabled: trueWFD DeviceInfo: 0
                          WFD CtrlPort: 0
                          WFD MaxThroughput: 0 (android.net.wifi.p2p.WifiP2pDeviceList)
WiFiDirectBroadcastRcvr: EXTRA DATA :: ------------------------FINISH

, requestPeers, WifiP2pDeviceList?

case WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION:
                Log.d(TAG, "onReceive: WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION");
                mWiFiPeer2PeerCommander.requestPeers(mWifiP2pManager, mWifiP2pManagerChannel);
                break;

WifiP2pDeviceList , requestPeers?

+4
1

. nexus 5x Android O. WifiP2pDeviceList. , (?) Android 6 SCAN_RESULTS_AVAILABLE_ACTION Android 6.0

...

+1

Source: https://habr.com/ru/post/1685230/


All Articles