diff --git a/buildScripts/gradle/versions.properties b/buildScripts/gradle/versions.properties index cd827dcef..a2efa2e26 100644 --- a/buildScripts/gradle/versions.properties +++ b/buildScripts/gradle/versions.properties @@ -1,4 +1,4 @@ -COMPILE_SDK_VERSION=31 +COMPILE_SDK_VERSION=33 MIN_SDK_VERSION=14 TARGET_SDK_VERSION=28 VERSION_CODE=1 diff --git a/projects/sdk/core/gradle-plugin/src/main/kotlin/com/tencent/shadow/core/gradle/ShadowPlugin.kt b/projects/sdk/core/gradle-plugin/src/main/kotlin/com/tencent/shadow/core/gradle/ShadowPlugin.kt index 93df1a3b6..c532bb394 100644 --- a/projects/sdk/core/gradle-plugin/src/main/kotlin/com/tencent/shadow/core/gradle/ShadowPlugin.kt +++ b/projects/sdk/core/gradle-plugin/src/main/kotlin/com/tencent/shadow/core/gradle/ShadowPlugin.kt @@ -247,7 +247,6 @@ class ShadowPlugin : Plugin { tempCL.loadClass("com.android.tools.apk.analyzer.BinaryXmlParser") val decodeXmlMethod = binaryXmlParserClass.getDeclaredMethod( "decodeXml", - String::class.java, ByteArray::class.java ) @@ -258,7 +257,6 @@ class ShadowPlugin : Plugin { val outputXmlBytes = decodeXmlMethod.invoke( null, - "AndroidManifest.xml", binaryXml ) as ByteArray decodeXml.parentFile.mkdirs() diff --git a/projects/sdk/core/loader/src/main/kotlin/com/tencent/shadow/core/loader/managers/PluginPackageManagerImpl.kt b/projects/sdk/core/loader/src/main/kotlin/com/tencent/shadow/core/loader/managers/PluginPackageManagerImpl.kt index 5e57f62f3..14ce37e67 100644 --- a/projects/sdk/core/loader/src/main/kotlin/com/tencent/shadow/core/loader/managers/PluginPackageManagerImpl.kt +++ b/projects/sdk/core/loader/src/main/kotlin/com/tencent/shadow/core/loader/managers/PluginPackageManagerImpl.kt @@ -19,9 +19,18 @@ package com.tencent.shadow.core.loader.managers import android.annotation.SuppressLint +import android.annotation.TargetApi import android.content.ComponentName import android.content.Intent -import android.content.pm.* +import android.content.pm.ActivityInfo +import android.content.pm.ApplicationInfo +import android.content.pm.ComponentInfo +import android.content.pm.PackageInfo +import android.content.pm.PackageManager +import android.content.pm.ProviderInfo +import android.content.pm.ResolveInfo +import android.content.pm.ServiceInfo +import android.os.Build import com.tencent.shadow.core.runtime.PluginPackageManager @SuppressLint("WrongConstant") @@ -41,13 +50,28 @@ internal class PluginPackageManagerImpl( override fun getPackageInfo(packageName: String, flags: Int): PackageInfo? { val hostPackageInfo = hostPackageManager.getPackageInfo(packageName, flags) return if (packageName.isPlugin()) { - val packageInfo = hostPackageManager.getPackageArchiveInfo(pluginArchiveFilePath, flags) - if (packageInfo != null) { - packageInfo.applicationInfo = getPluginApplicationInfo(flags) - packageInfo.permissions = hostPackageInfo.permissions - packageInfo.requestedPermissions = hostPackageInfo.requestedPermissions - } - packageInfo + getPluginPackageInfo(flags, hostPackageInfo) + } else { + hostPackageInfo + } + } + + private fun getPluginPackageInfo(flags: Int, hostPackageInfo: PackageInfo): PackageInfo? { + return hostPackageManager.getPackageArchiveInfo(pluginArchiveFilePath, flags)?.apply { + applicationInfo = getPluginApplicationInfo(flags) + permissions = hostPackageInfo.permissions + requestedPermissions = hostPackageInfo.requestedPermissions + } + } + + @TargetApi(Build.VERSION_CODES.TIRAMISU) + override fun getPackageInfo( + packageName: String, + flags: PackageManager.PackageInfoFlags + ): PackageInfo? { + val hostPackageInfo = hostPackageManager.getPackageInfo(packageName, flags) + return if (packageName.isPlugin()) { + getPluginPackageInfo(flags.value.toInt(), hostPackageInfo) } else { hostPackageInfo } diff --git a/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PackageManagerInvokeRedirect.java b/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PackageManagerInvokeRedirect.java index 208fb900c..fa41dd92c 100644 --- a/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PackageManagerInvokeRedirect.java +++ b/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PackageManagerInvokeRedirect.java @@ -70,6 +70,12 @@ public static PackageInfo getPackageInfo(ClassLoader classLoaderOfInvokeCode, Ve return getPluginPackageManager(classLoaderOfInvokeCode).getPackageInfo(versionedPackage.getPackageName(), flags); } + @TargetApi(Build.VERSION_CODES.TIRAMISU) + public static PackageInfo getPackageInfo(ClassLoader classLoaderOfInvokeCode, VersionedPackage versionedPackage, + PackageManager.PackageInfoFlags flags) throws PackageManager.NameNotFoundException { + return getPluginPackageManager(classLoaderOfInvokeCode).getPackageInfo(versionedPackage.getPackageName(), flags); + } + public static ProviderInfo resolveContentProvider(ClassLoader classLoaderOfInvokeCode, String name, int flags) { return getPluginPackageManager(classLoaderOfInvokeCode).resolveContentProvider(name, flags); } diff --git a/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginPackageManager.java b/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginPackageManager.java index 1fbea4787..a8a72bbf7 100644 --- a/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginPackageManager.java +++ b/projects/sdk/core/runtime/src/main/java/com/tencent/shadow/core/runtime/PluginPackageManager.java @@ -1,13 +1,16 @@ package com.tencent.shadow.core.runtime; +import android.annotation.TargetApi; import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; import android.content.pm.ProviderInfo; import android.content.pm.ResolveInfo; import android.content.pm.ServiceInfo; +import android.os.Build; import java.util.List; @@ -22,6 +25,9 @@ public interface PluginPackageManager { PackageInfo getPackageInfo(String packageName, int flags); + @TargetApi(Build.VERSION_CODES.TIRAMISU) + PackageInfo getPackageInfo(String packageName, PackageManager.PackageInfoFlags flags); + ProviderInfo resolveContentProvider(String name, int flags); List queryContentProviders(String processName, int uid, int flags);