Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-services-Analytics: Commit

packages/services/Analytics


Commit MetaInfo

Révision7fb018989776c73a66d647817cc4c0136a7e02ee (tree)
l'heure2017-10-19 12:10:37
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

AnalyticsService: combine two services

The functionality of HardwareCollectorService is very simple.
It's unnecessary to make it as a separate service.

Just merge it into the AnalyticsService to save resources.

Change Summary

  • add: CleanSpec.mk (diff)
  • delete: HardwareCollector/Android.mk
  • delete: HardwareCollector/AndroidManifest.xml
  • delete: HardwareCollector/res/values/strings.xml
  • delete: HardwareCollector/src/org/android_x86/hardwarecollector/BootCompletedReceiver.java
  • delete: HardwareCollector/src/org/android_x86/hardwarecollector/HardwareCollectorService.java => Service/src/org/android_x86/analytics/HardwareCollector.java
  • modified: NOTICE (diff)
  • modified: Service/src/org/android_x86/analytics/AnalyticsService.java (diff)

Modification

--- /dev/null
+++ b/CleanSpec.mk
@@ -0,0 +1,3 @@
1+# Clean up HardwareCollector which is being removed.
2+$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/HardwareCollector_intermediates)
3+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/HardwareCollector)
--- a/HardwareCollector/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
1-LOCAL_PATH := $(call my-dir)
2-
3-include $(CLEAR_VARS)
4-
5-LOCAL_MODULE_TAGS := optional
6-LOCAL_STATIC_JAVA_LIBRARIES := analytics-utils
7-
8-LOCAL_SRC_FILES := $(call all-java-files-under, src)
9-
10-LOCAL_PACKAGE_NAME := HardwareCollector
11-LOCAL_CERTIFICATE := platform
12-LOCAL_PRIVILEGED_MODULE := true
13-
14-include $(BUILD_PACKAGE)
--- a/HardwareCollector/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
1-<?xml version="1.0" encoding="utf-8"?>
2-<!-- Copyright (C) 2016 Jide Technology Ltd.
3-
4- Licensed under the Apache License, Version 2.0 (the "License");
5- you may not use this file except in compliance with the License.
6- You may obtain a copy of the License at
7-
8- http://www.apache.org/licenses/LICENSE-2.0
9-
10- Unless required by applicable law or agreed to in writing, software
11- distributed under the License is distributed on an "AS IS" BASIS,
12- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- See the License for the specific language governing permissions and
14- limitations under the License.
15--->
16-
17-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
18- package="org.android_x86.hardwarecollector">
19-
20- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
21- <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
22- <uses-permission android:name="android.permission.RESTART_PACKAGES"/>
23- <application android:label="@string/app_name">
24- <service android:name=".HardwareCollectorService"
25- android:exported="true"/>
26- <receiver android:name=".BootCompletedReceiver">
27- <intent-filter>
28- <action android:name="android.intent.action.BOOT_COMPLETED" />
29- </intent-filter>
30- </receiver>
31- </application>
32-</manifest>
--- a/HardwareCollector/res/values/strings.xml
+++ /dev/null
@@ -1,18 +0,0 @@
1-<?xml version="1.0" encoding="utf-8"?>
2-<!-- Copyright (C) 2016 Jide Technology Ltd.
3-
4- Licensed under the Apache License, Version 2.0 (the "License");
5- you may not use this file except in compliance with the License.
6- You may obtain a copy of the License at
7-
8- http://www.apache.org/licenses/LICENSE-2.0
9-
10- Unless required by applicable law or agreed to in writing, software
11- distributed under the License is distributed on an "AS IS" BASIS,
12- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- See the License for the specific language governing permissions and
14- limitations under the License.
15--->
16-<resources>
17- <string name="app_name">HardwareCollector</string>
18-</resources>
--- a/HardwareCollector/src/org/android_x86/hardwarecollector/BootCompletedReceiver.java
+++ /dev/null
@@ -1,33 +0,0 @@
1-/*
2- * Copyright 2016 Jide Technology Ltd.
3- *
4- * Licensed under the Apache License, Version 2.0 (the "License");
5- * you may not use this file except in compliance with the License.
6- * You may obtain a copy of the License at
7- *
8- * http://www.apache.org/licenses/LICENSE-2.0
9- *
10- * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an "AS IS" BASIS,
12- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13- * See the License for the specific language governing permissions and
14- * limitations under the License.
15- */
16-package org.android_x86.hardwarecollector;
17-
18-import android.content.BroadcastReceiver;
19-import android.content.Context;
20-import android.content.Intent;
21-import android.os.SystemProperties;
22-
23-public class BootCompletedReceiver extends BroadcastReceiver {
24- @Override
25- public void onReceive(Context context, Intent data) {
26- if (SystemProperties.getBoolean("persist.sys.hw_statistics", true)) {
27- String action = data.getAction();
28- Intent startIntent = new Intent(context, HardwareCollectorService.class);
29- startIntent.setAction(action);
30- context.startService(startIntent);
31- }
32- }
33-}
--- a/NOTICE
+++ b/NOTICE
@@ -1,4 +1,5 @@
11 Copyright (C) 2016 Jide Technology Ltd.
2+ Copyright (C) 2017 Android-x86 Open Source Project
23
34 Licensed under the Apache License, Version 2.0 (the "License");
45 you may not use this file except in compliance with the License.
--- a/Service/src/org/android_x86/analytics/AnalyticsService.java
+++ b/Service/src/org/android_x86/analytics/AnalyticsService.java
@@ -1,5 +1,6 @@
11 /*
22 * Copyright 2016 Jide Technology Ltd.
3+ * Copyright 2017 Android-x86 Open Source Project
34 *
45 * Licensed under the Apache License, Version 2.0 (the "License");
56 * you may not use this file except in compliance with the License.
@@ -30,6 +31,7 @@ import android.os.SystemProperties;
3031 import android.util.Log;
3132 import org.android_x86.analytics.AnalyticsHelper;
3233 import org.android_x86.analytics.GeneralLogs;
34+import org.android_x86.analytics.HardwareCollector;
3335 import org.android_x86.analytics.ImmortalIntentService;
3436
3537 import java.util.HashMap;
@@ -207,6 +209,10 @@ public class AnalyticsService extends ImmortalIntentService {
207209 long bootTime = SystemClock.elapsedRealtime() / MS_IN_SECOND;
208210 mLogHelper.newEventBuilder(EVENT_CATEGORY_POWER, EVENT_BOOT_COMPLETED, null, bootTime)
209211 .send();
212+
213+ if (SystemProperties.getBoolean("persist.sys.hw_statistics", true)) {
214+ new HardwareCollector(this).uploadHardwareInfo();
215+ }
210216 }
211217
212218 private void onShutdown(Intent data) {
--- a/HardwareCollector/src/org/android_x86/hardwarecollector/HardwareCollectorService.java
+++ b/Service/src/org/android_x86/analytics/HardwareCollector.java
@@ -1,5 +1,6 @@
11 /*
22 * Copyright 2016 Jide Technology Ltd.
3+ * Copyright 2017 Android-x86 Open Source Project
34 *
45 * Licensed under the Apache License, Version 2.0 (the "License");
56 * you may not use this file except in compliance with the License.
@@ -13,12 +14,8 @@
1314 * See the License for the specific language governing permissions and
1415 * limitations under the License.
1516 */
16-package org.android_x86.hardwarecollector;
17+package org.android_x86.analytics;
1718
18-import org.android_x86.analytics.AnalyticsHelper;
19-import org.android_x86.analytics.GeneralLogs;
20-
21-import android.app.IntentService;
2219 import android.content.Context;
2320 import android.content.Intent;
2421 import android.content.IntentFilter;
@@ -31,8 +28,6 @@ import android.system.Os;
3128 import android.util.Log;
3229 import android.view.InputDevice;
3330
34-import org.json.JSONObject;
35-
3631 import javax.microedition.khronos.egl.EGL10;
3732 import javax.microedition.khronos.egl.EGLConfig;
3833 import javax.microedition.khronos.egl.EGLContext;
@@ -45,8 +40,12 @@ import java.io.FileWriter;
4540 import java.io.IOException;
4641 import java.io.PrintWriter;
4742
48-public class HardwareCollectorService extends IntentService {
49- private static final String TAG = "HardwareCollectorService";
43+import org.android_x86.analytics.AnalyticsHelper;
44+import org.android_x86.analytics.GeneralLogs;
45+import org.json.JSONObject;
46+
47+public class HardwareCollector {
48+ private static final String TAG = "HardwareCollector";
5049
5150 private static final String GA_CATEGORY = "hardware_info";
5251 private static final String GA_ACTION_GPU_RENDERER = "gpu_renderer";
@@ -69,27 +68,12 @@ public class HardwareCollectorService extends IntentService {
6968 private File mInfoFile;
7069 private JSONObject mInfoJson;
7170
72- public HardwareCollectorService() {
73- super("HardwareCollectorService");
74- }
75-
76- @Override
77- public void onCreate() {
78- super.onCreate();
79- mContext = getBaseContext();
80- mInfoFile = new File(getApplicationContext().getFilesDir(), LAST_INFO_FILE_NAME);
81- }
82-
83- @Override
84- protected void onHandleIntent(Intent intent) {
85- String action = intent.getAction();
86- Log.i(TAG, "handle intent:" + intent);
87- if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
88- uploadHardwareInfo();
89- }
71+ public HardwareCollector(Context context) {
72+ mContext = context;
73+ mInfoFile = new File(context.getFilesDir(), LAST_INFO_FILE_NAME);
9074 }
9175
92- private void uploadHardwareInfo() {
76+ public void uploadHardwareInfo() {
9377 getLastInfo();
9478 collectOpenGLInfo();
9579 collectCPUInfo();
@@ -169,7 +153,7 @@ public class HardwareCollectorService extends IntentService {
169153 IntentFilter filter = new IntentFilter();
170154 filter.addAction(Intent.ACTION_BATTERY_CHANGED);
171155 Intent batteryIntent = mContext.registerReceiver(null, filter);
172- String label = batteryIntent.getBooleanExtra("present", false) ?
156+ String label = (batteryIntent != null && batteryIntent.getBooleanExtra("present", false)) ?
173157 GA_LABEL_HAS_BATTERY : GA_LABEL_NO_BATTERY;
174158 AnalyticsHelper.CustomEvent customEvent = AnalyticsHelper.newSystemCoreEvent(
175159 mContext, GA_CATEGORY, GA_ACTION_HAS_BATTERY);
Afficher sur ancien navigateur de dépôt.