Merge "Revise and update CellInfo API's"
This commit is contained in:
@@ -35,6 +35,7 @@ import android.text.TextUtils;
|
||||
import android.util.Slog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.NetworkInterface;
|
||||
@@ -109,7 +110,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
|
||||
private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN;
|
||||
|
||||
private CellInfo mCellInfo = null;
|
||||
private List<CellInfo> mCellInfo = null;
|
||||
|
||||
static final int PHONE_STATE_PERMISSION_MASK =
|
||||
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
|
||||
@@ -242,7 +243,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
}
|
||||
if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
|
||||
try {
|
||||
r.callback.onCellInfoChanged(new CellInfo(mCellInfo));
|
||||
r.callback.onCellInfoChanged(mCellInfo);
|
||||
} catch (RemoteException ex) {
|
||||
remove(r.binder);
|
||||
}
|
||||
@@ -336,7 +337,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
broadcastSignalStrengthChanged(signalStrength);
|
||||
}
|
||||
|
||||
public void notifyCellInfo(CellInfo cellInfo) {
|
||||
public void notifyCellInfo(List<CellInfo> cellInfo) {
|
||||
if (!checkNotifyPermission("notifyCellInfo()")) {
|
||||
return;
|
||||
}
|
||||
@@ -346,7 +347,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
|
||||
for (Record r : mRecords) {
|
||||
if ((r.events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
|
||||
try {
|
||||
r.callback.onCellInfoChanged(new CellInfo(cellInfo));
|
||||
r.callback.onCellInfoChanged(cellInfo);
|
||||
} catch (RemoteException ex) {
|
||||
mRemoveList.add(r.binder);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2012 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.
|
||||
@@ -20,70 +20,79 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* CellIdentity is to represent ONE unique cell in the world
|
||||
* CellIdentity is immutable and represents ONE unique cell in the world
|
||||
* it contains all levels of info to identity country, carrier, etc.
|
||||
*
|
||||
* @hide pending API review
|
||||
* @hide
|
||||
*/
|
||||
public abstract class CellIdentity implements Parcelable {
|
||||
|
||||
// Cell is a GSM Cell {@link GsmCellIdentity}
|
||||
public static final int CELLID_TYPE_GSM = 1;
|
||||
// Cell is a CMDA Cell {@link CdmaCellIdentity}
|
||||
public static final int CELLID_TYPE_CDMA = 2;
|
||||
// Cell is a LTE Cell {@link LteCellIdentity}
|
||||
public static final int CELLID_TYPE_LTE = 3;
|
||||
// Type fields for parceling
|
||||
protected static final int TYPE_GSM = 1;
|
||||
protected static final int TYPE_CDMA = 2;
|
||||
protected static final int TYPE_LTE = 3;
|
||||
|
||||
private int mCellIdType;
|
||||
private String mCellIdAttributes;
|
||||
|
||||
protected CellIdentity(int type, String attr) {
|
||||
this.mCellIdType = type;
|
||||
this.mCellIdAttributes = new String(attr);
|
||||
protected CellIdentity() {
|
||||
}
|
||||
|
||||
protected CellIdentity(Parcel in) {
|
||||
this.mCellIdType = in.readInt();
|
||||
this.mCellIdAttributes = new String(in.readString());
|
||||
}
|
||||
|
||||
protected CellIdentity(CellIdentity cid) {
|
||||
this.mCellIdType = cid.mCellIdType;
|
||||
this.mCellIdAttributes = new String(cid.mCellIdAttributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Cell Identity type as one of CELLID_TYPE_XXXX
|
||||
* @return a copy of this object with package visibility.
|
||||
*/
|
||||
public int getCellIdType() {
|
||||
return mCellIdType;
|
||||
abstract CellIdentity copy();
|
||||
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
return (other instanceof CellIdentity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Cell identity attribute pairs
|
||||
* Comma separated “key=value” pairs.
|
||||
* key := must must an single alpha-numeric word
|
||||
* value := “quoted value string”
|
||||
*
|
||||
* Current list of keys and values:
|
||||
* type = fixed | mobile
|
||||
*/
|
||||
public String getCellIdAttributes() {
|
||||
return mCellIdAttributes;
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mCellIdType);
|
||||
dest.writeString(mCellIdAttributes);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellIdentity> CREATOR =
|
||||
new Creator<CellIdentity>() {
|
||||
@Override
|
||||
public CellIdentity createFromParcel(Parcel in) {
|
||||
int type = in.readInt();
|
||||
switch (type) {
|
||||
case TYPE_GSM: return CellIdentityGsm.createFromParcelBody(in);
|
||||
case TYPE_CDMA: return CellIdentityCdma.createFromParcelBody(in);
|
||||
case TYPE_LTE: return CellIdentityLte.createFromParcelBody(in);
|
||||
default: throw new RuntimeException("Bad CellIdentity Parcel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellIdentity[] newArray(int size) {
|
||||
return new CellIdentity[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2012 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.
|
||||
@@ -18,13 +18,18 @@ package android.telephony;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* CellIdentity is to represent a unique CDMA cell
|
||||
*
|
||||
* @hide pending API review
|
||||
* @hide
|
||||
*/
|
||||
public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
public final class CellIdentityCdma extends CellIdentity implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellSignalStrengthCdma";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
// Network Id 0..65535
|
||||
private final int mNetworkId;
|
||||
// CDMA System Id 0..32767
|
||||
@@ -46,6 +51,17 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
*/
|
||||
private final int mLatitude;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityCdma() {
|
||||
mNetworkId = Integer.MAX_VALUE;
|
||||
mSystemId = Integer.MAX_VALUE;
|
||||
mBasestationId = Integer.MAX_VALUE;
|
||||
mLongitude = Integer.MAX_VALUE;
|
||||
mLatitude = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* public constructor
|
||||
* @param nid Network Id 0..65535
|
||||
@@ -55,11 +71,10 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
* to 2592000
|
||||
* @param lat Latitude is a decimal number ranges from -1296000
|
||||
* to 1296000
|
||||
* @param attr is comma separated “key=value” attribute pairs.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CdmaCellIdentity (int nid, int sid,
|
||||
int bid, int lon, int lat, String attr) {
|
||||
super(CELLID_TYPE_CDMA, attr);
|
||||
public CellIdentityCdma (int nid, int sid, int bid, int lon, int lat) {
|
||||
mNetworkId = nid;
|
||||
mSystemId = sid;
|
||||
mBasestationId = bid;
|
||||
@@ -67,16 +82,7 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
mLatitude = lat;
|
||||
}
|
||||
|
||||
private CdmaCellIdentity(Parcel in) {
|
||||
super(in);
|
||||
mNetworkId = in.readInt();
|
||||
mSystemId = in.readInt();
|
||||
mBasestationId = in.readInt();
|
||||
mLongitude = in.readInt();
|
||||
mLatitude = in.readInt();
|
||||
}
|
||||
|
||||
CdmaCellIdentity(CdmaCellIdentity cid) {
|
||||
private CellIdentityCdma(CellIdentityCdma cid) {
|
||||
super(cid);
|
||||
mNetworkId = cid.mNetworkId;
|
||||
mSystemId = cid.mSystemId;
|
||||
@@ -85,6 +91,11 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
mLatitude = cid.mLatitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
CellIdentityCdma copy() {
|
||||
return new CellIdentityCdma(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Network Id 0..65535
|
||||
*/
|
||||
@@ -117,9 +128,6 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
return mLongitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Base station
|
||||
*/
|
||||
/**
|
||||
* @return Base station latitude, which is a decimal number as
|
||||
* specified in 3GPP2 C.S0005-A v6.0. It is represented in units
|
||||
@@ -131,15 +139,55 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
return mLatitude;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mNetworkId * primeNum) + (mSystemId * primeNum) + (mBasestationId * primeNum) +
|
||||
(mLatitude * primeNum) + (mLongitude * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (super.equals(other)) {
|
||||
try {
|
||||
CellIdentityCdma o = (CellIdentityCdma)other;
|
||||
return mNetworkId == o.mNetworkId &&
|
||||
mSystemId == o.mSystemId &&
|
||||
mBasestationId == o.mBasestationId &&
|
||||
mLatitude == o.mLatitude &&
|
||||
mLongitude == o.mLongitude;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("CdmaCellIdentitiy:");
|
||||
sb.append(super.toString());
|
||||
sb.append(" mNetworkId="); sb.append(mNetworkId);
|
||||
sb.append(" mSystemId="); sb.append(mSystemId);
|
||||
sb.append(" mBasestationId="); sb.append(mBasestationId);
|
||||
sb.append(" mLongitude="); sb.append(mLongitude);
|
||||
sb.append(" mLatitude="); sb.append(mLatitude);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(TYPE_CDMA);
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(mNetworkId);
|
||||
dest.writeInt(mSystemId);
|
||||
@@ -148,17 +196,42 @@ public final class CdmaCellIdentity extends CellIdentity implements Parcelable {
|
||||
dest.writeInt(mLatitude);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
public static final Creator<CdmaCellIdentity> CREATOR =
|
||||
new Creator<CdmaCellIdentity>() {
|
||||
/** Construct from Parcel, type has already been processed */
|
||||
private CellIdentityCdma(Parcel in) {
|
||||
super(in);
|
||||
mNetworkId = in.readInt();
|
||||
mSystemId = in.readInt();
|
||||
mBasestationId = in.readInt();
|
||||
mLongitude = in.readInt();
|
||||
mLatitude = in.readInt();
|
||||
if (DBG) log("CellIdentityCdma(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Creator<CellIdentityCdma> CREATOR =
|
||||
new Creator<CellIdentityCdma>() {
|
||||
@Override
|
||||
public CdmaCellIdentity createFromParcel(Parcel in) {
|
||||
return new CdmaCellIdentity(in);
|
||||
public CellIdentityCdma createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CdmaCellIdentity[] newArray(int size) {
|
||||
return new CdmaCellIdentity[size];
|
||||
public CellIdentityCdma[] newArray(int size) {
|
||||
return new CellIdentityCdma[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
static CellIdentityCdma createFromParcelBody(Parcel in) {
|
||||
return new CellIdentityCdma(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2012 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.
|
||||
@@ -18,13 +18,17 @@ package android.telephony;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* CellIdentity to represent a unique GSM or UMTS cell
|
||||
*
|
||||
* @hide pending API review
|
||||
* @hide
|
||||
*/
|
||||
public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
public final class CellIdentityGsm extends CellIdentity implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellIdentityGsm";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
// 3-digit Mobile Country Code, 0..999
|
||||
private final int mMcc;
|
||||
@@ -38,6 +42,16 @@ public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
// 9-bit UMTS Primary Scrambling Code described in TS 25.331, 0..511
|
||||
private final int mPsc;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityGsm() {
|
||||
mMcc = Integer.MAX_VALUE;
|
||||
mMnc = Integer.MAX_VALUE;
|
||||
mLac = Integer.MAX_VALUE;
|
||||
mCid = Integer.MAX_VALUE;
|
||||
mPsc = Integer.MAX_VALUE;
|
||||
}
|
||||
/**
|
||||
* public constructor
|
||||
* @param mcc 3-digit Mobile Country Code, 0..999
|
||||
@@ -45,11 +59,10 @@ public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
* @param lac 16-bit Location Area Code, 0..65535
|
||||
* @param cid 16-bit GSM Cell Identity or 28-bit UMTS Cell Identity
|
||||
* @param psc 9-bit UMTS Primary Scrambling Code
|
||||
* @param attr is comma separated “key=value” attribute pairs.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public GsmCellIdentity (int mcc, int mnc,
|
||||
int lac, int cid, int psc, String attr) {
|
||||
super(CELLID_TYPE_GSM, attr);
|
||||
public CellIdentityGsm (int mcc, int mnc, int lac, int cid, int psc) {
|
||||
mMcc = mcc;
|
||||
mMnc = mnc;
|
||||
mLac = lac;
|
||||
@@ -57,16 +70,7 @@ public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
mPsc = psc;
|
||||
}
|
||||
|
||||
private GsmCellIdentity(Parcel in) {
|
||||
super(in);
|
||||
mMcc = in.readInt();
|
||||
mMnc = in.readInt();
|
||||
mLac = in.readInt();
|
||||
mCid = in.readInt();
|
||||
mPsc = in.readInt();
|
||||
}
|
||||
|
||||
GsmCellIdentity(GsmCellIdentity cid) {
|
||||
private CellIdentityGsm(CellIdentityGsm cid) {
|
||||
super(cid);
|
||||
mMcc = cid.mMcc;
|
||||
mMnc = cid.mMnc;
|
||||
@@ -75,6 +79,11 @@ public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
mPsc = cid.mPsc;
|
||||
}
|
||||
|
||||
@Override
|
||||
CellIdentityGsm copy() {
|
||||
return new CellIdentityGsm(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 3-digit Mobile Country Code, 0..999
|
||||
*/
|
||||
@@ -115,15 +124,55 @@ public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
return mPsc;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mMcc * primeNum) + (mMnc * primeNum) + (mLac * primeNum) + (mCid * primeNum) +
|
||||
(mPsc * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (super.equals(other)) {
|
||||
try {
|
||||
CellIdentityGsm o = (CellIdentityGsm)other;
|
||||
return mMcc == o.mMcc &&
|
||||
mMnc == o.mMnc &&
|
||||
mLac == o.mLac &&
|
||||
mCid == o.mCid &&
|
||||
mPsc == o.mPsc;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("GsmCellIdentitiy:");
|
||||
sb.append(super.toString());
|
||||
sb.append(" mMcc=").append(mMcc);
|
||||
sb.append(" mMnc=").append(mMcc);
|
||||
sb.append(" mLac=").append(mLac);
|
||||
sb.append(" mCid=").append(mCid);
|
||||
sb.append(" mPsc=").append(mPsc);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(TYPE_GSM);
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(mMcc);
|
||||
dest.writeInt(mMnc);
|
||||
@@ -132,17 +181,42 @@ public final class GsmCellIdentity extends CellIdentity implements Parcelable {
|
||||
dest.writeInt(mPsc);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
public static final Creator<GsmCellIdentity> CREATOR =
|
||||
new Creator<GsmCellIdentity>() {
|
||||
/** Construct from Parcel, type has already been processed */
|
||||
private CellIdentityGsm(Parcel in) {
|
||||
super(in);
|
||||
mMcc = in.readInt();
|
||||
mMnc = in.readInt();
|
||||
mLac = in.readInt();
|
||||
mCid = in.readInt();
|
||||
mPsc = in.readInt();
|
||||
if (DBG) log("CellIdentityGsm(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Creator<CellIdentityGsm> CREATOR =
|
||||
new Creator<CellIdentityGsm>() {
|
||||
@Override
|
||||
public GsmCellIdentity createFromParcel(Parcel in) {
|
||||
return new GsmCellIdentity(in);
|
||||
public CellIdentityGsm createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GsmCellIdentity[] newArray(int size) {
|
||||
return new GsmCellIdentity[size];
|
||||
public CellIdentityGsm[] newArray(int size) {
|
||||
return new CellIdentityGsm[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
static CellIdentityGsm createFromParcelBody(Parcel in) {
|
||||
return new CellIdentityGsm(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
217
telephony/java/android/telephony/CellIdentityLte.java
Normal file
217
telephony/java/android/telephony/CellIdentityLte.java
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* CellIdentity is to represent a unique LTE cell
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class CellIdentityLte extends CellIdentity implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellIdentityLte";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
// 3-digit Mobile Country Code, 0..999
|
||||
private final int mMcc;
|
||||
// 2 or 3-digit Mobile Network Code, 0..999
|
||||
private final int mMnc;
|
||||
// 28-bit cell identity
|
||||
private final int mCi;
|
||||
// physical cell id 0..503
|
||||
private final int mPci;
|
||||
// 16-bit tracking area code
|
||||
private final int mTac;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityLte() {
|
||||
mMcc = Integer.MAX_VALUE;
|
||||
mMnc = Integer.MAX_VALUE;
|
||||
mCi = Integer.MAX_VALUE;
|
||||
mPci = Integer.MAX_VALUE;
|
||||
mTac = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mcc 3-digit Mobile Country Code, 0..999
|
||||
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
|
||||
* @param ci 28-bit Cell Identity
|
||||
* @param pci Physical Cell Id 0..503
|
||||
* @param tac 16-bit Tracking Area Code
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellIdentityLte (int mcc, int mnc, int ci, int pci, int tac) {
|
||||
mMcc = mcc;
|
||||
mMnc = mnc;
|
||||
mCi = ci;
|
||||
mPci = pci;
|
||||
mTac = tac;
|
||||
}
|
||||
|
||||
private CellIdentityLte(CellIdentityLte cid) {
|
||||
super(cid);
|
||||
mMcc = cid.mMcc;
|
||||
mMnc = cid.mMnc;
|
||||
mCi = cid.mCi;
|
||||
mPci = cid.mPci;
|
||||
mTac = cid.mTac;
|
||||
}
|
||||
|
||||
@Override
|
||||
CellIdentityLte copy() {
|
||||
return new CellIdentityLte(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 3-digit Mobile Country Code, 0..999
|
||||
*/
|
||||
public int getMcc() {
|
||||
return mMcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999
|
||||
*/
|
||||
public int getMnc() {
|
||||
return mMnc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 28-bit Cell Identity
|
||||
*/
|
||||
public int getCi() {
|
||||
return mCi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Physical Cell Id 0..503
|
||||
*/
|
||||
public int getPci() {
|
||||
return mPci;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 16-bit Tracking Area Code
|
||||
*/
|
||||
public int getTac() {
|
||||
return mTac;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mMcc * primeNum) + (mMnc * primeNum) + (mCi * primeNum) + (mPci * primeNum) +
|
||||
(mTac * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (super.equals(other)) {
|
||||
try {
|
||||
CellIdentityLte o = (CellIdentityLte)other;
|
||||
return mMcc == o.mMcc &&
|
||||
mMnc == o.mMnc &&
|
||||
mCi == o.mCi &&
|
||||
mPci == o.mCi &&
|
||||
mTac == o.mTac;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("LteCellIdentitiy:");
|
||||
sb.append(super.toString());
|
||||
sb.append(" mMcc="); sb.append(mMcc);
|
||||
sb.append(" mMnc="); sb.append(mMnc);
|
||||
sb.append(" mCi="); sb.append(mCi);
|
||||
sb.append(" mPci="); sb.append(mPci);
|
||||
sb.append(" mTac="); sb.append(mTac);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(TYPE_LTE);
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(mMcc);
|
||||
dest.writeInt(mMnc);
|
||||
dest.writeInt(mCi);
|
||||
dest.writeInt(mPci);
|
||||
dest.writeInt(mTac);
|
||||
}
|
||||
|
||||
/** Construct from Parcel, type has already been processed */
|
||||
private CellIdentityLte(Parcel in) {
|
||||
super(in);
|
||||
mMcc = in.readInt();
|
||||
mMnc = in.readInt();
|
||||
mCi = in.readInt();
|
||||
mPci = in.readInt();
|
||||
mTac = in.readInt();
|
||||
if (DBG) log("CellIdentityLte(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Creator<CellIdentityLte> CREATOR =
|
||||
new Creator<CellIdentityLte>() {
|
||||
@Override
|
||||
public CellIdentityLte createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellIdentityLte[] newArray(int size) {
|
||||
return new CellIdentityLte[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
static CellIdentityLte createFromParcelBody(Parcel in) {
|
||||
return new CellIdentityLte(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* Copyright (C) 2012 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.
|
||||
@@ -20,194 +20,171 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Represent one snapshot observation of one cell info
|
||||
* which contains the time of observation.
|
||||
* Immutable cell information from a point in time.
|
||||
*
|
||||
* @hide Pending API review
|
||||
* @hide
|
||||
*/
|
||||
public final class CellInfo implements Parcelable {
|
||||
public class CellInfo implements Parcelable {
|
||||
|
||||
// Type fields for parceling
|
||||
protected static final int TYPE_GSM = 1;
|
||||
protected static final int TYPE_CDMA = 2;
|
||||
protected static final int TYPE_LTE = 3;
|
||||
|
||||
// Type to distinguish where time stamp gets recorded.
|
||||
public static final int CELL_INFO_TIMESTAMP_TYPE_UNKNOWN = 0;
|
||||
public static final int CELL_INFO_TIMESTAMP_TYPE_ANTENNA = 1;
|
||||
public static final int CELL_INFO_TIMESTAMP_TYPE_MODEM = 2;
|
||||
public static final int CELL_INFO_TIMESTAMP_TYPE_OEM_RIL = 3;
|
||||
public static final int CELL_INFO_TIMESTAMP_TYPE_JAVA_RIL = 4;
|
||||
|
||||
/** @hide */
|
||||
public static final int TIMESTAMP_TYPE_UNKNOWN = 0;
|
||||
/** @hide */
|
||||
public static final int TIMESTAMP_TYPE_ANTENNA = 1;
|
||||
/** @hide */
|
||||
public static final int TIMESTAMP_TYPE_MODEM = 2;
|
||||
/** @hide */
|
||||
public static final int TIMESTAMP_TYPE_OEM_RIL = 3;
|
||||
/** @hide */
|
||||
public static final int TIMESTAMP_TYPE_JAVA_RIL = 4;
|
||||
|
||||
// True if device is mRegistered to the mobile network
|
||||
private boolean mRegistered;
|
||||
|
||||
// Observation time stamped as type in nanoseconds since boot
|
||||
private final long mTimeStamp;
|
||||
private long mTimeStamp;
|
||||
|
||||
// Where time stamp gets recorded.
|
||||
// Value of CELL_INFO_TIMESTAMP_TYPE_XXXX
|
||||
private final int mTimeStampType;
|
||||
// Value of TIMESTAMP_TYPE_XXXX
|
||||
private int mTimeStampType;
|
||||
|
||||
private final boolean mRegistered;
|
||||
|
||||
private final SignalStrength mStrength;
|
||||
private final long mTimingAdvance;
|
||||
|
||||
private final int mCellIdentityType;
|
||||
private final CellIdentity mCellIdentity;
|
||||
|
||||
/**
|
||||
* Public constructor
|
||||
* @param timeStampType is one of CELL_INFO_TIMESTAMP_TYPE_XXXX
|
||||
* @param timeStamp is observation time in nanoseconds since boot
|
||||
* @param timingAdv is observed timing advance
|
||||
* @param registered is true when register to this cellIdentity
|
||||
* @param strength is observed signal strength
|
||||
* @param cellIdentity is observed mobile cell
|
||||
*/
|
||||
public CellInfo(int timeStampType, long timeStamp, long timingAdv,
|
||||
boolean registered, SignalStrength strength,
|
||||
CellIdentity cellIdentity) {
|
||||
|
||||
if (timeStampType < CELL_INFO_TIMESTAMP_TYPE_UNKNOWN ||
|
||||
timeStampType > CELL_INFO_TIMESTAMP_TYPE_JAVA_RIL) {
|
||||
mTimeStampType = CELL_INFO_TIMESTAMP_TYPE_UNKNOWN;
|
||||
} else {
|
||||
mTimeStampType = timeStampType;
|
||||
}
|
||||
|
||||
mRegistered = registered;
|
||||
mTimeStamp = timeStamp;
|
||||
mTimingAdvance = timingAdv;
|
||||
mStrength = new SignalStrength(strength);
|
||||
|
||||
mCellIdentityType = cellIdentity.getCellIdType();
|
||||
// TODO: make defense copy
|
||||
mCellIdentity = cellIdentity;
|
||||
protected CellInfo() {
|
||||
this.mRegistered = false;
|
||||
this.mTimeStampType = TIMESTAMP_TYPE_UNKNOWN;
|
||||
this.mTimeStamp = Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
public CellInfo(CellInfo ci) {
|
||||
this.mTimeStampType = ci.mTimeStampType;
|
||||
protected CellInfo(CellInfo ci) {
|
||||
this.mRegistered = ci.mRegistered;
|
||||
this.mTimeStampType = ci.mTimeStampType;
|
||||
this.mTimeStamp = ci.mTimeStamp;
|
||||
this.mTimingAdvance = ci.mTimingAdvance;
|
||||
this.mCellIdentityType = ci.mCellIdentityType;
|
||||
this.mStrength = new SignalStrength(ci.mStrength);
|
||||
switch(mCellIdentityType) {
|
||||
case CellIdentity.CELLID_TYPE_GSM:
|
||||
mCellIdentity = new GsmCellIdentity((GsmCellIdentity)ci.mCellIdentity);
|
||||
break;
|
||||
default:
|
||||
mCellIdentity = null;
|
||||
}
|
||||
}
|
||||
|
||||
private CellInfo(Parcel in) {
|
||||
mTimeStampType = in.readInt();
|
||||
mRegistered = (in.readInt() == 1) ? true : false;
|
||||
mTimeStamp = in.readLong();
|
||||
mTimingAdvance = in.readLong();
|
||||
mCellIdentityType = in.readInt();
|
||||
mStrength = SignalStrength.CREATOR.createFromParcel(in);
|
||||
switch(mCellIdentityType) {
|
||||
case CellIdentity.CELLID_TYPE_GSM:
|
||||
mCellIdentity = GsmCellIdentity.CREATOR.createFromParcel(in);
|
||||
break;
|
||||
default:
|
||||
mCellIdentity = null;
|
||||
}
|
||||
/** True if this cell is registered to the mobile network */
|
||||
public boolean isRegistered() {
|
||||
return mRegistered;
|
||||
}
|
||||
/** @hide */
|
||||
public void setRegisterd(boolean registered) {
|
||||
mRegistered = registered;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the observation time in nanoseconds since boot
|
||||
*/
|
||||
/** Approximate time of this cell information in nanos since boot */
|
||||
public long getTimeStamp() {
|
||||
return mTimeStamp;
|
||||
}
|
||||
/** @hide */
|
||||
public void setTimeStamp(long timeStamp) {
|
||||
mTimeStamp = timeStamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Where time stamp gets recorded.
|
||||
* one of CELL_INFO_TIMESTAMP_TYPE_XXXX
|
||||
* Where time stamp gets recorded.
|
||||
* @return one of TIMESTAMP_TYPE_XXXX
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public int getTimeStampType() {
|
||||
return mTimeStampType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when register to this cellIdentity
|
||||
*/
|
||||
public boolean isRegistered() {
|
||||
return mRegistered;
|
||||
/** @hide */
|
||||
public void setTimeStampType(int timeStampType) {
|
||||
if (timeStampType < TIMESTAMP_TYPE_UNKNOWN || timeStampType > TIMESTAMP_TYPE_JAVA_RIL) {
|
||||
mTimeStampType = TIMESTAMP_TYPE_UNKNOWN;
|
||||
} else {
|
||||
mTimeStampType = timeStampType;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return observed timing advance
|
||||
*/
|
||||
public long getTimingAdvance() {
|
||||
return mTimingAdvance;
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return ((mRegistered ? 0 : 1) * primeNum) + ((int)(mTimeStamp / 1000) * primeNum)
|
||||
+ (mTimeStampType * primeNum);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return observed signal strength
|
||||
*/
|
||||
public SignalStrength getSignalStrength() {
|
||||
// make a defense copy
|
||||
return new SignalStrength(mStrength);
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null) {
|
||||
return false;
|
||||
}
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
CellInfo o = (CellInfo) other;
|
||||
return mRegistered == o.mRegistered
|
||||
&& mTimeStamp == o.mTimeStamp && mTimeStampType == o.mTimeStampType;
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return observed cell identity
|
||||
*/
|
||||
public CellIdentity getCellIdentity() {
|
||||
// TODO: make a defense copy
|
||||
return mCellIdentity;
|
||||
private static String timeStampTypeToString(int type) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return "antenna";
|
||||
case 2:
|
||||
return "modem";
|
||||
case 3:
|
||||
return "oem_ril";
|
||||
case 4:
|
||||
return "java_ril";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String timeStampType;
|
||||
|
||||
sb.append("TimeStampType: ");
|
||||
switch(mTimeStampType) {
|
||||
case 1:
|
||||
sb.append("antenna");
|
||||
break;
|
||||
case 2:
|
||||
sb.append("modem");
|
||||
break;
|
||||
case 3:
|
||||
sb.append("oem_ril");
|
||||
break;
|
||||
case 4:
|
||||
sb.append("java_ril");
|
||||
break;
|
||||
default:
|
||||
sb.append("unknown");
|
||||
}
|
||||
sb.append(", TimeStamp: ").append(mTimeStamp).append(" ns");
|
||||
sb.append(", Registered: ").append(mRegistered ? "YES" : "NO");
|
||||
sb.append(", TimingAdvance: ").append(mTimingAdvance);
|
||||
sb.append(", Strength : " + mStrength);
|
||||
sb.append(", Cell Iden: " + mCellIdentity);
|
||||
sb.append(" mRegistered=").append(mRegistered ? "YES" : "NO");
|
||||
timeStampType = timeStampTypeToString(mTimeStampType);
|
||||
sb.append(" mTimeStampType=").append(timeStampType);
|
||||
sb.append(" mTimeStamp=").append(mTimeStamp).append("ns");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(mTimeStampType);
|
||||
dest.writeInt(mRegistered ? 1 : 0);
|
||||
dest.writeInt(mTimeStampType);
|
||||
dest.writeLong(mTimeStamp);
|
||||
dest.writeLong(mTimingAdvance);
|
||||
dest.writeInt(mCellIdentityType);
|
||||
mStrength.writeToParcel(dest, flags);
|
||||
mCellIdentity.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
public static final Creator<CellInfo> CREATOR =
|
||||
new Creator<CellInfo>() {
|
||||
protected CellInfo(Parcel in) {
|
||||
mRegistered = (in.readInt() == 1) ? true : false;
|
||||
mTimeStampType = in.readInt();
|
||||
mTimeStamp = in.readLong();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellInfo> CREATOR = new Creator<CellInfo>() {
|
||||
@Override
|
||||
public CellInfo createFromParcel(Parcel in) {
|
||||
return new CellInfo(in);
|
||||
int type = in.readInt();
|
||||
switch (type) {
|
||||
case TYPE_GSM: return CellInfoGsm.createFromParcelBody(in);
|
||||
case TYPE_CDMA: return CellInfoCdma.createFromParcelBody(in);
|
||||
case TYPE_LTE: return CellInfoLte.createFromParcelBody(in);
|
||||
default: throw new RuntimeException("Bad CellInfo Parcel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
152
telephony/java/android/telephony/CellInfoCdma.java
Normal file
152
telephony/java/android/telephony/CellInfoCdma.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Immutable cell information from a point in time.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class CellInfoCdma extends CellInfo implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellInfoCdma";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private CellIdentityCdma mCellIdentityCdma;
|
||||
private CellSignalStrengthCdma mCellSignalStrengthCdma;
|
||||
|
||||
/** @hide */
|
||||
public CellInfoCdma() {
|
||||
super();
|
||||
mCellIdentityCdma = new CellIdentityCdma();
|
||||
mCellSignalStrengthCdma = new CellSignalStrengthCdma();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public CellInfoCdma(CellInfoCdma ci) {
|
||||
super(ci);
|
||||
this.mCellIdentityCdma = ci.mCellIdentityCdma.copy();
|
||||
this.mCellSignalStrengthCdma = ci.mCellSignalStrengthCdma.copy();
|
||||
}
|
||||
|
||||
public CellIdentityCdma getCellIdentity() {
|
||||
return mCellIdentityCdma;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellIdentity(CellIdentityCdma cid) {
|
||||
mCellIdentityCdma = cid;
|
||||
}
|
||||
|
||||
public CellSignalStrengthCdma getCellSignalStrength() {
|
||||
return mCellSignalStrengthCdma;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellSignalStrength(CellSignalStrengthCdma css) {
|
||||
mCellSignalStrengthCdma = css;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + mCellIdentityCdma.hashCode() + mCellSignalStrengthCdma.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!super.equals(other)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
CellInfoCdma o = (CellInfoCdma) other;
|
||||
return mCellIdentityCdma.equals(o.mCellIdentityCdma)
|
||||
&& mCellSignalStrengthCdma.equals(o.mCellSignalStrengthCdma);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append("CellInfoCdma:");
|
||||
sb.append(super.toString());
|
||||
sb.append(", ").append(mCellIdentityCdma);
|
||||
sb.append(", ").append(mCellSignalStrengthCdma);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(TYPE_LTE);
|
||||
super.writeToParcel(dest, flags);
|
||||
mCellIdentityCdma.writeToParcel(dest, flags);
|
||||
mCellSignalStrengthCdma.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a CellInfoCdma object from the given parcel
|
||||
* where the token is already been processed.
|
||||
*/
|
||||
private CellInfoCdma(Parcel in) {
|
||||
super(in);
|
||||
mCellIdentityCdma = CellIdentityCdma.CREATOR.createFromParcel(in);
|
||||
mCellSignalStrengthCdma = CellSignalStrengthCdma.CREATOR.createFromParcel(in);
|
||||
if (DBG) log("CellInfoCdma(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellInfoCdma> CREATOR = new Creator<CellInfoCdma>() {
|
||||
@Override
|
||||
public CellInfoCdma createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellInfoCdma[] newArray(int size) {
|
||||
return new CellInfoCdma[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
protected static CellInfoCdma createFromParcelBody(Parcel in) {
|
||||
return new CellInfoCdma(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
150
telephony/java/android/telephony/CellInfoGsm.java
Normal file
150
telephony/java/android/telephony/CellInfoGsm.java
Normal file
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Immutable cell information from a point in time.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class CellInfoGsm extends CellInfo implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellInfoGsm";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private CellIdentityGsm mCellIdentityGsm;
|
||||
private CellSignalStrengthGsm mCellSignalStrengthGsm;
|
||||
|
||||
/** @hide */
|
||||
public CellInfoGsm() {
|
||||
super();
|
||||
mCellIdentityGsm = new CellIdentityGsm();
|
||||
mCellSignalStrengthGsm = new CellSignalStrengthGsm();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public CellInfoGsm(CellInfoGsm ci) {
|
||||
super(ci);
|
||||
this.mCellIdentityGsm = ci.mCellIdentityGsm.copy();
|
||||
this.mCellSignalStrengthGsm = ci.mCellSignalStrengthGsm.copy();
|
||||
}
|
||||
|
||||
public CellIdentityGsm getCellIdentity() {
|
||||
return mCellIdentityGsm;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellIdentity(CellIdentityGsm cid) {
|
||||
mCellIdentityGsm = cid;
|
||||
}
|
||||
|
||||
public CellSignalStrengthGsm getCellSignalStrength() {
|
||||
return mCellSignalStrengthGsm;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellSignalStrength(CellSignalStrengthGsm css) {
|
||||
mCellSignalStrengthGsm = css;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + mCellIdentityGsm.hashCode() + mCellSignalStrengthGsm.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!super.equals(other)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
CellInfoGsm o = (CellInfoGsm) other;
|
||||
return mCellIdentityGsm.equals(o.mCellIdentityGsm)
|
||||
&& mCellSignalStrengthGsm.equals(o.mCellSignalStrengthGsm);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append("CellInfoGsm:");
|
||||
sb.append(super.toString());
|
||||
sb.append(", ").append(mCellIdentityGsm);
|
||||
sb.append(", ").append(mCellSignalStrengthGsm);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(TYPE_LTE);
|
||||
super.writeToParcel(dest, flags);
|
||||
mCellIdentityGsm.writeToParcel(dest, flags);
|
||||
mCellSignalStrengthGsm.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a CellInfoGsm object from the given parcel
|
||||
* where the token is already been processed.
|
||||
*/
|
||||
private CellInfoGsm(Parcel in) {
|
||||
super(in);
|
||||
mCellIdentityGsm = CellIdentityGsm.CREATOR.createFromParcel(in);
|
||||
mCellSignalStrengthGsm = CellSignalStrengthGsm.CREATOR.createFromParcel(in);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellInfoGsm> CREATOR = new Creator<CellInfoGsm>() {
|
||||
@Override
|
||||
public CellInfoGsm createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellInfoGsm[] newArray(int size) {
|
||||
return new CellInfoGsm[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
protected static CellInfoGsm createFromParcelBody(Parcel in) {
|
||||
return new CellInfoGsm(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
152
telephony/java/android/telephony/CellInfoLte.java
Normal file
152
telephony/java/android/telephony/CellInfoLte.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Immutable cell information from a point in time.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class CellInfoLte extends CellInfo implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellInfoLte";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private CellIdentityLte mCellIdentityLte;
|
||||
private CellSignalStrengthLte mCellSignalStrengthLte;
|
||||
|
||||
/** @hide */
|
||||
public CellInfoLte() {
|
||||
super();
|
||||
mCellIdentityLte = new CellIdentityLte();
|
||||
mCellSignalStrengthLte = new CellSignalStrengthLte();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public CellInfoLte(CellInfoLte ci) {
|
||||
super(ci);
|
||||
this.mCellIdentityLte = ci.mCellIdentityLte.copy();
|
||||
this.mCellSignalStrengthLte = ci.mCellSignalStrengthLte.copy();
|
||||
}
|
||||
|
||||
public CellIdentityLte getCellIdentity() {
|
||||
return mCellIdentityLte;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellIdentity(CellIdentityLte cid) {
|
||||
mCellIdentityLte = cid;
|
||||
}
|
||||
|
||||
public CellSignalStrengthLte getCellSignalStrength() {
|
||||
return mCellSignalStrengthLte;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCellSignalStrength(CellSignalStrengthLte css) {
|
||||
mCellSignalStrengthLte = css;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return hash code
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode() + mCellIdentityLte.hashCode() + mCellSignalStrengthLte.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!super.equals(other)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
CellInfoLte o = (CellInfoLte) other;
|
||||
return mCellIdentityLte.equals(o.mCellIdentityLte)
|
||||
&& mCellSignalStrengthLte.equals(o.mCellSignalStrengthLte);
|
||||
} catch (ClassCastException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append("CellInfoLte:");
|
||||
sb.append(super.toString());
|
||||
sb.append(", ").append(mCellIdentityLte);
|
||||
sb.append(", ").append(mCellSignalStrengthLte);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(TYPE_LTE);
|
||||
super.writeToParcel(dest, flags);
|
||||
mCellIdentityLte.writeToParcel(dest, flags);
|
||||
mCellSignalStrengthLte.writeToParcel(dest, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a CellInfoLte object from the given parcel
|
||||
* where the TYPE_LTE token is already been processed.
|
||||
*/
|
||||
private CellInfoLte(Parcel in) {
|
||||
super(in);
|
||||
mCellIdentityLte = CellIdentityLte.CREATOR.createFromParcel(in);
|
||||
mCellSignalStrengthLte = CellSignalStrengthLte.CREATOR.createFromParcel(in);
|
||||
if (DBG) log("CellInfoLte(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellInfoLte> CREATOR = new Creator<CellInfoLte>() {
|
||||
@Override
|
||||
public CellInfoLte createFromParcel(Parcel in) {
|
||||
in.readInt(); // Skip past token, we know what it is
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellInfoLte[] newArray(int size) {
|
||||
return new CellInfoLte[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
protected static CellInfoLte createFromParcelBody(Parcel in) {
|
||||
return new CellInfoLte(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
120
telephony/java/android/telephony/CellSignalStrength.java
Normal file
120
telephony/java/android/telephony/CellSignalStrength.java
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.view.InputEvent;
|
||||
|
||||
/**
|
||||
* Abstract base class for cell phone signal strength related information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public abstract class CellSignalStrength implements Parcelable {
|
||||
|
||||
// Type fields for parceling
|
||||
protected static final int TYPE_GSM = 1;
|
||||
protected static final int TYPE_CDMA = 2;
|
||||
protected static final int TYPE_LTE = 3;
|
||||
|
||||
|
||||
/** @hide */
|
||||
public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
|
||||
/** @hide */
|
||||
public static final int SIGNAL_STRENGTH_POOR = 1;
|
||||
/** @hide */
|
||||
public static final int SIGNAL_STRENGTH_MODERATE = 2;
|
||||
/** @hide */
|
||||
public static final int SIGNAL_STRENGTH_GOOD = 3;
|
||||
/** @hide */
|
||||
public static final int SIGNAL_STRENGTH_GREAT = 4;
|
||||
/** @hide */
|
||||
public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
|
||||
/** @hide */
|
||||
public static final String[] SIGNAL_STRENGTH_NAMES = {
|
||||
"none", "poor", "moderate", "good", "great"
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
public abstract void setDefaultValues();
|
||||
|
||||
/**
|
||||
* Get signal level as an int from 0..4
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public abstract int getLevel();
|
||||
|
||||
/**
|
||||
* Get the signal level as an asu value between 0..31, 99 is unknown
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public abstract int getAsuLevel();
|
||||
|
||||
/**
|
||||
* Get the signal strength as dBm
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public abstract int getDbm();
|
||||
|
||||
/**
|
||||
* Copies the CellSignalStrength.
|
||||
*
|
||||
* @return A deep copy of this class.
|
||||
* @hide
|
||||
*/
|
||||
public abstract CellSignalStrength copy();
|
||||
|
||||
@Override
|
||||
public abstract int hashCode();
|
||||
|
||||
@Override
|
||||
public abstract boolean equals (Object o);
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public abstract void writeToParcel(Parcel dest, int flags);
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
public static final Creator<CellSignalStrength> CREATOR =
|
||||
new Creator<CellSignalStrength>() {
|
||||
@Override
|
||||
public CellSignalStrength createFromParcel(Parcel in) {
|
||||
int type = in.readInt();
|
||||
switch (type) {
|
||||
case TYPE_GSM: return CellSignalStrengthGsm.createFromParcelBody(in);
|
||||
case TYPE_CDMA: return CellSignalStrengthCdma.createFromParcelBody(in);
|
||||
case TYPE_LTE: return CellSignalStrengthLte.createFromParcelBody(in);
|
||||
default: throw new RuntimeException("Bad CellSignalStrength Parcel");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellSignalStrength[] newArray(int size) {
|
||||
return new CellSignalStrength[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
402
telephony/java/android/telephony/CellSignalStrengthCdma.java
Normal file
402
telephony/java/android/telephony/CellSignalStrengthCdma.java
Normal file
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* LTE signal strength related information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class CellSignalStrengthCdma extends CellSignalStrength implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellSignalStrengthCdma";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private int mCdmaDbm; // This value is the RSSI value
|
||||
private int mCdmaEcio; // This value is the Ec/Io
|
||||
private int mEvdoDbm; // This value is the EVDO RSSI value
|
||||
private int mEvdoEcio; // This value is the EVDO Ec/Io
|
||||
private int mEvdoSnr; // Valid values are 0-8. 8 is the highest signal to noise ratio
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthCdma() {
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthCdma(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio,
|
||||
int evdoSnr) {
|
||||
initialize(cdmaDbm, cdmaEcio, evdoDbm, evdoEcio, evdoSnr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructors
|
||||
*
|
||||
* @param s Source SignalStrength
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthCdma(CellSignalStrengthCdma s) {
|
||||
copyFrom(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all the values
|
||||
*
|
||||
* @param cdmaDbm
|
||||
* @param cdmaEcio
|
||||
* @param evdoDbm
|
||||
* @param evdoEcio
|
||||
* @param evdoSnr
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void initialize(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio, int evdoSnr) {
|
||||
mCdmaDbm = cdmaDbm;
|
||||
mCdmaEcio = cdmaEcio;
|
||||
mEvdoDbm = evdoDbm;
|
||||
mEvdoEcio = evdoEcio;
|
||||
mEvdoSnr = evdoSnr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
protected void copyFrom(CellSignalStrengthCdma s) {
|
||||
mCdmaDbm = s.mCdmaDbm;
|
||||
mCdmaEcio = s.mCdmaEcio;
|
||||
mEvdoDbm = s.mEvdoDbm;
|
||||
mEvdoEcio = s.mEvdoEcio;
|
||||
mEvdoSnr = s.mEvdoSnr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public CellSignalStrengthCdma copy() {
|
||||
return new CellSignalStrengthCdma(this);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void setDefaultValues() {
|
||||
mCdmaDbm = Integer.MAX_VALUE;
|
||||
mCdmaEcio = Integer.MAX_VALUE;
|
||||
mEvdoDbm = Integer.MAX_VALUE;
|
||||
mEvdoEcio = Integer.MAX_VALUE;
|
||||
mEvdoSnr = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LTE as level 0..4
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getLevel() {
|
||||
int level;
|
||||
|
||||
int cdmaLevel = getCdmaLevel();
|
||||
int evdoLevel = getEvdoLevel();
|
||||
if (evdoLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
|
||||
/* We don't know evdo, use cdma */
|
||||
level = getCdmaLevel();
|
||||
} else if (cdmaLevel == SIGNAL_STRENGTH_NONE_OR_UNKNOWN) {
|
||||
/* We don't know cdma, use evdo */
|
||||
level = getEvdoLevel();
|
||||
} else {
|
||||
/* We know both, use the lowest level */
|
||||
level = cdmaLevel < evdoLevel ? cdmaLevel : evdoLevel;
|
||||
}
|
||||
if (DBG) log("getLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LTE signal level as an asu value between 0..97, 99 is unknown
|
||||
* Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getAsuLevel() {
|
||||
final int cdmaDbm = getCdmaDbm();
|
||||
final int cdmaEcio = getCdmaEcio();
|
||||
int cdmaAsuLevel;
|
||||
int ecioAsuLevel;
|
||||
|
||||
if (cdmaDbm >= -75) cdmaAsuLevel = 16;
|
||||
else if (cdmaDbm >= -82) cdmaAsuLevel = 8;
|
||||
else if (cdmaDbm >= -90) cdmaAsuLevel = 4;
|
||||
else if (cdmaDbm >= -95) cdmaAsuLevel = 2;
|
||||
else if (cdmaDbm >= -100) cdmaAsuLevel = 1;
|
||||
else cdmaAsuLevel = 99;
|
||||
|
||||
// Ec/Io are in dB*10
|
||||
if (cdmaEcio >= -90) ecioAsuLevel = 16;
|
||||
else if (cdmaEcio >= -100) ecioAsuLevel = 8;
|
||||
else if (cdmaEcio >= -115) ecioAsuLevel = 4;
|
||||
else if (cdmaEcio >= -130) ecioAsuLevel = 2;
|
||||
else if (cdmaEcio >= -150) ecioAsuLevel = 1;
|
||||
else ecioAsuLevel = 99;
|
||||
|
||||
int level = (cdmaAsuLevel < ecioAsuLevel) ? cdmaAsuLevel : ecioAsuLevel;
|
||||
if (DBG) log("getAsuLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cdma as level 0..4
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public int getCdmaLevel() {
|
||||
final int cdmaDbm = getCdmaDbm();
|
||||
final int cdmaEcio = getCdmaEcio();
|
||||
int levelDbm;
|
||||
int levelEcio;
|
||||
|
||||
if (cdmaDbm >= -75) levelDbm = SIGNAL_STRENGTH_GREAT;
|
||||
else if (cdmaDbm >= -85) levelDbm = SIGNAL_STRENGTH_GOOD;
|
||||
else if (cdmaDbm >= -95) levelDbm = SIGNAL_STRENGTH_MODERATE;
|
||||
else if (cdmaDbm >= -100) levelDbm = SIGNAL_STRENGTH_POOR;
|
||||
else levelDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||
|
||||
// Ec/Io are in dB*10
|
||||
if (cdmaEcio >= -90) levelEcio = SIGNAL_STRENGTH_GREAT;
|
||||
else if (cdmaEcio >= -110) levelEcio = SIGNAL_STRENGTH_GOOD;
|
||||
else if (cdmaEcio >= -130) levelEcio = SIGNAL_STRENGTH_MODERATE;
|
||||
else if (cdmaEcio >= -150) levelEcio = SIGNAL_STRENGTH_POOR;
|
||||
else levelEcio = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||
|
||||
int level = (levelDbm < levelEcio) ? levelDbm : levelEcio;
|
||||
if (DBG) log("getCdmaLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Evdo as level 0..4
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public int getEvdoLevel() {
|
||||
int evdoDbm = getEvdoDbm();
|
||||
int evdoSnr = getEvdoSnr();
|
||||
int levelEvdoDbm;
|
||||
int levelEvdoSnr;
|
||||
|
||||
if (evdoDbm >= -65) levelEvdoDbm = SIGNAL_STRENGTH_GREAT;
|
||||
else if (evdoDbm >= -75) levelEvdoDbm = SIGNAL_STRENGTH_GOOD;
|
||||
else if (evdoDbm >= -90) levelEvdoDbm = SIGNAL_STRENGTH_MODERATE;
|
||||
else if (evdoDbm >= -105) levelEvdoDbm = SIGNAL_STRENGTH_POOR;
|
||||
else levelEvdoDbm = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||
|
||||
if (evdoSnr >= 7) levelEvdoSnr = SIGNAL_STRENGTH_GREAT;
|
||||
else if (evdoSnr >= 5) levelEvdoSnr = SIGNAL_STRENGTH_GOOD;
|
||||
else if (evdoSnr >= 3) levelEvdoSnr = SIGNAL_STRENGTH_MODERATE;
|
||||
else if (evdoSnr >= 1) levelEvdoSnr = SIGNAL_STRENGTH_POOR;
|
||||
else levelEvdoSnr = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||
|
||||
int level = (levelEvdoDbm < levelEvdoSnr) ? levelEvdoDbm : levelEvdoSnr;
|
||||
if (DBG) log("getEvdoLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get as dBm
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getDbm() {
|
||||
int cdmaDbm = getCdmaDbm();
|
||||
int evdoDbm = getEvdoDbm();
|
||||
|
||||
// Use the lower value to be conservative
|
||||
return (cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CDMA RSSI value in dBm
|
||||
*/
|
||||
public int getCdmaDbm() {
|
||||
return mCdmaDbm;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCdmaDbm(int cdmaDbm) {
|
||||
mCdmaDbm = cdmaDbm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CDMA Ec/Io value in dB*10
|
||||
*/
|
||||
public int getCdmaEcio() {
|
||||
return mCdmaEcio;
|
||||
}
|
||||
/** @hide */
|
||||
public void setCdmaEcio(int cdmaEcio) {
|
||||
mCdmaEcio = cdmaEcio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the EVDO RSSI value in dBm
|
||||
*/
|
||||
public int getEvdoDbm() {
|
||||
return mEvdoDbm;
|
||||
}
|
||||
/** @hide */
|
||||
public void setEvdoDbm(int evdoDbm) {
|
||||
mEvdoDbm = evdoDbm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the EVDO Ec/Io value in dB*10
|
||||
*/
|
||||
public int getEvdoEcio() {
|
||||
return mEvdoEcio;
|
||||
}
|
||||
/** @hide */
|
||||
public void setEvdoEcio(int evdoEcio) {
|
||||
mEvdoEcio = evdoEcio;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signal to noise ratio. Valid values are 0-8. 8 is the highest.
|
||||
*/
|
||||
public int getEvdoSnr() {
|
||||
return mEvdoSnr;
|
||||
}
|
||||
/** @hide */
|
||||
public void setEvdoSnr(int evdoSnr) {
|
||||
mEvdoSnr = evdoSnr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return ((mCdmaDbm * primeNum) + (mCdmaEcio * primeNum)
|
||||
+ (mEvdoDbm * primeNum) + (mEvdoEcio * primeNum) + (mEvdoSnr * primeNum));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object o) {
|
||||
CellSignalStrengthCdma s;
|
||||
|
||||
try {
|
||||
s = (CellSignalStrengthCdma) o;
|
||||
} catch (ClassCastException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mCdmaDbm == s.mCdmaDbm
|
||||
&& mCdmaEcio == s.mCdmaEcio
|
||||
&& mEvdoDbm == s.mEvdoDbm
|
||||
&& mEvdoEcio == s.mEvdoEcio
|
||||
&& mEvdoSnr == s.mEvdoSnr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string representation.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CellSignalStrengthCdma:"
|
||||
+ " cdmaDbm=" + mCdmaDbm
|
||||
+ " cdmaEcio=" + mCdmaEcio
|
||||
+ " evdoDbm=" + mEvdoDbm
|
||||
+ " evdoEcio=" + mEvdoEcio
|
||||
+ " evdoSnr=" + mEvdoSnr;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(CellSignalStrength.TYPE_CDMA);
|
||||
dest.writeInt(mCdmaDbm);
|
||||
dest.writeInt(mCdmaEcio);
|
||||
dest.writeInt(mEvdoDbm);
|
||||
dest.writeInt(mEvdoEcio);
|
||||
dest.writeInt(mEvdoSnr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a SignalStrength object from the given parcel
|
||||
* where the TYPE_LTE token is already been processed.
|
||||
*/
|
||||
private CellSignalStrengthCdma(Parcel in) {
|
||||
mCdmaDbm = in.readInt();
|
||||
mCdmaEcio = in.readInt();
|
||||
mEvdoDbm = in.readInt();
|
||||
mEvdoEcio = in.readInt();
|
||||
mEvdoSnr = in.readInt();
|
||||
if (DBG) log("CellSignalStrengthCdma(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Parcelable.Creator<CellSignalStrengthCdma> CREATOR =
|
||||
new Parcelable.Creator<CellSignalStrengthCdma>() {
|
||||
@Override
|
||||
public CellSignalStrengthCdma createFromParcel(Parcel in) {
|
||||
if (in.readInt() != CellSignalStrength.TYPE_CDMA) {
|
||||
throw new RuntimeException("Expecting TYPE_CDMA");
|
||||
}
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellSignalStrengthCdma[] newArray(int size) {
|
||||
return new CellSignalStrengthCdma[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
public static CellSignalStrengthCdma createFromParcelBody(Parcel in) {
|
||||
return new CellSignalStrengthCdma(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
251
telephony/java/android/telephony/CellSignalStrengthGsm.java
Normal file
251
telephony/java/android/telephony/CellSignalStrengthGsm.java
Normal file
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* LTE signal strength related information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class CellSignalStrengthGsm extends CellSignalStrength implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellSignalStrengthGsm";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private static final int GSM_SIGNAL_STRENGTH_GREAT = 12;
|
||||
private static final int GSM_SIGNAL_STRENGTH_GOOD = 8;
|
||||
private static final int GSM_SIGNAL_STRENGTH_MODERATE = 8;
|
||||
|
||||
private int mSignalStrength; // Valid values are (0-31, 99) as defined in TS 27.007 8.5
|
||||
private int mBitErrorRate; // bit error rate (0-7, 99) as defined in TS 27.007 8.5
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthGsm() {
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthGsm(int ss, int ber) {
|
||||
initialize(ss, ber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructors
|
||||
*
|
||||
* @param s Source SignalStrength
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthGsm(CellSignalStrengthGsm s) {
|
||||
copyFrom(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all the values
|
||||
*
|
||||
* @param SignalStrength
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void initialize(int ss, int ber) {
|
||||
mSignalStrength = ss;
|
||||
mBitErrorRate = ber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
protected void copyFrom(CellSignalStrengthGsm s) {
|
||||
mSignalStrength = s.mSignalStrength;
|
||||
mBitErrorRate = s.mBitErrorRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public CellSignalStrengthGsm copy() {
|
||||
return new CellSignalStrengthGsm(this);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void setDefaultValues() {
|
||||
mSignalStrength = Integer.MAX_VALUE;
|
||||
mBitErrorRate = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LTE as level 0..4
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getLevel() {
|
||||
int level;
|
||||
|
||||
// ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
|
||||
// asu = 0 (-113dB or less) is very weak
|
||||
// signal, its better to show 0 bars to the user in such cases.
|
||||
// asu = 99 is a special case, where the signal strength is unknown.
|
||||
int asu = mSignalStrength;
|
||||
if (asu <= 2 || asu == 99) level = SIGNAL_STRENGTH_NONE_OR_UNKNOWN;
|
||||
else if (asu >= GSM_SIGNAL_STRENGTH_GREAT) level = SIGNAL_STRENGTH_GREAT;
|
||||
else if (asu >= GSM_SIGNAL_STRENGTH_GOOD) level = SIGNAL_STRENGTH_GOOD;
|
||||
else if (asu >= GSM_SIGNAL_STRENGTH_MODERATE) level = SIGNAL_STRENGTH_MODERATE;
|
||||
else level = SIGNAL_STRENGTH_POOR;
|
||||
if (DBG) log("getLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LTE as dBm
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getDbm() {
|
||||
int dBm;
|
||||
|
||||
int level = mSignalStrength;
|
||||
int asu = (level == 99 ? Integer.MAX_VALUE : level);
|
||||
if (asu != Integer.MAX_VALUE) {
|
||||
dBm = -113 + (2 * asu);
|
||||
} else {
|
||||
dBm = Integer.MAX_VALUE;
|
||||
}
|
||||
if (DBG) log("getDbm=" + dBm);
|
||||
return dBm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LTE signal level as an asu value between 0..97, 99 is unknown
|
||||
* Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getAsuLevel() {
|
||||
// ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
|
||||
// asu = 0 (-113dB or less) is very weak
|
||||
// signal, its better to show 0 bars to the user in such cases.
|
||||
// asu = 99 is a special case, where the signal strength is unknown.
|
||||
int level = mSignalStrength;
|
||||
if (DBG) log("getAsuLevel=" + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mSignalStrength * primeNum) + (mBitErrorRate * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object o) {
|
||||
CellSignalStrengthGsm s;
|
||||
|
||||
try {
|
||||
s = (CellSignalStrengthGsm) o;
|
||||
} catch (ClassCastException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mSignalStrength == s.mSignalStrength && mBitErrorRate == s.mBitErrorRate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string representation.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CellSignalStrengthGsm:"
|
||||
+ " ss=" + mSignalStrength
|
||||
+ " ber=" + mBitErrorRate;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(CellSignalStrength.TYPE_GSM);
|
||||
dest.writeInt(mSignalStrength);
|
||||
dest.writeInt(mBitErrorRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a SignalStrength object from the given parcel
|
||||
* where the token is already been processed.
|
||||
*/
|
||||
private CellSignalStrengthGsm(Parcel in) {
|
||||
mSignalStrength = in.readInt();
|
||||
mBitErrorRate = in.readInt();
|
||||
if (DBG) log("CellSignalStrengthGsm(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Parcelable.Creator<CellSignalStrengthGsm> CREATOR =
|
||||
new Parcelable.Creator<CellSignalStrengthGsm>() {
|
||||
@Override
|
||||
public CellSignalStrengthGsm createFromParcel(Parcel in) {
|
||||
if (in.readInt() != CellSignalStrength.TYPE_GSM) {
|
||||
throw new RuntimeException("Expecting TYPE_GSM");
|
||||
}
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellSignalStrengthGsm[] newArray(int size) {
|
||||
return new CellSignalStrengthGsm[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
public static CellSignalStrengthGsm createFromParcelBody(Parcel in) {
|
||||
return new CellSignalStrengthGsm(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
299
telephony/java/android/telephony/CellSignalStrengthLte.java
Normal file
299
telephony/java/android/telephony/CellSignalStrengthLte.java
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* LTE signal strength related information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public class CellSignalStrengthLte extends CellSignalStrength implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "CellSignalStrengthLte";
|
||||
private static final boolean DBG = false;
|
||||
|
||||
private int mSignalStrength;
|
||||
private int mRsrp;
|
||||
private int mRsrq;
|
||||
private int mRssnr;
|
||||
private int mCqi;
|
||||
private int mTimingAdvance;
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthLte() {
|
||||
setDefaultValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthLte(int signalStrength, int rsrp, int rsrq, int rssnr, int cqi,
|
||||
int timingAdvance) {
|
||||
initialize(signalStrength, rsrp, rsrq, rssnr, cqi, timingAdvance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructors
|
||||
*
|
||||
* @param s Source SignalStrength
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public CellSignalStrengthLte(CellSignalStrengthLte s) {
|
||||
copyFrom(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all the values
|
||||
*
|
||||
* @param lteSignalStrength
|
||||
* @param rsrp
|
||||
* @param rsrq
|
||||
* @param rssnr
|
||||
* @param cqi
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void initialize(int lteSignalStrength, int rsrp, int rsrq, int rssnr, int cqi,
|
||||
int timingAdvance) {
|
||||
mSignalStrength = lteSignalStrength;
|
||||
mRsrp = rsrp;
|
||||
mRsrq = rsrq;
|
||||
mRssnr = rssnr;
|
||||
mCqi = cqi;
|
||||
mTimingAdvance = timingAdvance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
protected void copyFrom(CellSignalStrengthLte s) {
|
||||
mSignalStrength = s.mSignalStrength;
|
||||
mRsrp = s.mRsrp;
|
||||
mRsrq = s.mRsrq;
|
||||
mRssnr = s.mRssnr;
|
||||
mCqi = s.mCqi;
|
||||
mTimingAdvance = s.mTimingAdvance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public CellSignalStrengthLte copy() {
|
||||
return new CellSignalStrengthLte(this);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public void setDefaultValues() {
|
||||
mSignalStrength = Integer.MAX_VALUE;
|
||||
mRsrp = Integer.MAX_VALUE;
|
||||
mRsrq = Integer.MAX_VALUE;
|
||||
mRssnr = Integer.MAX_VALUE;
|
||||
mCqi = Integer.MAX_VALUE;
|
||||
mTimingAdvance = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LTE as level 0..4
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getLevel() {
|
||||
int levelRsrp = 0;
|
||||
int levelRssnr = 0;
|
||||
|
||||
if (mRsrp == Integer.MAX_VALUE) levelRsrp = 0;
|
||||
else if (mRsrp >= -95) levelRsrp = SIGNAL_STRENGTH_GREAT;
|
||||
else if (mRsrp >= -105) levelRsrp = SIGNAL_STRENGTH_GOOD;
|
||||
else if (mRsrp >= -115) levelRsrp = SIGNAL_STRENGTH_MODERATE;
|
||||
else levelRsrp = SIGNAL_STRENGTH_POOR;
|
||||
|
||||
// See RIL_LTE_SignalStrength in ril.h
|
||||
if (mRssnr == Integer.MAX_VALUE) levelRssnr = 0;
|
||||
else if (mRssnr >= 45) levelRssnr = SIGNAL_STRENGTH_GREAT;
|
||||
else if (mRssnr >= 10) levelRssnr = SIGNAL_STRENGTH_GOOD;
|
||||
else if (mRssnr >= -30) levelRssnr = SIGNAL_STRENGTH_MODERATE;
|
||||
else levelRssnr = SIGNAL_STRENGTH_POOR;
|
||||
|
||||
int level;
|
||||
if (mRsrp == Integer.MAX_VALUE)
|
||||
level = levelRssnr;
|
||||
else if (mRssnr == Integer.MAX_VALUE)
|
||||
level = levelRsrp;
|
||||
else
|
||||
level = (levelRssnr < levelRsrp) ? levelRssnr : levelRsrp;
|
||||
|
||||
if (DBG) log("Lte rsrp level: " + levelRsrp
|
||||
+ " snr level: " + levelRssnr + " level: " + level);
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get LTE as dBm
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getDbm() {
|
||||
return mRsrp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the LTE signal level as an asu value between 0..97, 99 is unknown
|
||||
* Asu is calculated based on 3GPP RSRP. Refer to 3GPP 27.007 (Ver 10.3.0) Sec 8.69
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@Override
|
||||
public int getAsuLevel() {
|
||||
int lteAsuLevel = 99;
|
||||
int lteDbm = getDbm();
|
||||
if (lteDbm <= -140) lteAsuLevel = 0;
|
||||
else if (lteDbm >= -43) lteAsuLevel = 97;
|
||||
else lteAsuLevel = lteDbm + 140;
|
||||
if (DBG) log("Lte Asu level: "+lteAsuLevel);
|
||||
return lteAsuLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the timing advance value for LTE.
|
||||
* See 3GPP xxxx
|
||||
*/
|
||||
public int getTimingAdvance() {
|
||||
return mTimingAdvance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int primeNum = 31;
|
||||
return (mSignalStrength * primeNum) + (mRsrp * primeNum)
|
||||
+ (mRsrq * primeNum) + (mRssnr * primeNum) + (mCqi * primeNum)
|
||||
+ (mTimingAdvance * primeNum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object o) {
|
||||
CellSignalStrengthLte s;
|
||||
|
||||
try {
|
||||
s = (CellSignalStrengthLte) o;
|
||||
} catch (ClassCastException ex) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mSignalStrength == s.mSignalStrength
|
||||
&& mRsrp == s.mRsrp
|
||||
&& mRsrq == s.mRsrq
|
||||
&& mRssnr == s.mRssnr
|
||||
&& mCqi == s.mCqi
|
||||
&& mTimingAdvance == s.mTimingAdvance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string representation.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CellSignalStrengthLte:"
|
||||
+ " ss=" + mSignalStrength
|
||||
+ " rsrp=" + mRsrp
|
||||
+ " rsrq=" + mRsrq
|
||||
+ " rssnr=" + mRssnr
|
||||
+ " cqi=" + mCqi
|
||||
+ " ta=" + mTimingAdvance;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
if (DBG) log("writeToParcel(Parcel, int): " + toString());
|
||||
dest.writeInt(CellSignalStrength.TYPE_LTE);
|
||||
dest.writeInt(mSignalStrength);
|
||||
dest.writeInt(mRsrp);
|
||||
dest.writeInt(mRsrq);
|
||||
dest.writeInt(mRssnr);
|
||||
dest.writeInt(mCqi);
|
||||
dest.writeInt(mTimingAdvance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a SignalStrength object from the given parcel
|
||||
* where the token is already been processed.
|
||||
*/
|
||||
private CellSignalStrengthLte(Parcel in) {
|
||||
mSignalStrength = in.readInt();
|
||||
mRsrp = in.readInt();
|
||||
mRsrq = in.readInt();
|
||||
mRssnr = in.readInt();
|
||||
mCqi = in.readInt();
|
||||
mTimingAdvance = in.readInt();
|
||||
if (DBG) log("CellSignalStrengthLte(Parcel): " + toString());
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface */
|
||||
@SuppressWarnings("hiding")
|
||||
public static final Parcelable.Creator<CellSignalStrengthLte> CREATOR =
|
||||
new Parcelable.Creator<CellSignalStrengthLte>() {
|
||||
@Override
|
||||
public CellSignalStrengthLte createFromParcel(Parcel in) {
|
||||
if (in.readInt() != CellSignalStrength.TYPE_LTE) {
|
||||
throw new RuntimeException("Expecting TYPE_LTE");
|
||||
}
|
||||
return createFromParcelBody(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CellSignalStrengthLte[] newArray(int size) {
|
||||
return new CellSignalStrengthLte[size];
|
||||
}
|
||||
};
|
||||
|
||||
/** @hide */
|
||||
public static CellSignalStrengthLte createFromParcelBody(Parcel in) {
|
||||
return new CellSignalStrengthLte(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* log
|
||||
*/
|
||||
private static void log(String s) {
|
||||
Log.w(LOG_TAG, s);
|
||||
}
|
||||
}
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 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.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* CellIdentity is to represent a unique LTE cell
|
||||
*
|
||||
* @hide pending API review
|
||||
*/
|
||||
public final class LteCellIdentity extends CellIdentity implements Parcelable {
|
||||
|
||||
// 3-digit Mobile Country Code, 0..999
|
||||
private final int mMcc;
|
||||
// 2 or 3-digit Mobile Network Code, 0..999
|
||||
private final int mMnc;
|
||||
// 28-bit cell identity
|
||||
private final int mCi;
|
||||
// physical cell id 0..503
|
||||
private final int mPci;
|
||||
// 16-bit tracking area code
|
||||
private final int mTac;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mcc 3-digit Mobile Country Code, 0..999
|
||||
* @param mnc 2 or 3-digit Mobile Network Code, 0..999
|
||||
* @param ci 28-bit Cell Identity
|
||||
* @param pci Physical Cell Id 0..503
|
||||
* @param tac 16-bit Tracking Area Code
|
||||
* @param attr is comma separated “key=value” attribute pairs.
|
||||
*/
|
||||
public LteCellIdentity (int mcc, int mnc,
|
||||
int ci, int pci, int tac, String attr) {
|
||||
super(CELLID_TYPE_CDMA, attr);
|
||||
mMcc = mcc;
|
||||
mMnc = mnc;
|
||||
mCi = ci;
|
||||
mPci = pci;
|
||||
mTac = tac;
|
||||
}
|
||||
|
||||
private LteCellIdentity(Parcel in) {
|
||||
super(in);
|
||||
mMcc = in.readInt();
|
||||
mMnc = in.readInt();
|
||||
mCi = in.readInt();
|
||||
mPci = in.readInt();
|
||||
mTac = in.readInt();
|
||||
}
|
||||
|
||||
LteCellIdentity(LteCellIdentity cid) {
|
||||
super(cid);
|
||||
mMcc = cid.mMcc;
|
||||
mMnc = cid.mMnc;
|
||||
mCi = cid.mCi;
|
||||
mPci = cid.mPci;
|
||||
mTac = cid.mTac;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 3-digit Mobile Country Code, 0..999
|
||||
*/
|
||||
public int getMcc() {
|
||||
return mMcc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 2 or 3-digit Mobile Network Code, 0..999
|
||||
*/
|
||||
public int getMnc() {
|
||||
return mMnc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 28-bit Cell Identity
|
||||
*/
|
||||
public int getCi() {
|
||||
return mCi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Physical Cell Id 0..503
|
||||
*/
|
||||
public int getPci() {
|
||||
return mPci;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 16-bit Tracking Area Code
|
||||
*/
|
||||
public int getTac() {
|
||||
return mTac;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeInt(mMcc);
|
||||
dest.writeInt(mMnc);
|
||||
dest.writeInt(mCi);
|
||||
dest.writeInt(mPci);
|
||||
dest.writeInt(mTac);
|
||||
}
|
||||
|
||||
/** Implement the Parcelable interface {@hide} */
|
||||
public static final Creator<LteCellIdentity> CREATOR =
|
||||
new Creator<LteCellIdentity>() {
|
||||
@Override
|
||||
public LteCellIdentity createFromParcel(Parcel in) {
|
||||
return new LteCellIdentity(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LteCellIdentity[] newArray(int size) {
|
||||
return new LteCellIdentity[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -27,6 +27,8 @@ import android.util.Log;
|
||||
|
||||
import com.android.internal.telephony.IPhoneStateListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A listener class for monitoring changes in specific telephony states
|
||||
* on the device, including service state, signal strength, message
|
||||
@@ -160,7 +162,8 @@ public class PhoneStateListener {
|
||||
* Listen for changes to observed cell info.
|
||||
*
|
||||
* @see #onCellInfoChanged
|
||||
* @hide pending API review
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int LISTEN_CELL_INFO = 0x00000400;
|
||||
|
||||
@@ -284,17 +287,13 @@ public class PhoneStateListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback invoked when a observed cell info gets changed.
|
||||
* Callback invoked when a observed cell info has changed,
|
||||
* or new cells have been added or removed.
|
||||
* @param cellInfo is the list of currently visible cells.
|
||||
*
|
||||
* A notification should be sent when:
|
||||
* 1. a cell is newly-observed.
|
||||
* 2. a observed cell is not visible.
|
||||
* 3. any of the cell info of a observed cell has changed.
|
||||
*
|
||||
* @hide pending API review
|
||||
* @hide
|
||||
*/
|
||||
public void onCellInfoChanged(CellInfo cellInfo) {
|
||||
// default implementation empty
|
||||
public void onCellInfoChanged(List<CellInfo> cellInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,8 +345,8 @@ public class PhoneStateListener {
|
||||
Message.obtain(mHandler, LISTEN_OTASP_CHANGED, otaspMode, 0).sendToTarget();
|
||||
}
|
||||
|
||||
public void onCellInfoChanged(CellInfo cellInfo) {
|
||||
Message.obtain(mHandler, LISTEN_CELL_INFO, 0, 0).sendToTarget();
|
||||
public void onCellInfoChanged(List<CellInfo> cellInfo) {
|
||||
Message.obtain(mHandler, LISTEN_CELL_INFO, 0, 0, cellInfo).sendToTarget();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -387,7 +386,7 @@ public class PhoneStateListener {
|
||||
PhoneStateListener.this.onOtaspChanged(msg.arg1);
|
||||
break;
|
||||
case LISTEN_CELL_INFO:
|
||||
PhoneStateListener.this.onCellInfoChanged((CellInfo)msg.obj);
|
||||
PhoneStateListener.this.onCellInfoChanged((List<CellInfo>)msg.obj);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
* Copyright (C) 2012 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.
|
||||
@@ -28,7 +27,7 @@ import android.util.Log;
|
||||
public class SignalStrength implements Parcelable {
|
||||
|
||||
private static final String LOG_TAG = "SignalStrength";
|
||||
private static final boolean DBG = false;
|
||||
private static final boolean DBG = true;
|
||||
|
||||
/** @hide */
|
||||
public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
|
||||
@@ -114,19 +113,9 @@ public class SignalStrength implements Parcelable {
|
||||
int evdoDbm, int evdoEcio, int evdoSnr,
|
||||
int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi,
|
||||
boolean gsm) {
|
||||
mGsmSignalStrength = gsmSignalStrength;
|
||||
mGsmBitErrorRate = gsmBitErrorRate;
|
||||
mCdmaDbm = cdmaDbm;
|
||||
mCdmaEcio = cdmaEcio;
|
||||
mEvdoDbm = evdoDbm;
|
||||
mEvdoEcio = evdoEcio;
|
||||
mEvdoSnr = evdoSnr;
|
||||
mLteSignalStrength = lteSignalStrength;
|
||||
mLteRsrp = lteRsrp;
|
||||
mLteRsrq = lteRsrq;
|
||||
mLteRssnr = lteRssnr;
|
||||
mLteCqi = lteCqi;
|
||||
isGsm = gsm;
|
||||
initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
|
||||
evdoDbm, evdoEcio, evdoSnr, lteSignalStrength, lteRsrp,
|
||||
lteRsrq, lteRssnr, lteCqi, gsm);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +127,7 @@ public class SignalStrength implements Parcelable {
|
||||
int cdmaDbm, int cdmaEcio,
|
||||
int evdoDbm, int evdoEcio, int evdoSnr,
|
||||
boolean gsm) {
|
||||
this(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
|
||||
initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
|
||||
evdoDbm, evdoEcio, evdoSnr, -1, -1,
|
||||
-1, INVALID_SNR, -1, gsm);
|
||||
}
|
||||
@@ -154,6 +143,69 @@ public class SignalStrength implements Parcelable {
|
||||
copyFrom(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize gsm/cdma values, sets lte values to defaults.
|
||||
*
|
||||
* @param gsmSignalStrength
|
||||
* @param gsmBitErrorRate
|
||||
* @param cdmaDbm
|
||||
* @param cdmaEcio
|
||||
* @param evdoDbm
|
||||
* @param evdoEcio
|
||||
* @param evdoSnr
|
||||
* @param gsm
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void initialize(int gsmSignalStrength, int gsmBitErrorRate,
|
||||
int cdmaDbm, int cdmaEcio,
|
||||
int evdoDbm, int evdoEcio, int evdoSnr,
|
||||
boolean gsm) {
|
||||
initialize(gsmSignalStrength, gsmBitErrorRate, cdmaDbm, cdmaEcio,
|
||||
evdoDbm, evdoEcio, evdoSnr, -1, -1,
|
||||
-1, INVALID_SNR, -1, gsm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all the values
|
||||
*
|
||||
* @param gsmSignalStrength
|
||||
* @param gsmBitErrorRate
|
||||
* @param cdmaDbm
|
||||
* @param cdmaEcio
|
||||
* @param evdoDbm
|
||||
* @param evdoEcio
|
||||
* @param evdoSnr
|
||||
* @param lteSignalStrength
|
||||
* @param lteRsrp
|
||||
* @param lteRsrq
|
||||
* @param lteRssnr
|
||||
* @param lteCqi
|
||||
* @param gsm
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void initialize(int gsmSignalStrength, int gsmBitErrorRate,
|
||||
int cdmaDbm, int cdmaEcio,
|
||||
int evdoDbm, int evdoEcio, int evdoSnr,
|
||||
int lteSignalStrength, int lteRsrp, int lteRsrq, int lteRssnr, int lteCqi,
|
||||
boolean gsm) {
|
||||
mGsmSignalStrength = gsmSignalStrength;
|
||||
mGsmBitErrorRate = gsmBitErrorRate;
|
||||
mCdmaDbm = cdmaDbm;
|
||||
mCdmaEcio = cdmaEcio;
|
||||
mEvdoDbm = evdoDbm;
|
||||
mEvdoEcio = evdoEcio;
|
||||
mEvdoSnr = evdoSnr;
|
||||
mLteSignalStrength = lteSignalStrength;
|
||||
mLteRsrp = lteRsrp;
|
||||
mLteRsrq = lteRsrq;
|
||||
mLteRssnr = lteRssnr;
|
||||
mLteCqi = lteCqi;
|
||||
isGsm = gsm;
|
||||
if (DBG) log("initialize: " + toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
||||
@@ -1272,7 +1272,7 @@ public class TelephonyManager {
|
||||
* <p>Requires Permission:
|
||||
* (@link android.Manifest.permission#ACCESS_COARSE_UPDATES}
|
||||
*
|
||||
* @hide pending API review
|
||||
* @hide
|
||||
*/
|
||||
public List<CellInfo> getAllCellInfo() {
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,6 @@ oneway interface IPhoneStateListener {
|
||||
void onDataActivity(int direction);
|
||||
void onSignalStrengthsChanged(in SignalStrength signalStrength);
|
||||
void onOtaspChanged(in int otaspMode);
|
||||
void onCellInfoChanged(in CellInfo cellInfo);
|
||||
void onCellInfoChanged(in List<CellInfo> cellInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,5 +40,5 @@ interface ITelephonyRegistry {
|
||||
void notifyDataConnectionFailed(String reason, String apnType);
|
||||
void notifyCellLocation(in Bundle cellLocation);
|
||||
void notifyOtaspChanged(in int otaspMode);
|
||||
void notifyCellInfo(in CellInfo cellInfo);
|
||||
void notifyCellInfo(in List<CellInfo> cellInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user