2021年1月21日星期四

Network connection prompt loops when my android app attempts to connect to specified network

I am new to android development and am attempting to create a simple example app that connects to a specified network when a button is pressed.

I have found a few examples of other questions but they are using the now deprecated WifiManager.addNetwork()

Currently when I test locally on my Huawei P20 (Android Version 10) a connection prompt pops up, scans for and finds the correct network, I connect, gives "Connection Successful" message, then prompt pops up again and repeats and repeats and repeats...

With "verbose" debugging these messages keep repeating as I keep connecting in prompt

D/ZrHung.AppEyeUiProbe: not watching, wait.  D/ZrHung.AppEyeUiProbe: restart watching  D/ZrHung.AppEyeUiProbe: not watching, wait.  D/ZrHung.AppEyeUiProbe: restart watching  

My onClick calls

fun onConnectClick (view: View)      {          val wifiSpecs = WifiNetworkSpecifier.Builder()              .setSsid("SSID")              .setWpa2Passphrase("PASSWORD")              .build()          val networkRequest = NetworkRequest.Builder()              .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)              .setNetworkSpecifier(wifiSpecs)              .build()          val connectivityManager = getSystemService((Context.CONNECTIVITY_SERVICE)) as ConnectivityManager          val networkCallback = ConnectivityManager.NetworkCallback()            connectivityManager.requestNetwork(networkRequest, networkCallback)          Reply.text = "Connect Clicked"        }  

I have tried replacing

val networkCallback = ConnectivityManager.NetworkCallback()

with

val networkCallback = object:ConnectivityManager.NetworkCallback() {              override fun onAvailable(network:Network) {                  super.onAvailable(network)                  connectivityManager.bindProcessToNetwork(network)              }  

as mentioned elsewhere but no change

The Full logcat output is:

I/e.myapplicatio: Late-enabling -Xcheck:jni  E/e.myapplicatio: Unknown bits set in runtime_flags: 0x8000  I/e.myapplicatio: Reinit property: dalvik.vm.checkjni= false  E/libc: Access denied finding property "runtime.mmitest.isrunning"  D/ActivityThread: Attach thread to application  W/ActivityThread: Application com.example.myapplication is waiting for the debugger on port 8100...  I/System.out: Sending WAIT chunk  I/System.out: Debugger has connected  I/System.out: waiting for debugger to settle...  I/chatty: uid=10270(com.example.myapplication) identical 1 line  I/System.out: waiting for debugger to settle...  I/System.out: waiting for debugger to settle...  I/System.out: waiting for debugger to settle...  I/System.out: waiting for debugger to settle...  I/System.out: waiting for debugger to settle...  I/System.out: debugger has settled (1421)  I/e.myapplicatio: QarthPatchMonintor::Init  I/e.myapplicatio: QarthPatchMonintor::StartWatch  I/e.myapplicatio: QarthPatchMonintor::WatchPackage: /data/hotpatch/fwkhotpatch/  I/e.myapplicatio: QarthPatchMonintor::CheckAndWatchPatch: /data/hotpatch/fwkhotpatch/com.example.myapplication  I/e.myapplicatio: QarthPatchMonintor::CheckAndWatchPatch: /data/hotpatch/fwkhotpatch/all  I/e.myapplicatio: QarthPatchMonintor::Run  I/e.myapplicatio: QarthPatchMonintor::Reading  I/e.myapplicatio: QarthPatchMonintor::CheckNotifyEvent  I/e.myapplicatio: QarthPatchMonintor::CheckNotifyEvent before read  I/HwApiCacheMangerEx: apicache path=/storage/emulated/0 state=mounted key=com.example.myapplication#10270#256  I/HwApiCacheMangerEx: apicache path=/storage/emulated/0 state=mounted key=com.example.myapplication#10270#0  I/AwareBitmapCacher: init processName:com.example.myapplication pid=24286 uid=10270  E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@88ec3a  E/AwareLog: AtomicFileUtils: readFileLines file not exist: android.util.AtomicFile@12270eb  V/ActivityThread: callActivityOnCreate  V/HwWidgetFactory: : successes to get AllImpl object and return....  I/OverScrollerOptimization: start init SmartSlideOverScroller and get the overscroller config  I/OverScrollerOptimization: get the overscroller config  W/e.myapplicatio: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)  W/e.myapplicatio: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)  D/ActivityThread: add activity client record, r= ActivityRecord{cf15e4 token=android.os.BinderProxy@5401765 {com.example.myapplication/com.example.myapplication.MainActivity}} token= android.os.BinderProxy@5401765  W/HiTouch_HiTouchSensor: depended package hiTouch does n't exist!  I/HiTouch_HiTouchSensor: HiTouch restricted: system app HiTouch don't exist.  D/HiTouch_PressGestureDetector: onAttached, package=com.example.myapplication, windowType=1, mHiTouchRestricted=true  I/iGraphics: [0020080c] pn: com.example.myapplication, p: 24286  I/iGraphics: [0030080c] no spt app: com.example.myapplication  D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000  W/Gralloc3: mapper 3.x is not supported  I/HwViewRootImpl: removeInvalidNode jank list is null  D/AwareBitmapCacher: handleInit switch not opened pid=24286  I/HwViewRootImpl: removeInvalidNode all the node in jank list is out of time  V/AudioManager: querySoundEffectsEnabled...  D/ConnectivityManager: requestNetwork and the calling app is: com.example.myapplication  D/ZrHung.AppEyeUiProbe: not watching, wait.  D/ZrHung.AppEyeUiProbe: restart watching  D/HwFrameworkSecurityPartsFactory: HwFrameworkSecurityPartsFactory in.  I/HwFrameworkSecurityPartsFactory: add HwFrameworkSecurityPartsFactory to memory.  W/libEGL: EGLNativeWindowType 0x7c3502cc10 disconnect failed  D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000  D/ZrHung.AppEyeUiProbe: not watching, wait.  W/libEGL: EGLNativeWindowType 0x7c3502cc10 disconnect failed  D/ZrHung.AppEyeUiProbe: restart watching  D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000  I/HwViewRootImpl: removeInvalidNode all the node in jank list is out of time  W/libEGL: EGLNativeWindowType 0x7c26c4b750 disconnect failed  D/ZrHung.AppEyeUiProbe: not watching, wait.  

Full code can be found here

EDIT: Apparently this is a known issue link1 link2 with some OEM hardware

https://stackoverflow.com/questions/65741321/network-connection-prompt-loops-when-my-android-app-attempts-to-connect-to-speci January 16, 2021 at 02:02AM

没有评论:

发表评论