code: public static boolean ensureSameSignature(Context context, String targetPackageName, String expectedHash) {
          if (targetPackageName == null || expectedHash == null) {
              // cannot proceed anymore.
              return false;
          }
          String hash = expectedHash.replace(" ", "");
          return hash.equals(getSignatureHexCode(context, targetPackageName));
      }
docs: Ensure the running application and the target package has the same signature.
  @param context the running application context.
  @param targetPackageName the target package name.
  @param expectedHash signature hash that the target package is expected to have signed.
  @return true if the same signature.