summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiContext.java49
1 files changed, 43 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiContext.java b/service/java/com/android/server/wifi/WifiContext.java
index 5ac6f208d..0a67a1e15 100644
--- a/service/java/com/android/server/wifi/WifiContext.java
+++ b/service/java/com/android/server/wifi/WifiContext.java
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.pm.PackageManager;
+import android.content.res.AssetManager;
import android.content.res.Resources;
import android.util.Log;
@@ -32,26 +33,62 @@ public class WifiContext extends ContextWrapper {
private static final String WIFI_OVERLAY_APK_PKG_NAME = "com.android.wifi.resources";
// Cached resources from the resources APK.
+ private AssetManager mWifiAssetsFromApk;
private Resources mWifiResourcesFromApk;
+ private Resources.Theme mWifiThemeFromApk;
public WifiContext(@NonNull Context contextBase) {
super(contextBase);
}
+ private Context getResourcesApkContext() {
+ try {
+ return createPackageContext(WIFI_OVERLAY_APK_PKG_NAME, 0);
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.wtf(TAG, "Failed to load resources", e);
+ }
+ return null;
+ }
+
+ /**
+ * Retrieve assets held in the wifi resources APK.
+ */
+ @Override
+ public AssetManager getAssets() {
+ if (mWifiAssetsFromApk == null) {
+ Context resourcesApkContext = getResourcesApkContext();
+ if (resourcesApkContext != null) {
+ mWifiAssetsFromApk = resourcesApkContext.getAssets();
+ }
+ }
+ return mWifiAssetsFromApk;
+ }
+
/**
* Retrieve resources held in the wifi resources APK.
*/
@Override
public Resources getResources() {
if (mWifiResourcesFromApk == null) {
- try {
- Context overlayAppContext =
- createPackageContext(WIFI_OVERLAY_APK_PKG_NAME, 0);
- mWifiResourcesFromApk = overlayAppContext.getResources();
- } catch (PackageManager.NameNotFoundException e) {
- Log.wtf(TAG, "Failed to load resources", e);
+ Context resourcesApkContext = getResourcesApkContext();
+ if (resourcesApkContext != null) {
+ mWifiResourcesFromApk = resourcesApkContext.getResources();
}
}
return mWifiResourcesFromApk;
}
+
+ /**
+ * Retrieve theme held in the wifi resources APK.
+ */
+ @Override
+ public Resources.Theme getTheme() {
+ if (mWifiThemeFromApk == null) {
+ Context resourcesApkContext = getResourcesApkContext();
+ if (resourcesApkContext != null) {
+ mWifiThemeFromApk = resourcesApkContext.getTheme();
+ }
+ }
+ return mWifiThemeFromApk;
+ }
}