use of org.thoughtcrime.securesms.emoji.EmojiJsonRequest in project Signal-Android by WhisperSystems.
the class DownloadLatestEmojiDataJob method downloadJson.
@NonNull
private static EmojiData downloadJson(@NonNull Context context, @NonNull EmojiFiles.Version version) throws IOException, InvalidEmojiDataJsonException {
EmojiFiles.NameCollection names = EmojiFiles.NameCollection.read(context, version);
UUID emojiData = names.getUUIDForEmojiData();
byte[] remoteHash = EmojiRemote.getMd5(new EmojiJsonRequest(version.getVersion()));
byte[] localHash;
if (emojiData != null) {
localHash = EmojiFiles.getMd5(context, version, emojiData);
} else {
localHash = null;
}
if (!Arrays.equals(localHash, remoteHash)) {
Log.d(TAG, "Downloading JSON from Remote");
assertRemoteDownloadConstraints(context);
EmojiFiles.Name name = EmojiDownloader.downloadAndVerifyJsonFromRemote(context, version);
EmojiFiles.NameCollection.append(context, names, name);
} else {
Log.d(TAG, "Already have JSON from remote, skipping download");
}
EmojiData latestData = EmojiFiles.getLatestEmojiData(context, version);
if (latestData == null) {
throw new InvalidEmojiDataJsonException();
}
return latestData;
}
Aggregations