List of usage examples for android.content.pm PackageManager SIGNATURE_UNKNOWN_PACKAGE
int SIGNATURE_UNKNOWN_PACKAGE
To view the source code for android.content.pm PackageManager SIGNATURE_UNKNOWN_PACKAGE.
Click Source Link
From source file:de.ub0r.android.lib.DonationHelper.java
/** * Check if ads should be hidden.//from ww w .j a v a 2s . co m * * @param context * {@link Context} * @return true if ads should be hidden */ public static boolean hideAds(final Context context) { PackageManager pm = context.getPackageManager(); Intent donationCheck = new Intent(DONATOR_BROADCAST_CHECK); ResolveInfo ri = pm.resolveService(donationCheck, 0); // Log.d(TAG, "ri: " + ri); int match = PackageManager.SIGNATURE_UNKNOWN_PACKAGE; if (ri != null) { Log.d(TAG, "found package: " + ri.serviceInfo.packageName); ComponentName cn = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name); // Log.d(TAG, "component name: " + cn); int i = pm.getComponentEnabledSetting(cn); // Log.d(TAG, "component status: " + i); // Log.d(TAG, "package status: " + ri.serviceInfo.enabled); if (i == PackageManager.COMPONENT_ENABLED_STATE_ENABLED || i == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT && ri.serviceInfo.enabled) { match = pm.checkSignatures(context.getPackageName(), ri.serviceInfo.packageName); } else { Log.w(TAG, ri.serviceInfo.packageName + ": " + ri.serviceInfo.enabled); } } Log.i(TAG, "signature match: " + match); if (match != PackageManager.SIGNATURE_UNKNOWN_PACKAGE) { if (Math.random() < CHECK_DONATOR_LIC) { // verify donator license ComponentName cn = context.startService(donationCheck); Log.d(TAG, "Started service: " + cn); if (cn == null) { return false; } } return match == PackageManager.SIGNATURE_MATCH; } pm = null; // no donator app installed, check donation traditionally // do not drop legacy donators boolean ret = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREFS_HIDEADS, false); Log.d(TAG, "legacy donation check: " + ret); return ret; }