From 5b15f9bb9dcf92340c8263c1070dac97a50599c7 Mon Sep 17 00:00:00 2001 From: Winson Date: Tue, 19 Apr 2016 16:18:28 -0700 Subject: [PATCH] Fixing crash when dumping secondary SystemUI user service. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Secondary user’s SystemUI process is initialized with SERVICES_PER_USER, which is a strict subset of SERVICES, but mServices is a fixed size array that does not change, so we need to add a null check when iterating through the current list of services for the non-primary user. Bug: 28153575 Change-Id: I0a6b4726e82f2efddda358a835b1ef3d9f165375 --- .../systemui/SystemUISecondaryUserService.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java b/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java index f619bfbcd047a..c8a2e1758ad15 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUISecondaryUserService.java @@ -16,11 +16,9 @@ package com.android.systemui; -import android.app.ActivityManager; import android.app.Service; import android.content.Intent; import android.os.IBinder; -import android.os.Process; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -43,15 +41,19 @@ public class SystemUISecondaryUserService extends Service { SystemUI[] services = ((SystemUIApplication) getApplication()).getServices(); if (args == null || args.length == 0) { for (SystemUI ui: services) { - pw.println("dumping service: " + ui.getClass().getName()); - ui.dump(fd, pw, args); + if (ui != null) { + pw.println("dumping service: " + ui.getClass().getName()); + ui.dump(fd, pw, args); + } } } else { String svc = args[0]; for (SystemUI ui: services) { - String name = ui.getClass().getName(); - if (name.endsWith(svc)) { - ui.dump(fd, pw, args); + if (ui != null) { + String name = ui.getClass().getName(); + if (name.endsWith(svc)) { + ui.dump(fd, pw, args); + } } } }