本文整理了Java中com.facebook.internal.Utility.sha1hash()
方法的一些代码示例,展示了Utility.sha1hash()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utility.sha1hash()
方法的具体详情如下:
包路径:com.facebook.internal.Utility
类名称:Utility
方法名:sha1hash
暂无
代码示例来源:origin: facebook/facebook-android-sdk
String hashedSignature = Utility.sha1hash(signature.toByteArray());
if (!validAppSignatureHashes.contains(hashedSignature)) {
return false;
代码示例来源:origin: facebook/facebook-android-sdk
/**
* Sets up the PackageManager to return what we expect depending on whether app is installed.
* @param isInstalled true to simulate that app is installed
*/
private void setupPackageManagerForApp(boolean isInstalled, boolean hasValidSignature)
throws Exception {
if (isInstalled) {
PackageInfo packageInfo = new PackageInfo();
when(mMockPackageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_SIGNATURES))
.thenReturn(packageInfo);
Signature signature = mock(Signature.class);
packageInfo.signatures = new Signature[]{signature};
if (hasValidSignature) {
when(Utility.sha1hash(signature.toByteArray())).thenReturn(APP_HASH);
}
} else {
when(mMockPackageManager.getPackageInfo(PACKAGE_NAME, PackageManager.GET_SIGNATURES))
.thenThrow(new PackageManager.NameNotFoundException());
}
}
}
代码示例来源:origin: fr.avianey/facebook-android-api
public static String getHashedDeviceAndAppID(Context context, String applicationId) {
String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
if (androidId == null) {
return null;
} else {
return sha1hash(androidId + applicationId);
}
}
代码示例来源:origin: fr.avianey/facebook-android-api
public boolean validateSignature(Context context, String packageName) {
String brand = Build.BRAND;
int applicationFlags = context.getApplicationInfo().flags;
if (brand.startsWith("generic") && (applicationFlags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// We are debugging on an emulator, don't validate package signature.
return true;
}
PackageInfo packageInfo = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(packageName,
PackageManager.GET_SIGNATURES);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
for (Signature signature : packageInfo.signatures) {
String hashedSignature = Utility.sha1hash(signature.toByteArray());
if (validAppSignatureHashes.contains(hashedSignature)) {
return true;
}
}
return false;
}
}
内容来源于网络,如有侵权,请联系作者删除!