From ce717adc8d05bbf027011006d3081283fe00704b Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Mon, 3 May 2021 14:54:18 -0700 Subject: [PATCH] Add debugging to diagnose failure Bug: 186558987 Test: Manual. Builds and runs Change-Id: Ia65d60590f33f4321697e9e1814b47f5e185bf99 --- .../server/pm/PackageManagerService.java | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index dad37f40babb6..8921a14024fe8 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -26019,18 +26019,29 @@ public class PackageManagerService extends IPackageManager.Stub @Override public String[] getNamesForUids(int[] uids) throws RemoteException { - if (uids == null || uids.length == 0) { - return null; - } - final String[] names = PackageManagerService.this.getNamesForUids(uids); - final String[] results = (names != null) ? names : new String[uids.length]; - // massage results so they can be parsed by the native binder - for (int i = results.length - 1; i >= 0; --i) { - if (results[i] == null) { - results[i] = ""; + String[] names = null; + String[] results = null; + try { + if (uids == null || uids.length == 0) { + return null; } + names = PackageManagerService.this.getNamesForUids(uids); + results = (names != null) ? names : new String[uids.length]; + // massage results so they can be parsed by the native binder + for (int i = results.length - 1; i >= 0; --i) { + if (results[i] == null) { + results[i] = ""; + } + } + return results; + } catch (Throwable t) { + // STOPSHIP(186558987): revert addition of try/catch/log + Slog.e(TAG, "uids: " + Arrays.toString(uids)); + Slog.e(TAG, "names: " + Arrays.toString(names)); + Slog.e(TAG, "results: " + Arrays.toString(results)); + Slog.e(TAG, "throwing exception", t); + throw t; } - return results; } // NB: this differentiates between preloads and sideloads