You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Android 13(SDK 33)中启用以太网设置界面的源码修改方案咨询

Android 13(SDK 33)中启用以太网设置界面的源码修改方案咨询

Hey there! I’ve gone through the hassle of enabling Ethernet settings on Android 13 (SDK 33) before, and since the Android 9 method is totally incompatible with the newer codebase, let’s break down the exact source code changes you need to make to get this working without build errors:

1. Make Ethernet Visible in the Settings App

First, we need to unhide the Ethernet entry in the Network & Internet section of the Settings app:

  • Navigate to the Settings app source: packages/apps/Settings
  • Open res/xml/network_and_internet_settings.xml
    Look for the Ethernet preference entry—it might be commented out or set to android:visibility="gone". Update it to android:visibility="visible" and remove any conditional attributes like settings:userRestriction="no_ethernet" that might be hiding it.
  • Next, open src/com/android/settings/network/NetworkAndInternetDashboardFragment.java
    In the getAvailableTiles() method, ensure that the Ethernet settings tile is included. If it’s commented out, uncomment the line that adds EthernetSettings.class to the list of available network tiles. For example:
    // Uncomment or add this line
    addTile(new Tile.Builder()
            .setCategory(CATEGORY_NETWORK)
            .setFragment(EthernetSettings.class.getName())
            .setPriority(10)
            .build());
    

2. Enable System-Level Ethernet Support

Even if the Settings entry is visible, the system might still block Ethernet functionality by default:

  • Go to frameworks/base/core/res/res/values/config.xml
    Find the boolean resource config_disable_ethernet and change its value from true to false:
    <bool name="config_disable_ethernet">false</bool>
    
  • Check the Ethernet service module in frameworks/opt/net/ethernet
    Ensure the module is set to compile for your target. Open the Android.bp file here and confirm there’s no visibility: ["//visibility:private"] or enabled: false that would prevent it from being included in the build. If needed, adjust it to:
    android_library {
        name: "ethernet-service",
        srcs: ["java/**/*.java"],
        resource_dirs: ["res"],
        manifest: "AndroidManifest.xml",
        sdk_version: "33",
        visibility: ["//visibility:public"],
    }
    

3. Fix SELinux Permissions (If Needed)

If you still run into issues after the above steps, SELinux might be blocking Ethernet operations:

  • Navigate to your device’s SEpolicy directory, usually device/[your_oem]/[your_device]/sepolicy
  • Add rules to allow the Ethernet service to access necessary system resources. For example, create or update ethernet.te with:
    allow ethernet_service netd_service:service_manager find;
    allow ethernet_service sysfs_net:file rw_file_perms;
    allow ethernet_service system_netctl:service_manager find;
    
    These rules mirror common permissions granted to other network services like Wi-Fi.

Quick Build & Test Tips

  • After making changes, you can build just the affected modules to save time:
    make Settings framework-base ethernet-service -j$(nproc)
    
  • Flash the updated modules to your device, or do a full system build with make -j$(nproc) if you’re rebuilding the entire image.
  • Once booted, head to Settings > Network & Internet—you should see the Ethernet option now, and it should detect connected adapters properly.

内容来源于stack exchange

火山引擎 最新活动