【问题标题】:is it possible to block the installation of android app in rooted device?是否可以阻止在根设备中安装 android 应用程序?
【发布时间】:2021-12-17 13:05:31
【问题描述】:
是否可以阻止在根设备上安装 android 应用程序?我想阻止在根设备上安装 android 应用程序。怎么做?

【问题讨论】:

    标签: android linux flutter android-studio


    【解决方案1】:

    我不知道它是否可以完成,但你可以做的是让你的应用程序在 root 设备上无法使用,这意味着即使安装了用户也无法使用它。

    为此,您所要做的就是确定您的应用程序是否在根设备上运行,或者通过以下任何方法(Android 代码)

    public class RootUtil {
        public static boolean isDeviceRooted() {
            return checkRootMethod1() || checkRootMethod2() || checkRootMethod3();
        }
    
        private static boolean checkRootMethod1() {
            String buildTags = android.os.Build.TAGS;
            return buildTags != null && buildTags.contains("test-keys");
        }
    
        private static boolean checkRootMethod2() {
            String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
                    "/system/bin/failsafe/su", "/data/local/su", "/su/bin/su"};
            for (String path : paths) {
                if (new File(path).exists()) return true;
            }
            return false;
        }
    
        private static boolean checkRootMethod3() {
            Process process = null;
            try {
                process = Runtime.getRuntime().exec(new String[] { "/system/xbin/which", "su" });
                BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
                if (in.readLine() != null) return true;
                return false;
            } catch (Throwable t) {
                return false;
            } finally {
                if (process != null) process.destroy();
            }
        }
    }
    

    然后如果device is rooted 然后navigate 到一个“ 与exit button 类似“应用程序不能在根设备上运行”的消息。

    对于颤振

    您可以使用来自pub.devtrust_fall 包,

    import 'package:trust_fall/trust_fall.dart';
    bool isJailBroken = await TrustFall.isJailBroken;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2016-08-01
      • 1970-01-01
      相关资源
      最近更新 更多