Merge "Revert "Add WTF when a system server wrapper can't be found"" into rvc-dev
This commit is contained in:
@@ -186,7 +186,6 @@ import android.telephony.TelephonyFrameworkInitializer;
|
|||||||
import android.telephony.TelephonyRegistryManager;
|
import android.telephony.TelephonyRegistryManager;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Slog;
|
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -223,8 +222,6 @@ import java.util.Objects;
|
|||||||
public final class SystemServiceRegistry {
|
public final class SystemServiceRegistry {
|
||||||
private static final String TAG = "SystemServiceRegistry";
|
private static final String TAG = "SystemServiceRegistry";
|
||||||
|
|
||||||
private static final boolean ENABLE_SERVICE_NOT_FOUND_WTF = true;
|
|
||||||
|
|
||||||
// Service registry information.
|
// Service registry information.
|
||||||
// This information is never changed once static initialization has completed.
|
// This information is never changed once static initialization has completed.
|
||||||
private static final Map<Class<?>, String> SYSTEM_SERVICE_NAMES =
|
private static final Map<Class<?>, String> SYSTEM_SERVICE_NAMES =
|
||||||
@@ -1377,29 +1374,8 @@ public final class SystemServiceRegistry {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static Object getSystemService(ContextImpl ctx, String name) {
|
public static Object getSystemService(ContextImpl ctx, String name) {
|
||||||
if (name == null) {
|
ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS.get(name);
|
||||||
return null;
|
return fetcher != null ? fetcher.getService(ctx) : 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1407,15 +1383,7 @@ public final class SystemServiceRegistry {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static String getSystemServiceName(Class<?> serviceClass) {
|
public static String getSystemServiceName(Class<?> serviceClass) {
|
||||||
if (serviceClass == null) {
|
return SYSTEM_SERVICE_NAMES.get(serviceClass);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1712,9 +1680,7 @@ public final class SystemServiceRegistry {
|
|||||||
try {
|
try {
|
||||||
cache.wait();
|
cache.wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// This shouldn't normally happen, but if someone interrupts the
|
Log.w(TAG, "getService() interrupted");
|
||||||
// thread, it will.
|
|
||||||
Slog.wtf(TAG, "getService() interrupted");
|
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user