Loading core/java/android/app/SystemServiceRegistry.java +38 −4 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ 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; Loading Loading @@ -222,6 +223,8 @@ 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<Class<?>, String> SYSTEM_SERVICE_NAMES = Loading Loading @@ -1373,8 +1376,29 @@ public final class SystemServiceRegistry { * @hide */ public static Object getSystemService(ContextImpl ctx, String name) { ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS.get(name); return fetcher != null ? fetcher.getService(ctx) : null; 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; } /** Loading @@ -1382,7 +1406,15 @@ public final class SystemServiceRegistry { * @hide */ public static String getSystemServiceName(Class<?> serviceClass) { return SYSTEM_SERVICE_NAMES.get(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; } /** Loading Loading @@ -1679,7 +1711,9 @@ public final class SystemServiceRegistry { try { cache.wait(); } catch (InterruptedException e) { Log.w(TAG, "getService() interrupted"); // This shouldn't normally happen, but if someone interrupts the // thread, it will. Slog.wtf(TAG, "getService() interrupted"); Thread.currentThread().interrupt(); return null; } Loading Loading
core/java/android/app/SystemServiceRegistry.java +38 −4 Original line number Diff line number Diff line Loading @@ -186,6 +186,7 @@ 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; Loading Loading @@ -222,6 +223,8 @@ 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<Class<?>, String> SYSTEM_SERVICE_NAMES = Loading Loading @@ -1373,8 +1376,29 @@ public final class SystemServiceRegistry { * @hide */ public static Object getSystemService(ContextImpl ctx, String name) { ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS.get(name); return fetcher != null ? fetcher.getService(ctx) : null; 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; } /** Loading @@ -1382,7 +1406,15 @@ public final class SystemServiceRegistry { * @hide */ public static String getSystemServiceName(Class<?> serviceClass) { return SYSTEM_SERVICE_NAMES.get(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; } /** Loading Loading @@ -1679,7 +1711,9 @@ public final class SystemServiceRegistry { try { cache.wait(); } catch (InterruptedException e) { Log.w(TAG, "getService() interrupted"); // This shouldn't normally happen, but if someone interrupts the // thread, it will. Slog.wtf(TAG, "getService() interrupted"); Thread.currentThread().interrupt(); return null; } Loading