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

Commit 3b2f6cda authored by Xiao Ma's avatar Xiao Ma Committed by Gerrit Code Review
Browse files

Merge "Get the l2key and grouphint from the initial provisioning configuration."

parents 1162d1cd b5721cc0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ import java.util.Objects;

/** @hide */
public class Layer2Information {
    private final String mL2Key;
    private final String mGroupHint;
    private final MacAddress mBssid;
    public final String mL2Key;
    public final String mGroupHint;
    public final MacAddress mBssid;

    /**
     * Create a Layer2Information with the specified configuration.
@@ -60,7 +60,7 @@ public class Layer2Information {
     * Create an instance of {@link Layer2Information} based on the contents of the specified
     * {@link Layer2InformationParcelable}.
     */
    public Layer2Information fromStableParcelable(Layer2InformationParcelable p) {
    public static Layer2Information fromStableParcelable(Layer2InformationParcelable p) {
        if (p == null) return null;
        return new Layer2Information(p.l2Key, p.groupHint, p.bssid);
    }
+15 −1
Original line number Diff line number Diff line
@@ -218,6 +218,14 @@ public class ProvisioningConfiguration {
            return this;
        }

        /**
         * Specify the L2 information(bssid, l2key and groupHint) that the IpClient should use.
         */
        public Builder withLayer2Information(Layer2Information layer2Info) {
            mConfig.mLayer2Info = layer2Info;
            return this;
        }

        /**
         * Build the configuration using previously specified parameters.
         */
@@ -421,6 +429,7 @@ public class ProvisioningConfiguration {
    public Network mNetwork = null;
    public String mDisplayName = null;
    public ScanResultInfo mScanResultInfo;
    public Layer2Information mLayer2Info;

    public ProvisioningConfiguration() {} // used by Builder

@@ -441,6 +450,7 @@ public class ProvisioningConfiguration {
        mNetwork = other.mNetwork;
        mDisplayName = other.mDisplayName;
        mScanResultInfo = other.mScanResultInfo;
        mLayer2Info = other.mLayer2Info;
    }

    /**
@@ -464,6 +474,7 @@ public class ProvisioningConfiguration {
        p.network = mNetwork;
        p.displayName = mDisplayName;
        p.scanResultInfo = mScanResultInfo == null ? null : mScanResultInfo.toStableParcelable();
        p.layer2Info = mLayer2Info == null ? null : mLayer2Info.toStableParcelable();
        return p;
    }

@@ -490,6 +501,7 @@ public class ProvisioningConfiguration {
        config.mNetwork = p.network;
        config.mDisplayName = p.displayName;
        config.mScanResultInfo = ScanResultInfo.fromStableParcelable(p.scanResultInfo);
        config.mLayer2Info = Layer2Information.fromStableParcelable(p.layer2Info);
        return config;
    }

@@ -510,6 +522,7 @@ public class ProvisioningConfiguration {
                .add("mNetwork: " + mNetwork)
                .add("mDisplayName: " + mDisplayName)
                .add("mScanResultInfo: " + mScanResultInfo)
                .add("mLayer2Info: " + mLayer2Info)
                .toString();
    }

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

    public boolean isValid() {
+1 −0
Original line number Diff line number Diff line
@@ -31,4 +31,5 @@ parcelable ProvisioningConfigurationParcelable {
  String displayName;
  boolean enablePreconnection;
  android.net.ScanResultInfoParcelable scanResultInfo;
  android.net.Layer2InformationParcelable layer2Info;
}
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
package android.net;

import android.net.InitialConfigurationParcelable;
import android.net.Layer2InformationParcelable;
import android.net.Network;
import android.net.ScanResultInfoParcelable;
import android.net.StaticIpConfiguration;
@@ -38,4 +39,5 @@ parcelable ProvisioningConfigurationParcelable {
    String displayName;
    boolean enablePreconnection;
    ScanResultInfoParcelable scanResultInfo;
    Layer2InformationParcelable layer2Info;
}
+10 −9
Original line number Diff line number Diff line
@@ -793,6 +793,11 @@ public class IpClient extends StateMachine {
                        + " in provisioning configuration", e);
            }
        }

        if (req.mLayer2Info != null) {
            mL2Key = req.mLayer2Info.mL2Key;
            mGroupHint = req.mLayer2Info.mGroupHint;
        }
        sendMessage(CMD_START, new android.net.shared.ProvisioningConfiguration(req));
    }

@@ -903,7 +908,7 @@ public class IpClient extends StateMachine {
    }

    /**
     * Update the network bssid, L2Key and GroupHint layer2 information.
     * Update the network bssid, L2Key and GroupHint on L2 roaming happened.
     */
    public void updateLayer2Information(@NonNull Layer2InformationParcelable info) {
        sendMessage(CMD_UPDATE_L2INFORMATION, info);
@@ -1532,10 +1537,10 @@ public class IpClient extends StateMachine {
        mL2Key = info.l2Key;
        mGroupHint = info.groupHint;

        // This means IpClient is still in the StoppedState, WiFi is trying to associate
        // to the AP, just update L2Key and GroupHint at this stage, because these members
        // will be used when starting DhcpClient.
        if (info.bssid == null || mCurrentBssid == null) return;
        if (info.bssid == null || mCurrentBssid == null) {
            Log.wtf(mTag, "bssid in the parcelable or current tracked bssid should be non-null");
            return;
        }

        // If the BSSID has not changed, there is nothing to do.
        if (info.bssid.equals(mCurrentBssid)) return;
@@ -1610,10 +1615,6 @@ public class IpClient extends StateMachine {
                    break;
                }

                case CMD_UPDATE_L2INFORMATION:
                    handleUpdateL2Information((Layer2InformationParcelable) msg.obj);
                    break;

                case CMD_SET_MULTICAST_FILTER:
                    mMulticastFiltering = (boolean) msg.obj;
                    break;
Loading