Merge "Move network selection utils to Connectivity"
This commit is contained in:
20
framework/aidl-export/android/net/NetworkScore.aidl
Normal file
20
framework/aidl-export/android/net/NetworkScore.aidl
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) 2021, 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;
|
||||
|
||||
parcelable NetworkScore;
|
||||
|
||||
23
framework/src/android/net/IOnCompleteListener.aidl
Normal file
23
framework/src/android/net/IOnCompleteListener.aidl
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
*
|
||||
* Copyright (C) 2021 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;
|
||||
|
||||
/** @hide */
|
||||
oneway interface IOnCompleteListener {
|
||||
void onComplete();
|
||||
}
|
||||
108
framework/src/android/net/NetworkScore.java
Normal file
108
framework/src/android/net/NetworkScore.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Object representing the quality of a network as perceived by the user.
|
||||
*
|
||||
* A NetworkScore object represents the characteristics of a network that affects how good the
|
||||
* network is considered for a particular use.
|
||||
* @hide
|
||||
*/
|
||||
// TODO : @SystemApi when the implementation is complete
|
||||
public final class NetworkScore implements Parcelable {
|
||||
// This will be removed soon. Do *NOT* depend on it for any new code that is not part of
|
||||
// a migration.
|
||||
private final int mLegacyInt;
|
||||
|
||||
/** @hide */
|
||||
NetworkScore(final int legacyInt) {
|
||||
this.mLegacyInt = legacyInt;
|
||||
}
|
||||
|
||||
private NetworkScore(@NonNull final Parcel in) {
|
||||
mLegacyInt = in.readInt();
|
||||
}
|
||||
|
||||
public int getLegacyInt() {
|
||||
return mLegacyInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Score(" + mLegacyInt + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull final Parcel dest, final int flags) {
|
||||
dest.writeInt(mLegacyInt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@NonNull public static final Creator<NetworkScore> CREATOR = new Creator<>() {
|
||||
@Override
|
||||
@NonNull
|
||||
public NetworkScore createFromParcel(@NonNull final Parcel in) {
|
||||
return new NetworkScore(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public NetworkScore[] newArray(int size) {
|
||||
return new NetworkScore[size];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A builder for NetworkScore.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private static final int INVALID_LEGACY_INT = Integer.MIN_VALUE;
|
||||
private int mLegacyInt = INVALID_LEGACY_INT;
|
||||
|
||||
/**
|
||||
* Sets the legacy int for this score.
|
||||
*
|
||||
* Do not rely on this. It will be gone by the time S is released.
|
||||
*
|
||||
* @param score the legacy int
|
||||
* @return this
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setLegacyInt(final int score) {
|
||||
mLegacyInt = score;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds this NetworkScore.
|
||||
* @return The built NetworkScore object.
|
||||
*/
|
||||
@NonNull
|
||||
public NetworkScore build() {
|
||||
return new NetworkScore(mLegacyInt);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user