Code example for PackageManager

Methods: checkSignaturesgetPackagesForUid

-1
		final String pname = getPackageNameByUid(uid);
		return checkSignature(pname);
	} 
 
	public boolean checkSignature(final String pname) {
		return mPackageManager.checkSignatures(pname, mContext.getPackageName()) == PackageManager.SIGNATURE_MATCH;
	} 
 
	public boolean deny(final String package_name) {
		if (package_name == null) return false;
		final SharedPreferences.Editor editor = mPreferences.edit();
		editor.putInt(package_name, PERMISSION_DENIED);
		return editor.commit();
 
	} 
 
	public int getPermissions(final int uid) {
		return getPermissions(getPackageNameByUid(uid));
	} 
 
	public int getPermissions(final String package_name) {
		if (isEmpty(package_name)) return PERMISSION_INVALID;
		return mPreferences.getInt(package_name, PERMISSION_NONE);
	} 
 
	public boolean revoke(final String package_name) {
		if (package_name == null) return false;
		final SharedPreferences.Editor editor = mPreferences.edit();
		editor.remove(package_name);
		return editor.commit();
	} 
 
	private String getPackageNameByUid(final int uid) {
		final String[] pkgs = mPackageManager.getPackagesForUid(uid);
		if (pkgs != null && pkgs.length > 0) return pkgs[0];
		return null; 
	} 
}