diff options
author | Sooraj Sasindran <sasindran@google.com> | 2020-11-12 21:34:48 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-11-12 21:34:48 +0000 |
commit | eca4612629a149da951b8931d8cef208898c9d19 (patch) | |
tree | 2b10a28dbc98f3bfbdd71ab94c42cbb78113d6ed | |
parent | ec0f77a84ec2cf097790ee13d9af8371f69cc9ac (diff) | |
parent | a63c16f36a6b8951b74de419213a0b9a88e3c57f (diff) |
Merge "Provide API to retrive dual connected bandwidth"
-rwxr-xr-x | api/system-current.txt | 12 | ||||
-rw-r--r-- | core/api/system-current.txt | 12 | ||||
-rw-r--r-- | telephony/java/android/telephony/CarrierBandwidth.aidl | 17 | ||||
-rw-r--r-- | telephony/java/android/telephony/CarrierBandwidth.java | 208 | ||||
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 27 | ||||
-rw-r--r-- | telephony/java/com/android/internal/telephony/ITelephony.aidl | 7 |
6 files changed, 283 insertions, 0 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index abe95aebf8b2..d93f14753673 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -10592,6 +10592,17 @@ package android.telephony { field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallQuality> CREATOR; } + public final class CarrierBandwidth implements android.os.Parcelable { + ctor public CarrierBandwidth(int, int, int, int); + method public int describeContents(); + method public int getPrimaryDownlinkCapacityKbps(); + method public int getPrimaryUplinkCapacityKbps(); + method public int getSecondaryDownlinkCapacityKbps(); + method public int getSecondaryUplinkCapacityKbps(); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CarrierBandwidth> CREATOR; + field public static final int INVALID = -1; // 0xffffffff + } + public class CarrierConfigManager { method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDefaultCarrierServicePackageName(); method @NonNull public static android.os.PersistableBundle getDefaultConfig(); @@ -11208,6 +11219,7 @@ package android.telephony { method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallForwarding(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CallForwardingInfoCallback); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallWaitingStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); + method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.CarrierBandwidth getCarrierBandwidth(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); diff --git a/core/api/system-current.txt b/core/api/system-current.txt index a795a53ac3b5..b263bf45a97e 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -9474,6 +9474,17 @@ package android.telephony { field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CallQuality> CREATOR; } + public final class CarrierBandwidth implements android.os.Parcelable { + ctor public CarrierBandwidth(int, int, int, int); + method public int describeContents(); + method public int getPrimaryDownlinkCapacityKbps(); + method public int getPrimaryUplinkCapacityKbps(); + method public int getSecondaryDownlinkCapacityKbps(); + method public int getSecondaryUplinkCapacityKbps(); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.CarrierBandwidth> CREATOR; + field public static final int INVALID = -1; // 0xffffffff + } + public class CarrierConfigManager { method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public String getDefaultCarrierServicePackageName(); method @NonNull public static android.os.PersistableBundle getDefaultConfig(); @@ -10090,6 +10101,7 @@ package android.telephony { method @Nullable @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS) public android.content.ComponentName getAndUpdateDefaultRespondViaMessageApplication(); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallForwarding(int, @NonNull java.util.concurrent.Executor, @NonNull android.telephony.TelephonyManager.CallForwardingInfoCallback); method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public void getCallWaitingStatus(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.lang.Integer>); + method @NonNull @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.CarrierBandwidth getCarrierBandwidth(); method @Nullable @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public android.telephony.ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntent(android.content.Intent); method public java.util.List<java.lang.String> getCarrierPackageNamesForIntentAndPhone(android.content.Intent, int); diff --git a/telephony/java/android/telephony/CarrierBandwidth.aidl b/telephony/java/android/telephony/CarrierBandwidth.aidl new file mode 100644 index 000000000000..d0861b88e737 --- /dev/null +++ b/telephony/java/android/telephony/CarrierBandwidth.aidl @@ -0,0 +1,17 @@ +/* + * Copyright 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.telephony; +parcelable CarrierBandwidth;
\ No newline at end of file diff --git a/telephony/java/android/telephony/CarrierBandwidth.java b/telephony/java/android/telephony/CarrierBandwidth.java new file mode 100644 index 000000000000..17747a3919ee --- /dev/null +++ b/telephony/java/android/telephony/CarrierBandwidth.java @@ -0,0 +1,208 @@ +/* + * 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.telephony; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.annotation.SystemApi; +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Objects; + +/** + * Defines downlink and uplink capacity of a network in kbps + * @hide + */ +@SystemApi +public final class CarrierBandwidth implements Parcelable { + /** + * Any field that is not reported shall be set to INVALID + */ + public static final int INVALID = -1; + + /** + * Estimated downlink capacity in kbps of the primary carrier. + * This bandwidth estimate shall be the estimated maximum sustainable link bandwidth. + * This will be {@link #INVALID} if the network is not connected + */ + private int mPrimaryDownlinkCapacityKbps; + + /** + * Estimated uplink capacity in kbps of the primary carrier. + * This bandwidth estimate shall be the estimated maximum sustainable link bandwidth. + * This will be {@link #INVALID} if the network is not connected + */ + private int mPrimaryUplinkCapacityKbps; + + /** + * Estimated downlink capacity in kbps of the secondary carrier in a dual connected network. + * This bandwidth estimate shall be the estimated maximum sustainable link bandwidth. + * This will be {@link #INVALID} if the network is not connected + */ + private int mSecondaryDownlinkCapacityKbps; + + /** + * Estimated uplink capacity in kbps of the secondary carrier in a dual connected network. + * This bandwidth estimate shall be the estimated maximum sustainable link bandwidth. + * This will be {@link #INVALID} if the network is not connected + */ + private int mSecondaryUplinkCapacityKbps; + + /** @hide **/ + public CarrierBandwidth(Parcel in) { + mPrimaryDownlinkCapacityKbps = in.readInt(); + mPrimaryUplinkCapacityKbps = in.readInt(); + mSecondaryDownlinkCapacityKbps = in.readInt(); + mSecondaryUplinkCapacityKbps = in.readInt(); + } + + /** @hide **/ + public CarrierBandwidth() { + mPrimaryDownlinkCapacityKbps = INVALID; + mPrimaryUplinkCapacityKbps = INVALID; + mSecondaryDownlinkCapacityKbps = INVALID; + mSecondaryUplinkCapacityKbps = INVALID; + } + + /** + * Constructor. + * + * @param primaryDownlinkCapacityKbps Estimated downlink capacity in kbps of + * the primary carrier. + * @param primaryUplinkCapacityKbps Estimated uplink capacity in kbps of + * the primary carrier. + * @param secondaryDownlinkCapacityKbps Estimated downlink capacity in kbps of + * the secondary carrier + * @param secondaryUplinkCapacityKbps Estimated uplink capacity in kbps of + * the secondary carrier + */ + public CarrierBandwidth(int primaryDownlinkCapacityKbps, int primaryUplinkCapacityKbps, + int secondaryDownlinkCapacityKbps, int secondaryUplinkCapacityKbps) { + mPrimaryDownlinkCapacityKbps = primaryDownlinkCapacityKbps; + mPrimaryUplinkCapacityKbps = primaryUplinkCapacityKbps; + mSecondaryDownlinkCapacityKbps = secondaryDownlinkCapacityKbps; + mSecondaryUplinkCapacityKbps = secondaryUplinkCapacityKbps; + } + + /** + * Retrieves the upstream bandwidth for the primary network in Kbps. This always only refers to + * the estimated first hop transport bandwidth. + * This will be INVALID if the network is not connected + * + * @return The estimated first hop upstream (device to network) bandwidth. + */ + public int getPrimaryDownlinkCapacityKbps() { + return mPrimaryDownlinkCapacityKbps; + } + + /** + * Retrieves the downstream bandwidth for the primary network in Kbps. This always only refers + * to the estimated first hop transport bandwidth. + * This will be INVALID if the network is not connected + * + * @return The estimated first hop downstream (network to device) bandwidth. + */ + public int getPrimaryUplinkCapacityKbps() { + return mPrimaryUplinkCapacityKbps; + } + + /** + * Retrieves the upstream bandwidth for the secondary network in Kbps. This always only refers + * to the estimated first hop transport bandwidth. + * This will be INVALID if the network is not connected + * + * @return The estimated first hop upstream (device to network) bandwidth. + */ + public int getSecondaryDownlinkCapacityKbps() { + return mSecondaryDownlinkCapacityKbps; + } + + /** + * Retrieves the downstream bandwidth for the secondary network in Kbps. This always only + * refers to the estimated first hop transport bandwidth. + * This will be INVALID if the network is not connected + * + * @return The estimated first hop downstream (network to device) bandwidth. + */ + public int getSecondaryUplinkCapacityKbps() { + return mSecondaryUplinkCapacityKbps; + } + + @NonNull + @Override + public String toString() { + return "CarrierBandwidth: {primaryDownlinkCapacityKbps=" + mPrimaryDownlinkCapacityKbps + + " primaryUplinkCapacityKbps=" + mPrimaryUplinkCapacityKbps + + " secondaryDownlinkCapacityKbps=" + mSecondaryDownlinkCapacityKbps + + " secondaryUplinkCapacityKbps=" + mSecondaryUplinkCapacityKbps + + "}"; + } + + @Override + public int hashCode() { + return Objects.hash( + mPrimaryDownlinkCapacityKbps, + mPrimaryUplinkCapacityKbps, + mSecondaryDownlinkCapacityKbps, + mSecondaryUplinkCapacityKbps); + } + + @Override + public boolean equals(@Nullable Object o) { + if (o == null || !(o instanceof CallQuality) || hashCode() != o.hashCode()) { + return false; + } + if (this == o) { + return true; + } + CarrierBandwidth s = (CarrierBandwidth) o; + return (mPrimaryDownlinkCapacityKbps == s.mPrimaryDownlinkCapacityKbps + && mPrimaryUplinkCapacityKbps == s.mPrimaryUplinkCapacityKbps + && mSecondaryDownlinkCapacityKbps == s.mSecondaryDownlinkCapacityKbps + && mSecondaryDownlinkCapacityKbps == s.mSecondaryDownlinkCapacityKbps); + } + + /** + * {@link Parcelable#describeContents} + */ + public int describeContents() { + return 0; + } + + /** + * {@link Parcelable#writeToParcel} + * @hide + */ + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mPrimaryDownlinkCapacityKbps); + dest.writeInt(mPrimaryUplinkCapacityKbps); + dest.writeInt(mSecondaryDownlinkCapacityKbps); + dest.writeInt(mSecondaryUplinkCapacityKbps); + } + + public static final @android.annotation.NonNull Parcelable.Creator<CarrierBandwidth> CREATOR = + new Parcelable.Creator() { + public CarrierBandwidth createFromParcel(Parcel in) { + return new CarrierBandwidth(in); + } + + public CarrierBandwidth[] newArray(int size) { + return new CarrierBandwidth[size]; + } + }; +} diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 88aec5184548..27aadd56dac5 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -13440,6 +13440,33 @@ public class TelephonyManager { } /** + * Get carrier bandwidth. In case of Dual connected network this will report + * bandwidth per primary and secondary network. + * @return CarrierBandwidth with bandwidth of both primary and secondary carrier. + * @throws IllegalStateException if the Telephony process is not currently available. + * @hide + */ + @SystemApi + @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) + @NonNull + public CarrierBandwidth getCarrierBandwidth() { + try { + ITelephony service = getITelephony(); + if (service != null) { + return service.getCarrierBandwidth(getSubId()); + } else { + throw new IllegalStateException("telephony service is null."); + } + } catch (RemoteException ex) { + Log.e(TAG, "getCarrierBandwidth RemoteException", ex); + ex.rethrowFromSystemServer(); + } + + //Should not reach. Adding return statement to make compiler happy + return null; + } + + /** * Called when userActivity is signalled in the power manager. * This should only be called from system Uid. * @hide diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 36d01f459fb8..d16cb16a290c 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -31,6 +31,7 @@ import android.service.carrier.CarrierIdentifier; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.CallForwardingInfo; +import android.telephony.CarrierBandwidth; import android.telephony.CarrierRestrictionRules; import android.telephony.CellIdentity; import android.telephony.CellInfo; @@ -2232,4 +2233,10 @@ interface ITelephony { * @return true if dual connectivity is enabled else false */ boolean isNrDualConnectivityEnabled(int subId); + + /** + * Get carrier bandwidth per primary and secondary carrier + * @return CarrierBandwidth with bandwidth of both primary and secondary carrier. + */ + CarrierBandwidth getCarrierBandwidth(int subId); } |