diff options
author | Martijn Coenen <maco@google.com> | 2016-08-12 12:05:54 +0200 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2016-08-12 10:07:37 +0000 |
commit | 1ff09042e0f95cd4adcca60a250a80f1638703ac (patch) | |
tree | 17d526da2b220efc5433baf1fd766fea4723bf47 | |
parent | 2603a23b04792ffb771ab5e8c32d767af47883f7 (diff) | |
download | android_packages_apps_Nfc-1ff09042e0f95cd4adcca60a250a80f1638703ac.tar.gz android_packages_apps_Nfc-1ff09042e0f95cd4adcca60a250a80f1638703ac.tar.bz2 android_packages_apps_Nfc-1ff09042e0f95cd4adcca60a250a80f1638703ac.zip |
Fix Tron stats reporting.
Fix counter names, as "tron_varz" is automatically
appended. Also, only try to upload stats every four
hours.
Bug: 30424959
Change-Id: I1b168467888e1d5d6e7bc478ccc833c498292108
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 6e5af15f..d91e3b55 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -108,9 +108,9 @@ public class NfcService implements DeviceHostListener { static final String PREF_FIRST_BEAM = "first_beam"; static final String PREF_FIRST_BOOT = "first_boot"; - static final String TRON_NFC_CE = "tron_nfc_ce"; - static final String TRON_NFC_P2P = "tron_nfc_p2p"; - static final String TRON_NFC_TAG = "tron_nfc_tag"; + static final String TRON_NFC_CE = "nfc_ce"; + static final String TRON_NFC_P2P = "nfc_p2p"; + static final String TRON_NFC_TAG = "nfc_tag"; static final int MSG_NDEF_TAG = 0; static final int MSG_LLCP_LINK_ACTIVATION = 1; @@ -127,7 +127,10 @@ public class NfcService implements DeviceHostListener { static final int MSG_REGISTER_T3T_IDENTIFIER = 12; static final int MSG_DEREGISTER_T3T_IDENTIFIER = 13; static final int MSG_TAG_DEBOUNCE = 14; + static final int MSG_UPDATE_STATS = 15; + // Update stats every 4 hours + static final long STATS_UPDATE_INTERVAL_MS = 4 * 60 * 60 * 1000; static final long MAX_POLLING_PAUSE_TIMEOUT = 40000; static final int TASK_ENABLE = 1; @@ -425,6 +428,8 @@ public class NfcService implements DeviceHostListener { ServiceManager.addService(SERVICE_NAME, mNfcAdapter); new EnableDisableTask().execute(TASK_BOOT); // do blocking boot tasks + + mHandler.sendEmptyMessageDelayed(MSG_UPDATE_STATS, STATS_UPDATE_INTERVAL_MS); } void initSoundPool() { @@ -1474,16 +1479,6 @@ public class NfcService implements DeviceHostListener { * Read mScreenState and apply NFC-C polling and NFC-EE routing */ void applyRouting(boolean force) { - // Since this operation may anyway take some time, and we do it - // regularly, update metrics here. - if (mNumTagsDetected.get() > 0 || mNumHceDetected.get() > 0 || mNumP2pDetected.get() > 0) { - MetricsLogger.count(mContext, TRON_NFC_TAG, mNumTagsDetected.get()); - mNumTagsDetected.set(0); - MetricsLogger.count(mContext, TRON_NFC_CE, mNumHceDetected.get()); - mNumHceDetected.set(0); - MetricsLogger.count(mContext, TRON_NFC_P2P, mNumP2pDetected.get()); - mNumP2pDetected.set(0); - } synchronized (this) { if (!isNfcEnabledOrShuttingDown()) { return; @@ -1976,6 +1971,22 @@ public class NfcService implements DeviceHostListener { } } break; + case MSG_UPDATE_STATS: + if (mNumTagsDetected.get() > 0) { + MetricsLogger.count(mContext, TRON_NFC_TAG, mNumTagsDetected.get()); + mNumTagsDetected.set(0); + } + if (mNumHceDetected.get() > 0) { + MetricsLogger.count(mContext, TRON_NFC_CE, mNumHceDetected.get()); + mNumHceDetected.set(0); + } + if (mNumP2pDetected.get() > 0) { + MetricsLogger.count(mContext, TRON_NFC_P2P, mNumP2pDetected.get()); + mNumP2pDetected.set(0); + } + removeMessages(MSG_UPDATE_STATS); + sendEmptyMessageDelayed(MSG_UPDATE_STATS, STATS_UPDATE_INTERVAL_MS); + break; default: Log.e(TAG, "Unknown message received"); break; |