diff options
| author | 2018-11-06 15:49:08 -0800 | |
|---|---|---|
| committer | 2018-11-14 11:59:20 -0800 | |
| commit | 48d362e323e05c821f3d0b88db49dc1ad4f6c3a6 (patch) | |
| tree | 725bd4c67817033f6e58d43d69490ccff46e1d5e | |
| parent | e9f5e860547e7314c4c0e03fa4838c5b06164f5d (diff) | |
Statsd atom: GpsSignalQuality
Gps Signal Quality is used in the BatteryStats power usage calculations,
so it should also be logged to statsd.
Bug: 113524439
Test: Turned GPS on and made sure a signal level was logged
Change-Id: Id770ec549bbb47621f2585b9dbd09333f78656d1
| -rw-r--r-- | cmds/statsd/src/atoms.proto | 14 | ||||
| -rw-r--r-- | core/proto/android/server/location/enums.proto | 30 | ||||
| -rw-r--r-- | location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java | 24 |
3 files changed, 63 insertions, 5 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index 53d967363765..85725172e22a 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -27,6 +27,7 @@ import "frameworks/base/core/proto/android/app/job/enums.proto"; import "frameworks/base/core/proto/android/bluetooth/enums.proto"; import "frameworks/base/core/proto/android/os/enums.proto"; import "frameworks/base/core/proto/android/server/enums.proto"; +import "frameworks/base/core/proto/android/server/location/enums.proto"; import "frameworks/base/core/proto/android/service/procstats_enum.proto"; import "frameworks/base/core/proto/android/stats/enums.proto"; import "frameworks/base/core/proto/android/stats/launcher/launcher.proto"; @@ -118,7 +119,7 @@ message Atom { ResourceConfigurationChanged resource_configuration_changed = 66; BluetoothEnabledStateChanged bluetooth_enabled_state_changed = 67; BluetoothConnectionStateChanged bluetooth_connection_state_changed = 68; - // 69 is blank but need not be. + GpsSignalQualityChanged gps_signal_quality_changed = 69; UsbConnectorStateChanged usb_connector_state_changed = 70; SpeakerImpedanceReported speaker_impedance_reported = 71; HardwareFailed hardware_failed = 72; @@ -486,7 +487,6 @@ message SensorStateChanged { optional State state = 3; } - /** * Logs when GPS state changes. * @@ -503,6 +503,16 @@ message GpsScanStateChanged { optional State state = 2; } +/** + * Logs when GPS signal quality. + * + * Logged from: + * /frameworks/base/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java + */ +message GpsSignalQualityChanged { + optional android.server.location.GpsSignalQualityEnum level = 1; +} + /** * Logs when a sync manager sync state changes. diff --git a/core/proto/android/server/location/enums.proto b/core/proto/android/server/location/enums.proto new file mode 100644 index 000000000000..b6dc58932ce7 --- /dev/null +++ b/core/proto/android/server/location/enums.proto @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2018 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. + */ + +syntax = "proto2"; + +package android.server.location; + +option java_outer_classname = "ServerLocationProtoEnums"; +option java_multiple_files = true; + +// GPS Signal Quality levels, +// primarily used by location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java +enum GpsSignalQualityEnum { + GPS_SIGNAL_QUALITY_UNKNOWN = -1; + GPS_SIGNAL_QUALITY_POOR = 0; + GPS_SIGNAL_QUALITY_GOOD = 1; +} diff --git a/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java b/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java index 8a02a82194df..057a4ae879f4 100644 --- a/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java +++ b/location/java/com/android/internal/location/gnssmetrics/GnssMetrics.java @@ -20,9 +20,12 @@ import android.os.SystemClock; import android.os.connectivity.GpsBatteryStats; import android.os.SystemProperties; +import android.server.location.ServerLocationProtoEnums; + import android.text.format.DateUtils; import android.util.Base64; import android.util.Log; +import android.util.StatsLog; import android.util.TimeUtils; import java.util.Arrays; @@ -39,11 +42,17 @@ public class GnssMetrics { private static final String TAG = GnssMetrics.class.getSimpleName(); + /* Constant which indicates GPS signal quality is as yet unknown */ + public static final int GPS_SIGNAL_QUALITY_UNKNOWN = + ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_UNKNOWN; // -1 + /* Constant which indicates GPS signal quality is poor */ - public static final int GPS_SIGNAL_QUALITY_POOR = 0; + public static final int GPS_SIGNAL_QUALITY_POOR = + ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_POOR; // 0 /* Constant which indicates GPS signal quality is good */ - public static final int GPS_SIGNAL_QUALITY_GOOD = 1; + public static final int GPS_SIGNAL_QUALITY_GOOD = + ServerLocationProtoEnums.GPS_SIGNAL_QUALITY_GOOD; // 1 /* Number of GPS signal quality levels */ public static final int NUM_GPS_SIGNAL_QUALITY_LEVELS = GPS_SIGNAL_QUALITY_GOOD + 1; @@ -329,11 +338,15 @@ public class GnssMetrics { /* Last reported Top Four Average CN0 */ private double mLastAverageCn0; + /* Last reported signal quality bin (based on Top Four Average CN0) */ + private int mLastSignalLevel; + public GnssPowerMetrics(IBatteryStats stats) { mBatteryStats = stats; // Used to initialize the variable to a very small value (unachievable in practice) so that // the first CNO report will trigger an update to BatteryStats mLastAverageCn0 = -100.0; + mLastSignalLevel = GPS_SIGNAL_QUALITY_UNKNOWN; } /** @@ -384,8 +397,13 @@ public class GnssMetrics { if (Math.abs(avgCn0 - mLastAverageCn0) < REPORTING_THRESHOLD_DB_HZ) { return; } + int signalLevel = getSignalLevel(avgCn0); + if (signalLevel != mLastSignalLevel) { + StatsLog.write(StatsLog.GPS_SIGNAL_QUALITY_CHANGED, signalLevel); + mLastSignalLevel = signalLevel; + } try { - mBatteryStats.noteGpsSignalQuality(getSignalLevel(avgCn0)); + mBatteryStats.noteGpsSignalQuality(signalLevel); mLastAverageCn0 = avgCn0; } catch (Exception e) { Log.w(TAG, "Exception", e); |