diff options
| author | 2020-02-06 13:33:04 -0800 | |
|---|---|---|
| committer | 2020-02-12 20:31:22 -0800 | |
| commit | 73036c4075f5aacd73874e11ec55889ca434be8f (patch) | |
| tree | e587186c74c8de4d248382726c955d32d9da9d21 | |
| parent | 6b1b31f0cfbfc49de9dc5974e4e136728ec8b5c5 (diff) | |
Added telephony display info support
Added the new APIs allowing clients like System UI to display
network icons correctly based on the provided telephony display
info.
Test: Telephony sanity tests
Bug: 148540139
Change-Id: I4dfb6eb7a313539e0565a4239d555426f12e503e
| -rw-r--r-- | api/current.txt | 15 | ||||
| -rwxr-xr-x | api/system-current.txt | 1 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/telephony/PhoneStateListener.java | 31 | ||||
| -rw-r--r-- | core/java/android/telephony/TelephonyRegistryManager.java | 18 | ||||
| -rw-r--r-- | core/java/com/android/internal/telephony/IPhoneStateListener.aidl | 2 | ||||
| -rw-r--r-- | core/java/com/android/internal/telephony/ITelephonyRegistry.aidl | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/TelephonyRegistry.java | 72 | ||||
| -rw-r--r-- | telephony/java/android/telephony/Annotation.java | 12 | ||||
| -rw-r--r-- | telephony/java/android/telephony/DisplayInfo.aidl | 18 | ||||
| -rw-r--r-- | telephony/java/android/telephony/DisplayInfo.java | 172 |
11 files changed, 343 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index 475506a317bc..71866f575f01 100644 --- a/api/current.txt +++ b/api/current.txt @@ -47051,6 +47051,19 @@ package android.telephony { field @NonNull public static final android.os.Parcelable.Creator<android.telephony.ClosedSubscriberGroupInfo> CREATOR; } + public final class DisplayInfo implements android.os.Parcelable { + method public int describeContents(); + method public int getNetworkType(); + method public int getOverrideNetworkType(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator<android.telephony.DisplayInfo> CREATOR; + field public static final int OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = 2; // 0x2 + field public static final int OVERRIDE_NETWORK_TYPE_LTE_CA = 1; // 0x1 + field public static final int OVERRIDE_NETWORK_TYPE_NONE = 0; // 0x0 + field public static final int OVERRIDE_NETWORK_TYPE_NR_NSA = 3; // 0x3 + field public static final int OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE = 4; // 0x4 + } + public class IccOpenLogicalChannelResponse implements android.os.Parcelable { method public int describeContents(); method public int getChannel(); @@ -47307,6 +47320,7 @@ package android.telephony { method public void onDataActivity(int); method public void onDataConnectionStateChanged(int); method public void onDataConnectionStateChanged(int, int); + method @RequiresPermission("android.permission.READ_PHONE_STATE") public void onDisplayInfoChanged(@NonNull android.telephony.DisplayInfo); method @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public void onImsCallDisconnectCauseChanged(@NonNull android.telephony.ims.ImsReasonInfo); method public void onMessageWaitingIndicatorChanged(boolean); method @RequiresPermission("android.permission.MODIFY_PHONE_STATE") public void onPreciseDataConnectionStateChanged(@NonNull android.telephony.PreciseDataConnectionState); @@ -47324,6 +47338,7 @@ package android.telephony { field public static final int LISTEN_CELL_LOCATION = 16; // 0x10 field public static final int LISTEN_DATA_ACTIVITY = 128; // 0x80 field public static final int LISTEN_DATA_CONNECTION_STATE = 64; // 0x40 + field public static final int LISTEN_DISPLAY_INFO_CHANGED = 1048576; // 0x100000 field public static final int LISTEN_EMERGENCY_NUMBER_LIST = 16777216; // 0x1000000 field @RequiresPermission("android.permission.READ_PRECISE_PHONE_STATE") public static final int LISTEN_IMS_CALL_DISCONNECT_CAUSES = 134217728; // 0x8000000 field public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 4; // 0x4 diff --git a/api/system-current.txt b/api/system-current.txt index 97b31516f7c0..666dd92b74b3 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -12584,6 +12584,7 @@ package android.telephony { method public void notifyDataActivityChanged(int, int); method public void notifyDataConnectionForSubscriber(int, int, int, @Nullable android.telephony.PreciseDataConnectionState); method public void notifyDisconnectCause(int, int, int, int); + method public void notifyDisplayInfoChanged(int, int, @NonNull android.telephony.DisplayInfo); method public void notifyEmergencyNumberList(int, int); method public void notifyImsDisconnectCause(int, @NonNull android.telephony.ims.ImsReasonInfo); method public void notifyMessageWaitingChanged(int, int, boolean); diff --git a/api/test-current.txt b/api/test-current.txt index 8598c167cab0..b2b4fcf6bcf8 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3709,6 +3709,7 @@ package android.telephony { method public void notifyDataActivityChanged(int, int); method public void notifyDataConnectionForSubscriber(int, int, int, @Nullable android.telephony.PreciseDataConnectionState); method public void notifyDisconnectCause(int, int, int, int); + method public void notifyDisplayInfoChanged(int, int, @NonNull android.telephony.DisplayInfo); method public void notifyEmergencyNumberList(int, int); method public void notifyImsDisconnectCause(int, @NonNull android.telephony.ims.ImsReasonInfo); method public void notifyMessageWaitingChanged(int, int, boolean); diff --git a/core/java/android/telephony/PhoneStateListener.java b/core/java/android/telephony/PhoneStateListener.java index e65bd9f20ec4..d2735008611c 100644 --- a/core/java/android/telephony/PhoneStateListener.java +++ b/core/java/android/telephony/PhoneStateListener.java @@ -301,6 +301,13 @@ public class PhoneStateListener { public static final int LISTEN_USER_MOBILE_DATA_STATE = 0x00080000; /** + * Listen for display info changed event. + * + * @see #onDisplayInfoChanged + */ + public static final int LISTEN_DISPLAY_INFO_CHANGED = 0x00100000; + + /** * Listen for changes to the phone capability. * * @see #onPhoneCapabilityChanged @@ -848,6 +855,21 @@ public class PhoneStateListener { } /** + * Callback invoked when the display info has changed on the registered subscription. + * <p> The {@link DisplayInfo} contains status information shown to the user based on + * carrier policy. + * + * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling + * app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). + * + * @param displayInfo The display information. + */ + @RequiresPermission((android.Manifest.permission.READ_PHONE_STATE)) + public void onDisplayInfoChanged(@NonNull DisplayInfo displayInfo) { + // default implementation empty + } + + /** * Callback invoked when the current emergency number list has changed on the registered * subscription. * Note, the registration subId comes from {@link TelephonyManager} object which registers @@ -1226,6 +1248,15 @@ public class PhoneStateListener { () -> psl.onUserMobileDataStateChanged(enabled))); } + public void onDisplayInfoChanged(DisplayInfo displayInfo) { + PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); + if (psl == null) return; + + Binder.withCleanCallingIdentity( + () -> mExecutor.execute( + () -> psl.onDisplayInfoChanged(displayInfo))); + } + public void onOemHookRawEvent(byte[] rawData) { PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); if (psl == null) return; diff --git a/core/java/android/telephony/TelephonyRegistryManager.java b/core/java/android/telephony/TelephonyRegistryManager.java index 4024db1e16c4..2c077bbdc772 100644 --- a/core/java/android/telephony/TelephonyRegistryManager.java +++ b/core/java/android/telephony/TelephonyRegistryManager.java @@ -589,6 +589,24 @@ public class TelephonyRegistryManager { } /** + * Notify display info changed. + * + * @param slotIndex The SIM slot index for which display info has changed. Can be + * derived from {@code subscriptionId} except when {@code subscriptionId} is invalid, such as + * when the device is in emergency-only mode. + * @param subscriptionId Subscription id for which display network info has changed. + * @param displayInfo The display info. + */ + public void notifyDisplayInfoChanged(int slotIndex, int subscriptionId, + @NonNull DisplayInfo displayInfo) { + try { + sRegistry.notifyDisplayInfoChanged(slotIndex, subscriptionId, displayInfo); + } catch (RemoteException ex) { + // system process is dead + } + } + + /** * Notify IMS call disconnect causes which contains {@link android.telephony.ims.ImsReasonInfo}. * * @param subId for which ims call disconnect. diff --git a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl index 0f50596f935d..3d5dfbbb871a 100644 --- a/core/java/com/android/internal/telephony/IPhoneStateListener.aidl +++ b/core/java/com/android/internal/telephony/IPhoneStateListener.aidl @@ -21,6 +21,7 @@ import android.telephony.CallAttributes; import android.telephony.CellIdentity; import android.telephony.CellInfo; import android.telephony.DataConnectionRealTimeInfo; +import android.telephony.DisplayInfo; import android.telephony.PhoneCapability; import android.telephony.PreciseCallState; import android.telephony.PreciseDataConnectionState; @@ -54,6 +55,7 @@ oneway interface IPhoneStateListener { void onOemHookRawEvent(in byte[] rawData); void onCarrierNetworkChange(in boolean active); void onUserMobileDataStateChanged(in boolean enabled); + void onDisplayInfoChanged(in DisplayInfo displayInfo); void onPhoneCapabilityChanged(in PhoneCapability capability); void onActiveDataSubIdChanged(in int subId); void onRadioPowerStateChanged(in int state); diff --git a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl index 47752c5b2d94..520ffc9584e2 100644 --- a/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl +++ b/core/java/com/android/internal/telephony/ITelephonyRegistry.aidl @@ -23,6 +23,7 @@ import android.telephony.BarringInfo; import android.telephony.CallQuality; import android.telephony.CellIdentity; import android.telephony.CellInfo; +import android.telephony.DisplayInfo; import android.telephony.ims.ImsReasonInfo; import android.telephony.PhoneCapability; import android.telephony.PhysicalChannelConfig; @@ -87,6 +88,7 @@ interface ITelephonyRegistry { void notifyOpportunisticSubscriptionInfoChanged(); void notifyCarrierNetworkChange(in boolean active); void notifyUserMobileDataStateChangedForPhoneId(in int phoneId, in int subId, in boolean state); + void notifyDisplayInfoChanged(int slotIndex, int subId, in DisplayInfo displayInfo); void notifyPhoneCapabilityChanged(in PhoneCapability capability); void notifyActiveDataSubIdChanged(int activeDataSubId); void notifyRadioPowerStateChanged(in int phoneId, in int subId, in int state); diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java index 0e5a6bb8bd1c..f85fc284330c 100644 --- a/services/core/java/com/android/server/TelephonyRegistry.java +++ b/services/core/java/com/android/server/TelephonyRegistry.java @@ -61,6 +61,7 @@ import android.telephony.CellSignalStrengthTdscdma; import android.telephony.CellSignalStrengthWcdma; import android.telephony.DataFailCause; import android.telephony.DisconnectCause; +import android.telephony.DisplayInfo; import android.telephony.LocationAccessPolicy; import android.telephony.PhoneCapability; import android.telephony.PhoneStateListener; @@ -205,6 +206,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { private boolean[] mUserMobileDataState; + private DisplayInfo[] mDisplayInfos; + private SignalStrength[] mSignalStrength; private boolean[] mMessageWaiting; @@ -284,7 +287,8 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { static final int ENFORCE_PHONE_STATE_PERMISSION_MASK = PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR - | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST; + | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST + | PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED; static final int ENFORCE_PRECISE_PHONE_STATE_PERMISSION_MASK = PhoneStateListener.LISTEN_PRECISE_CALL_STATE @@ -443,6 +447,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mCallAttributes = copyOf(mCallAttributes, mNumPhones); mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones); mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones); + mDisplayInfos = copyOf(mDisplayInfos, mNumPhones); // ds -> ss switch. if (mNumPhones < oldNumPhones) { @@ -482,6 +487,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; mPreciseDataConnectionStates.add(new HashMap<Integer, PreciseDataConnectionState>()); mBarringInfo.add(i, new BarringInfo()); + mDisplayInfos[i] = null; } } @@ -540,6 +546,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mOutgoingCallEmergencyNumber = new EmergencyNumber[numPhones]; mOutgoingSmsEmergencyNumber = new EmergencyNumber[numPhones]; mBarringInfo = new ArrayList<>(); + mDisplayInfos = new DisplayInfo[numPhones]; for (int i = 0; i < numPhones; i++) { mCallState[i] = TelephonyManager.CALL_STATE_IDLE; mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; @@ -568,6 +575,7 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; mPreciseDataConnectionStates.add(new HashMap<Integer, PreciseDataConnectionState>()); mBarringInfo.add(i, new BarringInfo()); + mDisplayInfos[i] = null; } mAppOps = mContext.getSystemService(AppOpsManager.class); @@ -978,6 +986,15 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { remove(r.binder); } } + if ((events & PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) != 0) { + try { + if (mDisplayInfos[phoneId] != null) { + r.callback.onDisplayInfoChanged(mDisplayInfos[phoneId]); + } + } catch (RemoteException ex) { + remove(r.binder); + } + } if ((events & PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) != 0) { try { r.callback.onEmergencyNumberListChanged(mEmergencyNumberList); @@ -1501,6 +1518,45 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + /** + * Notify display network info changed. + * + * @param phoneId Phone id + * @param subId Subscription id + * @param displayInfo Display network info + * + * @see PhoneStateListener#onDisplayInfoChanged(DisplayInfo) + */ + public void notifyDisplayInfoChanged(int phoneId, int subId, + @NonNull DisplayInfo displayInfo) { + if (!checkNotifyPermission("notifyDisplayInfoChanged()")) { + return; + } + if (VDBG) { + log("notifyDisplayInfoChanged: PhoneId=" + phoneId + + " subId=" + subId + " displayInfo=" + displayInfo); + } + synchronized (mRecords) { + if (validatePhoneId(phoneId)) { + if (mDisplayInfos[phoneId] != null) { + mDisplayInfos[phoneId] = displayInfo; + for (Record r : mRecords) { + if (r.matchPhoneStateListenerEvent( + PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) + && idMatch(r.subId, subId, phoneId)) { + try { + r.callback.onDisplayInfoChanged(displayInfo); + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } + } + } + } + handleRemoveListLocked(); + } + } + public void notifyCallForwardingChanged(boolean cfi) { notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi); } @@ -2730,6 +2786,20 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub { } } + if ((events & PhoneStateListener.LISTEN_DISPLAY_INFO_CHANGED) != 0) { + try { + if (VDBG) { + log("checkPossibleMissNotify: onDisplayInfoChanged phoneId=" + + phoneId + " dpi=" + mDisplayInfos[phoneId]); + } + if (mDisplayInfos[phoneId] != null) { + r.callback.onDisplayInfoChanged(mDisplayInfos[phoneId]); + } + } catch (RemoteException ex) { + mRemoveList.add(r.binder); + } + } + if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { try { if (VDBG) { diff --git a/telephony/java/android/telephony/Annotation.java b/telephony/java/android/telephony/Annotation.java index d2a5905f7a99..a27c4802c306 100644 --- a/telephony/java/android/telephony/Annotation.java +++ b/telephony/java/android/telephony/Annotation.java @@ -661,4 +661,16 @@ public class Annotation { }) @Retention(RetentionPolicy.SOURCE) public @interface Skip464XlatStatus {} + + /** + * Override network type + */ + @Retention(RetentionPolicy.SOURCE) + @IntDef(prefix = "OVERRIDE_NETWORK_TYPE_", value = { + DisplayInfo.OVERRIDE_NETWORK_TYPE_NONE, + DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_CA, + DisplayInfo.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO, + DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA, + DisplayInfo.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE}) + public @interface OverrideNetworkType {} } diff --git a/telephony/java/android/telephony/DisplayInfo.aidl b/telephony/java/android/telephony/DisplayInfo.aidl new file mode 100644 index 000000000000..861b0fe04848 --- /dev/null +++ b/telephony/java/android/telephony/DisplayInfo.aidl @@ -0,0 +1,18 @@ +/* + * 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; + +parcelable DisplayInfo; diff --git a/telephony/java/android/telephony/DisplayInfo.java b/telephony/java/android/telephony/DisplayInfo.java new file mode 100644 index 000000000000..d54bcf931c33 --- /dev/null +++ b/telephony/java/android/telephony/DisplayInfo.java @@ -0,0 +1,172 @@ +/* + * 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; + +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; +import android.telephony.Annotation.NetworkType; +import android.telephony.Annotation.OverrideNetworkType; + +import java.util.Objects; + +/** + * DisplayInfo contains telephony-related information used for display purposes only. This + * information is provided in accordance with carrier policy and branding preferences; it is not + * necessarily a precise or accurate representation of the current state and should be treated + * accordingly. + */ +public final class DisplayInfo implements Parcelable { + /** + * No override. {@link #getNetworkType()} should be used for display network + * type. + */ + public static final int OVERRIDE_NETWORK_TYPE_NONE = 0; + + /** + * Override network type when the device is connected to + * {@link TelephonyManager#NETWORK_TYPE_LTE} cellular network and is using carrier aggregation. + */ + public static final int OVERRIDE_NETWORK_TYPE_LTE_CA = 1; + + /** + * Override network type when the device is connected to advanced pro + * {@link TelephonyManager#NETWORK_TYPE_LTE} cellular network. + */ + public static final int OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO = 2; + + /** + * Override network type when the device is connected to + * {@link TelephonyManager#NETWORK_TYPE_LTE} network and has E-UTRA-NR Dual Connectivity(EN-DC) + * capability or is currently connected to the secondary + * {@link TelephonyManager#NETWORK_TYPE_NR} cellular network. + */ + public static final int OVERRIDE_NETWORK_TYPE_NR_NSA = 3; + + /** + * Override network type when the device is connected to + * {@link TelephonyManager#NETWORK_TYPE_LTE} network and has E-UTRA-NR Dual Connectivity(EN-DC) + * capability or is currently connected to the secondary + * {@link TelephonyManager#NETWORK_TYPE_NR} cellular network on millimeter wave bands. + * + * @see AccessNetworkConstants.NgranBands#FREQUENCY_RANGE_GROUP_2 + */ + public static final int OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE = 4; + + @NetworkType + private final int mNetworkType; + + @OverrideNetworkType + private final int mOverrideNetworkType; + + /** + * Constructor + * + * @param networkType Current packet-switching cellular network type + * @param overrideNetworkType The override network type + * + * @hide + */ + public DisplayInfo(@NetworkType int networkType, @OverrideNetworkType int overrideNetworkType) { + mNetworkType = networkType; + mOverrideNetworkType = overrideNetworkType; + } + + /** @hide */ + public DisplayInfo(Parcel p) { + mNetworkType = p.readInt(); + mOverrideNetworkType = p.readInt(); + } + + /** + * Get current packet-switching cellular network type. This is the actual network type the + * device is camped on. + * + * @return The network type. + */ + @NetworkType + public int getNetworkType() { + return mNetworkType; + } + + /** + * Get the override network type. Note the override network type is for market branding + * or visualization purposes only. It cannot be treated as the actual network type device is + * camped on. + * + * @return The override network type. + */ + @OverrideNetworkType + public int getOverrideNetworkType() { + return mOverrideNetworkType; + } + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + dest.writeInt(mNetworkType); + dest.writeInt(mOverrideNetworkType); + } + + public static final @NonNull Parcelable.Creator<DisplayInfo> CREATOR = + new Parcelable.Creator<DisplayInfo>() { + @Override + public DisplayInfo createFromParcel(Parcel source) { + return new DisplayInfo(source); + } + + @Override + public DisplayInfo[] newArray(int size) { + return new DisplayInfo[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DisplayInfo that = (DisplayInfo) o; + return mNetworkType == that.mNetworkType + && mOverrideNetworkType == that.mOverrideNetworkType; + } + + @Override + public int hashCode() { + return Objects.hash(mNetworkType, mOverrideNetworkType); + } + + private static String overrideNetworkTypeToString(@OverrideNetworkType int type) { + switch (type) { + case OVERRIDE_NETWORK_TYPE_NONE: return "NONE"; + case OVERRIDE_NETWORK_TYPE_LTE_CA: return "LTE_CA"; + case OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO: return "LTE_ADV_PRO"; + case OVERRIDE_NETWORK_TYPE_NR_NSA: return "NR_NSA"; + case OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE: return "NR_NSA_MMWAVE"; + default: return "UNKNOWN"; + } + } + + @Override + public String toString() { + return "DisplayInfo {network=" + TelephonyManager.getNetworkTypeName(mNetworkType) + + ", override=" + overrideNetworkTypeToString(mOverrideNetworkType); + } +} |