Android Solution Android 10.0 Specifies hotspot network non-communicative issues via hotspot name and password connections

1 Question

Android 10.0 devices connect to another device through a hotspot name and password to specify a hotspot, but they still cannot communicate with each other and the network is unreachable.

The Android 10.0 device connects another set of designated hotspots by hotspot name and password. I'm using the official API and can refer to this blog

Android returns the -1 question by specifying a wifi hotspot through a user name and password connection (compatible with Android 9.0 and Android 10.0 and addNetwork)

The key code for Android 10.0 Connection Hot Spots is as follows

  boolean isOpenWifi = mWifiManager.isWifiEnabled();
            if (!isOpenWifi) {
                Log.i(TAG, "User needs to open wifi switch");
                context.startActivity(new Intent(Settings.Panel.ACTION_INTERNET_CONNECTIVITY));
                callBack.connnectResult(false);
                return;
            }
            NetworkSpecifier specifier =
                    new WifiNetworkSpecifier.Builder()
                            .setSsidPattern(new PatternMatcher(wifiApName, PatternMatcher.PATTERN_PREFIX))
                            .setWpa2Passphrase(password)
                            .build();
 
            NetworkRequest request =
                    new NetworkRequest.Builder()
                            .addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
                            .removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                            .setNetworkSpecifier(specifier)
                            .build();
 
            ConnectivityManager connectivityManager = (ConnectivityManager)
                    context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
            ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
                @Override
                public void onAvailable(Network network) {
                    // do success processing here..
                    Log.i(TAG, "onAvailable success");
                    Log.i(TAG, "network" + network.toString());
                    callBack.connnectResult(true);
                }
 
                @Override
                public void onUnavailable() {
                    // do failure processing here..
                    Log.i(TAG, "onUnavailable fail");
                    callBack.connnectResult(false);
                }
            };
            connectivityManager.requestNetwork(request, networkCallback);

 

 

 

 

 

 

2 Analysis

Looking at the competition "Eggplant Express", we found that Android 10.0 devices connect another set of designated hotspots by hotspot name and password, and then communicate normally after successful connection. First decompile the Eggplant code with jadx, then search for the keyword WifiNetworkSpecifier of the official API above

 

No search, and then we will use the official 10.0API mobile phone pop-up prompt to let the user agree, but the competition does not have this prompt, it means that it is not connected in this way to the specified hotspot, but it can still connect and communicate normally. We analyze if there is any other special way, we open the competition to scan the QR code, and then grab the logs printed by the current process.

adb shell ps | grep share
adb logcat | grep pid

Still no clue found, and then global search for the keyword enableNetwork

That's all, and then we'll go online and find out why Android 10.0 enableNetwork returns -1

 

 

 

 

 

 

3 Solutions

Keywords: Android network Mobile shell

Added by modigy on Tue, 23 Jun 2020 04:07:36 +0300