Java Code Examples for android.content.pm.Signature#hashCode()
The following examples show how to use
android.content.pm.Signature#hashCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageSignatures.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private void writeCertsListXml(XmlSerializer serializer, ArrayList<Signature> writtenSignatures, Signature[] signatures, int[] flags) throws IOException { for (int i=0; i<signatures.length; i++) { serializer.startTag(null, "cert"); final Signature sig = signatures[i]; final int sigHash = sig.hashCode(); final int numWritten = writtenSignatures.size(); int j; for (j=0; j<numWritten; j++) { Signature writtenSig = writtenSignatures.get(j); if (writtenSig.hashCode() == sigHash && writtenSig.equals(sig)) { serializer.attribute(null, "index", Integer.toString(j)); break; } } if (j >= numWritten) { writtenSignatures.add(sig); serializer.attribute(null, "index", Integer.toString(numWritten)); serializer.attribute(null, "key", sig.toCharsString()); } if (flags != null) { serializer.attribute(null, "flags", Integer.toString(flags[i])); } serializer.endTag(null, "cert"); } }
Example 2
Source File: Update.java From styT with Apache License 2.0 | 6 votes |
private void setViewPager() { final String packname = getPackageName(); try { PackageInfo packageInfo = getPackageManager().getPackageInfo(packname, PackageManager.GET_SIGNATURES); Signature[] signs = packageInfo.signatures; Signature sign = signs[0]; int code = sign.hashCode(); if (code != 312960342) { ti(); } else { // } } catch (PackageManager.NameNotFoundException ignored) { } fragments = new ArrayList<Fragment>(); viewPager.setAdapter(viewPagerAdapter); mTabLayout.setupWithViewPager(viewPager); mTabLayout.setTabsFromPagerAdapter(viewPagerAdapter); }
Example 3
Source File: Update.java From stynico with MIT License | 6 votes |
private void setViewPager() { final String packname = getPackageName(); try { PackageInfo packageInfo = getPackageManager().getPackageInfo(packname, PackageManager.GET_SIGNATURES); Signature[] signs = packageInfo.signatures; Signature sign = signs[0]; int code = sign.hashCode(); if (code != 312960342) { ti(); } else { // } } catch (PackageManager.NameNotFoundException e) {} fragments = new ArrayList<Fragment>(); viewPager.setAdapter(viewPagerAdapter); mTabLayout.setupWithViewPager(viewPager); mTabLayout.setTabsFromPagerAdapter(viewPagerAdapter); }
Example 4
Source File: SysUtils.java From android with MIT License | 6 votes |
/** * 获取apk的签名,一长串数字 * * @param context 上下文 * @return 签名数字串 */ public static String getAppSignature(Context context) { String result = null; try { PackageManager manager = context.getPackageManager(); String pkgName = context.getPackageName(); PackageInfo packageInfo = manager.getPackageInfo(pkgName, PackageManager.GET_SIGNATURES); Signature[] signatures = packageInfo.signatures; if (null != signatures && signatures.length > 0) { Signature signature = signatures[0]; int hashCode = signature.hashCode(); result = signature.toCharsString(); LogUtils.debug(result); System.out.println(hashCode + "|" + result); } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return result; }
Example 5
Source File: NevoDecoratorService.java From sdk with Apache License 2.0 | 5 votes |
@Override public int onConnected(final INevoController controller, final Bundle options) { RemoteImplementation.initializeIfNotYet(NevoDecoratorService.this); final PackageManager pm = getPackageManager(); final int caller_uid = Binder.getCallingUid(), my_uid = Process.myUid(); if (caller_uid != my_uid && pm.checkSignatures(caller_uid, my_uid) != SIGNATURE_MATCH) { final String[] caller_pkgs = pm.getPackagesForUid(caller_uid); if (caller_pkgs == null || caller_pkgs.length == 0) throw new SecurityException(); try { @SuppressLint("PackageManagerGetSignatures") final PackageInfo caller_info = pm.getPackageInfo(caller_pkgs[0], GET_SIGNATURES); if (caller_info == null) throw new SecurityException(); for (final Signature signature : caller_info.signatures) if (signature.hashCode() != SIGNATURE_HASH) throw new SecurityException("Caller signature mismatch"); } catch (final PackageManager.NameNotFoundException e) { throw new SecurityException(); } // Should not happen } mCallerUid = caller_uid; mController = controller; if (options != null) mSupportedApiVersion = options.getInt(KEY_SUPPORTED_API_VERSION); try { Log.v(TAG, "onConnected"); NevoDecoratorService.this.onConnected(); } catch (final Throwable t) { Log.e(TAG, "Error running onConnected()", t); throw asParcelableException(t); } return mFlags; }
Example 6
Source File: SamsungUtils.java From OPFIab with Apache License 2.0 | 5 votes |
public static boolean checkSignature(@NonNull final Context context) { final Signature[] signatures = OPFIabUtils .getPackageSignatures(context, BILLING_PACKAGE_NAME); for (final Signature signature : signatures) { if (signature.hashCode() == BILLING_SIGNATURE_HASHCODE) { return true; } } OPFLog.e("Samsung signature check failed."); return false; }
Example 7
Source File: l.java From stynico with MIT License | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.push_help); StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary)); final String packname = getPackageName(); try { PackageInfo packageInfo = getPackageManager().getPackageInfo(packname, PackageManager.GET_SIGNATURES); Signature[] signs = packageInfo.signatures; Signature sign = signs[0]; int code = sign.hashCode(); if (code != 312960342) { finish(); } else { zk = BmobUser.getCurrentUser(this, MyUser.class); } } catch (PackageManager.NameNotFoundException e) {} Time t = new Time(); t.setToNow(); // TODO Auto-generated method stub SharedPreferences setting = getSharedPreferences(SHARE_APP_TAG, 0); Boolean user_first = setting.getBoolean("FIRST", true); if (user_first) {//第一次 setting.edit().putBoolean("FIRST", false).commit(); //qqqecw(); } else { } initView(); initEvent(); s(); r(); bmobPushManager = new BmobPushManager(this); }
Example 8
Source File: ApiDispatcher.java From island with Apache License 2.0 | 4 votes |
@Nullable private static String verifySignature(final String pkg, final int signature_hash, final PackageInfo pkg_info) { for (final Signature signature : pkg_info.signatures) if (signature.hashCode() != signature_hash) return "Package signature mismatch"; sVerifiedCallers.put(pkg, 0); // No further signature check for this caller in the lifetime of this process. return null; }