Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9629 Remove five files' calls to GMS APIs for utility functions #9644

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -10,7 +10,6 @@
import androidx.annotation.Nullable;

import com.annimon.stream.Stream;
import com.google.android.gms.common.util.ArrayUtils;

import net.sqlcipher.database.SQLiteConstraintException;
import net.sqlcipher.database.SQLiteDatabase;
Expand Down Expand Up @@ -150,14 +149,14 @@ public class RecipientDatabase extends Database {

private static final String[] MENTION_SEARCH_PROJECTION = new String[]{ID, removeWhitespace("COALESCE(" + nullIfEmpty(SYSTEM_DISPLAY_NAME) + ", " + nullIfEmpty(PROFILE_JOINED_NAME) + ", " + nullIfEmpty(PROFILE_GIVEN_NAME) + ", " + nullIfEmpty(USERNAME) + ", " + nullIfEmpty(PHONE) + ")") + " AS " + SORT_NAME};

private static final String[] RECIPIENT_FULL_PROJECTION = ArrayUtils.concat(
private static final String[] RECIPIENT_FULL_PROJECTION = Stream.of(
new String[] { TABLE_NAME + "." + ID,
TABLE_NAME + "." + STORAGE_PROTO },
TYPED_RECIPIENT_PROJECTION,
new String[] {
IdentityDatabase.TABLE_NAME + "." + IdentityDatabase.VERIFIED + " AS " + IDENTITY_STATUS,
IdentityDatabase.TABLE_NAME + "." + IdentityDatabase.IDENTITY_KEY + " AS " + IDENTITY_KEY
});
}).flatMap(Stream::of).toArray(String[]::new);

public static final String[] CREATE_INDEXS = new String[] {
"CREATE INDEX IF NOT EXISTS recipient_dirty_index ON " + TABLE_NAME + " (" + DIRTY + ");",
Expand Down Expand Up @@ -1041,8 +1040,8 @@ private List<RecipientSettings> getRecipientSettingsForSync(@Nullable String que
+ " LEFT OUTER JOIN " + GroupDatabase.TABLE_NAME + " ON " + TABLE_NAME + "." + GROUP_ID + " = " + GroupDatabase.TABLE_NAME + "." + GroupDatabase.GROUP_ID;
List<RecipientSettings> out = new ArrayList<>();

String[] columns = ArrayUtils.concat(RECIPIENT_FULL_PROJECTION,
new String[]{GroupDatabase.TABLE_NAME + "." + GroupDatabase.V2_MASTER_KEY });
String[] columns = Stream.of(RECIPIENT_FULL_PROJECTION,
new String[]{GroupDatabase.TABLE_NAME + "." + GroupDatabase.V2_MASTER_KEY }).flatMap(Stream::of).toArray(String[]::new);

try (Cursor cursor = db.query(table, columns, query, args, null, null, null)) {
while (cursor != null && cursor.moveToNext()) {
Expand Down
Expand Up @@ -27,7 +27,6 @@

import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.dd.CircularProgressButton;
import com.google.android.gms.common.util.IOUtils;

import org.thoughtcrime.securesms.LoggingFragment;
import org.thoughtcrime.securesms.R;
Expand All @@ -45,6 +44,7 @@
import org.thoughtcrime.securesms.util.CommunicationActions;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.StringUtil;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.concurrent.SimpleTask;
import org.thoughtcrime.securesms.util.text.AfterTextChanged;
import org.thoughtcrime.securesms.util.views.LearnMoreTextView;
Expand Down Expand Up @@ -174,7 +174,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
Media result = data.getParcelableExtra(AvatarSelectionActivity.EXTRA_MEDIA);
InputStream stream = BlobProvider.getInstance().getStream(requireContext(), result.getUri());

return IOUtils.readInputStreamFully(stream);
return Util.readFully(stream);
} catch (IOException ioException) {
Log.w(TAG, ioException);
return null;
Expand Down
Expand Up @@ -6,7 +6,7 @@
import androidx.annotation.WorkerThread;

import com.annimon.stream.Stream;
import com.google.android.gms.common.util.Hex;
import org.thoughtcrime.securesms.util.Hex;

import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.database.StickerDatabase;
Expand Down Expand Up @@ -77,8 +77,8 @@ private Optional<StickerManifestResult> getManifestFromDatabase(@NonNull String
@WorkerThread
private Optional<StickerManifestResult> getManifestRemote(@NonNull String packId, @NonNull String packKey) {
try {
byte[] packIdBytes = Hex.stringToBytes(packId);
byte[] packKeyBytes = Hex.stringToBytes(packKey);
byte[] packIdBytes = Hex.fromStringCondensed(packId);
byte[] packKeyBytes = Hex.fromStringCondensed(packKey);
SignalServiceStickerManifest remoteManifest = receiver.retrieveStickerManifest(packIdBytes, packKeyBytes);
StickerManifest localManifest = new StickerManifest(packId,
packKey,
Expand Down
Expand Up @@ -5,7 +5,7 @@
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.data.DataFetcher;
import com.google.android.gms.common.util.Hex;
import org.thoughtcrime.securesms.util.Hex;

import org.thoughtcrime.securesms.logging.Log;
import org.whispersystems.libsignal.InvalidMessageException;
Expand All @@ -32,8 +32,8 @@ public StickerRemoteUriFetcher(@NonNull SignalServiceMessageReceiver receiver, @
@Override
public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) {
try {
byte[] packIdBytes = Hex.stringToBytes(stickerUri.getPackId());
byte[] packKeyBytes = Hex.stringToBytes(stickerUri.getPackKey());
byte[] packIdBytes = Hex.fromStringCondensed(stickerUri.getPackId());
byte[] packKeyBytes = Hex.fromStringCondensed(stickerUri.getPackKey());
InputStream stream = receiver.retrieveSticker(packIdBytes, packKeyBytes, stickerUri.getStickerId());

callback.onDataReady(stream);
Expand Down
Expand Up @@ -5,7 +5,7 @@
import androidx.annotation.Nullable;
import android.text.TextUtils;

import com.google.android.gms.common.util.Hex;
import org.thoughtcrime.securesms.util.Hex;

import org.whispersystems.libsignal.util.Pair;
import org.whispersystems.libsignal.util.guava.Optional;
Expand Down Expand Up @@ -70,7 +70,7 @@ public static String createShareLink(@NonNull String packId, @NonNull String pac

private static boolean isValidHex(String value) {
try {
Hex.stringToBytes(value);
Hex.fromStringCondensed(value);
return true;
} catch (Exception e) {
return false;
Expand Down
Expand Up @@ -4,8 +4,6 @@

import androidx.annotation.NonNull;

import com.google.android.gms.common.util.concurrent.NumberedThreadFactory;

import org.thoughtcrime.securesms.util.LinkedBlockingLifoQueue;

import java.util.Queue;
Expand Down