Skip to content

Commit

Permalink
Merge pull request #57 from snikket-im/remove-contacts-permissions
Browse files Browse the repository at this point in the history
Remove READ_CONTACTS permission from Play Store version
  • Loading branch information
mwild1 authored Mar 1, 2024
2 parents 7d92e2b + 15de57c commit fee3744
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ ext {

android {
namespace 'eu.siacs.conversations'
compileSdkVersion 32
compileSdkVersion 33

defaultConfig {
minSdkVersion 21
targetSdkVersion 32
versionCode 42050
versionName "2.12.2"
targetSdkVersion 33
versionCode 42051
versionName "2.12.2-2"
archivesBaseName += "-$versionName"
applicationId "org.snikket.android"
resValue "string", "applicationId", applicationId
Expand Down Expand Up @@ -142,10 +142,12 @@ android {
playstore {
dimension "distribution"
versionNameSuffix "+playstore"
buildConfigField "boolean", "CONTACTS_INTEGRATION", "false"
}
free {
dimension "distribution"
versionNameSuffix "+free"
buildConfigField "boolean", "CONTACTS_INTEGRATION", "true"
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/conversationsFree/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.READ_CONTACTS" />

</manifest>
1 change: 0 additions & 1 deletion src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/eu/siacs/conversations/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public static boolean multipleEncryptionChoices() {

public static final long CONTACT_SYNC_RETRY_INTERVAL = 1000L * 60 * 5;

// 2024-02-14: Contacts integration has been removed from Play Store builds, at least for now,
// due to Google aggressively delisting XMPP apps that use it, claiming that the apps are uploading
// contact lists to the server (even though they are not).
public static final boolean CONTACTS_INTEGRATION = BuildConfig.CONTACTS_INTEGRATION;

public static final boolean QUICKSTART_ENABLED = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static boolean allFilesUnderSize(
"do not consider video file with min width larger than 720 for size check");
continue;
}
} catch (NotAVideoFile notAVideoFile) {
} catch (final IOException | NotAVideoFile e) {
// ignore and fall through
}
}
Expand Down Expand Up @@ -268,7 +268,7 @@ private static int calcSampleSize(BitmapFactory.Options options, int size) {
return inSampleSize;
}

private static Dimensions getVideoDimensions(Context context, Uri uri) throws NotAVideoFile {
private static Dimensions getVideoDimensions(Context context, Uri uri) throws NotAVideoFile, IOException {
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
try {
mediaMetadataRetriever.setDataSource(context, uri);
Expand All @@ -294,7 +294,7 @@ private static Dimensions getVideoDimensionsOfFrame(
}

private static Dimensions getVideoDimensions(MediaMetadataRetriever metadataRetriever)
throws NotAVideoFile {
throws NotAVideoFile, IOException {
String hasVideo =
metadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_HAS_VIDEO);
if (hasVideo == null) {
Expand Down Expand Up @@ -1527,7 +1527,7 @@ public void updateFileParams(final Message message, final String url) {
Log.d(Config.LOGTAG, "ambiguous file " + mime + " is audio");
body.append("|0|0|").append(getMediaRuntime(file));
}
} catch (final NotAVideoFile e) {
} catch (final IOException | NotAVideoFile e) {
Log.d(Config.LOGTAG, "ambiguous file " + mime + " is audio");
body.append("|0|0|").append(getMediaRuntime(file));
}
Expand All @@ -1547,7 +1547,7 @@ public void updateFileParams(final Message message, final String url) {
.append('|')
.append(dimensions.height);
}
} catch (NotAVideoFile notAVideoFile) {
} catch (final IOException | NotAVideoFile notAVideoFile) {
Log.d(
Config.LOGTAG,
"file with mime type " + file.getMimeType() + " was not a video file");
Expand Down Expand Up @@ -1592,7 +1592,7 @@ private Dimensions getImageDimensions(File file) {
return new Dimensions(imageHeight, imageWidth);
}

private Dimensions getVideoDimensions(File file) throws NotAVideoFile {
private Dimensions getVideoDimensions(final File file) throws NotAVideoFile, IOException {
MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever();
try {
metadataRetriever.setDataSource(file.getAbsolutePath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
private void checkContactPermissionAndShowAddDialog() {
if (hasContactsPermission()) {
showAddToPhoneBookDialog();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
} else if (Config.CONTACTS_INTEGRATION && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, REQUEST_SYNC_CONTACTS);
}
}
Expand Down

0 comments on commit fee3744

Please sign in to comment.