From b2eabd4e7b52ca7770c5b51b3cec8aaba87f29a9 Mon Sep 17 00:00:00 2001 From: Remi NGUYEN VAN Date: Tue, 2 Mar 2021 12:12:49 +0900 Subject: [PATCH] Move UidRange to connectivity UidRange is a data class that is an implementation detail of Connectivity. Move it to the connectivity boundary. Remaining usages of UidRange outside of Connectivity (in VPN) should be migrated to other classes, like Range or UidRangeParcel. Bug: 181512874 Test: m Change-Id: I6f2e3685ad1c07171dd90480d1e546329de8732d --- framework/src/android/net/UidRange.aidl | 24 +++++++++++++++++ .../src}/android/net/UidRange.java | 27 +++++++++---------- 2 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 framework/src/android/net/UidRange.aidl rename {core/java => framework/src}/android/net/UidRange.java (89%) diff --git a/framework/src/android/net/UidRange.aidl b/framework/src/android/net/UidRange.aidl new file mode 100644 index 0000000000..f70fc8e2fe --- /dev/null +++ b/framework/src/android/net/UidRange.aidl @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2018 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; + +/** + * An inclusive range of UIDs. + * + * {@hide} + */ +parcelable UidRange; \ No newline at end of file diff --git a/core/java/android/net/UidRange.java b/framework/src/android/net/UidRange.java similarity index 89% rename from core/java/android/net/UidRange.java rename to framework/src/android/net/UidRange.java index be5964dca3..26518d32ed 100644 --- a/core/java/android/net/UidRange.java +++ b/framework/src/android/net/UidRange.java @@ -16,8 +16,6 @@ package android.net; -import static android.os.UserHandle.PER_USER_RANGE; - import android.annotation.Nullable; import android.os.Parcel; import android.os.Parcelable; @@ -60,6 +58,7 @@ public final class UidRange implements Parcelable { return UserHandle.getUserHandleForUid(stop).getIdentifier(); } + /** Returns whether the UidRange contains the specified UID. */ public boolean contains(int uid) { return start <= uid && uid <= stop; } @@ -72,7 +71,7 @@ public final class UidRange implements Parcelable { } /** - * @return {@code true} if this range contains every UID contained by the {@param other} range. + * @return {@code true} if this range contains every UID contained by the {@code other} range. */ public boolean containsRange(UidRange other) { return start <= other.start && other.stop <= stop; @@ -118,18 +117,18 @@ public final class UidRange implements Parcelable { } public static final @android.annotation.NonNull Creator CREATOR = - new Creator() { - @Override - public UidRange createFromParcel(Parcel in) { - int start = in.readInt(); - int stop = in.readInt(); + new Creator() { + @Override + public UidRange createFromParcel(Parcel in) { + int start = in.readInt(); + int stop = in.readInt(); - return new UidRange(start, stop); - } - @Override - public UidRange[] newArray(int size) { - return new UidRange[size]; - } + return new UidRange(start, stop); + } + @Override + public UidRange[] newArray(int size) { + return new UidRange[size]; + } }; /**