@@ -120,7 +120,7 @@ internal object XmlBlockBypass {
120120 // Context may be loaded from the preview and other non-Android platforms, ignoring this.
121121 if (context.javaClass.name.endsWith(" BridgeContext" )) return
122122 init (context.applicationContext.applicationInfo)
123- }
123+ }
124124
125125 /* *
126126 * Initialize.
@@ -148,9 +148,18 @@ internal object XmlBlockBypass {
148148 ).apply { isAccessible = true }.invoke(null , sourceDir, false , false , false )
149149 else -> error(" Unsupported Android version." )
150150 } as ? Long? ? : error(" Failed to create ApkAssets." )
151- blockParser = HiddenApiBypass .getDeclaredConstructor(XmlBlockClass , AssetManagerClass , LongType )
152- .apply { isAccessible = true }
153- .newInstance(null , xmlBlock) as ? AutoCloseable ? ? : error(" Failed to create XmlBlock\$ Parser." )
151+ blockParser = when {
152+ SystemVersion .isHighOrEqualsTo(36 ) ->
153+ // XmlBlock(@Nullable AssetManager assets, long xmlBlock, boolean usesFeatureFlags)
154+ HiddenApiBypass .getDeclaredConstructor(XmlBlockClass , AssetManagerClass , LongType , BooleanType )
155+ .apply { isAccessible = true }
156+ .newInstance(null , xmlBlock, false )
157+ else ->
158+ // XmlBlock(@Nullable AssetManager assets, long xmlBlock)
159+ HiddenApiBypass .getDeclaredConstructor(XmlBlockClass , AssetManagerClass , LongType )
160+ .apply { isAccessible = true }
161+ .newInstance(null , xmlBlock)
162+ } as ? AutoCloseable ? ? : error(" Failed to create XmlBlock\$ Parser." )
154163 isInitOnce = true
155164 }
156165
@@ -166,7 +175,7 @@ internal object XmlBlockBypass {
166175 * @return [XmlResourceParser]
167176 */
168177 fun createViewAttrs () = context.layoutInflater.inflateOrNull<HikageAttrsView >(R .layout.layout_hikage_attrs_view)?.attrs
169- as ? XmlResourceParser ? ? : error(" Failed to create AttributeSet." )
178+ as ? XmlResourceParser ? ? : error(" Failed to create AttributeSet." )
170179 return if (SystemVersion .isHighOrEqualsTo(SystemVersion .P )) {
171180 if (! isInitOnce) return createViewAttrs()
172181 require(blockParser != null ) { " Hikage initialization failed." }
0 commit comments