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

Commit 1244d44c authored by xshu's avatar xshu
Browse files

Store the randomized MAC last modified time

This is needed to force a re-randomization every 24 hours when enhanced
MAC randomization is active.

Bug: 162801581
Test: atest android.net.wifi
Change-Id: I9cee8ba75dcb69e29768a8ab5539fb4054ad9cd4
parent 2c89638c
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -1183,11 +1183,17 @@ public class WifiConfiguration implements Parcelable {

    /**
     * @hide
     * The wall clock time of when |mRandomizedMacAddress| should be re-randomized in aggressive
     * randomization mode.
     * The wall clock time of when |mRandomizedMacAddress| should be re-randomized in enhanced
     * MAC randomization mode.
     */
    public long randomizedMacExpirationTimeMs = 0;

    /**
     * The wall clock time of when |mRandomizedMacAddress| is last modified.
     * @hide
     */
    public long randomizedMacLastModifiedTimeMs = 0;

    /**
     * @hide
     * Checks if the given MAC address can be used for Connected Mac Randomization
@@ -2258,6 +2264,9 @@ public class WifiConfiguration implements Parcelable {
        sbuf.append(" randomizedMacExpirationTimeMs: ")
                .append(randomizedMacExpirationTimeMs == 0 ? "<none>"
                        : logTimeOfDay(randomizedMacExpirationTimeMs)).append("\n");
        sbuf.append(" randomizedMacLastModifiedTimeMs: ")
                .append(randomizedMacLastModifiedTimeMs == 0 ? "<none>"
                        : logTimeOfDay(randomizedMacLastModifiedTimeMs)).append("\n");
        sbuf.append(" KeyMgmt:");
        for (int k = 0; k < this.allowedKeyManagement.size(); k++) {
            if (this.allowedKeyManagement.get(k)) {
@@ -2803,6 +2812,7 @@ public class WifiConfiguration implements Parcelable {
            mRandomizedMacAddress = source.mRandomizedMacAddress;
            macRandomizationSetting = source.macRandomizationSetting;
            randomizedMacExpirationTimeMs = source.randomizedMacExpirationTimeMs;
            randomizedMacLastModifiedTimeMs = source.randomizedMacLastModifiedTimeMs;
            requirePmf = source.requirePmf;
            updateIdentifier = source.updateIdentifier;
            carrierId = source.carrierId;
@@ -2877,6 +2887,7 @@ public class WifiConfiguration implements Parcelable {
        dest.writeInt(macRandomizationSetting);
        dest.writeInt(osu ? 1 : 0);
        dest.writeLong(randomizedMacExpirationTimeMs);
        dest.writeLong(randomizedMacLastModifiedTimeMs);
        dest.writeInt(carrierId);
        dest.writeString(mPasspointUniqueId);
    }
@@ -2951,6 +2962,7 @@ public class WifiConfiguration implements Parcelable {
                config.macRandomizationSetting = in.readInt();
                config.osu = in.readInt() != 0;
                config.randomizedMacExpirationTimeMs = in.readLong();
                config.randomizedMacLastModifiedTimeMs = in.readLong();
                config.carrierId = in.readInt();
                config.mPasspointUniqueId = in.readString();
                return config;