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

Commit 10b918f2 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6206568 from 3cf2e45d to rvc-release

Change-Id: I6958367fd940ce82113d0602a5bd7732572055b1
parents d5c56704 3cf2e45d
Loading
Loading
Loading
Loading
+181 −1
Original line number Diff line number Diff line
@@ -16,14 +16,25 @@

package android.net.shared;

import static android.net.shared.ParcelableUtil.fromParcelableArray;
import static android.net.shared.ParcelableUtil.toParcelableArray;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.INetd;
import android.net.InformationElementParcelable;
import android.net.Network;
import android.net.ProvisioningConfigurationParcelable;
import android.net.ScanResultInfoParcelable;
import android.net.StaticIpConfiguration;
import android.net.apf.ApfCapabilities;
import android.net.ip.IIpClient;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

@@ -192,6 +203,17 @@ public class ProvisioningConfiguration {
            return this;
        }

        /**
         * Specify the information elements included in wifi scan result that was obtained
         * prior to connecting to the access point, if this is a WiFi network.
         *
         * <p>The scan result can be used to infer whether the network is metered.
         */
        public Builder withScanResultInfo(ScanResultInfo scanResultInfo) {
            mConfig.mScanResultInfo = scanResultInfo;
            return this;
        }

        /**
         * Build the configuration using previously specified parameters.
         */
@@ -200,6 +222,158 @@ public class ProvisioningConfiguration {
        }
    }

    /**
     * Class wrapper of {@link android.net.wifi.ScanResult} to encapsulate the SSID and
     * InformationElements fields of ScanResult.
     */
    public static class ScanResultInfo {
        private final String mSsid;
        private final List<InformationElement> mInformationElements;

       /**
        * Class wrapper of {@link android.net.wifi.ScanResult.InformationElement} to encapsulate
        * the specific IE id and payload fields.
        */
        public static class InformationElement {
            private final int mId;
            private final byte[] mPayload;

            public InformationElement(int id, @NonNull ByteBuffer payload) {
                mId = id;
                mPayload = convertToByteArray(payload.asReadOnlyBuffer());
            }

           /**
            * Get the element ID of the information element.
            */
            public int getId() {
                return mId;
            }

           /**
            * Get the specific content of the information element.
            */
            public ByteBuffer getPayload() {
                return ByteBuffer.wrap(mPayload).asReadOnlyBuffer();
            }

            @Override
            public boolean equals(Object o) {
                if (o == this) return true;
                if (!(o instanceof InformationElement)) return false;
                InformationElement other = (InformationElement) o;
                return mId == other.mId && Arrays.equals(mPayload, other.mPayload);
            }

            @Override
            public int hashCode() {
                return Objects.hash(mId, mPayload);
            }

            @Override
            public String toString() {
                return "ID: " + mId + ", " + Arrays.toString(mPayload);
            }

            /**
             * Convert this InformationElement to a {@link InformationElementParcelable}.
             */
            public InformationElementParcelable toStableParcelable() {
                final InformationElementParcelable p = new InformationElementParcelable();
                p.id = mId;
                p.payload = mPayload.clone();
                return p;
            }

            /**
             * Create an instance of {@link InformationElement} based on the contents of the
             * specified {@link InformationElementParcelable}.
             */
            public static InformationElement fromStableParcelable(InformationElementParcelable p) {
                if (p == null) return null;
                return new InformationElement(p.id,
                        ByteBuffer.wrap(p.payload.clone()).asReadOnlyBuffer());
            }
        }

        public ScanResultInfo(String ssid, @NonNull List<InformationElement> informationElements) {
            mSsid = ssid;
            mInformationElements =
                    Collections.unmodifiableList(new ArrayList<>(informationElements));
        }

        /**
         * Get the scanned network name.
         */
        public String getSsid() {
            return mSsid;
        }

        /**
         * Get all information elements found in the beacon.
         */
        public List<InformationElement> getInformationElements() {
            return mInformationElements;
        }

        @Override
        public String toString() {
            StringBuffer str = new StringBuffer();
            str.append("SSID: ").append(mSsid);
            str.append(", Information Elements: {");
            for (InformationElement ie : mInformationElements) {
                str.append("[").append(ie.toString()).append("]");
            }
            str.append("}");
            return str.toString();
        }

        @Override
        public boolean equals(Object o) {
            if (o == this) return true;
            if (!(o instanceof ScanResultInfo)) return false;
            ScanResultInfo other = (ScanResultInfo) o;
            return Objects.equals(mSsid, other.mSsid)
                    && mInformationElements.equals(other.mInformationElements);
        }

        @Override
        public int hashCode() {
            return Objects.hash(mSsid, mInformationElements);
        }

        /**
         * Convert this ScanResultInfo to a {@link ScanResultInfoParcelable}.
         */
        public ScanResultInfoParcelable toStableParcelable() {
            final ScanResultInfoParcelable p = new ScanResultInfoParcelable();
            p.ssid = mSsid;
            p.informationElements = toParcelableArray(mInformationElements,
                    InformationElement::toStableParcelable, InformationElementParcelable.class);
            return p;
        }

        /**
         * Create an instance of {@link ScanResultInfo} based on the contents of the specified
         * {@link ScanResultInfoParcelable}.
         */
        public static ScanResultInfo fromStableParcelable(ScanResultInfoParcelable p) {
            if (p == null) return null;
            final List<InformationElement> ies = new ArrayList<InformationElement>();
            ies.addAll(fromParcelableArray(p.informationElements,
                    InformationElement::fromStableParcelable));
            return new ScanResultInfo(p.ssid, ies);
        }

        private static byte[] convertToByteArray(final ByteBuffer buffer) {
            if (buffer == null) return null;
            byte[] bytes = new byte[buffer.limit()];
            final ByteBuffer copy = buffer.asReadOnlyBuffer();
            copy.get(bytes);
            return bytes;
        }
    }

    public boolean mEnableIPv4 = true;
    public boolean mEnableIPv6 = true;
    public boolean mEnablePreconnection = false;
