Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-services-Analytics: Commit

packages/services/Analytics


Commit MetaInfo

Révision7c415dfbcc4fb3b0cf599140435b086ebf463b87 (tree)
l'heure2017-10-18 19:29:31
AuteurChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Message de Log

AnalyticsService: handle AOSP's ACTION_BOOT_COMPLETED directly

I don't understand why it emits another custom ACTION_BOOT_COMPLETED
to do the work indirectly. It's totatly broken in Nougat.
The ActivityManager complains:

10-17 08:03:38.950 1426 1951 E ActivityManager: Sending non-protected broadcast org.android_x86.boot_completed from system 1985:org.android_x86.analytics/u0a0 pkg org.android_x86.analytics
10-17 08:03:38.950 1426 1951 E ActivityManager: java.lang.Throwable
10-17 08:03:38.950 1426 1951 E ActivityManager: at com.android.server.am.ActivityManagerService.checkBroadcastFromSystem(ActivityManagerService.java:17927)
10-17 08:03:38.950 1426 1951 E ActivityManager: at com.android.server.am.ActivityManagerService.broadcastIntentLocked(ActivityManagerService.java:18499)
10-17 08:03:38.950 1426 1951 E ActivityManager: at com.android.server.am.ActivityManagerService.broadcastIntent(ActivityManagerService.java:18590)
10-17 08:03:38.950 1426 1951 E ActivityManager: at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:499)
10-17 08:03:38.950 1426 1951 E ActivityManager: at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2806)
10-17 08:03:38.950 1426 1951 E ActivityManager: at android.os.Binder.execTransact(Binder.java:565)

Fix it by removing the custom ACTION_BOOT_COMPLETED and handle
ACTION_BOOT_COMPLETED of AOSP directly.

Change Summary

Modification

--- a/Service/src/org/android_x86/analytics/AnalyticsService.java
+++ b/Service/src/org/android_x86/analytics/AnalyticsService.java
@@ -95,9 +95,6 @@ public class AnalyticsService extends ImmortalIntentService {
9595 } else if (Intent.ACTION_SHUTDOWN.equals(action)) {
9696 AnalyticsHelper.onShutdown(getBaseContext());
9797 PowerStats.onScreenOff(context);
98- } else if (BootCompletedReceiver.ACTION_BOOT_COMPLETED.equals(action)) {
99- AnalyticsHelper.onBootCompleted(getBaseContext());
100- PowerStats.onScreenOn(context);
10198 } else if (Intent.ACTION_POWER_CONNECTED.equals(action)) {
10299 PowerStats.onPowerConnected(context);
103100 } else if (Intent.ACTION_POWER_DISCONNECTED.equals(action)) {
@@ -111,7 +108,6 @@ public class AnalyticsService extends ImmortalIntentService {
111108 filter.addAction(Intent.ACTION_SCREEN_OFF);
112109 filter.addAction(Intent.ACTION_SCREEN_ON);
113110 filter.addAction(Intent.ACTION_SHUTDOWN);
114- filter.addAction(BootCompletedReceiver.ACTION_BOOT_COMPLETED);
115111 filter.addAction(BootCompletedReceiver.ACTION_SEND_LOGS);
116112 filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
117113 filter.addAction(Intent.ACTION_POWER_CONNECTED);
@@ -135,6 +131,11 @@ public class AnalyticsService extends ImmortalIntentService {
135131 eventHandler.onEvent(intent);
136132 } else if (!Intent.ACTION_BOOT_COMPLETED.equals(action)){
137133 Log.w(TAG, "unknow action :" + action);
134+ } else {
135+ // save boot completed time
136+ saveScreenChangeTime(getCurrentTimeInSeconds());
137+ onBootCompleted(intent);
138+ PowerStats.onScreenOn(getBaseContext());
138139 }
139140 if (LOG) {
140141 Log.d(TAG, "Handle Intent: " + Util.toString(intent));
@@ -306,15 +307,6 @@ public class AnalyticsService extends ImmortalIntentService {
306307 onHitScreen(intent);
307308 }
308309 });
309- mStaticEventHandlers.put(AnalyticsHelper.ACTION_BOOT_COMPLETED, new EventHandler() {
310- @Override
311- void onEvent(Intent intent) {
312- // save boot completed time
313- saveScreenChangeTime(getCurrentTimeInSeconds());
314-
315- onBootCompleted(intent);
316- }
317- });
318310 mStaticEventHandlers.put(AnalyticsHelper.ACTION_SHUTDOWN, new EventHandler() {
319311 @Override
320312 void onEvent(Intent intent) {
--- a/Service/src/org/android_x86/analytics/BootCompletedReceiver.java
+++ b/Service/src/org/android_x86/analytics/BootCompletedReceiver.java
@@ -31,23 +31,16 @@ import org.android_x86.analytics.AnalyticsHelper;
3131 public class BootCompletedReceiver extends BroadcastReceiver {
3232 private static final String TAG = "BootCompletedReceiver";
3333
34- public static final String ACTION_BOOT_COMPLETED = "org.android_x86.boot_completed";
3534 public static final String ACTION_SEND_LOGS = "org.android_x86.send_logs";
3635
3736 @Override
3837 public void onReceive(Context context, Intent data) {
3938 String action = data.getAction();
40- Intent startIntent = new Intent(action);
41- startIntent.setComponent(
42- new ComponentName(
43- AnalyticsHelper.TARGET_PACKAGE_NAME,
44- AnalyticsHelper.TARGET_CLASS_NAME));
4539 if (!Intent.ACTION_BOOT_COMPLETED.equals(action)) {
4640 Log.w(TAG, "unknow action:" + action);
4741 return;
4842 }
49- context.startService(startIntent);
50- context.sendBroadcast(new Intent(ACTION_BOOT_COMPLETED));
43+ AnalyticsHelper.onBootCompleted(context);
5144
5245 // Set alarm to send logs periodically
5346 AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
--- a/Utils/src/org/android_x86/analytics/AnalyticsHelper.java
+++ b/Utils/src/org/android_x86/analytics/AnalyticsHelper.java
@@ -47,7 +47,6 @@ public class AnalyticsHelper {
4747 public static final String ACTION_HIT_SCREEN = "org.android_x86.hit_screen";
4848 public static final String ACTION_SCREEN_ON = "org.android_x86.screen_on";
4949 public static final String ACTION_SCREEN_OFF = "org.android_x86.screen_off";
50- public static final String ACTION_BOOT_COMPLETED = "org.android_x86.boot_completed";
5150 public static final String ACTION_SHUTDOWN = "org.android_x86.shutdown";
5251 public static final String ACTION_EXCEPTION = "org.android_x86.exception";
5352 public static final String ACTION_CUSTOM_EVENT = "org.android_x86.custom_event";
@@ -178,7 +177,7 @@ public class AnalyticsHelper {
178177
179178 public static void onBootCompleted(Context context) {
180179 Intent intent = getIntent();
181- intent.setAction(ACTION_BOOT_COMPLETED);
180+ intent.setAction(Intent.ACTION_BOOT_COMPLETED);
182181 context.startService(intent);
183182 }
184183
Afficher sur ancien navigateur de dépôt.