Android11 reflection limitations-pre-research on network connection

1. Background

1. Pre-research environment

 (1)Android系统:Android11,Api30

(2) Panel machine equipment: RK3568, E8 equipment

2. Project background

   E8产品预研
RK3568 E8产品预研:网络连接部分预研、

3. Pre-research network types

(1) Wired network: Ethernet

(2) WLAN network: Wireless LAN

2. Problem manifestations and causes

1. Ethernet connection

(1) Unable to connect to Ethernet: some functions involving reflection are unavailable: all functions for obtaining wired network configuration, including wired network management, obtaining IP configuration, obtaining IP address, obtaining subnet mask, obtaining gateway, obtaining domain name, and settings Static IP settings;

(2) Wired network network monitoring is not available: the three-code information of the room layer cannot be obtained, and the activity involved in the network monitoring part of the device has not been initialized.

2. WLAN network connection (Wifi network)

(1) Unable to connect to the Wifi network: the code involves the deprecation of some APIs such as WIFiManager;

(2) Unable to set Wifi static IP: reflection is not available.

(3) The device only supports connecting to the 2.4GHz band WLAN network.

3. System wired network and Wifi network cannot coexist.

(1) After connecting to the Wifi network, the Wifi network will be disconnected after plugging in the wired network.

(2) When connected to a wired network, the Wifi network cannot be connected.

3. Main problems and attempted solutions

1. Ethernet connection - reflection limitation problem:

(1) Use third-party libraries to shield reflection limitations

Third-party library dependencies: RestrictionBypass, FreeReflection, hiddenapibypass (https://github.com/LSPosed/AndroidHiddenApiBypass)
Result: Currently, shielding reflection restrictions has no effect

(2) Import the frameworks.jar package and directly call hidden classes and hidden methods

New class name: EthernetHelperFit11.java
Import directory: project lib_common\src\main\res\libs\framework.jar
Download address: https://gitee.com/xiayiye5/framework-jar-demo/tree/master/app/
Configure the dependency calling priority under the libs lib_common module build.gradle: increase the dependency calling priority of the framework.jar package to be higher than AndroidSDK

Implementation effect: The compilation is passed and the wired network is effectively connected and available.
Risks: Due to the different versions of the framework.jar package and AndroidSDK, there is a certain risk of class calling.

2. WLAN network connection (Wifi network)

(1) The Wifi connection network is unavailable (WifiManager is deprecated)

On Android 10 (API level 29) or higher devices, use the official recommended API to connect to the Wifi network. (WLAN network request API for peer-to-peer connections | Android Developers | Android Developers (google.cn))
Implementation effect: 2.4GHz band Wifi network can be connected and available (currently the device only supports connecting to 2.4GHz band network)
(2) Set up Wifi static IP part—reflection limitation problem

The solution is the same as the solution to the wired network reflection limitation problem mentioned above: directly call the hidden class to configure static IP related methods.

4. Implementation plans can currently be considered

1. Room layer support. Separately encapsulate the wired network-related API call jar package. According to the above-mentioned import framework.jar package dependencies, directly call the hidden API by coexisting with the Android SDK.

2. Room layer support, integrating wired network related hidden classes and methods into the Room layer, so that the application layer can continue to use reflection calls.

3. Integrate the following bypass non-SDK interface call restriction command into the Room layer to lift the call restrictions on hidden APIs and methods.

 官方对于非SDK接口的限制:针对非 SDK 接口的限制  |  Google Play  |  Android Developers

Guess you like

Origin blog.csdn.net/qq_46269365/article/details/130582030