NXP

I.MX6 Ethernet UI patch failed

2019-07-12 12:10发布

/*********************************************************************** * I.MX6 Ethernet UI patch failed * 说明: * 最近想要在I.MX6的Android上添加Ethernet UI界面,但是使用NXP提供的 * patch,结果失败了。 * * 2016-4-21 深圳 南山平山村 曾剑锋 **********************************************************************/ 一、参考文档: 1. How to Add Ethernet UI Support in ICS https://community.freescale.com/docs/DOC-93626 2. Couldn't parse API file “frameworks/base/api/current.txt” http://stackoverflow.com/questions/14622020/couldnt-parse-api-file-frameworks-base-api-current-txt 二、Introduction If you want to add Ethernet UI support , you need manually apply the attached patches in this file which is based on Android ICS and i.MX6. About what the patches do, here is some comments: 1. framework/base-----0001-ENGR00220371-Ethernet-add-support-for-ethernet.patch By default, Android has no support for Ethernet UI. So if you want to add Ethernet UI , add Ethernet state tracker & Ethernet service & Ethernet manager & Ethernet monitor like WiFi. Meanwhile we need add Ethernet display support in status bar. Here this patch can solve it. 2. Build---0001-ENGR00220371-Ethernet-add-ethernet-support.patch add package directory compile. 3. packagesappsSettings---0001-ENGR00220371-Ethernet-add-app-UI-in-setting.patch add UI logic in setting app. 4. packagesprovidersDownloadProvider---0001-ENGR00220371-Ethernet-add-downloadinfo.patch add ConnectivityManager.TYPE_ETHERNET type support in download provider’s DownloadInfo. 三、decompress: zengjf@zengjf:~/myandroid$ unzip imx6-ics-ethernet-v3.zip Archive: imx6-ics-ethernet-v3.zip inflating: build/0001-ENGR00220371-Ethernet-add-ethernet-support.patch creating: Frameworks/ creating: Frameworks/base/ inflating: Frameworks/base/0001-enhance-ethernet-handling-thanks-to-Android-x86-proj.patch inflating: packages/apps/Settings/0001-Adds-Ethernet-Settings-Android-x86-patch.patch inflating: packages/providers/DownloadProvider/0001-Adds-Ethernet-support-for-Freescale-platform.patch zengjf@zengjf:~/myandroid$ cp Frameworks/base/0001-enhance-ethernet-handling-thanks-to-Android-x86-proj.patch frameworks/base/ 四、patch: 1. 0001-ENGR00220371-Ethernet-add-ethernet-support.patch zengjf@zengjf:~/myandroid/build$ patch -p1 < 0001-ENGR00220371-Ethernet-add-ethernet-support.patch patching file core/pathmap.mk Hunk #1 succeeded at 94 (offset 7 lines). 2. 0001-Adds-Ethernet-Settings-Android-x86-patch.patch zengjf@zengjf:~/myandroid/packages/apps/Settings$ patch -p1 < 0001-Adds-Ethernet-Settings-Android-x86-patch.patch patching file AndroidManifest.xml Hunk #1 succeeded at 133 (offset 45 lines). patching file proguard.flags Hunk #1 FAILED at 11. 1 out of 1 hunk FAILED -- saving rejects to file proguard.flags.rej patching file res/drawable/ic_settings_ethernet.xml patching file res/layout/eth_configure.xml patching file res/values/strings.xml Hunk #1 succeeded at 1237 with fuzz 2 (offset 85 lines). patching file res/xml/ethernet_settings.xml patching file res/xml/settings_headers.xml Hunk #1 succeeded at 58 with fuzz 2 (offset 1 line). patching file src/com/android/settings/ethernet/EthernetConfigDialog.java patching file src/com/android/settings/ethernet/EthernetEnabler.java patching file src/com/android/settings/ethernet/EthernetLayer.java patching file src/com/android/settings/ethernet/EthernetSettings.java 3. 0001-Adds-Ethernet-support-for-Freescale-platform.patch zengjf@zengjf:~/myandroid/packages/providers/DownloadProvider$ patch -p1 < 0001-Adds-Ethernet-support-for-Freescale-platform.patch patching file src/com/android/providers/downloads/DownloadInfo.java Hunk #1 succeeded at 424 with fuzz 2 (offset 6 lines). Hunk #2 succeeded at 443 (offset 6 lines). 4. 0001-enhance-ethernet-handling-thanks-to-Android-x86-proj.patch zengjf@zengjf:~/myandroid/frameworks/base$ patch -p1 < 0001-enhance-ethernet-handling-thanks-to-Android-x86-proj.patch patching file Android.mk Hunk #1 FAILED at 197. 1 out of 1 hunk FAILED -- saving rejects to file Android.mk.rej patching file api/current.txt Hunk #1 succeeded at 3352 (offset 154 lines). Hunk #2 succeeded at 5439 with fuzz 2 (offset 328 lines). Hunk #3 succeeded at 12937 (offset 946 lines). Hunk #4 FAILED at 17632. 1 out of 4 hunks FAILED -- saving rejects to file api/current.txt.rej patching file core/java/android/app/ContextImpl.java Hunk #1 succeeded at 74 (offset 13 lines). Hunk #2 succeeded at 520 with fuzz 1 (offset 62 lines). patching file core/java/android/app/DownloadManager.java Hunk #1 succeeded at 351 with fuzz 2 (offset 10 lines). patching file core/java/android/content/Context.java Hunk #1 succeeded at 1838 (offset 377 lines). patching file core/java/android/net/EthernetDataTracker.java Hunk #1 FAILED at 139. 1 out of 1 hunk FAILED -- saving rejects to file core/java/android/net/EthernetDataTracker.java.rej patching file core/java/android/provider/Settings.java Hunk #1 FAILED at 3220. 1 out of 1 hunk FAILED -- saving rejects to file core/java/android/provider/Settings.java.rej patching file core/jni/Android.mk Hunk #1 succeeded at 76 with fuzz 2 (offset 2 lines). patching file core/jni/AndroidRuntime.cpp Hunk #1 succeeded at 146 with fuzz 1. Hunk #2 FAILED at 1160. 1 out of 2 hunks FAILED -- saving rejects to file core/jni/AndroidRuntime.cpp.rej patching file core/jni/android_net_ethernet.cpp patching file core/res/res/values/config.xml Hunk #1 succeeded at 34 (offset -1 lines). Hunk #2 succeeded at 146 (offset 30 lines). Hunk #3 succeeded at 169 (offset 30 lines). patching file ethernet/java/android/net/ethernet/EthernetDevInfo.aidl patching file ethernet/java/android/net/ethernet/EthernetDevInfo.java patching file ethernet/java/android/net/ethernet/EthernetManager.java patching file ethernet/java/android/net/ethernet/EthernetMonitor.java patching file ethernet/java/android/net/ethernet/EthernetNative.java patching file ethernet/java/android/net/ethernet/EthernetStateTracker.java patching file ethernet/java/android/net/ethernet/IEthernetManager.aidl patching file packages/SystemUI/res/layout/signal_cluster_view.xml patching file packages/SystemUI/res/values/strings.xml Hunk #1 succeeded at 413 (offset 66 lines). patching file packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java Hunk #1 FAILED at 41. Hunk #2 succeeded at 75 (offset 1 line). Hunk #3 succeeded at 92 (offset 2 lines). Hunk #4 FAILED at 110. Hunk #5 FAILED at 144. 3 out of 5 hunks FAILED -- saving rejects to file packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java.rej patching file packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java Hunk #1 succeeded at 26 (offset -5 lines). Hunk #2 succeeded at 60 (offset -3 lines). Hunk #4 succeeded at 115 (offset 1 line). Hunk #5 succeeded at 154 (offset 6 lines). Hunk #6 succeeded at 169 (offset 9 lines). Hunk #7 succeeded at 185 with fuzz 1 (offset 9 lines). Hunk #8 succeeded at 210 (offset 18 lines). Hunk #9 succeeded at 250 with fuzz 2 (offset 18 lines). Hunk #10 succeeded at 296 (offset 26 lines). Hunk #11 succeeded at 347 (offset 36 lines). Hunk #12 succeeded at 432 (offset 63 lines). Hunk #13 succeeded at 938 (offset 96 lines). Hunk #14 succeeded at 1025 (offset 108 lines). Hunk #15 succeeded at 1067 with fuzz 2 (offset 111 lines). Hunk #16 succeeded at 1081 with fuzz 1 (offset 113 lines). Hunk #17 succeeded at 1153 (offset 115 lines). Hunk #18 FAILED at 1090. Hunk #19 succeeded at 1237 (offset 127 lines). Hunk #20 FAILED at 1125. Hunk #21 succeeded at 1325 (offset 142 lines). Hunk #22 succeeded at 1356 (offset 142 lines). Hunk #23 succeeded at 1375 (offset 142 lines). Hunk #24 succeeded at 1452 with fuzz 1 (offset 154 lines). Hunk #25 succeeded at 1550 (offset 166 lines). 2 out of 25 hunks FAILED -- saving rejects to file packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java.rej patching file packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java Hunk #1 succeeded at 272 (offset 38 lines). patching file services/java/com/android/server/ConnectivityService.java Hunk #1 succeeded at 68 (offset 14 lines). Hunk #2 succeeded at 449 (offset 34 lines). Hunk #3 FAILED at 511. 1 out of 3 hunks FAILED -- saving rejects to file services/java/com/android/server/ConnectivityService.java.rej patching file services/java/com/android/server/EthernetService.java zengjf@zengjf:~/myandroid/frameworks/base$ 五、manual for patch Faileds: 1. 以下是打补丁出现问题的部分,需要手动打补丁。 2. 1 out of 1 hunk FAILED -- saving rejects to file proguard.flags.rej 1. cat packages/apps/Settings/proguard.flags.rej --- proguard.flags +++ proguard.flags @@ -11,4 +11,4 @@ -keep class com.android.settings.MasterClearConfirm -keep class com.android.settings.accounts.* -keep class com.android.settings.fuelgauge.* - +-keep class com.android.settings.ethernet.* 3. 1 out of 1 hunk FAILED -- saving rejects to file Android.mk.rej 1. cat framework/base/Android.mk.rej --- Android.mk +++ Android.mk @@ -197,6 +197,7 @@ telephony/java/com/android/internal/telephony/IWapPushManager.aidl wifi/java/android/net/wifi/IWifiManager.aidl wifi/java/android/net/wifi/p2p/IWifiP2pManager.aidl + ethernet/java/android/net/ethernet/IEthernetManager.aidl telephony/java/com/android/internal/telephony/IExtendedNetworkService.aidl voip/java/android/net/sip/ISipSession.aidl voip/java/android/net/sip/ISipSessionListener.aidl 4. 1 out of 4 hunks FAILED -- saving rejects to file api/current.txt.rej 1. cat framework/base/api/current.txt.rej --- api/current.txt +++ api/current.txt @@ -17632,6 +17758,14 @@ field public static final java.lang.String DEVICE_PROVISIONED = "device_provisioned"; field public static final java.lang.String ENABLED_ACCESSIBILITY_SERVICES = "enabled_accessibility_ser vices"; field public static final java.lang.String ENABLED_INPUT_METHODS = "enabled_input_methods"; + field public static final java.lang.String ETHERNET_CONF = "ethernet_conf"; + field public static final java.lang.String ETHERNET_DNS = "ethernet_dns"; + field public static final java.lang.String ETHERNET_IFNAME = "ethernet_ifname"; + field public static final java.lang.String ETHERNET_IP = "ethernet_ip"; + field public static final java.lang.String ETHERNET_MASK = "ethernet_netmask"; + field public static final java.lang.String ETHERNET_MODE = "ethernet_mode"; + field public static final java.lang.String ETHERNET_ON = "ethernet_on"; + field public static final java.lang.String ETHERNET_ROUTE = "ethernet_iproute"; field public static final java.lang.String HTTP_PROXY = "http_proxy"; field public static final java.lang.String INPUT_METHOD_SELECTOR_VISIBILITY = "input_method_selector_v isibility"; field public static final java.lang.String INSTALL_NON_MARKET_APPS = "install_non_market_apps"; 5. 1 out of 1 hunk FAILED -- saving rejects to file core/java/android/net/EthernetDataTracker.java.rej 1. cat framework/base/core/java/android/net/EthernetDataTracker.java.rej --- core/java/android/net/EthernetDataTracker.java +++ core/java/android/net/EthernetDataTracker.java @@ -139,20 +139,18 @@ mNetworkInfo.setIsAvailable(false); mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, null); - Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); - msg.sendToTarget(); - - msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); + Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo); msg.sendToTarget(); - if (mClearIp){ - IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); - INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); - try { - service.clearInterfaceAddresses(mIface); - } catch (Exception e) { - Log.e(TAG, "Failed to clear addresses or disable ip" + e); - } - } + + if (mClearIp){ + IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE); + INetworkManagementService service = INetworkManagementService.Stub.asInterface(b); + try { + service.clearInterfaceAddresses(mIface); + } catch (Exception e) { + Log.e(TAG, "Failed to clear addresses or disable ip" + e); + } + } } private void interfaceRemoved(String iface) { 6. 1 out of 1 hunk FAILED -- saving rejects to file core/java/android/provider/Settings.java.rej 1. cat frameworks/base/core/java/android/provider/Settings.java.rej --- core/java/android/provider/Settings.java +++ core/java/android/provider/Settings.java @@ -3220,6 +3220,18 @@ "wifi_mobile_data_transition_wakelock_timeout_ms"; /** + * Ethernet related configurations + */ + public static final String ETHERNET_ON = "ethernet_on"; + public static final String ETHERNET_MODE = "ethernet_mode"; + public static final String ETHERNET_IP = "ethernet_ip"; + public static final String ETHERNET_MASK = "ethernet_netmask"; + public static final String ETHERNET_DNS = "ethernet_dns"; + public static final String ETHERNET_ROUTE = "ethernet_iproute"; + public static final String ETHERNET_CONF = "ethernet_conf"; + public static final String ETHERNET_IFNAME = "ethernet_ifname"; + + /** * Whether background data usage is allowed by the user. See * ConnectivityManager for more info. */ 7. 1 out of 2 hunks FAILED -- saving rejects to file core/jni/AndroidRuntime.cpp.rej 1. cat framework/base/core/jni/AndroidRuntime.cpp.rej --- core/jni/AndroidRuntime.cpp +++ core/jni/AndroidRuntime.cpp @@ -1160,6 +1161,7 @@ REG_JNI(register_android_net_NetworkUtils), REG_JNI(register_android_net_TrafficStats), REG_JNI(register_android_net_wifi_WifiManager), + REG_JNI(register_android_net_ethernet_EthernetManager), REG_JNI(register_android_nfc_NdefMessage), REG_JNI(register_android_nfc_NdefRecord), REG_JNI(register_android_os_MemoryFile), 8. 3 out of 5 hunks FAILED -- saving rejects to file packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java.rej 1. cat framework/base/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java.rej --- packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java +++ packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java @@ -41,13 +41,15 @@ private boolean mWifiVisible = false; private int mWifiStrengthId = 0, mWifiActivityId = 0; + private boolean mEthernetVisible = false; + private int mEthernetId = 0; private boolean mMobileVisible = false; private int mMobileStrengthId = 0, mMobileActivityId = 0, mMobileTypeId = 0; private boolean mIsAirplaneMode = false; - private String mWifiDescription, mMobileDescription, mMobileTypeDescription; + private String mWifiDescription, mEthernetDescription, mMobileDescription, mMobileTypeDescription; - ViewGroup mWifiGroup, mMobileGroup; - ImageView mWifi, mMobile, mWifiActivity, mMobileActivity, mMobileType; + ViewGroup mWifiGroup, mEthernetGroup, mMobileGroup; + ImageView mWifi, mEthernet, mMobile, mWifiActivity, mMobileActivity, mMobileType; View mSpacer; public SignalClusterView(Context context) { @@ -110,6 +116,15 @@ apply(); } + public void setEthernetIndicators(boolean visible, int statusIcon, + String contentDescription) { + mEthernetVisible = visible; + mEthernetId = statusIcon; + mEthernetDescription = contentDescription; + + apply(); + } + public void setMobileDataIndicators(boolean visible, int strengthIcon, int activityIcon, int typeIcon, String contentDescription, String typeContentDescription) { mMobileVisible = visible; @@ -144,6 +159,14 @@ (mWifiVisible ? "VISIBLE" : "GONE"), mWifiStrengthId, mWifiActivityId)); + if (mEthernetVisible) { + mEthernetGroup.setVisibility(View.VISIBLE); + mEthernet.setImageResource(mEthernetId); + mEthernetGroup.setContentDescription(mEthernetDescription); + } else { + mEthernetGroup.setVisibility(View.GONE); + } + if (mMobileVisible) { mMobileGroup.setVisibility(View.VISIBLE); mMobile.setImageResource(mMobileStrengthId); 9. 2 out of 25 hunks FAILED -- saving rejects to file packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java.rej 1. cat framework/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java.rej --- packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java +++ packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkController.java @@ -1090,7 +1163,7 @@ combinedSignalIconId = mDataSignalIconId; } } EthernetService.java:116: cannot find symbol symbol : variable ETHERNET_IP - else if (!mDataConnected && !mWifiConnected && !mBluetoothTethered && !mWimaxConnected) { + else if (!mDataConnected && !mWifiConnected && !mEthernetConnected && !mBluetoothTethered && !mWimaxConnected) { // pretty much totally disconnected combinedLabel = context.getString(R.string.status_bar_settings_signal_meter_disconnected); @@ -1125,12 +1199,14 @@ + " mDataSignalIconId=0x" + Integer.toHexString(mDataSignalIconId) + " mDataTypeIconId=0x" + Integer.toHexString(mDataTypeIconId) + " mWifiIconId=0x" + Integer.toHexString(mWifiIconId) + + " mEthernetIconId=0x" + Integer.toHexString(mEthernetIconId) + " mBluetoothTetherIconId=0x" + Integer.toHexString(mBluetoothTetherIconId)); } if (mLastPhoneSignalIconId != mPhoneSignalIconId || mLastDataDirectionOverlayIconId != combinedActivityIconId || mLastWifiIconId != mWifiIconId + || mLastEthernetIconId != mEthernetIconId || mLastWimaxIconId != mWimaxIconId || mLastDataTypeIconId != mDataTypeIconId) { 10. 1 out of 3 hunks FAILED -- saving rejects to file services/java/com/android/server/ConnectivityService.java.rej 1. cat framework/base/services/java/com/android/server/ConnectivityService.java.rej --- services/java/com/android/server/ConnectivityService.java +++ services/java/com/android/server/ConnectivityService.java @@ -511,8 +512,14 @@ } break; case ConnectivityManager.TYPE_ETHERNET: - mNetTrackers[netType] = EthernetDataTracker.getInstance(); - mNetTrackers[netType].startMonitoring(context, mHandler); + //mNetTrackers[netType] = EthernetDataTracker.getInstance(); + //mNetTrackers[netType].startMonitoring(context, mHandler); + if (DBG) log("Starting Ethernet Service."); + EthernetStateTracker est = new EthernetStateTracker(context, mHandler); + EthernetService ethService = new EthernetService(context, est); + ServiceManager.addService(Context.ETHERNET_SERVICE, ethService); + mNetTrackers[ConnectivityManager.TYPE_ETHERNET] = est; + est.startMonitoring(context, mHandler); break; default: loge("Trying to create a DataStateTracker for an unknown radio type " + 2. 实际修改: case TYPE_WIMAX: return makeWimaxStateTracker(mContext, mTrackerHandler); case TYPE_ETHERNET: //mNetTrackers[netType] = EthernetDataTracker.getInstance(); //mNetTrackers[netType].startMonitoring(context, mHandler); if (DBG) log("Starting Ethernet Service."); EthernetStateTracker est = new EthernetStateTracker(mContext, mTrackerHandler); EthernetService ethService = new EthernetService(mContext, est); ServiceManager.addService(Context.ETHERNET_SERVICE, ethService); //mNetTrackers[ConnectivityManager.TYPE_ETHERNET] = est; est.startMonitoring(mContext, mTrackerHandler); //return EthernetDataTracker.getInstance(); return est; 六、error: 1. error1: 1. 现象: frameworks/base/core/res/res/values/config.xml:1029: Originally defined here. frameworks/base/core/res/res/values/config.xml.orig:1027: error: Resource entry config_notificationFallbackVibePattern already has bag item ^index_2. frameworks/base/core/res/res/values/config.xml:1030: Originally defined here. frameworks/base/core/res/res/values/config.xml.orig:1028: error: Resource entry config_notificationFallbackVibePattern already has bag item ^index_3. frameworks/base/core/res/res/values/config.xml:1031: Originally defined here. frameworks/base/core/res/res/values/config.xml.orig:1032: error: Resource entry config_speed_up_audio_on_mt_calls is already defined. frameworks/base/core/res/res/values/config.xml:1035: Originally defined here. make: *** [out/target/common/obj/APPS/framework-res_intermediates/package-export.apk] Error 1 make: *** Deleting file `out/target/common/obj/APPS/framework-res_intermediates/package-export.apk' 2. 解决办法: zengjf@zengjf:~/myandroid/frameworks/base/core/res/res/values$ rm config.xml.orig 2. error2: 1. 现象: ...... uct/sabresd_6dq/system/etc/permissions/android.software.live_wallpaper.xml' build/core/base_rules.mk:502: warning: ignoring old commands for target `out/target/product/sabresd_6dq/system/etc/permissions/android.software.live_wallpaper.xml' No private recovery resources for TARGET_DEVICE sabresd_6dq target Java: framework (out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes) frameworks/base/core/java/android/net/EthernetDataTracker.java:167: cannot find symbol symbol : variable mClearIp location: class android.net.EthernetDataTracker if (mClearIp){ ^ frameworks/base/ethernet/java/android/net/ethernet/EthernetStateTracker.java:66: android.net.ethernet.EthernetStateTracker is not abstract and does not override abstract method captivePortalCheckComplete() in android.net.NetworkStateTracker public class EthernetStateTracker extends Handler implements NetworkStateTracker { ^ frameworks/base/ethernet/java/android/net/ethernet/EthernetStateTracker.java:210: cannot find symbol symbol : variable addr location: class android.net.InterfaceConfiguration ifcfg.addr = mDhcpInfo.makeLinkAddress(); ^ frameworks/base/ethernet/java/android/net/ethernet/EthernetStateTracker.java:211: cannot find symbol symbol : variable interfaceFlags location: class android.net.InterfaceConfiguration ifcfg.interfaceFlags = "[up]"; ^ Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 4 errors 2. 解决办法: 1. cat frameworks/base/core/java/android/net/EthernetDataTracker.java ...... public class EthernetDataTracker implements NetworkStateTracker { ...... public void disconnect() { NetworkUtils.stopDhcp(mIface); mLinkProperties.clear(); mNetworkInfo.setIsAvailable(false); mNetworkInfo.setDetailedState(DetailedState.DISCONNECTED, null, mHwAddr); //Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); //msg.sendToTar