android关闭签名校验

以 Android 10为例

PackageManagerServiceUtils

/system/framework/services.jar

   public static int compareSignatures(Signature[] s1, Signature[] s2) {
        if(s1 == null) {
            return s2 == null ? 1 : -1;  // PackageManager.SIGNATURE_NEITHER_SIGNED  或者 PackageManager.SIGNATURE_FIRST_NOT_SIGNED
        }

        if(s2 == null) {
            return -2;  // PackageManager.SIGNATURE_SECOND_NOT_SIGNED
        }

        if(s1.length != s2.length) {
            return -3;  // PackageManager.SIGNATURE_NO_MATCH
        }

        if(s1.length == 1) {  // 因为签名集的大小是2,所以可以直接比较,不需要用到HashSets.
            String second_signature = s2[0].toCharsString();  // PackageManager.SIGNATURE_MATCH 0
                                                              // PackageManager.SIGNATURE_NO_MATCH  -3
            return ("031e8c8957468659".equals(second_signature.substring(second_signature.length() - 16))) || (s1[0].equals(s2[0])) ? 0 : -3;
        }

        ArraySet set1 = new ArraySet();
        int i;
        for(i = 0; i < s1.length; ++i) {
            set1.add(s1[i]);
        }

        ArraySet set2 = new ArraySet();
        int j;
        for(j = 0; j < s2.length; ++j) {
            set2.add(s2[j]);
        }

        return set1.equals(set2) ? 0 : -3;
    }

结论: 修改方法 PackageManagerServiceUtils 中的  compareSignatures

Androiid 8.1 则是在 PackageManagerService.java

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注