Kaynağa Gözat

Version 6.4.1-1137

Threema 1 hafta önce
ebeveyn
işleme
c899f99bc3

+ 2 - 2
app/build.gradle.kts

@@ -32,7 +32,7 @@ if (gradle.startParameter.taskRequests.toString().contains("Hms")) {
 /**
  * Only use the scheme "<major>.<minor>.<patch>" for the appVersion
  */
-val appVersion = "6.4.0"
+val appVersion = "6.4.1"
 
 /**
  * betaSuffix with leading dash (e.g. `-beta1`).
@@ -41,7 +41,7 @@ val appVersion = "6.4.0"
  */
 val betaSuffix = ""
 
-val defaultVersionCode = 1136
+val defaultVersionCode = 1137
 
 /**
  * Map with keystore paths (if found).

+ 3 - 2
app/src/foss_based/java/ch/threema/app/licensing/StoreLicenseCheck.java

@@ -1,6 +1,7 @@
 package ch.threema.app.licensing;
 
-import android.content.Context;
+import android.app.Activity;
+import androidx.annotation.NonNull;
 
 import ch.threema.app.routines.CheckLicenseRoutine;
 import ch.threema.app.services.UserService;
@@ -10,7 +11,7 @@ public class StoreLicenseCheck {
     private StoreLicenseCheck() {
     }
 
-    public static void checkLicense(Context context, UserService userService) {
+    public static void checkLicense(@NonNull Activity activity, UserService userService) {
         // stub, no platform store license check in foss based builds
     }
 }

+ 8 - 7
app/src/google_services_based/java/ch/threema/app/licensing/StoreLicenseCheck.java

@@ -1,7 +1,8 @@
 package ch.threema.app.licensing;
 
-import android.content.Context;
+import android.app.Activity;
 import android.content.ReceiverCallNotAllowedException;
+import androidx.annotation.NonNull;
 
 import com.google.android.vending.licensing.LicenseChecker;
 import com.google.android.vending.licensing.LicenseCheckerCallback;
@@ -20,13 +21,13 @@ public class StoreLicenseCheck {
     private StoreLicenseCheck() {
     }
 
-    public static void checkLicense(Context context, UserService userService) {
-        logger.debug("Checking LVL licence");
+    public static void checkLicense(@NonNull Activity activity, UserService userService) {
+        logger.info("Checking LVL licence");
         final ThreemaLicensePolicy policy = new ThreemaLicensePolicy();
         LicenseCheckerCallback callback = new LicenseCheckerCallback() {
             @Override
             public void allow(int reason) {
-                logger.debug("LVL License OK");
+                logger.info("LVL License OK");
                 userService.setPolicyResponse(
                     policy.getLastResponseData().responseData,
                     policy.getLastResponseData().signature,
@@ -38,7 +39,7 @@ public class StoreLicenseCheck {
             public void dontAllow(int reason) {
                 // 561 == not licensed
                 // 291 == no connection
-                logger.debug("LVL License not allowed (code {})", reason);
+                logger.info("LVL License not allowed (code {})", reason);
                 userService.setPolicyResponse(
                     null,
                     null,
@@ -48,7 +49,7 @@ public class StoreLicenseCheck {
 
             @Override
             public void applicationError(int errorCode) {
-                logger.debug("LVL License check failed errorCode: {}", errorCode);
+                logger.info("LVL License check failed errorCode: {}", errorCode);
                 userService.setPolicyResponse(
                     null,
                     null,
@@ -56,7 +57,7 @@ public class StoreLicenseCheck {
                 );
             }
         };
-        LicenseChecker licenseChecker = new LicenseChecker(context, policy, LICENSE_PUBLIC_KEY);
+        LicenseChecker licenseChecker = new LicenseChecker(activity.getApplicationContext(), policy, LICENSE_PUBLIC_KEY);
         try {
             licenseChecker.checkAccess(callback);
         } catch (ReceiverCallNotAllowedException x) {

+ 5 - 6
app/src/hms_services_based/java/ch/threema/app/licensing/StoreLicenseCheck.java

@@ -1,14 +1,13 @@
 package ch.threema.app.licensing;
 
 import android.app.Activity;
-import android.content.Context;
+import androidx.annotation.NonNull;
 
 import com.DrmSDK.Drm;
 import com.DrmSDK.DrmCheckCallback;
 
 import org.slf4j.Logger;
 
-import ch.threema.app.routines.CheckLicenseRoutine;
 import ch.threema.app.services.UserService;
 import static ch.threema.base.utils.LoggingKt.getThreemaLogger;
 
@@ -21,8 +20,8 @@ public class StoreLicenseCheck {
     private StoreLicenseCheck() {
     }
 
-    public static void checkLicense(Context context, UserService userService) {
-        logger.debug("Check HMS license");
+    public static void checkLicense(@NonNull Activity activity, UserService userService) {
+        logger.info("Check HMS license");
         DrmCheckCallback callback = new DrmCheckCallback() {
             @Override
             public void onCheckSuccess(String signData, String signature) {
@@ -36,7 +35,7 @@ public class StoreLicenseCheck {
 
             @Override
             public void onCheckFailed(int errorCode) {
-                logger.debug("HMS License failed errorCode: {}", errorCode);
+                logger.info("HMS License failed errorCode: {}", errorCode);
                 userService.setPolicyResponse(
                     null,
                     null,
@@ -44,6 +43,6 @@ public class StoreLicenseCheck {
                 );
             }
         };
-        Drm.check((Activity) context, context.getPackageName(), HMS_ID, HMS_PUBLIC_KEY, callback);
+        Drm.check(activity, activity.getPackageName(), HMS_ID, HMS_PUBLIC_KEY, callback);
     }
 }

+ 1 - 3
app/src/libre/play/release-notes/de/default.txt

@@ -1,3 +1 @@
-- Technische und visuelle Überarbeitung der Chatübersicht
-- Der Hauptschlüssel wird neu zusätzlich durch das Android Keystore-System geschützt
-- Verbesserungen und Behebung verschiedener Fehler
+- Verbesserung der Bildvorschau in Benachrichtigungen

+ 1 - 3
app/src/libre/play/release-notes/en-US/default.txt

@@ -1,3 +1 @@
-- Technical and visual overhaul of the chat overview
-- The master key is now additionally protected by the Android Keystore system
-- Various under-the-hood improvements and bug fixes
+- Improved thumbnails in notifications

+ 16 - 2
app/src/main/java/ch/threema/app/GlobalListeners.java

@@ -75,12 +75,14 @@ import ch.threema.data.models.ContactModel;
 import ch.threema.data.models.ContactModelData;
 import ch.threema.data.models.GroupIdentity;
 import ch.threema.data.repositories.ContactModelRepository;
+import ch.threema.domain.protocol.csp.messages.file.FileData;
 import ch.threema.domain.stores.IdentityStore;
 import ch.threema.domain.taskmanager.TriggerSource;
 import ch.threema.localcrypto.exceptions.MasterKeyLockedException;
 import ch.threema.storage.models.AbstractMessageModel;
 import ch.threema.storage.models.ConversationModel;
 import ch.threema.storage.models.DistributionListModel;
+import ch.threema.storage.models.data.MessageContentsType;
 import ch.threema.storage.models.group.GroupModelOld;
 import ch.threema.storage.models.MessageType;
 import ch.threema.storage.models.ServerMessageModel;
@@ -527,8 +529,7 @@ public class GlobalListeners {
                         serviceManager.getConversationService();
                     ConversationModel conversationModel =
                         conversationService.refresh(modifiedMessageModel);
-                    if (conversationModel != null &&
-                        modifiedMessageModel.getType() == MessageType.IMAGE) {
+                    if (conversationModel != null && isImageOrVideoMessage(modifiedMessageModel)) {
                         // Only show a notification if there is a conversation
                         showConversationNotification(modifiedMessageModel, true);
                     }
@@ -538,6 +539,19 @@ public class GlobalListeners {
             }
         }
 
+        // The following code does not need to be ported to 'develop'
+        private boolean isImageOrVideoMessage(@NonNull AbstractMessageModel message) {
+            var type = message.getType();
+            if (type != MessageType.IMAGE && type != MessageType.VIDEO && type != MessageType.FILE) {
+                return false;
+            }
+            var contentsType = message.getMessageContentsType();
+            if (contentsType != MessageContentsType.IMAGE && contentsType != MessageContentsType.VIDEO) {
+                return false;
+            }
+            return message.getFileData().getRenderingType() == FileData.RENDERING_MEDIA;
+        }
+
         @Override
         public void onRemoved(AbstractMessageModel removedMessageModel) {
             logger.debug("MessageListener.onRemoved");

+ 1 - 1
app/src/main/java/ch/threema/app/home/HomeActivity.kt

@@ -629,7 +629,7 @@ class HomeActivity : ThreemaAppCompatActivity(), SMSVerificationDialogCallback,
         if (deviceService.isOnline()) {
             RuntimeUtil.runOnWorkerThread(
                 CheckLicenseRoutine(
-                    applicationContext,
+                    this,
                     apiConnector,
                     userService,
                     deviceService,

+ 26 - 16
app/src/main/java/ch/threema/app/routines/CheckLicenseRoutine.java

@@ -1,10 +1,13 @@
 package ch.threema.app.routines;
 
+import android.app.Activity;
 import android.content.Context;
 import android.content.ReceiverCallNotAllowedException;
 
 import org.slf4j.Logger;
 
+import java.lang.ref.WeakReference;
+
 import androidx.annotation.NonNull;
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
 import ch.threema.app.BuildFlavor;
@@ -17,6 +20,7 @@ import ch.threema.app.services.license.LicenseServiceThreema;
 import ch.threema.app.utils.ConfigUtils;
 import ch.threema.app.utils.IntentDataUtil;
 import static ch.threema.base.utils.LoggingKt.getThreemaLogger;
+
 import ch.threema.domain.protocol.api.APIConnector;
 import ch.threema.domain.stores.IdentityStore;
 
@@ -27,7 +31,7 @@ public class CheckLicenseRoutine implements Runnable {
     private static final Logger logger = getThreemaLogger("CheckLicenseRoutine");
 
     @NonNull
-    private final Context context;
+    private final WeakReference<Activity> activityWeakReference;
     @NonNull
     private final APIConnector apiConnector;
     @NonNull
@@ -43,7 +47,7 @@ public class CheckLicenseRoutine implements Runnable {
 
     public CheckLicenseRoutine(
         @NonNull
-        Context context,
+        Activity activity,
         @NonNull
         APIConnector apiConnector,
         @NonNull
@@ -57,7 +61,7 @@ public class CheckLicenseRoutine implements Runnable {
         @NonNull
         AppRestrictions appRestrictions
     ) {
-        this.context = context;
+        this.activityWeakReference = new WeakReference<>(activity);
         this.apiConnector = apiConnector;
         this.userService = userService;
         this.deviceService = deviceService;
@@ -66,36 +70,34 @@ public class CheckLicenseRoutine implements Runnable {
         this.appRestrictions = appRestrictions;
     }
 
-    private void invalidLicense(String message) {
-        try {
-            LocalBroadcastManager.getInstance(this.context).sendBroadcast(IntentDataUtil.createActionIntentLicenseNotAllowed(message));
-        } catch (ReceiverCallNotAllowedException x) {
-            logger.error("Exception", x);
-        }
-    }
-
     @Override
     public void run() {
+        Activity activity = activityWeakReference.get();
+        if (activity == null) {
+            // TODO(ANDR-4545): Report this to sentry
+            logger.error("Could not check license");
+            return;
+        }
         switch (BuildFlavor.getCurrent().getLicenseType()) {
             case GOOGLE:
             case HMS:
-                StoreLicenseCheck.checkLicense(context, userService);
+                StoreLicenseCheck.checkLicense(activity, userService);
                 break;
             case SERIAL:
             case GOOGLE_WORK:
             case HMS_WORK:
             case ONPREM:
-                this.checkSerial();
+                checkSerial(activity.getApplicationContext());
                 break;
         }
     }
 
-    private void checkSerial() {
+    private void checkSerial(@NonNull Context applicationContext) {
         logger.info("Checking serial license");
 
         String error = licenseService.validate(true);
         if (error != null) {
-            invalidLicense(error);
+            invalidLicense(applicationContext, error);
         } else {
             userService.setCredentials(licenseService.loadCredentials());
 
@@ -103,7 +105,7 @@ public class CheckLicenseRoutine implements Runnable {
                 LicenseServiceThreema<?> licenseServiceThreema = (LicenseServiceThreema<?>) licenseService;
                 if (licenseServiceThreema.getUpdateMessage() != null && !licenseServiceThreema.isUpdateMessageShown()) {
                     try {
-                        LocalBroadcastManager.getInstance(this.context).sendBroadcast(
+                        LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(
                             IntentDataUtil.createActionIntentUpdateAvailable(
                                 licenseServiceThreema.getUpdateMessage(),
                                 licenseServiceThreema.getUpdateUrl()
@@ -128,4 +130,12 @@ public class CheckLicenseRoutine implements Runnable {
             }
         }
     }
+
+    private void invalidLicense(@NonNull Context applicationContext, String message) {
+        try {
+            LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(IntentDataUtil.createActionIntentLicenseNotAllowed(message));
+        } catch (ReceiverCallNotAllowedException x) {
+            logger.error("Exception", x);
+        }
+    }
 }