Loading AndroidManifest.xml +7 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,12 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.networkstack" android:sharedUserId="android.uid.networkstack"> <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" /> android:sharedUserId="android.uid.networkstack" android:versionCode="290000000" android:versionName="2019-09" > <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" /> <!-- Permissions must be defined here, and not in the base manifest, as the network stack running in the system server process does not need any permission, and having privileged Loading res/values/overlayable.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8" ?> <!-- Copyright (C) 2019 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <overlayable name="NetworkStackConfig"> <policy type="product|system|vendor"> <!-- Configuration values for NetworkMonitor --> <item type="integer" name="config_captive_portal_dns_probe_timeout"/> <item type="string" name="config_captive_portal_http_url"/> <item type="string" name="config_captive_portal_https_url"/> <item type="array" name="config_captive_portal_fallback_urls"/> <!-- Configuration value for DhcpResults --> <item type="array" name="config_default_dns_servers"/> </policy> </overlayable> </resources> src/android/net/util/NetworkStackUtils.java +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net.util; import android.annotation.NonNull; import android.annotation.Nullable; import android.provider.DeviceConfig; import android.util.SparseArray; import java.io.FileDescriptor; Loading Loading @@ -183,8 +184,8 @@ public class NetworkStackUtils { @Nullable public static String getDeviceConfigProperty(@NonNull String namespace, @NonNull String name, @Nullable String defaultValue) { // TODO: Link to DeviceConfig API once it is ready. return defaultValue; String value = DeviceConfig.getProperty(namespace, name); return value != null ? value : defaultValue; } /** Loading src/com/android/server/NetworkStackService.java +26 −14 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.net.shared.PrivateDnsConfig; import android.net.util.SharedLog; import android.os.IBinder; import android.os.RemoteException; import android.util.ArraySet; import androidx.annotation.VisibleForTesting; Loading @@ -63,7 +64,6 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.concurrent.atomic.AtomicInteger; /** * Android service used to start the network stack when bound to via an intent. Loading Loading @@ -124,14 +124,12 @@ public class NetworkStackService extends Service { @GuardedBy("mValidationLogs") private final ArrayDeque<SharedLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS); private static final int VERSION_UNKNOWN = 0; private static final String DUMPSYS_ARG_VERSION = "version"; /** Version of the AIDL interfaces observed on the system */ private final AtomicInteger mSystemAidlVersion = new AtomicInteger(VERSION_UNKNOWN); /** Whether different versions have been observed on interfaces provided by the system */ private volatile boolean mConflictingSystemAidlVersions = false; /** Version of the framework AIDL interfaces observed. Should hold only one value. */ @GuardedBy("mFrameworkAidlVersions") private final ArraySet<Integer> mFrameworkAidlVersions = new ArraySet<>(1); private final int mNetdAidlVersion; /** * Permission checking dependency of the connector, useful for testing. Loading Loading @@ -167,6 +165,15 @@ public class NetworkStackService extends Service { mObserverRegistry = new NetworkObserverRegistry(); mIpMemoryStoreService = new IpMemoryStoreService(context); int netdVersion; try { netdVersion = mNetd.getInterfaceVersion(); } catch (RemoteException e) { mLog.e("Error obtaining INetd version", e); netdVersion = -1; } mNetdAidlVersion = netdVersion; try { mObserverRegistry.register(mNetd); } catch (RemoteException e) { Loading @@ -175,9 +182,8 @@ public class NetworkStackService extends Service { } private void updateSystemAidlVersion(final int version) { final int previousVersion = mSystemAidlVersion.getAndSet(version); if (previousVersion != VERSION_UNKNOWN && previousVersion != version) { mConflictingSystemAidlVersions = true; synchronized (mFrameworkAidlVersions) { mFrameworkAidlVersions.add(version); } } Loading Loading @@ -254,12 +260,16 @@ public class NetworkStackService extends Service { protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout, @Nullable String[] args) { checkDumpPermission(); final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " "); pw.println("NetworkStack version:"); dumpVersion(pw); pw.println(); if (args != null && args.length >= 1 && DUMPSYS_ARG_VERSION.equals(args[0])) { dumpVersion(fout); return; } final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " "); pw.println("NetworkStack logs:"); mLog.dump(fd, pw, args); Loading Loading @@ -307,8 +317,10 @@ public class NetworkStackService extends Service { */ private void dumpVersion(@NonNull PrintWriter fout) { fout.println("NetworkStackConnector: " + this.VERSION); fout.println("SystemServer: " + mSystemAidlVersion); fout.println("SystemServerConflicts: " + mConflictingSystemAidlVersions); synchronized (mFrameworkAidlVersions) { fout.println("SystemServer: " + mFrameworkAidlVersions); } fout.println("Netd: " + mNetdAidlVersion); } /** Loading Loading
AndroidManifest.xml +7 −3 Original line number Diff line number Diff line Loading @@ -18,8 +18,12 @@ --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.networkstack" android:sharedUserId="android.uid.networkstack"> <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" /> android:sharedUserId="android.uid.networkstack" android:versionCode="290000000" android:versionName="2019-09" > <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" /> <!-- Permissions must be defined here, and not in the base manifest, as the network stack running in the system server process does not need any permission, and having privileged Loading
res/values/overlayable.xml 0 → 100644 +28 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8" ?> <!-- Copyright (C) 2019 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <overlayable name="NetworkStackConfig"> <policy type="product|system|vendor"> <!-- Configuration values for NetworkMonitor --> <item type="integer" name="config_captive_portal_dns_probe_timeout"/> <item type="string" name="config_captive_portal_http_url"/> <item type="string" name="config_captive_portal_https_url"/> <item type="array" name="config_captive_portal_fallback_urls"/> <!-- Configuration value for DhcpResults --> <item type="array" name="config_default_dns_servers"/> </policy> </overlayable> </resources>
src/android/net/util/NetworkStackUtils.java +3 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.net.util; import android.annotation.NonNull; import android.annotation.Nullable; import android.provider.DeviceConfig; import android.util.SparseArray; import java.io.FileDescriptor; Loading Loading @@ -183,8 +184,8 @@ public class NetworkStackUtils { @Nullable public static String getDeviceConfigProperty(@NonNull String namespace, @NonNull String name, @Nullable String defaultValue) { // TODO: Link to DeviceConfig API once it is ready. return defaultValue; String value = DeviceConfig.getProperty(namespace, name); return value != null ? value : defaultValue; } /** Loading
src/com/android/server/NetworkStackService.java +26 −14 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.net.shared.PrivateDnsConfig; import android.net.util.SharedLog; import android.os.IBinder; import android.os.RemoteException; import android.util.ArraySet; import androidx.annotation.VisibleForTesting; Loading @@ -63,7 +64,6 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.concurrent.atomic.AtomicInteger; /** * Android service used to start the network stack when bound to via an intent. Loading Loading @@ -124,14 +124,12 @@ public class NetworkStackService extends Service { @GuardedBy("mValidationLogs") private final ArrayDeque<SharedLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS); private static final int VERSION_UNKNOWN = 0; private static final String DUMPSYS_ARG_VERSION = "version"; /** Version of the AIDL interfaces observed on the system */ private final AtomicInteger mSystemAidlVersion = new AtomicInteger(VERSION_UNKNOWN); /** Whether different versions have been observed on interfaces provided by the system */ private volatile boolean mConflictingSystemAidlVersions = false; /** Version of the framework AIDL interfaces observed. Should hold only one value. */ @GuardedBy("mFrameworkAidlVersions") private final ArraySet<Integer> mFrameworkAidlVersions = new ArraySet<>(1); private final int mNetdAidlVersion; /** * Permission checking dependency of the connector, useful for testing. Loading Loading @@ -167,6 +165,15 @@ public class NetworkStackService extends Service { mObserverRegistry = new NetworkObserverRegistry(); mIpMemoryStoreService = new IpMemoryStoreService(context); int netdVersion; try { netdVersion = mNetd.getInterfaceVersion(); } catch (RemoteException e) { mLog.e("Error obtaining INetd version", e); netdVersion = -1; } mNetdAidlVersion = netdVersion; try { mObserverRegistry.register(mNetd); } catch (RemoteException e) { Loading @@ -175,9 +182,8 @@ public class NetworkStackService extends Service { } private void updateSystemAidlVersion(final int version) { final int previousVersion = mSystemAidlVersion.getAndSet(version); if (previousVersion != VERSION_UNKNOWN && previousVersion != version) { mConflictingSystemAidlVersions = true; synchronized (mFrameworkAidlVersions) { mFrameworkAidlVersions.add(version); } } Loading Loading @@ -254,12 +260,16 @@ public class NetworkStackService extends Service { protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout, @Nullable String[] args) { checkDumpPermission(); final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " "); pw.println("NetworkStack version:"); dumpVersion(pw); pw.println(); if (args != null && args.length >= 1 && DUMPSYS_ARG_VERSION.equals(args[0])) { dumpVersion(fout); return; } final IndentingPrintWriter pw = new IndentingPrintWriter(fout, " "); pw.println("NetworkStack logs:"); mLog.dump(fd, pw, args); Loading Loading @@ -307,8 +317,10 @@ public class NetworkStackService extends Service { */ private void dumpVersion(@NonNull PrintWriter fout) { fout.println("NetworkStackConnector: " + this.VERSION); fout.println("SystemServer: " + mSystemAidlVersion); fout.println("SystemServerConflicts: " + mConflictingSystemAidlVersions); synchronized (mFrameworkAidlVersions) { fout.println("SystemServer: " + mFrameworkAidlVersions); } fout.println("Netd: " + mNetdAidlVersion); } /** Loading