1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.wifi; 18 19 import android.telephony.Annotation.NetworkType; 20 import android.telephony.SignalStrength; 21 import android.telephony.TelephonyManager; 22 23 /** 24 * A class representing the link layer statistics of the primary registered cell 25 * of cellular network 26 */ 27 public class CellularLinkLayerStats { 28 /** Cellular data network type currently in use on the device for data transmission */ 29 private @NetworkType int mDataNetworkType = 30 TelephonyManager.NETWORK_TYPE_UNKNOWN; 31 /** 32 * Cellular signal strength in dBm, NR: CsiRsrp, LTE: Rsrp, WCDMA/TDSCDMA: Rscp, 33 * CDMA: Rssi, EVDO: Rssi, GSM: Rssi 34 */ 35 private int mSignalStrengthDbm = SignalStrength.INVALID; 36 /** 37 * Cellular signal strength in dB, NR: CsiSinr, LTE: Rsrq, WCDMA: EcNo, TDSCDMA: invalid, 38 * CDMA: Ecio, EVDO: SNR, GSM: invalid 39 */ 40 private int mSignalStrengthDb = SignalStrength.INVALID; 41 /** Whether it is a new or old registered cell */ 42 private boolean mIsSameRegisteredCell = false; 43 setDataNetworkType(@etworkType int dataNetworkType)44 public void setDataNetworkType(@NetworkType int dataNetworkType) { 45 mDataNetworkType = dataNetworkType; 46 } 47 setSignalStrengthDbm(int signalStrengthDbm)48 public void setSignalStrengthDbm(int signalStrengthDbm) { 49 mSignalStrengthDbm = signalStrengthDbm; 50 } 51 setIsSameRegisteredCell(boolean isSameRegisteredCell)52 public void setIsSameRegisteredCell(boolean isSameRegisteredCell) { 53 mIsSameRegisteredCell = isSameRegisteredCell; 54 } 55 setSignalStrengthDb(int signalStrengthDb)56 public void setSignalStrengthDb(int signalStrengthDb) { 57 mSignalStrengthDb = signalStrengthDb; 58 } 59 getDataNetworkType()60 public @NetworkType int getDataNetworkType() { 61 return mDataNetworkType; 62 } 63 getIsSameRegisteredCell()64 public boolean getIsSameRegisteredCell() { 65 return mIsSameRegisteredCell; 66 } 67 getSignalStrengthDb()68 public int getSignalStrengthDb() { 69 return mSignalStrengthDb; 70 } 71 getSignalStrengthDbm()72 public int getSignalStrengthDbm() { 73 return mSignalStrengthDbm; 74 } 75 76 @Override toString()77 public String toString() { 78 StringBuilder sbuf = new StringBuilder(); 79 sbuf.append(" CellularLinkLayerStats: ").append('\n') 80 .append(" Data Network Type: ") 81 .append(mDataNetworkType).append('\n') 82 .append(" Signal Strength in dBm: ") 83 .append(mSignalStrengthDbm).append('\n') 84 .append(" Signal Strength in dB: ") 85 .append(mSignalStrengthDb).append('\n') 86 .append(" Is it the same registered cell? ") 87 .append(mIsSameRegisteredCell).append('\n'); 88 return sbuf.toString(); 89 } 90 } 91