OSDN Git Service

Fix issue #62524613: Background limitation is not working as expected...
authorDianne Hackborn <hackbod@google.com>
Thu, 15 Jun 2017 21:33:16 +0000 (14:33 -0700)
committerDianne Hackborn <hackbod@google.com>
Thu, 15 Jun 2017 21:33:16 +0000 (14:33 -0700)
...for most background services.

Whoops, was only stopping the first service it found!

Test: bit CtsAppTestCases:ActivityManagerProcessStateTest
Change-Id: I42af2872afed8b49fab0f53eff36b62e55d23409

services/core/java/com/android/server/am/ActiveServices.java

index c417484..a9a41fb 100644 (file)
@@ -622,19 +622,19 @@ public final class ActiveServices {
                             != ActivityManager.APP_START_MODE_NORMAL) {
                         if (stopping == null) {
                             stopping = new ArrayList<>();
-                            String compName = service.name.flattenToShortString();
-                            EventLogTags.writeAmStopIdleService(service.appInfo.uid, compName);
-                            StringBuilder sb = new StringBuilder(64);
-                            sb.append("Stopping service due to app idle: ");
-                            UserHandle.formatUid(sb, service.appInfo.uid);
-                            sb.append(" ");
-                            TimeUtils.formatDuration(service.createTime
-                                    - SystemClock.elapsedRealtime(), sb);
-                            sb.append(" ");
-                            sb.append(compName);
-                            Slog.w(TAG, sb.toString());
-                            stopping.add(service);
                         }
+                        String compName = service.name.flattenToShortString();
+                        EventLogTags.writeAmStopIdleService(service.appInfo.uid, compName);
+                        StringBuilder sb = new StringBuilder(64);
+                        sb.append("Stopping service due to app idle: ");
+                        UserHandle.formatUid(sb, service.appInfo.uid);
+                        sb.append(" ");
+                        TimeUtils.formatDuration(service.createTime
+                                - SystemClock.elapsedRealtime(), sb);
+                        sb.append(" ");
+                        sb.append(compName);
+                        Slog.w(TAG, sb.toString());
+                        stopping.add(service);
                     }
                 }
             }