From 3495b81006374d0d04f974bcf507ddac6c31836e Mon Sep 17 00:00:00 2001 From: Zhuoyao Zhang Date: Sun, 23 Feb 2020 05:54:41 +0000 Subject: [PATCH] Revert "Add WTF when a system server wrapper can't be found" This reverts commit 2cddb8a8913aa1f5367bd590c123f93c597424b5. Reason for revert: break app compat test b/149923038 Bug: 149923038 Change-Id: Ibace06f704595d40a4439c0bdfea55d11294ba77 --- .../android/app/SystemServiceRegistry.java | 42 ++----------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index 4369680e77819..bf8f53cc0f408 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -186,7 +186,6 @@ import android.telephony.TelephonyFrameworkInitializer; import android.telephony.TelephonyRegistryManager; import android.util.ArrayMap; import android.util.Log; -import android.util.Slog; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.WindowManager; @@ -223,8 +222,6 @@ import java.util.Objects; public final class SystemServiceRegistry { private static final String TAG = "SystemServiceRegistry"; - private static final boolean ENABLE_SERVICE_NOT_FOUND_WTF = true; - // Service registry information. // This information is never changed once static initialization has completed. private static final Map, String> SYSTEM_SERVICE_NAMES = @@ -1370,29 +1367,8 @@ public final class SystemServiceRegistry { * @hide */ public static Object getSystemService(ContextImpl ctx, String name) { - if (name == null) { - return null; - } - final ServiceFetcher fetcher = SYSTEM_SERVICE_FETCHERS.get(name); - if (ENABLE_SERVICE_NOT_FOUND_WTF && fetcher == null) { - // This should be a caller bug. - Slog.wtf(TAG, "Unknown manager requested: " + name); - return null; - } - - final Object ret = fetcher.getService(ctx); - if (ENABLE_SERVICE_NOT_FOUND_WTF && ret == null) { - // Some services do return null in certain situations, so don't do WTF for them. - switch (name) { - case Context.CONTENT_CAPTURE_MANAGER_SERVICE: - case Context.APP_PREDICTION_SERVICE: - case Context.INCREMENTAL_SERVICE: - return null; - } - Slog.wtf(TAG, "Manager wrapper not available: " + name); - return null; - } - return ret; + ServiceFetcher fetcher = SYSTEM_SERVICE_FETCHERS.get(name); + return fetcher != null ? fetcher.getService(ctx) : null; } /** @@ -1400,15 +1376,7 @@ public final class SystemServiceRegistry { * @hide */ public static String getSystemServiceName(Class serviceClass) { - if (serviceClass == null) { - return null; - } - final String serviceName = SYSTEM_SERVICE_NAMES.get(serviceClass); - if (ENABLE_SERVICE_NOT_FOUND_WTF && serviceName == null) { - // This should be a caller bug. - Slog.wtf(TAG, "Unknown manager requested: " + serviceClass.getCanonicalName()); - } - return serviceName; + return SYSTEM_SERVICE_NAMES.get(serviceClass); } /** @@ -1705,9 +1673,7 @@ public final class SystemServiceRegistry { try { cache.wait(); } catch (InterruptedException e) { - // This shouldn't normally happen, but if someone interrupts the - // thread, it will. - Slog.wtf(TAG, "getService() interrupted"); + Log.w(TAG, "getService() interrupted"); Thread.currentThread().interrupt(); return null; }