Search in sources :

Example 1 with EmojiJsonRequest

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;
}
Also used : EmojiJsonRequest(org.thoughtcrime.securesms.emoji.EmojiJsonRequest) UUID(java.util.UUID) EmojiFiles(org.thoughtcrime.securesms.emoji.EmojiFiles) EmojiData(org.thoughtcrime.securesms.emoji.EmojiData) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1 UUID (java.util.UUID)1 EmojiData (org.thoughtcrime.securesms.emoji.EmojiData)1 EmojiFiles (org.thoughtcrime.securesms.emoji.EmojiFiles)1 EmojiJsonRequest (org.thoughtcrime.securesms.emoji.EmojiJsonRequest)1