Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efd27bd4 authored by Xin Li's avatar Xin Li
Browse files

DO NOT MERGE - Merge Android 10 into master

Bug: 139893257
Change-Id: If71a5217a446ea773d461eab0bc0109b18246e33
parents 6002e86e 8d6567a9
Loading
Loading
Loading
Loading
+7 −3
Original line number Original line Diff line number Diff line
@@ -18,8 +18,12 @@
-->
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.android.networkstack"
  package="com.android.networkstack"
          android:sharedUserId="android.uid.networkstack">
  android:sharedUserId="android.uid.networkstack"
    <uses-sdk android:minSdkVersion="28" android:targetSdkVersion="28" />
  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
    <!-- 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
         running in the system server process does not need any permission, and having privileged
+28 −0
Original line number Original line 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>
+3 −2
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.net.util;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.provider.DeviceConfig;
import android.util.SparseArray;
import android.util.SparseArray;


import java.io.FileDescriptor;
import java.io.FileDescriptor;
@@ -183,8 +184,8 @@ public class NetworkStackUtils {
    @Nullable
    @Nullable
    public static String getDeviceConfigProperty(@NonNull String namespace, @NonNull String name,
    public static String getDeviceConfigProperty(@NonNull String namespace, @NonNull String name,
            @Nullable String defaultValue) {
            @Nullable String defaultValue) {
        // TODO: Link to DeviceConfig API once it is ready.
        String value = DeviceConfig.getProperty(namespace, name);
        return defaultValue;
        return value != null ? value : defaultValue;
    }
    }


    /**
    /**
+26 −14
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ import android.net.shared.PrivateDnsConfig;
import android.net.util.SharedLog;
import android.net.util.SharedLog;
import android.os.IBinder;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.RemoteException;
import android.util.ArraySet;


import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.IndentingPrintWriter;
@@ -62,7 +63,6 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicInteger;


/**
/**
 * Android service used to start the network stack when bound to via an intent.
 * Android service used to start the network stack when bound to via an intent.
@@ -118,14 +118,12 @@ public class NetworkStackService extends Service {
        @GuardedBy("mValidationLogs")
        @GuardedBy("mValidationLogs")
        private final ArrayDeque<SharedLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS);
        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";
        private static final String DUMPSYS_ARG_VERSION = "version";


        /** Version of the AIDL interfaces observed on the system */
        /** Version of the framework AIDL interfaces observed. Should hold only one value. */
        private final AtomicInteger mSystemAidlVersion = new AtomicInteger(VERSION_UNKNOWN);
        @GuardedBy("mFrameworkAidlVersions")

        private final ArraySet<Integer> mFrameworkAidlVersions = new ArraySet<>(1);
        /** Whether different versions have been observed on interfaces provided by the system */
        private final int mNetdAidlVersion;
        private volatile boolean mConflictingSystemAidlVersions = false;


        private SharedLog addValidationLogs(Network network, String name) {
        private SharedLog addValidationLogs(Network network, String name) {
            final SharedLog log = new SharedLog(NUM_VALIDATION_LOG_LINES, network + " - " + name);
            final SharedLog log = new SharedLog(NUM_VALIDATION_LOG_LINES, network + " - " + name);
@@ -146,6 +144,15 @@ public class NetworkStackService extends Service {
            mCm = context.getSystemService(ConnectivityManager.class);
            mCm = context.getSystemService(ConnectivityManager.class);
            mIpMemoryStoreService = new IpMemoryStoreService(context);
            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 {
            try {
                mObserverRegistry.register(mNetd);
                mObserverRegistry.register(mNetd);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
@@ -154,9 +161,8 @@ public class NetworkStackService extends Service {
        }
        }


        private void updateSystemAidlVersion(final int version) {
        private void updateSystemAidlVersion(final int version) {
            final int previousVersion = mSystemAidlVersion.getAndSet(version);
            synchronized (mFrameworkAidlVersions) {
            if (previousVersion != VERSION_UNKNOWN && previousVersion != version) {
                mFrameworkAidlVersions.add(version);
                mConflictingSystemAidlVersions = true;
            }
            }
        }
        }


@@ -233,12 +239,16 @@ public class NetworkStackService extends Service {
        protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout,
        protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter fout,
                @Nullable String[] args) {
                @Nullable String[] args) {
            checkDumpPermission();
            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])) {
            if (args != null && args.length >= 1 && DUMPSYS_ARG_VERSION.equals(args[0])) {
                dumpVersion(fout);
                return;
                return;
            }
            }


            final IndentingPrintWriter pw = new IndentingPrintWriter(fout, "  ");
            pw.println("NetworkStack logs:");
            pw.println("NetworkStack logs:");
            mLog.dump(fd, pw, args);
            mLog.dump(fd, pw, args);


@@ -286,8 +296,10 @@ public class NetworkStackService extends Service {
         */
         */
        private void dumpVersion(@NonNull PrintWriter fout) {
        private void dumpVersion(@NonNull PrintWriter fout) {
            fout.println("NetworkStackConnector: " + this.VERSION);
            fout.println("NetworkStackConnector: " + this.VERSION);
            fout.println("SystemServer: " + mSystemAidlVersion);
            synchronized (mFrameworkAidlVersions) {
            fout.println("SystemServerConflicts: " + mConflictingSystemAidlVersions);
                fout.println("SystemServer: " + mFrameworkAidlVersions);
            }
            fout.println("Netd: " + mNetdAidlVersion);
        }
        }


        @Override
        @Override