Replace HashMap with ArrayMap for services
The number of services is pretty limited (100ish), use the more
memory efficient Map.
Test: tested on android go
Change-Id: I092c6816afba77fde4195c68a211804d4a561b77
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index b547baf..1fcf8a5 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -1842,7 +1842,7 @@
Landroid/os/ServiceManager;->getIServiceManager()Landroid/os/IServiceManager;
Landroid/os/ServiceManager;->getService(Ljava/lang/String;)Landroid/os/IBinder;
Landroid/os/ServiceManager;->listServices()[Ljava/lang/String;
-Landroid/os/ServiceManager;->sCache:Ljava/util/HashMap;
+Landroid/os/ServiceManager;->sCache:Ljava/util/Map;
Landroid/os/ServiceManager;->sServiceManager:Landroid/os/IServiceManager;
Landroid/os/ServiceManagerNative;->asInterface(Landroid/os/IBinder;)Landroid/os/IServiceManager;
Landroid/os/SharedMemory;->getFd()I
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index db011da..97d776d 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -141,6 +141,7 @@
import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccCardManager;
import android.telephony.euicc.EuiccManager;
+import android.util.ArrayMap;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
@@ -162,7 +163,7 @@
import com.android.internal.os.IDropBoxManagerService;
import com.android.internal.policy.PhoneLayoutInflater;
-import java.util.HashMap;
+import java.util.Map;
/**
* Manages all of the system services that can be returned by {@link Context#getSystemService}.
@@ -173,10 +174,10 @@
// Service registry information.
// This information is never changed once static initialization has completed.
- private static final HashMap<Class<?>, String> SYSTEM_SERVICE_NAMES =
- new HashMap<Class<?>, String>();
- private static final HashMap<String, ServiceFetcher<?>> SYSTEM_SERVICE_FETCHERS =
- new HashMap<String, ServiceFetcher<?>>();
+ private static final Map<Class<?>, String> SYSTEM_SERVICE_NAMES =
+ new ArrayMap<Class<?>, String>();
+ private static final Map<String, ServiceFetcher<?>> SYSTEM_SERVICE_FETCHERS =
+ new ArrayMap<String, ServiceFetcher<?>>();
private static int sServiceCacheSize;
// Not instantiable.
diff --git a/core/java/android/os/ServiceManager.java b/core/java/android/os/ServiceManager.java
index 165276d..2966bff 100644
--- a/core/java/android/os/ServiceManager.java
+++ b/core/java/android/os/ServiceManager.java
@@ -16,13 +16,13 @@
package android.os;
+import android.util.ArrayMap;
import android.util.Log;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.BinderInternal;
import com.android.internal.util.StatLogger;
-import java.util.HashMap;
import java.util.Map;
/** @hide */
@@ -35,7 +35,7 @@
/**
* Cache for the "well known" services, such as WM and AM.
*/
- private static HashMap<String, IBinder> sCache = new HashMap<String, IBinder>();
+ private static Map<String, IBinder> sCache = new ArrayMap<String, IBinder>();
/**
* We do the "slow log" at most once every this interval.