diff --git a/play-services-ads/core/src/main/java/com/google/android/gms/dynamite/descriptors/com/google/android/gms/ads/dynamite/ModuleDescriptor.java b/play-services-ads/core/src/main/java/com/google/android/gms/dynamite/descriptors/com/google/android/gms/ads/dynamite/ModuleDescriptor.java index 4583d77b57..7a14482b94 100644 --- a/play-services-ads/core/src/main/java/com/google/android/gms/dynamite/descriptors/com/google/android/gms/ads/dynamite/ModuleDescriptor.java +++ b/play-services-ads/core/src/main/java/com/google/android/gms/dynamite/descriptors/com/google/android/gms/ads/dynamite/ModuleDescriptor.java @@ -5,10 +5,20 @@ package com.google.android.gms.dynamite.descriptors.com.google.android.gms.ads.dynamite; +import android.content.Context; +import android.content.ContextWrapper; +import android.util.Log; +import android.webkit.WebSettings; import androidx.annotation.Keep; @Keep public class ModuleDescriptor { public static final String MODULE_ID = "com.google.android.gms.ads.dynamite"; public static final int MODULE_VERSION = 230500001; + + public static void init(ContextWrapper context) { + Context baseContext = context.getBaseContext(); + WebSettings.getDefaultUserAgent(baseContext); + Log.d("ModuleDescriptor", "init: context: " + baseContext); + } } diff --git a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java index cbc93d2777..f93fdae0d3 100644 --- a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java +++ b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteContext.java @@ -88,11 +88,14 @@ public static DynamiteContext create(String moduleId, Context originalContext) { DynamiteModuleInfo moduleInfo = new DynamiteModuleInfo(moduleId); Context gmsContext = originalContext.createPackageContext(Constants.GMS_PACKAGE_NAME, 0); Context originalAppContext = originalContext.getApplicationContext(); + DynamiteContext dynamiteContext; if (originalAppContext == null || originalAppContext == originalContext) { - return new DynamiteContext(moduleInfo, originalContext, gmsContext, null); + dynamiteContext = new DynamiteContext(moduleInfo, originalContext, gmsContext, null); } else { - return new DynamiteContext(moduleInfo, originalContext, gmsContext, new DynamiteContext(moduleInfo, originalAppContext, gmsContext, null)); + dynamiteContext = new DynamiteContext(moduleInfo, originalContext, gmsContext, new DynamiteContext(moduleInfo, originalAppContext, gmsContext, null)); } + moduleInfo.init(dynamiteContext); + return dynamiteContext; } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, e); return null; diff --git a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteModuleInfo.java b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteModuleInfo.java index 637a269fca..9f25008f24 100644 --- a/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteModuleInfo.java +++ b/play-services-core/src/main/java/com/google/android/gms/chimera/container/DynamiteModuleInfo.java @@ -10,6 +10,7 @@ import static android.content.Context.CONTEXT_IGNORE_SECURITY; import static android.content.Context.CONTEXT_INCLUDE_CODE; +import android.content.ContextWrapper; public class DynamiteModuleInfo { private Class descriptor; @@ -51,4 +52,12 @@ public Collection getMergedClasses() { return Collections.emptySet(); } } + + public void init(ContextWrapper dynamiteContext) { + try { + descriptor.getMethod("init", ContextWrapper.class).invoke(null, dynamiteContext); + } catch (Exception e) { + // Ignore + } + } }