{ "id": "171590", "key": "TIMOB-26001", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2018-06-13T18:36:57.000+0000", "created": "2018-05-01T17:05:18.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [ "module" ], "versions": [], "issuelinks": [], "assignee": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2018-06-13T18:36:57.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "We are using below code to connect to Android device Wifi programatically. This code is working fine Android devices 7 and below. Same code is not working in Android 8. We have developed sample app in Android studio where we are able to connect to WIFI using wifiManager manager class. Due to this we are suspecting this issue might exists only if we using Appcelerator module. Details are mentioned after the code.\r\nCode used to connect :\r\n{code}\r\nList scanResultList = getScanningResults();\r\nint res =0;\r\nfor (ScanResult result : scanResultList) {\r\n\r\nif (result.SSID.equals(networkSSID)) {\r\n\r\ntry\r\n{\r\nWifiConfiguration wifiConfiguration = createAPConfiguration(\r\nnetworkSSID, networkPasskey, securityMode);\r\nthis.wifiManager.setWifiEnabled(true);\r\nif (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {\r\nwifiConfiguration.SSID = networkSSID;\r\n// int pri = 99;\r\n//wifiConfiguration.priority = wifiConfiguration.priority + 1;\r\n} else {\r\nwifiConfiguration.SSID = \"\\\"\" + networkSSID + \"\\\"\";\r\nwifiConfiguration.priority = 40;\r\n}\r\nwhile(!this.wifiManager.pingSupplicant())\r\n{\r\nThread.sleep(1000);\r\n}\r\nres = this.wifiManager.addNetwork(wifiConfiguration);\r\nLog.i(\"WIFI_Connect\", \"# addNetwork returned \" + res);\r\nif (res == -1) {\r\n// Get existed network id if it is already added to WiFi network\r\nthis.wifiManager.updateNetwork(wifiConfiguration);\r\nres = getExistingNetworkId(networkSSID);\r\nLog.d(\"WIFI_Connect\", \"getExistingNetworkId: \" + res);\r\n}\r\nthis.wifiManager.disconnect();\r\nthis.wifiManager.enableNetwork(res, true);\r\n//this.wifiManager.saveConfiguration();\r\nthis.wifiManager.reconnect();\r\nreturn res;\r\n}catch(Exception ex)\r\n{\r\nLog.i(\"\", \"AddDynamicWifi--savewifi--Exception--\" + ex);\r\nreturn 1;\r\n}\r\n}\r\n}\r\n\r\nreturn -1;\r\n\r\n\r\nprivate WifiConfiguration createAPConfiguration(String networkSSID,\r\nString networkPass, String capabilities) {\r\nthis.wifiConfig.allowedKeyManagement.clear();\r\nWifiConfiguration wifiConfiguration = new WifiConfiguration();\r\nwifiConfiguration.allowedKeyManagement.clear();\r\nwifiConfiguration.status = WifiConfiguration.Status.ENABLED;\r\n//wifiConfiguration.priority = 40;\r\nwifiConfiguration.SSID = String.format(\"\\\"%s\\\"\",\r\nnew Object[] { networkSSID });\r\n\r\nLog.i(\"networkSSID\", \"=======\" + wifiConfiguration.SSID);\r\n\r\nif (capabilities.toUpperCase().contains(\"WEP\")) {\r\nLog.i(\"rht\", \"Configuring WEP\");\r\nwifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.RSN);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.WPA);\r\nwifiConfiguration.allowedAuthAlgorithms\r\n.set(WifiConfiguration.AuthAlgorithm.OPEN);\r\nwifiConfiguration.allowedAuthAlgorithms\r\n.set(WifiConfiguration.AuthAlgorithm.SHARED);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.CCMP);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.TKIP);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.WEP40);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.WEP104);\r\n\r\n/* if (networkPass.matches(\"^[0-9a-fA-F]+$\")) {\r\nwifiConfiguration.wepKeys[0] = networkPass;\r\n} else {\r\nwifiConfiguration.wepKeys[0] = \"\\\"\".concat(networkPass).concat(\r\n\"\\\"\");\r\n}*/\r\nwifiConfiguration.wepKeys[0] = String.format(\"\\\"%s\\\"\",\r\nnew Object[] { networkPass });\r\nLog.i(\"networkSSID\", \"=======\" + wifiConfiguration.wepKeys[0]);\r\nwifiConfiguration.wepTxKeyIndex = 0;\r\n\r\n} else if (capabilities.toUpperCase().contains(\"WPA\")) {\r\nLog.i(\"rht\", \"Configuring WPA\");\r\nwifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.WPA);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.WPA);\r\nwifiConfiguration.allowedAuthAlgorithms\r\n.set(WifiConfiguration.AuthAlgorithm.OPEN);\r\nwifiConfiguration.allowedKeyManagement\r\n.set(WifiConfiguration.KeyMgmt.WPA_PSK);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.CCMP);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.TKIP);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.WEP40);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.WEP104);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.CCMP);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.TKIP);\r\nwifiConfiguration.preSharedKey = String.format(\"\\\"%s\\\"\",\r\nnew Object[] { networkPass });\r\nLog.i(\"network password WPA\", \"=======\" + wifiConfiguration.preSharedKey);\r\n//wifiConfiguration.preSharedKey = \"\\\"\" + networkPass + \"\\\"\";\r\n\r\n} else if (capabilities.toUpperCase().contains(\"PSK\")) {\r\nLog.i(\"rht\", \"Configuring PSK\");\r\nwifiConfiguration.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);\r\nwifiConfiguration.preSharedKey = String.format(\"\\\"%s\\\"\",\r\nnew Object[] { networkPass });\r\nLog.i(\"network password PSK\", \"=======\" + wifiConfiguration.preSharedKey);\r\nwifiConfiguration.hiddenSSID = true;\r\nwifiConfiguration.status = WifiConfiguration.Status.ENABLED;\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.TKIP);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.CCMP);\r\nwifiConfiguration.allowedKeyManagement\r\n.set(WifiConfiguration.KeyMgmt.WPA_PSK);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.TKIP);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.CCMP);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.RSN);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.WPA);\r\n\r\n} else {\r\n\r\nLog.i(\"rht\", \"Configuring OPEN network\");\r\nwifiConfiguration.allowedKeyManagement\r\n.set(WifiConfiguration.KeyMgmt.NONE);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.RSN);\r\nwifiConfiguration.allowedProtocols\r\n.set(WifiConfiguration.Protocol.WPA);\r\nwifiConfiguration.allowedAuthAlgorithms.clear();\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.CCMP);\r\nwifiConfiguration.allowedPairwiseCiphers\r\n.set(WifiConfiguration.PairwiseCipher.TKIP);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.WEP40);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.WEP104);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.CCMP);\r\nwifiConfiguration.allowedGroupCiphers\r\n.set(WifiConfiguration.GroupCipher.TKIP);\r\n}\r\n\r\nreturn wifiConfiguration;\r\n\r\n}\r\n\r\n{code}\r\n\r\nPlease take a look on attached zip file.\r\n\r\n\r\nNote Our App which is consuming this module is targeted for Titanium SDK 5.5.1.GA.\r\n\r\nLet me know if you need more information.\r\n\r\n", "attachment": [ { "id": "65184", "filename": "NetworkStatusTest.js", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-17T23:31:40.000+0000", "size": 2811, "mimeType": "application/x-javascript" }, { "id": "65187", "filename": "Screenshot_20180518-235114.png", "author": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "created": "2018-05-18T17:52:25.000+0000", "size": 73867, "mimeType": "image/png" }, { "id": "65107", "filename": "wificonnect.zip", "author": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "created": "2018-05-01T17:04:01.000+0000", "size": 4684583, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android custom Module : Unable to connect WIFI of Android 8 devices ", "creator": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "subtasks": [], "reporter": { "name": "aislam", "key": "aislam", "displayName": "Aminul Islam", "active": false, "timeZone": "Etc/GMT-6" }, "environment": "Operating System\r\nName = Mac OS X\r\nVersion = 10.12.6\r\nArchitecture = 64bit\r\n# CPUs = 4\r\nMemory = 8589934592\r\nNode.js\r\nNode.js Version = 4.8.4\r\nnpm Version = 2.15.11\r\nTitanium CLI\r\nCLI Version = 5.0.14\r\nTitanium SDK\r\nSDK Version = 5.5.1.GA\r\nSDK Path = /Users/navistar/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA\r\nTarget Platform = android\r\nCommand", "closedSprints": [ { "id": 1035, "state": "closed", "name": "2018 Sprint 11 SDK", "startDate": "2018-05-20T20:57:43.542Z", "endDate": "2018-06-03T20:57:00.000Z", "completeDate": "2018-06-04T15:13:14.425Z", "originBoardId": 114 }, { "id": 1039, "state": "closed", "name": "2018 Sprint 12 SDK", "startDate": "2018-06-03T15:22:23.401Z", "endDate": "2018-06-17T15:22:00.000Z", "completeDate": "2018-06-18T20:45:36.363Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "437271", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Titanium 5.5.1 targets API Level 23 (aka: Android 6.0).\r\n\r\nI suggest in Android Studio for you to target API Level 23 as well to see if you can reproduce this issue. (I suspect you are using a higher API Level.)\r\n\r\nOther than that, I don't see how Titanium could cause this issue. You may be running into breaking changes or issues with this API on Android 8.0 as can be seen by other devs here...\r\nhttps://www.google.com/search?q=android+wifimanager+android+8+not+working+site:stackoverflow.com", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-01T23:53:39.000+0000", "updated": "2018-05-01T23:53:39.000+0000" }, { "id": "437747", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I just tested Titanium's \"Ti.Network\" JavaScript APIs via the attached [^NetworkStatusTest.js] and our \"online\" and \"networkType\" properties are definitely working correctly. I've tested it on the following real devices:\r\n- Pixel XL (1st generation) running Android 8.0\r\n- Pixel 2 running Android 8.1\r\n\r\nI've swiped down the status bar and disconnected/reconnected the device from WIFI by tapping the WIFI symbol. The app's network status labels were updated appropriately. The \"online\" property was set true when \"networkTypeName\" was set to \"WIFI\".\r\n\r\nI've tested this in Titanium 7.0.0 and 6.0.2. It works.\r\n\r\nIf you're having problems in Titanium 5.x.x, then you may want to double check that the {{\"android.permission.ACCESS_NETWORK_STATE\"}} permission is being added to the {{AndroidManifest.xml}} file since it's required to acquire this information.\r\n", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-17T22:59:17.000+0000", "updated": "2018-05-17T22:59:17.000+0000" }, { "id": "437780", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "From looking at our docs, I can see that description of {{Ti.Network.online}} is not correct. It states that indicates the device has Internet access. This is not true. It indicates the device is connected to the network. So, if you're connected to a private network without Internet access, this property will be set {{true}} as well. This is the correct behavior and how it work natively on both Android and iOS.\r\n\r\nWe'll be correcting the documentation in the near future. See: [TIDOC-3190]", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2018-05-18T22:16:50.000+0000", "updated": "2018-05-18T22:16:50.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }