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

Commit cbe2e7a7 authored by Jong Wook Kim's avatar Jong Wook Kim
Browse files

Add MacRandomizationSetting to WifiConfiguration

Allow setting different levels of MAC randomization for each network.
For now, we are going to support "Persistent" which generates randomized
MAC once and persist that MAC, and "Trusted" which uses the factory MAC.

Bug: 118396042
Test: Existing unittest verifying parcel
Test: adb shell dumpsys wifi | grep -B8 "MacRandomizationSetting"
Change-Id: I067f21a9a9a42370aa8dfe80b05aef3a4f9a7fad
parent 6b82d83d
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -783,6 +783,23 @@ public class WifiConfiguration implements Parcelable {
    @SystemApi
    public int numAssociation;

    /**
     * @hide
     * Use factory MAC when connecting to this network
     */
    public static final int RANDOMIZATION_NONE = 0;
    /**
     * @hide
     * Generate a randomized MAC once and reuse it for all connections to this network
     */
    public static final int RANDOMIZATION_PERSISTENT = 1;

    /**
     * @hide
     * Level of MAC randomization for this network
     */
    public int macRandomizationSetting = RANDOMIZATION_PERSISTENT;

    /**
     * @hide
     * Randomized MAC address to use with this particular network
@@ -1645,6 +1662,7 @@ public class WifiConfiguration implements Parcelable {
        if (this.meteredOverride != METERED_OVERRIDE_NONE) {
            sbuf.append(" meteredOverride ").append(meteredOverride).append("\n");
        }
        sbuf.append(" macRandomizationSetting ").append(macRandomizationSetting).append("\n");
        sbuf.append(" KeyMgmt:");
        for (int k = 0; k < this.allowedKeyManagement.size(); k++) {
            if (this.allowedKeyManagement.get(k)) {
@@ -2109,6 +2127,7 @@ public class WifiConfiguration implements Parcelable {
            shared = source.shared;
            recentFailure.setAssociationStatus(source.recentFailure.getAssociationStatus());
            mRandomizedMacAddress = source.mRandomizedMacAddress;
            macRandomizationSetting = source.macRandomizationSetting;
        }
    }

@@ -2173,6 +2192,7 @@ public class WifiConfiguration implements Parcelable {
        dest.writeString(mPasspointManagementObjectTree);
        dest.writeInt(recentFailure.getAssociationStatus());
        dest.writeParcelable(mRandomizedMacAddress, flags);
        dest.writeInt(macRandomizationSetting);
    }

    /** Implement the Parcelable interface {@hide} */
@@ -2239,6 +2259,7 @@ public class WifiConfiguration implements Parcelable {
                config.mPasspointManagementObjectTree = in.readString();
                config.recentFailure.setAssociationStatus(in.readInt());
                config.mRandomizedMacAddress = in.readParcelable(null);
                config.macRandomizationSetting = in.readInt();
                return config;
            }