Merge "Move NUM_GPS_SIGNAL_QUALITY_LEVELS to GnssSignalQuality"
This commit is contained in:
committed by
Android (Google) Code Review
commit
8068b16f2f
@@ -27,6 +27,7 @@ import android.app.job.JobParameters;
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.location.GnssSignalQuality;
|
||||
import android.os.BatteryStatsManager.WifiState;
|
||||
import android.os.BatteryStatsManager.WifiSupplState;
|
||||
import android.server.ServerProtoEnums;
|
||||
@@ -47,7 +48,6 @@ import android.util.proto.ProtoOutputStream;
|
||||
import android.view.Display;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.location.gnssmetrics.GnssMetrics;
|
||||
import com.android.internal.os.BatterySipper;
|
||||
import com.android.internal.os.BatteryStatsHelper;
|
||||
|
||||
@@ -5087,8 +5087,9 @@ public abstract class BatteryStats implements Parcelable {
|
||||
final String[] gpsSignalQualityDescription = new String[]{
|
||||
"poor (less than 20 dBHz): ",
|
||||
"good (greater than 20 dBHz): "};
|
||||
final int numGpsSignalQualityBins = Math.min(GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS,
|
||||
gpsSignalQualityDescription.length);
|
||||
final int numGpsSignalQualityBins = Math.min(
|
||||
GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS,
|
||||
gpsSignalQualityDescription.length);
|
||||
for (int i=0; i<numGpsSignalQualityBins; i++) {
|
||||
final long time = getGpsSignalQualityTime(i, rawRealtime, which);
|
||||
sb.append("\n ");
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package android.os.connectivity;
|
||||
|
||||
import android.location.GnssSignalQuality;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.internal.location.gnssmetrics.GnssMetrics;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
@@ -85,7 +84,7 @@ public final class GpsBatteryStats implements Parcelable {
|
||||
|
||||
public void setTimeInGpsSignalQualityLevel(long[] t) {
|
||||
mTimeInGpsSignalQualityLevel = Arrays.copyOfRange(t, 0,
|
||||
Math.min(t.length, GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS));
|
||||
Math.min(t.length, GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -102,7 +101,7 @@ public final class GpsBatteryStats implements Parcelable {
|
||||
private void initialize() {
|
||||
mLoggingDurationMs = 0;
|
||||
mEnergyConsumedMaMs = 0;
|
||||
mTimeInGpsSignalQualityLevel = new long[GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS];
|
||||
mTimeInGpsSignalQualityLevel = new long[GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS];
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.database.ContentObserver;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.location.GnssSignalQuality;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.INetworkStatsService;
|
||||
import android.net.NetworkStats;
|
||||
@@ -97,7 +98,6 @@ import android.view.Display;
|
||||
|
||||
import com.android.internal.annotations.GuardedBy;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.location.gnssmetrics.GnssMetrics;
|
||||
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidActiveTimeReader;
|
||||
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidClusterTimeReader;
|
||||
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidFreqTimeReader;
|
||||
@@ -895,7 +895,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
int mGpsSignalQualityBin = -1;
|
||||
@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
|
||||
protected final StopwatchTimer[] mGpsSignalQualityTimer =
|
||||
new StopwatchTimer[GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS];
|
||||
new StopwatchTimer[GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS];
|
||||
|
||||
int mPhoneSignalStrengthBin = -1;
|
||||
int mPhoneSignalStrengthBinRaw = -1;
|
||||
@@ -5049,7 +5049,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
if (mGpsNesting == 0) {
|
||||
return;
|
||||
}
|
||||
if (signalLevel < 0 || signalLevel >= GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS) {
|
||||
if (signalLevel < 0 || signalLevel >= mGpsSignalQualityTimer.length) {
|
||||
stopAllGpsSignalQualityTimersLocked(-1, elapsedRealtimeMs);
|
||||
return;
|
||||
}
|
||||
@@ -5460,7 +5460,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
|
||||
void stopAllGpsSignalQualityTimersLocked(int except, long elapsedRealtimeMs) {
|
||||
for (int i = 0; i < GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i = 0; i < mGpsSignalQualityTimer.length; i++) {
|
||||
if (i == except) {
|
||||
continue;
|
||||
}
|
||||
@@ -6911,7 +6911,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
|
||||
@Override public long getGpsSignalQualityTime(int strengthBin,
|
||||
long elapsedRealtimeUs, int which) {
|
||||
if (strengthBin < 0 || strengthBin >= GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS) {
|
||||
if (strengthBin < 0 || strengthBin >= mGpsSignalQualityTimer.length) {
|
||||
return 0;
|
||||
}
|
||||
return mGpsSignalQualityTimer[strengthBin].getTotalTimeLocked(
|
||||
@@ -6927,7 +6927,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
double energyUsedMaMs = 0.0;
|
||||
final int which = STATS_SINCE_CHARGED;
|
||||
final long rawRealtimeUs = SystemClock.elapsedRealtime() * 1000;
|
||||
for(int i=0; i < GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for(int i=0; i < mGpsSignalQualityTimer.length; i++) {
|
||||
energyUsedMaMs
|
||||
+= mPowerProfile.getAveragePower(PowerProfile.POWER_GPS_SIGNAL_QUALITY_BASED, i)
|
||||
* (getGpsSignalQualityTime(i, rawRealtimeUs, which) / 1000);
|
||||
@@ -10659,7 +10659,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mOnBatteryTimeBase);
|
||||
}
|
||||
mWifiActiveTimer = new StopwatchTimer(mClocks, null, -900, null, mOnBatteryTimeBase);
|
||||
for (int i=0; i< GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i=0; i< mGpsSignalQualityTimer.length; i++) {
|
||||
mGpsSignalQualityTimer[i] = new StopwatchTimer(mClocks, null, -1000-i, null,
|
||||
mOnBatteryTimeBase);
|
||||
}
|
||||
@@ -11351,7 +11351,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mWifiMulticastWakelockTimer.reset(false, elapsedRealtimeUs);
|
||||
mWifiActiveTimer.reset(false, elapsedRealtimeUs);
|
||||
mWifiActivity.reset(false, elapsedRealtimeUs);
|
||||
for (int i=0; i< GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i=0; i< mGpsSignalQualityTimer.length; i++) {
|
||||
mGpsSignalQualityTimer[i].reset(false, elapsedRealtimeUs);
|
||||
}
|
||||
mBluetoothActivity.reset(false, elapsedRealtimeUs);
|
||||
@@ -13641,7 +13641,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
final long rawRealTimeUs = SystemClock.elapsedRealtime() * 1000;
|
||||
s.setLoggingDurationMs(computeBatteryRealtime(rawRealTimeUs, which) / 1000);
|
||||
s.setEnergyConsumedMaMs(getGpsBatteryDrainMaMs());
|
||||
long[] time = new long[GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS];
|
||||
long[] time = new long[mGpsSignalQualityTimer.length];
|
||||
for (int i=0; i<time.length; i++) {
|
||||
time[i] = getGpsSignalQualityTime(i, rawRealTimeUs, which) / 1000;
|
||||
}
|
||||
@@ -14692,7 +14692,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
mWifiActiveTimer.readSummaryFromParcelLocked(in);
|
||||
mWifiActivity.readSummaryFromParcel(in);
|
||||
for (int i=0; i<GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i=0; i<mGpsSignalQualityTimer.length; i++) {
|
||||
mGpsSignalQualityTimer[i].readSummaryFromParcelLocked(in);
|
||||
}
|
||||
mBluetoothActivity.readSummaryFromParcel(in);
|
||||
@@ -15178,7 +15178,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
mWifiActiveTimer.writeSummaryFromParcelLocked(out, NOWREAL_SYS);
|
||||
mWifiActivity.writeSummaryToParcel(out);
|
||||
for (int i=0; i< GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i=0; i< mGpsSignalQualityTimer.length; i++) {
|
||||
mGpsSignalQualityTimer[i].writeSummaryFromParcelLocked(out, NOWREAL_SYS);
|
||||
}
|
||||
mBluetoothActivity.writeSummaryToParcel(out);
|
||||
@@ -15672,7 +15672,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
mOnBatteryTimeBase, in);
|
||||
mWifiActivity = new ControllerActivityCounterImpl(mOnBatteryTimeBase,
|
||||
NUM_WIFI_TX_LEVELS, in);
|
||||
for (int i=0; i<GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i=0; i<mGpsSignalQualityTimer.length; i++) {
|
||||
mGpsSignalQualityTimer[i] = new StopwatchTimer(mClocks, null, -1000-i,
|
||||
null, mOnBatteryTimeBase, in);
|
||||
}
|
||||
@@ -15886,7 +15886,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
}
|
||||
mWifiActiveTimer.writeToParcel(out, uSecRealtime);
|
||||
mWifiActivity.writeToParcel(out, 0);
|
||||
for (int i = 0; i < GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i = 0; i < mGpsSignalQualityTimer.length; i++) {
|
||||
mGpsSignalQualityTimer[i].writeToParcel(out, uSecRealtime);
|
||||
}
|
||||
mBluetoothActivity.writeToParcel(out, 0);
|
||||
@@ -16197,7 +16197,7 @@ public class BatteryStatsImpl extends BatteryStats {
|
||||
pr.println("*** Wifi signal strength #" + i + ":");
|
||||
mWifiSignalStrengthsTimer[i].logState(pr, " ");
|
||||
}
|
||||
for (int i=0; i<GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i=0; i<mGpsSignalQualityTimer.length; i++) {
|
||||
pr.println("*** GPS signal quality #" + i + ":");
|
||||
mGpsSignalQualityTimer[i].logState(pr, " ");
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@ package com.android.internal.os;
|
||||
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.location.GnssSignalQuality;
|
||||
import android.os.BatteryStats;
|
||||
import android.os.UserHandle;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import com.android.internal.location.gnssmetrics.GnssMetrics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SensorPowerCalculator extends PowerCalculator {
|
||||
@@ -83,7 +82,7 @@ public class SensorPowerCalculator extends PowerCalculator {
|
||||
averagePower = 0;
|
||||
long totalTime = 0;
|
||||
double totalPower = 0;
|
||||
for (int i = 0; i < GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i = 0; i < GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
long timePerLevel = stats.getGpsSignalQualityTime(i, rawRealtimeUs, statsType);
|
||||
totalTime += timePerLevel;
|
||||
totalPower +=
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
|
||||
package com.android.internal.os;
|
||||
|
||||
import android.location.GnssSignalQuality;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.SparseIntArray;
|
||||
|
||||
import com.android.internal.location.gnssmetrics.GnssMetrics;
|
||||
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidActiveTimeReader;
|
||||
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidClusterTimeReader;
|
||||
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidFreqTimeReader;
|
||||
@@ -47,7 +47,7 @@ public class MockBatteryStatsImpl extends BatteryStatsImpl {
|
||||
mBluetoothScanTimer = new StopwatchTimer(mClocks, null, -14, null, mOnBatteryTimeBase);
|
||||
setExternalStatsSyncLocked(new DummyExternalStatsSync());
|
||||
|
||||
for (int i = 0; i < GnssMetrics.NUM_GPS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
for (int i = 0; i < GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS; i++) {
|
||||
mGpsSignalQualityTimer[i] = new StopwatchTimer(clocks, null, -1000 - i, null,
|
||||
mOnBatteryTimeBase);
|
||||
}
|
||||
|
||||
38
location/java/android/location/GnssSignalQuality.java
Normal file
38
location/java/android/location/GnssSignalQuality.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.location;
|
||||
|
||||
import android.server.location.ServerLocationProtoEnums;
|
||||
|
||||
/**
|
||||
* Gnss signal quality information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public interface GnssSignalQuality {
|
||||
|
||||
int GNSS_SIGNAL_QUALITY_UNKNOWN =
|
||||
ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_UNKNOWN; // -1
|
||||
|
||||
int GNSS_SIGNAL_QUALITY_POOR =
|
||||
ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_POOR; // 0
|
||||
|
||||
int GNSS_SIGNAL_QUALITY_GOOD =
|
||||
ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_GOOD; // 1
|
||||
|
||||
int NUM_GNSS_SIGNAL_QUALITY_LEVELS = GNSS_SIGNAL_QUALITY_GOOD + 1;
|
||||
}
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package com.android.internal.location.gnssmetrics;
|
||||
|
||||
import static android.location.GnssSignalQuality.GNSS_SIGNAL_QUALITY_GOOD;
|
||||
import static android.location.GnssSignalQuality.GNSS_SIGNAL_QUALITY_POOR;
|
||||
import static android.location.GnssSignalQuality.GNSS_SIGNAL_QUALITY_UNKNOWN;
|
||||
import static android.location.GnssSignalQuality.NUM_GNSS_SIGNAL_QUALITY_LEVELS;
|
||||
|
||||
import android.app.StatsManager;
|
||||
import android.content.Context;
|
||||
import android.location.GnssStatus;
|
||||
@@ -23,7 +28,6 @@ import android.os.RemoteException;
|
||||
import android.os.SystemClock;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.connectivity.GpsBatteryStats;
|
||||
import android.server.location.ServerLocationProtoEnums;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
@@ -50,17 +54,6 @@ public class GnssMetrics {
|
||||
|
||||
private static final String TAG = "GnssMetrics";
|
||||
|
||||
private static final int GPS_SIGNAL_QUALITY_UNKNOWN =
|
||||
ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_UNKNOWN; // -1
|
||||
|
||||
private static final int GPS_SIGNAL_QUALITY_POOR =
|
||||
ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_POOR; // 0
|
||||
|
||||
private static final int GPS_SIGNAL_QUALITY_GOOD =
|
||||
ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_GOOD; // 1
|
||||
|
||||
public static final int NUM_GPS_SIGNAL_QUALITY_LEVELS = GPS_SIGNAL_QUALITY_GOOD + 1;
|
||||
|
||||
/** Default time between location fixes (in millisecs) */
|
||||
private static final int DEFAULT_TIME_BETWEEN_FIXES_MILLISECS = 1000;
|
||||
|
||||
@@ -397,7 +390,7 @@ public class GnssMetrics {
|
||||
stats.getLoggingDurationMs() / ((double) DateUtils.MINUTE_IN_MILLIS)).append(
|
||||
"\n");
|
||||
long[] t = stats.getTimeInGpsSignalQualityLevel();
|
||||
if (t != null && t.length == NUM_GPS_SIGNAL_QUALITY_LEVELS) {
|
||||
if (t != null && t.length == NUM_GNSS_SIGNAL_QUALITY_LEVELS) {
|
||||
s.append(" Amount of time (while on battery) Top 4 Avg CN0 > "
|
||||
+ GnssPowerMetrics.POOR_TOP_FOUR_AVG_CN0_THRESHOLD_DB_HZ
|
||||
+ " dB-Hz (min): ").append(
|
||||
@@ -512,7 +505,7 @@ public class GnssMetrics {
|
||||
// so that
|
||||
// the first CNO report will trigger an update to BatteryStats
|
||||
mLastAverageCn0 = -100.0;
|
||||
mLastSignalLevel = GPS_SIGNAL_QUALITY_UNKNOWN;
|
||||
mLastSignalLevel = GNSS_SIGNAL_QUALITY_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -584,9 +577,9 @@ public class GnssMetrics {
|
||||
*/
|
||||
private int getSignalLevel(double cn0) {
|
||||
if (cn0 > POOR_TOP_FOUR_AVG_CN0_THRESHOLD_DB_HZ) {
|
||||
return GnssMetrics.GPS_SIGNAL_QUALITY_GOOD;
|
||||
return GNSS_SIGNAL_QUALITY_GOOD;
|
||||
}
|
||||
return GnssMetrics.GPS_SIGNAL_QUALITY_POOR;
|
||||
return GNSS_SIGNAL_QUALITY_POOR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user