diff options
author | Xiao Ma <xiaom@google.com> | 2020-03-31 15:39:52 +0000 |
---|---|---|
committer | Xiao Ma <xiaom@google.com> | 2020-04-02 10:25:22 +0000 |
commit | ef0aa6f9e5718942a93c69bbe6be21bf6c0fa532 (patch) | |
tree | 269f14da0f638260002b69de8e04ce08e6b5d8b6 /common/moduleutils | |
parent | 9b105a99a3223fe2b573533cba503fb63bd97257 (diff) |
Add new method to update Layer2 information when L2 roaming happens.
This change adds an new method updateLayer2Information in IIpClient.aidl
to update layer2 info (e.g. bssid, l2key and grouphint) to detect
whether L2 roaming happens or not.
Bug: 131797393
Test: atest NetworkStackTests FrameworksNetTests
Merged-In: I85eabccb6f5d5f322c8e3df556ceef6647616f5a
(cherry picked from commit 3168e392320087c51a677b4d14e783c853ac652d)
Change-Id: Ife93fd162803ae89fa85905b45a4bb1cfb5e7e43
Diffstat (limited to 'common/moduleutils')
-rw-r--r-- | common/moduleutils/Android.bp | 1 | ||||
-rw-r--r-- | common/moduleutils/src/android/net/shared/Layer2Information.java | 81 |
2 files changed, 82 insertions, 0 deletions
diff --git a/common/moduleutils/Android.bp b/common/moduleutils/Android.bp index 81475d2..f32f8d8 100644 --- a/common/moduleutils/Android.bp +++ b/common/moduleutils/Android.bp @@ -23,6 +23,7 @@ filegroup { "src/android/net/util/SharedLog.java", "src/android/net/shared/InitialConfiguration.java", "src/android/net/shared/IpConfigurationParcelableUtil.java", + "src/android/net/shared/Layer2Information.java", "src/android/net/shared/LinkPropertiesParcelableUtil.java", "src/android/net/shared/ParcelableUtil.java", "src/android/net/shared/NetdUtils.java", diff --git a/common/moduleutils/src/android/net/shared/Layer2Information.java b/common/moduleutils/src/android/net/shared/Layer2Information.java new file mode 100644 index 0000000..77956a7 --- /dev/null +++ b/common/moduleutils/src/android/net/shared/Layer2Information.java @@ -0,0 +1,81 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 permissions and + * limitations under the License. + */ + +package android.net.shared; + +import android.net.Layer2InformationParcelable; +import android.net.MacAddress; + +import java.util.Objects; + +/** @hide */ +public class Layer2Information { + private final String mL2Key; + private final String mGroupHint; + private final MacAddress mBssid; + + /** + * Create a Layer2Information with the specified configuration. + */ + public Layer2Information(String l2Key, String groupHint, MacAddress bssid) { + mL2Key = l2Key; + mGroupHint = groupHint; + mBssid = bssid; + } + + @Override + public String toString() { + StringBuffer str = new StringBuffer(); + str.append("L2Key: ").append(mL2Key); + str.append(", GroupHint: ").append(mGroupHint); + str.append(", bssid: ").append(mBssid.toString()); + return str.toString(); + } + + /** + * Convert Layer2 Information to a {@link Layer2InformationParcelable}. + */ + public Layer2InformationParcelable toStableParcelable() { + final Layer2InformationParcelable p = new Layer2InformationParcelable(); + p.l2Key = mL2Key; + p.groupHint = mGroupHint; + p.bssid = mBssid; + return p; + } + + /** + * Create an instance of {@link Layer2Information} based on the contents of the specified + * {@link Layer2InformationParcelable}. + */ + public Layer2Information fromStableParcelable(Layer2InformationParcelable p) { + if (p == null) return null; + return new Layer2Information(p.l2Key, p.groupHint, p.bssid); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Layer2Information)) return false; + final Layer2Information other = (Layer2Information) obj; + return Objects.equals(mL2Key, other.mL2Key) + && Objects.equals(mGroupHint, other.mGroupHint) + && Objects.equals(mBssid, other.mBssid); + } + + @Override + public int hashCode() { + return Objects.hash(mL2Key, mGroupHint, mBssid); + } +} |