Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-services-Analytics: Commit

packages/services/Analytics


Commit MetaInfo

Révision844ae049e1baea4aab77f39f6ce435bd883f1b71 (tree)
l'heure2017-10-27 11:35:11
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

AnalyticsService: report the build info in power events

Set buind info to the label of power events so we can know
what the build is in Google Analytics.

Change Summary

Modification

--- a/Service/src/org/android_x86/analytics/AnalyticsService.java
+++ b/Service/src/org/android_x86/analytics/AnalyticsService.java
@@ -205,10 +205,18 @@ public class AnalyticsService extends ImmortalIntentService {
205205 return nowSeconds - latestChangeTime;
206206 }
207207
208+ private void sendPowerEvent(String event, long time, long powerOnNotSleep) {
209+ LogHelper.LogBuilder builder = mLogHelper.newEventBuilder(EVENT_CATEGORY_POWER,
210+ event, Util.BuildUtil.getProductVersion(), time);
211+ if (powerOnNotSleep != -1) {
212+ builder.setPower(powerOnNotSleep);
213+ }
214+ builder.send();
215+ }
216+
208217 private void onBootCompleted(Intent data) {
209218 long bootTime = SystemClock.elapsedRealtime() / MS_IN_SECOND;
210- mLogHelper.newEventBuilder(EVENT_CATEGORY_POWER, EVENT_BOOT_COMPLETED, null, bootTime)
211- .send();
219+ sendPowerEvent(EVENT_BOOT_COMPLETED, bootTime, -1);
212220
213221 if (SystemProperties.getBoolean("persist.sys.hw_statistics", true)) {
214222 new HardwareCollector(this).uploadHardwareInfo();
@@ -231,25 +239,17 @@ public class AnalyticsService extends ImmortalIntentService {
231239 Log.w(TAG, "onShutdown, cannot get data");
232240 return;
233241 }
234- mLogHelper.newEventBuilder(
235- EVENT_CATEGORY_POWER, EVENT_SHUTDOWN, null, powerOnIncludeSleep)
236- .setPower(powerOnNotSleep)
237- .send();
242+ sendPowerEvent(EVENT_SHUTDOWN, powerOnIncludeSleep, powerOnNotSleep);
238243 }
239244
240245 private void onScreenOn(Intent data) {
241246 Long screenOffDuration = getDurationAndSaveScreenChangeTime();
242-
243- mLogHelper.newEventBuilder(
244- EVENT_CATEGORY_POWER, EVENT_SCREEN_ON, null, screenOffDuration)
245- .send();
247+ sendPowerEvent(EVENT_SCREEN_ON, screenOffDuration, -1);
246248 }
247249
248250 private void onScreenOff(Intent data) {
249251 Long screenOnDuration = getDurationAndSaveScreenChangeTime();
250- mLogHelper.newEventBuilder(
251- EVENT_CATEGORY_POWER, EVENT_SCREEN_OFF, null, screenOnDuration)
252- .send();
252+ sendPowerEvent(EVENT_SCREEN_OFF, screenOnDuration, -1);
253253 }
254254
255255 private static final String MAIN_THREAD = "main";
--- a/Service/src/org/android_x86/analytics/Util.java
+++ b/Service/src/org/android_x86/analytics/Util.java
@@ -147,6 +147,13 @@ public class Util {
147147 }
148148 return Build.VERSION.RELEASE + '-' + Build.VERSION.INCREMENTAL;
149149 }
150+
151+ /**
152+ * Gets product version.
153+ */
154+ public static String getProductVersion() {
155+ return Build.PRODUCT + ' ' + Build.VERSION.RELEASE + ' ' + Build.ID;
156+ }
150157 }
151158
152159 /* --- IOUtil --- */
Afficher sur ancien navigateur de dépôt.