@@ -213,6 +387,7 @@ public class ProvisioningConfiguration {
    public int mIPv6AddrGenMode = INetd.IPV6_ADDR_GEN_MODE_STABLE_PRIVACY;
    public Network mNetwork = null;
    public String mDisplayName = null;
    public ScanResultInfo mScanResultInfo;

    public ProvisioningConfiguration() {} // used by Builder

@@ -232,6 +407,7 @@ public class ProvisioningConfiguration {
        mIPv6AddrGenMode = other.mIPv6AddrGenMode;
        mNetwork = other.mNetwork;
        mDisplayName = other.mDisplayName;
        mScanResultInfo = other.mScanResultInfo;
    }

    /**
@@ -254,6 +430,7 @@ public class ProvisioningConfiguration {
        p.ipv6AddrGenMode = mIPv6AddrGenMode;
        p.network = mNetwork;
        p.displayName = mDisplayName;
        p.scanResultInfo = mScanResultInfo == null ? null : mScanResultInfo.toStableParcelable();
        return p;
    }

@@ -279,6 +456,7 @@ public class ProvisioningConfiguration {
        config.mIPv6AddrGenMode = p.ipv6AddrGenMode;
        config.mNetwork = p.network;
        config.mDisplayName = p.displayName;
        config.mScanResultInfo = ScanResultInfo.fromStableParcelable(p.scanResultInfo);
        return config;
    }

@@ -298,6 +476,7 @@ public class ProvisioningConfiguration {
                .add("mIPv6AddrGenMode: " + mIPv6AddrGenMode)
                .add("mNetwork: " + mNetwork)
                .add("mDisplayName: " + mDisplayName)
                .add("mScanResultInfo: " + mScanResultInfo)
                .toString();
    }

@@ -317,7 +496,8 @@ public class ProvisioningConfiguration {
                && mProvisioningTimeoutMs == other.mProvisioningTimeoutMs
                && mIPv6AddrGenMode == other.mIPv6AddrGenMode
                && Objects.equals(mNetwork, other.mNetwork)
                && Objects.equals(mDisplayName, other.mDisplayName);
                && Objects.equals(mDisplayName, other.mDisplayName)
                && Objects.equals(mScanResultInfo, other.mScanResultInfo);
    }

    public boolean isValid() {
+3 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ aidl_interface {
    include_dirs: [
        "frameworks/base/core/java", // For framework parcelables.
        "frameworks/native/aidl/binder/android/os", // For PersistableBundle.aidl
        "frameworks/base/wifi/aidl-export", // For wifi parcelables.
    ],
    srcs: [
        "src/android/net/DhcpResultsParcelable.aidl",
@@ -53,14 +54,14 @@ aidl_interface {
        "src/android/net/INetworkStackConnector.aidl",
        "src/android/net/INetworkStackStatusCallback.aidl",
        "src/android/net/InitialConfigurationParcelable.aidl",
        "src/android/net/InformationElementParcelable.aidl",
        "src/android/net/Layer2PacketParcelable.aidl",
        "src/android/net/NattKeepalivePacketDataParcelable.aidl",
        "src/android/net/PrivateDnsConfigParcel.aidl",
        "src/android/net/ProvisioningConfigurationParcelable.aidl",
        "src/android/net/ScanResultInfoParcelable.aidl",
        "src/android/net/TcpKeepalivePacketDataParcelable.aidl",
        "src/android/net/dhcp/DhcpLeaseParcelable.aidl",
        "src/android/net/dhcp/DhcpServingParamsParcel.aidl",
        "src/android/net/dhcp/IDhcpLeaseCallbacks.aidl",
        "src/android/net/dhcp/IDhcpServer.aidl",
        "src/android/net/dhcp/IDhcpServerCallbacks.aidl",
        "src/android/net/ip/IIpClient.aidl",
+22 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2020, The Android Open Source Project
/*
 * Copyright (C) 2020 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.
@@ -10,23 +10,13 @@
 * 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 perNmissions and
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.dhcp;
package android.net;

parcelable DhcpLeaseParcelable {
    // Client ID of the lease; may be null.
    byte[] clientId;
    // MAC address provided by the client.
    byte[] hwAddr;
    // IPv4 address of the lease, in network byte order.
    int netAddr;
    // Prefix length of the lease (0-32)
    int prefixLength;
    // Expiration time of the lease, to compare with SystemClock.elapsedRealtime().
    long expTime;
    // Hostname provided by the client, if any, or null.
    String hostname;
parcelable InformationElementParcelable {
    int id;
    byte[] payload;
}
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.net;

import android.net.InitialConfigurationParcelable;
import android.net.Network;
import android.net.ScanResultInfoParcelable;
import android.net.StaticIpConfiguration;
import android.net.apf.ApfCapabilities;

@@ -36,4 +37,5 @@ parcelable ProvisioningConfigurationParcelable {
    Network network;
    String displayName;
    boolean enablePreconnection;
    ScanResultInfoParcelable scanResultInfo;
}
+24 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2020, The Android Open Source Project
/*
 * Copyright (C) 2020 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.
@@ -10,21 +10,15 @@
 * 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 perNmissions and
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.dhcp;
package android.net;

import android.net.dhcp.DhcpLeaseParcelable;
import android.net.InformationElementParcelable;

oneway interface IDhcpLeaseCallbacks {
    /**
     * Called when a lease is committed or released on the DHCP server.
     *
     * <p>This only reports lease changes after assigning a lease, or after releasing a lease
     * following a DHCPRELEASE: this callback will not be fired when a lease just expires.
     * @param newLeases The new list of leases tracked by the server.
     */
    void onLeasesChanged(in List<DhcpLeaseParcelable> newLeases);
parcelable ScanResultInfoParcelable {
    String ssid;
    InformationElementParcelable[] informationElements;
}
Loading