Java Code Examples for android.content.pm.PackageManager.SIGNATURE_MATCH

The following are Jave code examples for showing how to use SIGNATURE_MATCH of the android.content.pm.PackageManager class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DroidPlugin   File: RunningProcesList.java   View Source Code Vote up 6 votes
public String getStubProcessByTarget(ComponentInfo targetInfo) {
    for (ProcessItem processItem : items.values()) {
        if (processItem.pkgs.contains(targetInfo.packageName) && TextUtils.equals(processItem.targetProcessName, targetInfo.processName)) {
            return processItem.stubProcessName;
        } else {
            try {
                boolean signed = false;
                for (String pkg : processItem.pkgs) {
                    if (PluginManager.getInstance().checkSignatures(targetInfo.packageName, pkg) == PackageManager.SIGNATURE_MATCH) {
                        signed = true;
                        break;
                    }
                }
                if (signed && TextUtils.equals(processItem.targetProcessName, targetInfo.processName)) {
                    return processItem.stubProcessName;
                }
            } catch (Exception e) {
                Log.e(TAG, "getStubProcessByTarget:error", e);
            }
        }
    }
    return null;
}
 
Example 2
Project: DroidPlugin   File: RunningProcesList.java   View Source Code Vote up 6 votes
boolean isPkgCanRunInProcess(String packageName, String stubProcessName, String targetProcessName) throws RemoteException {
    for (ProcessItem item : items.values()) {
        if (TextUtils.equals(stubProcessName, item.stubProcessName)) {

            if (!TextUtils.isEmpty(item.targetProcessName) && !TextUtils.equals(item.targetProcessName, targetProcessName)) {
                continue;
            }

            if (item.pkgs.contains(packageName)) {
                return true;
            }

            boolean signed = false;
            for (String pkg : item.pkgs) {
                if (PluginManager.getInstance().checkSignatures(packageName, pkg) == PackageManager.SIGNATURE_MATCH) {
                    signed = true;
                    break;
                }
            }
            if (signed) {
                return true;
            }
        }
    }
    return false;
}
 
Example 3
Project: VirtualHook   File: MethodProxies.java   View Source Code Vote up 5 votes
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {

    if (args.length == 2 && args[0] instanceof String && args[1] instanceof String) {

        PackageManager pm = VirtualCore.getPM();

        String pkgNameOne = (String) args[0], pkgNameTwo = (String) args[1];
        try {
            PackageInfo pkgOne = pm.getPackageInfo(pkgNameOne, PackageManager.GET_SIGNATURES);
            PackageInfo pkgTwo = pm.getPackageInfo(pkgNameTwo, PackageManager.GET_SIGNATURES);

            Signature[] one = pkgOne.signatures;
            Signature[] two = pkgTwo.signatures;

            if (ArrayUtils.isEmpty(one)) {
                if (!ArrayUtils.isEmpty(two)) {
                    return PackageManager.SIGNATURE_FIRST_NOT_SIGNED;
                } else {
                    return PackageManager.SIGNATURE_NEITHER_SIGNED;
                }
            } else {
                if (ArrayUtils.isEmpty(two)) {
                    return PackageManager.SIGNATURE_SECOND_NOT_SIGNED;
                } else {
                    // 走到了这里说明两个包的签名都在
                    if (Arrays.equals(one, two)) {
                        return PackageManager.SIGNATURE_MATCH;
                    } else {
                        return PackageManager.SIGNATURE_NO_MATCH;
                    }
                }
            }
        } catch (Throwable e) {
            // Ignore
        }
    }

    return method.invoke(who, args);
}
 
Example 4
Project: Brevent   File: BreventActivity.java   View Source Code Vote up 5 votes
private boolean isFrameworkPackage(PackageManager packageManager, String packageName) {
    if (fakeFramework) {
        try {
            PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
            return isFrameworkPackage(packageManager, packageInfo);
        } catch (PackageManager.NameNotFoundException e) {
            UILog.w("cannot find " + packageName, e);
            return false;
        }
    } else {
        return packageManager.checkSignatures(PACKAGE_FRAMEWORK, packageName) ==
                PackageManager.SIGNATURE_MATCH;
    }
}
 
Example 5
Project: Matrix-Calculator-for-Android   File: GlobalValues.java   View Source Code Vote up 5 votes
public void SetDonationKeyStatus() {

        if (BuildConfig.DEBUG) {
            Status = true;
            return;
            //if debug mode, avoid the advertisements and use pro features
        }
        try {
            PackageManager packageManager = getPackageManager();
            packageManager.getPackageInfo("com.softminds.matrixcalculator.pro.key", 0);
            //Key is Installed
            //Checking the Authenticity of the Key
            if (packageManager.checkSignatures(getPackageName(),
                    "com.softminds.matrixcalculator.pro.key")
                    == PackageManager.SIGNATURE_MATCH) {
                Log.d(TAG, "The Signature of Key Matched with Application");
                String manager = packageManager.getInstallerPackageName("com.softminds.matrixcalculator.pro.key");
                if (manager != null) {
                    //Status = true;
                    Log.d(TAG, manager);
                    if (Objects.equals(manager, "com.android.vending")) {
                        Status = true;
                    } else {
                        Status = false;
                        Toast.makeText(this, R.string.clear_warn_invalid_install, Toast.LENGTH_LONG).show();
                    }
                }
                //the Key is Genuine and was Installed from Play
            }
        } catch (Exception e) {
            Status = false;
        }
    }
 
