From c2eb6039579b8a2fb1e11a753cea7662c07bec02 Mon Sep 17 00:00:00 2001 From: Wang Han <1701210638@pku.edu.cn> Date: Tue, 20 Aug 2024 23:40:52 +0800 Subject: [PATCH] Require GMS to be system app Fixes https://github.com/topjohnwu/Magisk/issues/8279. --- .../java/com/topjohnwu/magisk/ProviderInstaller.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java b/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java index 56ed00232..bb1b5ca93 100644 --- a/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java +++ b/app/shared/src/main/java/com/topjohnwu/magisk/ProviderInstaller.java @@ -1,13 +1,22 @@ package com.topjohnwu.magisk; import android.content.Context; +import android.content.pm.ApplicationInfo; public class ProviderInstaller { + private static final String GMS_PACKAGE_NAME = "com.google.android.gms"; + public static boolean install(Context context) { try { + // Check if gms is a system app + ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(GMS_PACKAGE_NAME, 0); + if ((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { + return false; + } + // Try installing new SSL provider from Google Play Service - Context gms = context.createPackageContext("com.google.android.gms", + Context gms = context.createPackageContext(GMS_PACKAGE_NAME, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); gms.getClassLoader() .loadClass("com.google.android.gms.common.security.ProviderInstallerImpl")