mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
Enable 64-bit.
* Multiply version codes by 10 and add a code for each abi in order to generate different version codes for the play store.
This commit is contained in:
parent
132c81b142
commit
5ad02f724c
32
build.gradle
32
build.gradle
@ -282,6 +282,15 @@ dependencyVerification {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def canonicalVersionCode = 487
|
||||||
|
def canonicalVersionName = "4.40.4"
|
||||||
|
|
||||||
|
def postFixSize = 10
|
||||||
|
def abiPostFix = ['armeabi-v7a' : 1,
|
||||||
|
'arm64-v8a' : 2,
|
||||||
|
'x86' : 3,
|
||||||
|
'x86_64' : 4,
|
||||||
|
'universal' : 5]
|
||||||
|
|
||||||
android {
|
android {
|
||||||
flavorDimensions "none"
|
flavorDimensions "none"
|
||||||
@ -294,8 +303,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
versionCode 487
|
versionCode canonicalVersionCode * postFixSize
|
||||||
versionName "4.40.4"
|
versionName canonicalVersionName
|
||||||
|
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
@ -316,9 +325,10 @@ android {
|
|||||||
buildConfigField "String", "MRENCLAVE", "\"cd6cfc342937b23b1bdd3bbf9721aa5615ac9ff50a75c5527d441cd3276826c9\""
|
buildConfigField "String", "MRENCLAVE", "\"cd6cfc342937b23b1bdd3bbf9721aa5615ac9ff50a75c5527d441cd3276826c9\""
|
||||||
buildConfigField "String", "UNIDENTIFIED_SENDER_TRUST_ROOT", "\"BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF\""
|
buildConfigField "String", "UNIDENTIFIED_SENDER_TRUST_ROOT", "\"BXu6QIKVz5MA8gstzfOgRQGqyLqOwNKHL6INkv3IHWMF\""
|
||||||
buildConfigField "String[]", "LANGUAGES", "new String[]{\"" + autoResConfig().collect { s -> s.replace('-r', '_') }.join('", "') + '"}'
|
buildConfigField "String[]", "LANGUAGES", "new String[]{\"" + autoResConfig().collect { s -> s.replace('-r', '_') }.join('", "') + '"}'
|
||||||
|
buildConfigField "int", "CANONICAL_VERSION_CODE", "$canonicalVersionCode"
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters 'armeabi-v7a', 'x86'
|
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||||
}
|
}
|
||||||
|
|
||||||
resConfigs autoResConfig()
|
resConfigs autoResConfig()
|
||||||
@ -327,7 +337,7 @@ android {
|
|||||||
abi {
|
abi {
|
||||||
enable true
|
enable true
|
||||||
reset()
|
reset()
|
||||||
include 'armeabi-v7a', 'x86'
|
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
|
||||||
universalApk true
|
universalApk true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,8 +407,14 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android.applicationVariants.all { variant ->
|
android.applicationVariants.all { variant ->
|
||||||
variant.outputs.all {
|
variant.outputs.each { output ->
|
||||||
outputFileName = outputFileName.replace(".apk", "-${variant.versionName}.apk")
|
output.outputFileName = output.outputFileName.replace(".apk", "-${variant.versionName}.apk")
|
||||||
|
def abiName = output.getFilter("ABI") ?: 'universal'
|
||||||
|
def postFix = abiPostFix.get(abiName, 0)
|
||||||
|
|
||||||
|
if (postFix >= postFixSize) throw new AssertionError("postFix is too large")
|
||||||
|
|
||||||
|
output.versionCodeOverride = canonicalVersionCode * postFixSize + postFix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,8 +464,8 @@ def assembleWebsiteDescriptor = { variant, file ->
|
|||||||
String apkName = file.getName()
|
String apkName = file.getName()
|
||||||
|
|
||||||
String descriptor = "{" +
|
String descriptor = "{" +
|
||||||
"\"versionCode\" : $project.android.defaultConfig.versionCode," +
|
"\"versionCode\" : $canonicalVersionCode," +
|
||||||
"\"versionName\" : \"$project.android.defaultConfig.versionName\"," +
|
"\"versionName\" : \"$canonicalVersionName\"," +
|
||||||
"\"sha256sum\" : \"$digest\"," +
|
"\"sha256sum\" : \"$digest\"," +
|
||||||
"\"url\" : \"$url/$apkName\"" +
|
"\"url\" : \"$url/$apkName\"" +
|
||||||
"}"
|
"}"
|
||||||
|
@ -20,19 +20,16 @@ package org.thoughtcrime.securesms;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.preference.PreferenceManager;
|
import android.support.v7.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.color.MaterialColor;
|
|
||||||
import org.thoughtcrime.securesms.contacts.avatars.ContactColorsLegacy;
|
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
||||||
|
import org.thoughtcrime.securesms.color.MaterialColor;
|
||||||
|
import org.thoughtcrime.securesms.contacts.avatars.ContactColorsLegacy;
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil;
|
||||||
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
||||||
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
||||||
@ -46,6 +43,7 @@ import org.thoughtcrime.securesms.jobs.CreateSignedPreKeyJob;
|
|||||||
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
import org.thoughtcrime.securesms.jobs.DirectoryRefreshJob;
|
||||||
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
import org.thoughtcrime.securesms.jobs.PushDecryptJob;
|
||||||
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
import org.thoughtcrime.securesms.jobs.RefreshAttributesJob;
|
||||||
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp;
|
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||||
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
import org.thoughtcrime.securesms.notifications.MessageNotifier;
|
||||||
import org.thoughtcrime.securesms.service.KeyCachingService;
|
import org.thoughtcrime.securesms.service.KeyCachingService;
|
||||||
@ -148,7 +146,7 @@ public class DatabaseUpgradeActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean needsUpgradeTask() {
|
private boolean needsUpgradeTask() {
|
||||||
int currentVersionCode = Util.getCurrentApkReleaseVersion(this);
|
int currentVersionCode = Util.getCanonicalVersionCode();
|
||||||
int lastSeenVersion = VersionTracker.getLastSeenVersion(this);
|
int lastSeenVersion = VersionTracker.getLastSeenVersion(this);
|
||||||
|
|
||||||
Log.i("DatabaseUpgradeActivity", "LastSeenVersion: " + lastSeenVersion);
|
Log.i("DatabaseUpgradeActivity", "LastSeenVersion: " + lastSeenVersion);
|
||||||
@ -166,14 +164,10 @@ public class DatabaseUpgradeActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUpdate(Context context) {
|
public static boolean isUpdate(Context context) {
|
||||||
try {
|
int currentVersionCode = Util.getCanonicalVersionCode();
|
||||||
int currentVersionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
|
||||||
int previousVersionCode = VersionTracker.getLastSeenVersion(context);
|
int previousVersionCode = VersionTracker.getLastSeenVersion(context);
|
||||||
|
|
||||||
return previousVersionCode < currentVersionCode;
|
return previousVersionCode < currentVersionCode;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
throw new AssertionError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
@ -185,7 +185,7 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity implements
|
|||||||
private void onContinue(Optional<ExperienceUpgrade> seenUpgrade) {
|
private void onContinue(Optional<ExperienceUpgrade> seenUpgrade) {
|
||||||
ServiceUtil.getNotificationManager(this).cancel(NOTIFICATION_ID);
|
ServiceUtil.getNotificationManager(this).cancel(NOTIFICATION_ID);
|
||||||
int latestVersion = seenUpgrade.isPresent() ? seenUpgrade.get().getVersion()
|
int latestVersion = seenUpgrade.isPresent() ? seenUpgrade.get().getVersion()
|
||||||
: Util.getCurrentApkReleaseVersion(this);
|
: Util.getCanonicalVersionCode();
|
||||||
TextSecurePreferences.setLastExperienceVersionCode(this, latestVersion);
|
TextSecurePreferences.setLastExperienceVersionCode(this, latestVersion);
|
||||||
if (seenUpgrade.isPresent() && seenUpgrade.get().nextIntent != null) {
|
if (seenUpgrade.isPresent() && seenUpgrade.get().nextIntent != null) {
|
||||||
Intent intent = new Intent(this, seenUpgrade.get().nextIntent);
|
Intent intent = new Intent(this, seenUpgrade.get().nextIntent);
|
||||||
@ -204,7 +204,7 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<ExperienceUpgrade> getExperienceUpgrade(Context context) {
|
public static Optional<ExperienceUpgrade> getExperienceUpgrade(Context context) {
|
||||||
final int currentVersionCode = Util.getCurrentApkReleaseVersion(context);
|
final int currentVersionCode = Util.getCanonicalVersionCode();
|
||||||
final int lastSeenVersion = TextSecurePreferences.getLastExperienceVersionCode(context);
|
final int lastSeenVersion = TextSecurePreferences.getLastExperienceVersionCode(context);
|
||||||
Log.i(TAG, "getExperienceUpgrade(" + lastSeenVersion + ")");
|
Log.i(TAG, "getExperienceUpgrade(" + lastSeenVersion + ")");
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ public class ExperienceUpgradeActivity extends BaseActionBarActivity implements
|
|||||||
.build();
|
.build();
|
||||||
ServiceUtil.getNotificationManager(context).notify(NOTIFICATION_ID, notification);
|
ServiceUtil.getNotificationManager(context).notify(NOTIFICATION_ID, notification);
|
||||||
} else if (DISMISS_ACTION.equals(intent.getAction())) {
|
} else if (DISMISS_ACTION.equals(intent.getAction())) {
|
||||||
TextSecurePreferences.setExperienceDismissedVersionCode(context, Util.getCurrentApkReleaseVersion(context));
|
TextSecurePreferences.setExperienceDismissedVersionCode(context, Util.getCanonicalVersionCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class PassphraseCreateActivity extends PassphraseActivity {
|
|||||||
IdentityKeyUtil.generateIdentityKeys(PassphraseCreateActivity.this);
|
IdentityKeyUtil.generateIdentityKeys(PassphraseCreateActivity.this);
|
||||||
VersionTracker.updateLastSeenVersion(PassphraseCreateActivity.this);
|
VersionTracker.updateLastSeenVersion(PassphraseCreateActivity.this);
|
||||||
|
|
||||||
TextSecurePreferences.setLastExperienceVersionCode(PassphraseCreateActivity.this, Util.getCurrentApkReleaseVersion(PassphraseCreateActivity.this));
|
TextSecurePreferences.setLastExperienceVersionCode(PassphraseCreateActivity.this, Util.getCanonicalVersionCode());
|
||||||
TextSecurePreferences.setPasswordDisabled(PassphraseCreateActivity.this, true);
|
TextSecurePreferences.setPasswordDisabled(PassphraseCreateActivity.this, true);
|
||||||
TextSecurePreferences.setReadReceiptsEnabled(PassphraseCreateActivity.this, true);
|
TextSecurePreferences.setReadReceiptsEnabled(PassphraseCreateActivity.this, true);
|
||||||
TextSecurePreferences.setTypingIndicatorsEnabled(PassphraseCreateActivity.this, true);
|
TextSecurePreferences.setTypingIndicatorsEnabled(PassphraseCreateActivity.this, true);
|
||||||
|
@ -506,7 +506,9 @@ public class SubmitLogFragment extends Fragment {
|
|||||||
builder.append(pm.getApplicationLabel(pm.getApplicationInfo(context.getPackageName(), 0)))
|
builder.append(pm.getApplicationLabel(pm.getApplicationInfo(context.getPackageName(), 0)))
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(pm.getPackageInfo(context.getPackageName(), 0).versionName)
|
.append(pm.getPackageInfo(context.getPackageName(), 0).versionName)
|
||||||
.append("\n");
|
.append(" (")
|
||||||
|
.append(Util.getManifestApkVersion(context))
|
||||||
|
.append(")\n");
|
||||||
} catch (PackageManager.NameNotFoundException nnfe) {
|
} catch (PackageManager.NameNotFoundException nnfe) {
|
||||||
builder.append("Unknown\n");
|
builder.append("Unknown\n");
|
||||||
}
|
}
|
||||||
|
@ -512,13 +512,13 @@ public class TextSecurePreferences {
|
|||||||
|
|
||||||
public static void setFcmToken(Context context, String registrationId) {
|
public static void setFcmToken(Context context, String registrationId) {
|
||||||
setStringPreference(context, GCM_REGISTRATION_ID_PREF, registrationId);
|
setStringPreference(context, GCM_REGISTRATION_ID_PREF, registrationId);
|
||||||
setIntegerPrefrence(context, GCM_REGISTRATION_ID_VERSION_PREF, Util.getCurrentApkReleaseVersion(context));
|
setIntegerPrefrence(context, GCM_REGISTRATION_ID_VERSION_PREF, Util.getCanonicalVersionCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFcmToken(Context context) {
|
public static String getFcmToken(Context context) {
|
||||||
int storedRegistrationIdVersion = getIntegerPreference(context, GCM_REGISTRATION_ID_VERSION_PREF, 0);
|
int storedRegistrationIdVersion = getIntegerPreference(context, GCM_REGISTRATION_ID_VERSION_PREF, 0);
|
||||||
|
|
||||||
if (storedRegistrationIdVersion != Util.getCurrentApkReleaseVersion(context)) {
|
if (storedRegistrationIdVersion != Util.getCanonicalVersionCode()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return getStringPreference(context, GCM_REGISTRATION_ID_PREF, null);
|
return getStringPreference(context, GCM_REGISTRATION_ID_PREF, null);
|
||||||
|
@ -25,7 +25,6 @@ import android.content.Context;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -39,7 +38,6 @@ import android.text.Spannable;
|
|||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.style.StyleSpan;
|
import android.text.style.StyleSpan;
|
||||||
import org.thoughtcrime.securesms.logging.Log;
|
|
||||||
|
|
||||||
import com.google.android.mms.pdu_alt.CharacterSets;
|
import com.google.android.mms.pdu_alt.CharacterSets;
|
||||||
import com.google.android.mms.pdu_alt.EncodedStringValue;
|
import com.google.android.mms.pdu_alt.EncodedStringValue;
|
||||||
@ -50,6 +48,7 @@ import com.google.i18n.phonenumbers.Phonenumber;
|
|||||||
import org.thoughtcrime.securesms.BuildConfig;
|
import org.thoughtcrime.securesms.BuildConfig;
|
||||||
import org.thoughtcrime.securesms.components.ComposeText;
|
import org.thoughtcrime.securesms.components.ComposeText;
|
||||||
import org.thoughtcrime.securesms.database.Address;
|
import org.thoughtcrime.securesms.database.Address;
|
||||||
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.mms.OutgoingLegacyMmsConnection;
|
import org.thoughtcrime.securesms.mms.OutgoingLegacyMmsConnection;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
|
||||||
@ -60,7 +59,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -370,7 +368,24 @@ public class Util {
|
|||||||
return context.getPackageName().equals(Telephony.Sms.getDefaultSmsPackage(context));
|
return context.getPackageName().equals(Telephony.Sms.getDefaultSmsPackage(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCurrentApkReleaseVersion(Context context) {
|
/**
|
||||||
|
* The app version.
|
||||||
|
* <p>
|
||||||
|
* This code should be used in all places that compare app versions rather than
|
||||||
|
* {@link #getManifestApkVersion(Context)} or {@link BuildConfig#VERSION_CODE}.
|
||||||
|
*/
|
||||||
|
public static int getCanonicalVersionCode() {
|
||||||
|
return BuildConfig.CANONICAL_VERSION_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link BuildConfig#VERSION_CODE} may not be the actual version due to ABI split code adding a
|
||||||
|
* postfix after BuildConfig is generated.
|
||||||
|
* <p>
|
||||||
|
* However, in most cases you want to use {@link BuildConfig#CANONICAL_VERSION_CODE} via
|
||||||
|
* {@link #getCanonicalVersionCode()}
|
||||||
|
*/
|
||||||
|
public static int getManifestApkVersion(Context context) {
|
||||||
try {
|
try {
|
||||||
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
@ -1,20 +1,19 @@
|
|||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class VersionTracker {
|
public class VersionTracker {
|
||||||
|
|
||||||
|
public static int getLastSeenVersion(@NonNull Context context) {
|
||||||
public static int getLastSeenVersion(Context context) {
|
|
||||||
return TextSecurePreferences.getLastVersionCode(context);
|
return TextSecurePreferences.getLastVersionCode(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateLastSeenVersion(Context context) {
|
public static void updateLastSeenVersion(@NonNull Context context) {
|
||||||
try {
|
try {
|
||||||
int currentVersionCode = Util.getCurrentApkReleaseVersion(context);
|
int currentVersionCode = Util.getCanonicalVersionCode();
|
||||||
TextSecurePreferences.setLastVersionCode(context, currentVersionCode);
|
TextSecurePreferences.setLastVersionCode(context, currentVersionCode);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new AssertionError(ioe);
|
throw new AssertionError(ioe);
|
||||||
|
Loading…
Reference in New Issue
Block a user