Example 6
Project: TPlayer   File: MethodProxies.java   View Source Code Vote up 5 votes
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {

    if (args.length == 2 && args[0] instanceof String && args[1] instanceof String) {

        PackageManager pm = VirtualCore.getPM();

        String pkgNameOne = (String) args[0], pkgNameTwo = (String) args[1];
        try {
            PackageInfo pkgOne = pm.getPackageInfo(pkgNameOne, PackageManager.GET_SIGNATURES);
            PackageInfo pkgTwo = pm.getPackageInfo(pkgNameTwo, PackageManager.GET_SIGNATURES);

            Signature[] one = pkgOne.signatures;
            Signature[] two = pkgTwo.signatures;

            if (ArrayUtils.isEmpty(one)) {
                if (!ArrayUtils.isEmpty(two)) {
                    return PackageManager.SIGNATURE_FIRST_NOT_SIGNED;
                } else {
                    return PackageManager.SIGNATURE_NEITHER_SIGNED;
                }
            } else {
                if (ArrayUtils.isEmpty(two)) {
                    return PackageManager.SIGNATURE_SECOND_NOT_SIGNED;
                } else {
                    if (Arrays.equals(one, two)) {
                        return PackageManager.SIGNATURE_MATCH;
                    } else {
                        return PackageManager.SIGNATURE_NO_MATCH;
                    }
                }
            }
        } catch (Throwable e) {
            // Ignore
        }
    }

    return method.invoke(who, args);
}
 
Example 7
Project: TPlayer   File: MethodProxies.java   View Source Code Vote up 5 votes
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {
    int uid1 = (int) args[0];
    int uid2 = (int) args[1];
    // TODO: verify the signatures by uid.
    return PackageManager.SIGNATURE_MATCH;
}
 
Example 8
Project: IFWManager   File: IntentFirewall.java   View Source Code Vote up 5 votes
boolean signaturesMatch(int uid1, int uid2) {
    try {
        IPackageManager pm = AppGlobals.getPackageManager();
        return pm.checkUidSignatures(uid1, uid2) == PackageManager.SIGNATURE_MATCH;
    } catch (RemoteException ex) {
        Slog.e(TAG, "Remote exception while checking signatures", ex);
        return false;
    }
}
 
Example 9
Project: container   File: CheckSignatures.java   View Source Code Vote up 5 votes
@Override
public Object call(Object who, Method method, Object... args) throws Throwable {

	if (args.length == 2 && args[0] instanceof String && args[1] instanceof String) {

		PackageManager pm = VirtualCore.getPM();

		String pkgNameOne = (String) args[0], pkgNameTwo = (String) args[1];
		try {
			PackageInfo pkgOne = pm.getPackageInfo(pkgNameOne, PackageManager.GET_SIGNATURES);
			PackageInfo pkgTwo = pm.getPackageInfo(pkgNameTwo, PackageManager.GET_SIGNATURES);

			Signature[] one = pkgOne.signatures;
			Signature[] two = pkgTwo.signatures;

			if (ArrayUtils.isEmpty(one)) {
				if (!ArrayUtils.isEmpty(two)) {
					return PackageManager.SIGNATURE_FIRST_NOT_SIGNED;
				} else {
					return PackageManager.SIGNATURE_NEITHER_SIGNED;
				}
			} else {
				if (ArrayUtils.isEmpty(two)) {
					return PackageManager.SIGNATURE_SECOND_NOT_SIGNED;
				} else {
					// 走到了这里说明两个包的签名都在
					if (Arrays.equals(one, two)) {
						return PackageManager.SIGNATURE_MATCH;
					} else {
						return PackageManager.SIGNATURE_NO_MATCH;
					}
				}
			}
		} catch (Throwable e) {
			// Ignore
		}
	}

	return method.invoke(who, args);
}
 
Example 10
Project: GitHub   File: RepositoryActivity.java   View Source Code Vote up 4 votes
private boolean isDonated() {
    return getPackageManager().checkSignatures(getPackageName(), "ru.meefik.donate")
            == PackageManager.SIGNATURE_MATCH;
}
 
Example 11
Project: Brevent   File: BreventActivity.java   View Source Code Vote up 4 votes
private boolean isBreventFramework() {
    PackageManager packageManager = getPackageManager();
    return packageManager.checkSignatures(PACKAGE_FRAMEWORK, BuildConfig.APPLICATION_ID) ==
            PackageManager.SIGNATURE_MATCH;
}
 
Example 12
Project: Zero   File: Utils.java   View Source Code Vote up 4 votes
public static boolean checkProVersion(Context context) {
    PackageManager manager = context.getPackageManager();
    return (manager.checkSignatures(context.getPackageName(), PRO_NAME) == PackageManager.SIGNATURE_MATCH || (BuildConfig.DEBUG && Constants.DEBUG_PRO));
}
 
Example 13
Project: XPrivacy   File: Util.java   View Source Code Vote up 4 votes
private static boolean hasValidProEnablerSignature(Context context) {
	return (context.getPackageManager()
			.checkSignatures(context.getPackageName(), context.getPackageName() + ".pro") == PackageManager.SIGNATURE_MATCH);
}