Merge "Change timestamp unit from nanos to millis"

This commit is contained in:
Mingming Cai
2020-02-13 08:16:18 +00:00
committed by Gerrit Code Review
3 changed files with 22 additions and 20 deletions

View File

@@ -45043,7 +45043,7 @@ package android.telephony {
method @NonNull public abstract android.telephony.CellIdentity getCellIdentity(); method @NonNull public abstract android.telephony.CellIdentity getCellIdentity();
method @NonNull public abstract android.telephony.CellSignalStrength getCellSignalStrength(); method @NonNull public abstract android.telephony.CellSignalStrength getCellSignalStrength();
method @Deprecated public long getTimeStamp(); method @Deprecated public long getTimeStamp();
method public long getTimestampNanos(); method public long getTimestampMillis();
method public boolean isRegistered(); method public boolean isRegistered();
field public static final int CONNECTION_NONE = 0; // 0x0 field public static final int CONNECTION_NONE = 0; // 0x0
field public static final int CONNECTION_PRIMARY_SERVING = 1; // 0x1 field public static final int CONNECTION_PRIMARY_SERVING = 1; // 0x1
@@ -45549,7 +45549,7 @@ package android.telephony {
method @Deprecated public int getGsmBitErrorRate(); method @Deprecated public int getGsmBitErrorRate();
method @Deprecated public int getGsmSignalStrength(); method @Deprecated public int getGsmSignalStrength();
method public int getLevel(); method public int getLevel();
method public long getTimestampNanos(); method public long getTimestampMillis();
method @Deprecated public boolean isGsm(); method @Deprecated public boolean isGsm();
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SignalStrength> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SignalStrength> CREATOR;

View File

@@ -16,9 +16,9 @@
package android.telephony; package android.telephony;
import android.annotation.ElapsedRealtimeLong;
import android.annotation.IntDef; import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.radio.V1_4.CellInfo.Info; import android.hardware.radio.V1_4.CellInfo.Info;
import android.os.Parcel; import android.os.Parcel;
@@ -178,18 +178,18 @@ public abstract class CellInfo implements Parcelable {
/** /**
* Approximate time this cell information was received from the modem. * Approximate time this cell information was received from the modem.
* *
* @return a time stamp in nanos since boot. * @return a time stamp in millis since boot.
*/ */
@SuppressLint("MethodNameUnits") @ElapsedRealtimeLong
public long getTimestampNanos() { public long getTimestampMillis() {
return mTimeStamp; return mTimeStamp / 1000000;
} }
/** /**
* Approximate time this cell information was received from the modem. * Approximate time this cell information was received from the modem.
* *
* @return a time stamp in nanos since boot. * @return a time stamp in nanos since boot.
* @deprecated Use {@link #getTimestampNanos} instead. * @deprecated Use {@link #getTimestampMillis} instead.
*/ */
@Deprecated @Deprecated
public long getTimeStamp() { public long getTimeStamp() {

View File

@@ -16,8 +16,8 @@
package android.telephony; package android.telephony;
import android.annotation.ElapsedRealtimeLong;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage;
import android.os.Build; import android.os.Build;
@@ -79,8 +79,9 @@ public class SignalStrength implements Parcelable {
/* The type of signal measurement */ /* The type of signal measurement */
private static final String MEASUREMENT_TYPE_RSCP = "rscp"; private static final String MEASUREMENT_TYPE_RSCP = "rscp";
// timeStamp of signalStrength in nanoseconds since boot // Timestamp of SignalStrength since boot
private long mTimestamp = Long.MAX_VALUE; // Effectively final. Timestamp is set during construction of SignalStrength
private long mTimestampMillis;
CellSignalStrengthCdma mCdma; CellSignalStrengthCdma mCdma;
CellSignalStrengthGsm mGsm; CellSignalStrengthGsm mGsm;
@@ -140,7 +141,7 @@ public class SignalStrength implements Parcelable {
mTdscdma = tdscdma; mTdscdma = tdscdma;
mLte = lte; mLte = lte;
mNr = nr; mNr = nr;
mTimestamp = SystemClock.elapsedRealtimeNanos(); mTimestampMillis = SystemClock.elapsedRealtime();
} }
/** /**
@@ -275,7 +276,6 @@ public class SignalStrength implements Parcelable {
mTdscdma.updateLevel(cc, ss); mTdscdma.updateLevel(cc, ss);
mLte.updateLevel(cc, ss); mLte.updateLevel(cc, ss);
mNr.updateLevel(cc, ss); mNr.updateLevel(cc, ss);
mTimestamp = SystemClock.elapsedRealtimeNanos();
} }
/** /**
@@ -301,7 +301,7 @@ public class SignalStrength implements Parcelable {
mTdscdma = new CellSignalStrengthTdscdma(s.mTdscdma); mTdscdma = new CellSignalStrengthTdscdma(s.mTdscdma);
mLte = new CellSignalStrengthLte(s.mLte); mLte = new CellSignalStrengthLte(s.mLte);
mNr = new CellSignalStrengthNr(s.mNr); mNr = new CellSignalStrengthNr(s.mNr);
mTimestamp = s.getTimestampNanos(); mTimestampMillis = s.getTimestampMillis();
} }
/** /**
@@ -319,7 +319,7 @@ public class SignalStrength implements Parcelable {
mTdscdma = in.readParcelable(CellSignalStrengthTdscdma.class.getClassLoader()); mTdscdma = in.readParcelable(CellSignalStrengthTdscdma.class.getClassLoader());
mLte = in.readParcelable(CellSignalStrengthLte.class.getClassLoader()); mLte = in.readParcelable(CellSignalStrengthLte.class.getClassLoader());
mNr = in.readParcelable(CellSignalStrengthLte.class.getClassLoader()); mNr = in.readParcelable(CellSignalStrengthLte.class.getClassLoader());
mTimestamp = in.readLong(); mTimestampMillis = in.readLong();
} }
/** /**
@@ -332,15 +332,17 @@ public class SignalStrength implements Parcelable {
out.writeParcelable(mTdscdma, flags); out.writeParcelable(mTdscdma, flags);
out.writeParcelable(mLte, flags); out.writeParcelable(mLte, flags);
out.writeParcelable(mNr, flags); out.writeParcelable(mNr, flags);
out.writeLong(mTimestamp); out.writeLong(mTimestampMillis);
} }
/** /**
* @return mTimestamp in nanoseconds * @return timestamp in milliseconds since boot for {@link SignalStrength}.
* This timestamp reports the approximate time that the signal was measured and reported
* by the modem. It can be used to compare the recency of {@link SignalStrength} instances.
*/ */
@SuppressLint("MethodNameUnits") @ElapsedRealtimeLong
public long getTimestampNanos() { public long getTimestampMillis() {
return mTimestamp; return mTimestampMillis;
} }
/** /**