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

Commit b1be20a2 authored by Jimmy Chen's avatar Jimmy Chen
Browse files

Wifi: define OEM IE parsing hook function

OEM needs to implement this hook for OEM-supported
security type.

This hook function is empty by default in AOSP.

Bug: 139257562
Test: FrameworksWifiApiTests
Change-Id: Id223c6acc015d33a42afa4dababc1ca6304d471a
parent 3a9f1e91
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -5606,8 +5606,32 @@ package android.net.wifi {
  }
  public class ScanResult implements android.os.Parcelable {
    field public static final int CIPHER_CCMP = 3; // 0x3
    field public static final int CIPHER_GCMP_256 = 4; // 0x4
    field public static final int CIPHER_NONE = 0; // 0x0
    field public static final int CIPHER_NO_GROUP_ADDRESSED = 1; // 0x1
    field public static final int CIPHER_SMS4 = 5; // 0x5
    field public static final int CIPHER_TKIP = 2; // 0x2
    field public static final int KEY_MGMT_EAP = 2; // 0x2
    field public static final int KEY_MGMT_EAP_SHA256 = 6; // 0x6
    field public static final int KEY_MGMT_EAP_SUITE_B_192 = 10; // 0xa
    field public static final int KEY_MGMT_FT_EAP = 4; // 0x4
    field public static final int KEY_MGMT_FT_PSK = 3; // 0x3
    field public static final int KEY_MGMT_FT_SAE = 11; // 0xb
    field public static final int KEY_MGMT_NONE = 0; // 0x0
    field public static final int KEY_MGMT_OSEN = 7; // 0x7
    field public static final int KEY_MGMT_OWE = 9; // 0x9
    field public static final int KEY_MGMT_OWE_TRANSITION = 12; // 0xc
    field public static final int KEY_MGMT_PSK = 1; // 0x1
    field public static final int KEY_MGMT_PSK_SHA256 = 5; // 0x5
    field public static final int KEY_MGMT_SAE = 8; // 0x8
    field public static final int KEY_MGMT_WAPI_CERT = 14; // 0xe
    field public static final int KEY_MGMT_WAPI_PSK = 13; // 0xd
    field public static final int PROTOCOL_NONE = 0; // 0x0
    field public static final int PROTOCOL_OSEN = 3; // 0x3
    field public static final int PROTOCOL_RSN = 2; // 0x2
    field public static final int PROTOCOL_WAPI = 4; // 0x4
    field public static final int PROTOCOL_WPA = 1; // 0x1
  }
  public final class SoftApCapability implements android.os.Parcelable {
@@ -6346,6 +6370,7 @@ package android.net.wifi.wificond {
    method @NonNull public java.util.List<android.net.wifi.wificond.NativeScanResult> getScanResults(@NonNull String, int);
    method @Nullable public android.net.wifi.wificond.WifiCondManager.TxPacketCounters getTxPacketCounters(@NonNull String);
    method public boolean initialize(@NonNull Runnable);
    method @Nullable public static android.net.wifi.wificond.WifiCondManager.OemSecurityType parseOemSecurityTypeElement(int, int, @NonNull byte[]);
    method public boolean registerApCallback(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.wificond.WifiCondManager.SoftApCallback);
    method public void sendMgmtFrame(@NonNull String, @NonNull byte[], int, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.wificond.WifiCondManager.SendMgmtFrameCallback);
    method public boolean setupInterfaceForClientMode(@NonNull String, @NonNull java.util.concurrent.Executor, @NonNull android.net.wifi.wificond.WifiCondManager.ScanEventCallback, @NonNull android.net.wifi.wificond.WifiCondManager.ScanEventCallback);
@@ -6366,6 +6391,14 @@ package android.net.wifi.wificond {
    field public static final int SEND_MGMT_FRAME_ERROR_UNKNOWN = 1; // 0x1
  }
  public static class WifiCondManager.OemSecurityType {
    ctor public WifiCondManager.OemSecurityType(int, @NonNull java.util.List<java.lang.Integer>, @NonNull java.util.List<java.lang.Integer>, int);
    field public final int groupCipher;
    field @NonNull public final java.util.List<java.lang.Integer> keyManagement;
    field @NonNull public final java.util.List<java.lang.Integer> pairwiseCipher;
    field public final int protocol;
  }
  public static interface WifiCondManager.PnoScanRequestCallback {
    method public void onPnoRequestFailed();
    method public void onPnoRequestSucceeded();
+25 −0
Original line number Diff line number Diff line
@@ -82,16 +82,19 @@ public class ScanResult implements Parcelable {
     * @hide
     * No security protocol.
     */
    @SystemApi
    public static final int PROTOCOL_NONE = 0;
    /**
     * @hide
     * Security protocol type: WPA version 1.
     */
    @SystemApi
    public static final int PROTOCOL_WPA = 1;
    /**
     * @hide
     * Security protocol type: RSN, for WPA version 2, and version 3.
     */
    @SystemApi
    public static final int PROTOCOL_RSN = 2;
    /**
     * @hide
@@ -99,79 +102,94 @@ public class ScanResult implements Parcelable {
     * OSU Server-only authenticated layer 2 Encryption Network.
     * Used for Hotspot 2.0.
     */
    @SystemApi
    public static final int PROTOCOL_OSEN = 3;

    /**
     * @hide
     * Security protocol type: WAPI.
     */
    @SystemApi
    public static final int PROTOCOL_WAPI = 4;

    /**
     * @hide
     * No security key management scheme.
     */
    @SystemApi
    public static final int KEY_MGMT_NONE = 0;
    /**
     * @hide
     * Security key management scheme: PSK.
     */
    @SystemApi
    public static final int KEY_MGMT_PSK = 1;
    /**
     * @hide
     * Security key management scheme: EAP.
     */
    @SystemApi
    public static final int KEY_MGMT_EAP = 2;
    /**
     * @hide
     * Security key management scheme: FT_PSK.
     */
    @SystemApi
    public static final int KEY_MGMT_FT_PSK = 3;
    /**
     * @hide
     * Security key management scheme: FT_EAP.
     */
    @SystemApi
    public static final int KEY_MGMT_FT_EAP = 4;
    /**
     * @hide
     * Security key management scheme: PSK_SHA256
     */
    @SystemApi
    public static final int KEY_MGMT_PSK_SHA256 = 5;
    /**
     * @hide
     * Security key management scheme: EAP_SHA256.
     */
    @SystemApi
    public static final int KEY_MGMT_EAP_SHA256 = 6;
    /**
     * @hide
     * Security key management scheme: OSEN.
     * Used for Hotspot 2.0.
     */
    @SystemApi
    public static final int KEY_MGMT_OSEN = 7;
     /**
     * @hide
     * Security key management scheme: SAE.
     */
    @SystemApi
    public static final int KEY_MGMT_SAE = 8;
    /**
     * @hide
     * Security key management scheme: OWE.
     */
    @SystemApi
    public static final int KEY_MGMT_OWE = 9;
    /**
     * @hide
     * Security key management scheme: SUITE_B_192.
     */
    @SystemApi
    public static final int KEY_MGMT_EAP_SUITE_B_192 = 10;
    /**
     * @hide
     * Security key management scheme: FT_SAE.
     */
    @SystemApi
    public static final int KEY_MGMT_FT_SAE = 11;
    /**
     * @hide
     * Security key management scheme: OWE in transition mode.
     */
    @SystemApi
    public static final int KEY_MGMT_OWE_TRANSITION = 12;
    /**
     * @hide
@@ -185,35 +203,42 @@ public class ScanResult implements Parcelable {
     */
    @SystemApi
    public static final int KEY_MGMT_WAPI_CERT = 14;

    /**
     * @hide
     * No cipher suite.
     */
    @SystemApi
    public static final int CIPHER_NONE = 0;
    /**
     * @hide
     * No group addressed, only used for group data cipher.
     */
    @SystemApi
    public static final int CIPHER_NO_GROUP_ADDRESSED = 1;
    /**
     * @hide
     * Cipher suite: TKIP
     */
    @SystemApi
    public static final int CIPHER_TKIP = 2;
    /**
     * @hide
     * Cipher suite: CCMP
     */
    @SystemApi
    public static final int CIPHER_CCMP = 3;
    /**
     * @hide
     * Cipher suite: GCMP
     */
    @SystemApi
    public static final int CIPHER_GCMP_256 = 4;
    /**
     * @hide
     * Cipher suite: SMS4
     */
    @SystemApi
    public static final int CIPHER_SMS4 = 5;

    /**
+41 −0
Original line number Diff line number Diff line
@@ -60,4 +60,45 @@ public final class WifiAnnotations {
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Bandwidth {}

    @IntDef(prefix = { "PROTOCOL_" }, value = {
            ScanResult.PROTOCOL_NONE,
            ScanResult.PROTOCOL_WPA,
            ScanResult.PROTOCOL_RSN,
            ScanResult.PROTOCOL_OSEN,
            ScanResult.PROTOCOL_WAPI
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Protocol {}

    @IntDef(prefix = { "KEY_MGMT_" }, value = {
        ScanResult.KEY_MGMT_NONE,
        ScanResult.KEY_MGMT_PSK,
        ScanResult.KEY_MGMT_EAP,
        ScanResult.KEY_MGMT_FT_PSK,
        ScanResult.KEY_MGMT_FT_EAP,
        ScanResult.KEY_MGMT_PSK_SHA256,
        ScanResult.KEY_MGMT_EAP_SHA256,
        ScanResult.KEY_MGMT_OSEN,
        ScanResult.KEY_MGMT_SAE,
        ScanResult.KEY_MGMT_OWE,
        ScanResult.KEY_MGMT_EAP_SUITE_B_192,
        ScanResult.KEY_MGMT_FT_SAE,
        ScanResult.KEY_MGMT_OWE_TRANSITION,
        ScanResult.KEY_MGMT_WAPI_PSK,
        ScanResult.KEY_MGMT_WAPI_CERT
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface KeyMgmt {}

    @IntDef(prefix = { "CIPHER_" }, value = {
        ScanResult.CIPHER_NONE,
        ScanResult.CIPHER_NO_GROUP_ADDRESSED,
        ScanResult.CIPHER_TKIP,
        ScanResult.CIPHER_CCMP,
        ScanResult.CIPHER_GCMP_256,
        ScanResult.CIPHER_SMS4
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Cipher {}
}
+64 −0
Original line number Diff line number Diff line
@@ -1154,4 +1154,68 @@ public class WifiCondManager {
        mApInterfaceListeners.clear();
        mSendMgmtFrameInProgress.set(false);
    }

    /**
     * OEM parsed security type
     */
    public static class OemSecurityType {
        /** The protocol defined in {@link android.net.wifi.WifiAnnotations.Protocol}. */
        public final @WifiAnnotations.Protocol int protocol;
        /**
         * Supported key management types defined
         * in {@link android.net.wifi.WifiAnnotations.KeyMgmt}.
         */
        @NonNull public final List<Integer> keyManagement;
        /**
         * Supported pairwise cipher types defined
         * in {@link android.net.wifi.WifiAnnotations.Cipher}.
         */
        @NonNull public final List<Integer> pairwiseCipher;
        /** The group cipher type defined in {@link android.net.wifi.WifiAnnotations.Cipher}. */
        public final @WifiAnnotations.Cipher int groupCipher;
        /**
         * Default constructor for OemSecurityType
         *
         * @param protocol The protocol defined in
         *                 {@link android.net.wifi.WifiAnnotations.Protocol}.
         * @param keyManagement Supported key management types defined
         *                      in {@link android.net.wifi.WifiAnnotations.KeyMgmt}.
         * @param pairwiseCipher Supported pairwise cipher types defined
         *                       in {@link android.net.wifi.WifiAnnotations.Cipher}.
         * @param groupCipher The group cipher type defined
         *                    in {@link android.net.wifi.WifiAnnotations.Cipher}.
         */
        public OemSecurityType(
                @WifiAnnotations.Protocol int protocol,
                @NonNull List<Integer> keyManagement,
                @NonNull List<Integer> pairwiseCipher,
                @WifiAnnotations.Cipher int groupCipher) {
            this.protocol = protocol;
            this.keyManagement = (keyManagement != null)
                ? keyManagement : new ArrayList<Integer>();
            this.pairwiseCipher = (pairwiseCipher != null)
                ? pairwiseCipher : new ArrayList<Integer>();
            this.groupCipher = groupCipher;
        }
    }

    /**
     * OEM information element parser for security types not parsed by the framework.
     *
     * The OEM method should use the method inputs {@code id}, {@code idExt}, and {@code bytes}
     * to perform the parsing. The method should place the results in an OemSecurityType objct.
     *
     * @param id The information element id.
     * @param idExt The information element extension id. This is valid only when id is
     *        the extension id, {@code 255}.
     * @param bytes The raw bytes of information element data, 'Element ID' and 'Length' are
     *              stripped off already.
     * @return an OemSecurityType object if this IE is parsed successfully, null otherwise.
     */
    @Nullable public static OemSecurityType parseOemSecurityTypeElement(
            int id,
            int idExt,
            @NonNull byte[] bytes) {
        return null;
    }
}