Android native logs (#8384)
* Android native logs * Use latest version of the library
This commit is contained in:
parent
3cda8df6f4
commit
640ff93e01
9 changed files with 44 additions and 40 deletions
|
|
@ -20,7 +20,6 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
|
@ -32,6 +31,7 @@ import androidx.core.graphics.drawable.IconCompat;
|
|||
import com.mattermost.rnbeta.*;
|
||||
import com.mattermost.rnutils.helpers.NotificationHelper;
|
||||
import com.nozbe.watermelondb.WMDatabase;
|
||||
import com.mattermost.turbolog.TurboLog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.KeyFactory;
|
||||
|
|
@ -241,36 +241,36 @@ public class CustomPushNotificationHelper {
|
|||
public static boolean verifySignature(final Context context, String signature, String serverUrl, String ackId) {
|
||||
if (signature == null) {
|
||||
// Backward compatibility with old push proxies
|
||||
Log.i("Mattermost Notifications Signature verification", "No signature in the notification");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "No signature in the notification");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (serverUrl == null) {
|
||||
Log.i("Mattermost Notifications Signature verification", "No server_url for server_id");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "No server_url for server_id");
|
||||
return false;
|
||||
}
|
||||
|
||||
DatabaseHelper dbHelper = DatabaseHelper.Companion.getInstance();
|
||||
if (dbHelper == null) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Cannot access the database");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "Cannot access the database");
|
||||
return false;
|
||||
}
|
||||
|
||||
WMDatabase db = getDatabaseForServer(dbHelper, context, serverUrl);
|
||||
if (db == null) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Cannot access the server database");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "Cannot access the server database");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (signature.equals("NO_SIGNATURE")) {
|
||||
String version = queryConfigServerVersion(db);
|
||||
if (version == null) {
|
||||
Log.i("Mattermost Notifications Signature verification", "No server version");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "No server version");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!version.matches("[0-9]+(\\.[0-9]+)*")) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Invalid server version");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "Invalid server version");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ public class CustomPushNotificationHelper {
|
|||
}
|
||||
|
||||
if (rejected) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Server version should send signature");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "Server version should send signature");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -334,7 +334,7 @@ public class CustomPushNotificationHelper {
|
|||
|
||||
String signingKey = queryConfigSigningKey(db);
|
||||
if (signingKey == null) {
|
||||
Log.i("Mattermost Notifications Signature verification", "No signing key");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "No signing key");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -345,17 +345,17 @@ public class CustomPushNotificationHelper {
|
|||
|
||||
String storedDeviceToken = getDeviceToken(dbHelper);
|
||||
if (storedDeviceToken == null) {
|
||||
Log.i("Mattermost Notifications Signature verification", "No device token stored");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "No device token stored");
|
||||
return false;
|
||||
}
|
||||
String[] tokenParts = storedDeviceToken.split(":", 2);
|
||||
if (tokenParts.length != 2) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Wrong stored device token format");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "Wrong stored device token format");
|
||||
return false;
|
||||
}
|
||||
String deviceToken = tokenParts[1].substring(0, tokenParts[1].length() -1 );
|
||||
if (deviceToken.isEmpty()) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Empty stored device token");
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", "Empty stored device token");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -366,19 +366,19 @@ public class CustomPushNotificationHelper {
|
|||
.build()
|
||||
.parseSignedClaims(signature);
|
||||
} catch (MissingClaimException e) {
|
||||
Log.i("Mattermost Notifications Signature verification", String.format("Missing claim: %s", e.getMessage()));
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Missing claim: %s", e.getMessage()));
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (IncorrectClaimException e) {
|
||||
Log.i("Mattermost Notifications Signature verification", String.format("Incorrect claim: %s", e.getMessage()));
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Incorrect claim: %s", e.getMessage()));
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (JwtException e) {
|
||||
Log.i("Mattermost Notifications Signature verification", String.format("Cannot verify JWT: %s", e.getMessage()));
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Cannot verify JWT: %s", e.getMessage()));
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
Log.i("Mattermost Notifications Signature verification", String.format("Exception while parsing JWT: %s", e.getMessage()));
|
||||
TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Exception while parsing JWT: %s", e.getMessage()));
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
|
@ -572,7 +572,7 @@ public class CustomPushNotificationHelper {
|
|||
Double lastUpdateAt = 0.0;
|
||||
if (!TextUtils.isEmpty(urlOverride)) {
|
||||
Request request = new Request.Builder().url(urlOverride).build();
|
||||
Log.i("ReactNative", String.format("Fetch override profile image %s", urlOverride));
|
||||
TurboLog.Companion.i("ReactNative", String.format("Fetch override profile image %s", urlOverride));
|
||||
response = client.newCall(request).execute();
|
||||
} else {
|
||||
DatabaseHelper dbHelper = DatabaseHelper.Companion.getInstance();
|
||||
|
|
@ -594,7 +594,7 @@ public class CustomPushNotificationHelper {
|
|||
|
||||
bitmapCache.removeBitmap(userId, serverUrl);
|
||||
String url = String.format("api/v4/users/%s/image", userId);
|
||||
Log.i("ReactNative", String.format("Fetch profile image %s", url));
|
||||
TurboLog.Companion.i("ReactNative", String.format("Fetch profile image %s", url));
|
||||
response = Network.getSync(serverUrl, url, null);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.mattermost.helpers
|
|||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import com.facebook.react.bridge.Arguments
|
||||
import com.facebook.react.bridge.ReadableArray
|
||||
import com.facebook.react.bridge.ReadableMap
|
||||
|
|
@ -15,6 +14,7 @@ import com.mattermost.helpers.push_notification.fetchNeededUsers
|
|||
import com.mattermost.helpers.push_notification.fetchPosts
|
||||
import com.mattermost.helpers.push_notification.fetchTeamIfNeeded
|
||||
import com.mattermost.helpers.push_notification.fetchThread
|
||||
import com.mattermost.turbolog.TurboLog
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
|
|
@ -50,7 +50,7 @@ class PushNotificationDataRunnable {
|
|||
val isCRTEnabled = initialData.getString("is_crt_enabled") == "true"
|
||||
val ackId = initialData.getString("ack_id")
|
||||
|
||||
Log.i("ReactNative", "Start fetching notification data in server=$serverUrl for channel=$channelId and ack=$ackId")
|
||||
TurboLog.i("ReactNative", "Start fetching notification data in server=$serverUrl for channel=$channelId and ack=$ackId")
|
||||
|
||||
val receivingThreads = isCRTEnabled && !rootId.isNullOrEmpty()
|
||||
val notificationData = Arguments.createMap()
|
||||
|
|
@ -104,13 +104,13 @@ class PushNotificationDataRunnable {
|
|||
dbHelper.saveToDatabase(db, notificationData, teamId, channelId, receivingThreads)
|
||||
}
|
||||
|
||||
Log.i("ReactNative", "Done processing push notification=$serverUrl for channel=$channelId and ack=$ackId")
|
||||
TurboLog.i("ReactNative", "Done processing push notification=$serverUrl for channel=$channelId and ack=$ackId")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
db?.close()
|
||||
Log.i("ReactNative", "DONE fetching notification data")
|
||||
TurboLog.i("ReactNative", "DONE fetching notification data")
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.mattermost.rnbeta
|
|||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.mattermost.helpers.CustomPushNotificationHelper
|
||||
import com.mattermost.helpers.DatabaseHelper
|
||||
|
|
@ -11,6 +10,7 @@ import com.mattermost.helpers.Network
|
|||
import com.mattermost.helpers.PushNotificationDataHelper
|
||||
import com.mattermost.helpers.database_extension.getServerUrlForIdentifier
|
||||
import com.mattermost.rnutils.helpers.NotificationHelper
|
||||
import com.mattermost.turbolog.TurboLog
|
||||
import com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME
|
||||
import com.wix.reactnativenotifications.core.AppLaunchHelper
|
||||
import com.wix.reactnativenotifications.core.AppLifecycleFacade
|
||||
|
|
@ -84,7 +84,7 @@ class CustomPushNotification(
|
|||
}
|
||||
|
||||
if (!CustomPushNotificationHelper.verifySignature(mContext, signature, serverUrl, ackId)) {
|
||||
Log.i("Mattermost Notifications Signature verification", "Notification skipped because we could not verify it.")
|
||||
TurboLog.i("Mattermost Notifications Signature verification", "Notification skipped because we could not verify it.")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ class CustomPushNotification(
|
|||
when (type) {
|
||||
CustomPushNotificationHelper.PUSH_TYPE_MESSAGE, CustomPushNotificationHelper.PUSH_TYPE_SESSION -> {
|
||||
val currentActivityName = mAppLifecycleFacade.runningReactContext?.currentActivity?.componentName?.className ?: ""
|
||||
Log.i("ReactNative", currentActivityName)
|
||||
TurboLog.i("ReactNative", currentActivityName)
|
||||
if (!mAppLifecycleFacade.isAppVisible() || currentActivityName != "MainActivity") {
|
||||
var createSummary = type == CustomPushNotificationHelper.PUSH_TYPE_MESSAGE
|
||||
if (type == CustomPushNotificationHelper.PUSH_TYPE_MESSAGE) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.annotation.SuppressLint
|
|||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import com.facebook.react.PackageList
|
||||
import com.facebook.react.ReactHost
|
||||
import com.facebook.react.ReactInstanceManager
|
||||
|
|
@ -20,6 +19,8 @@ import com.facebook.react.modules.network.OkHttpClientProvider
|
|||
import com.facebook.soloader.SoLoader
|
||||
import com.mattermost.networkclient.RCTOkHttpClientFactory
|
||||
import com.mattermost.rnshare.helpers.RealPathUtil
|
||||
import com.mattermost.turbolog.TurboLog
|
||||
import com.mattermost.turbolog.ConfigureOptions
|
||||
import com.nozbe.watermelondb.jsi.JSIInstaller
|
||||
import com.reactnativenavigation.NavigationApplication
|
||||
import com.wix.reactnativenotifications.RNNotificationsPackage
|
||||
|
|
@ -63,7 +64,9 @@ class MainApplication : NavigationApplication(), INotificationsApplication {
|
|||
// Delete any previous temp files created by the app
|
||||
val tempFolder = File(applicationContext.cacheDir, RealPathUtil.CACHE_DIR_NAME)
|
||||
RealPathUtil.deleteTempFiles(tempFolder)
|
||||
Log.i("ReactNative", "Cleaning temp cache " + tempFolder.absolutePath)
|
||||
TurboLog.configure(options = ConfigureOptions(logsDirectory = applicationContext.cacheDir.absolutePath + "/logs", logPrefix = applicationContext.packageName))
|
||||
|
||||
TurboLog.i("ReactNative", "Cleaning temp cache " + tempFolder.absolutePath)
|
||||
|
||||
// Tells React Native to use our RCTOkHttpClientFactory which builds an OKHttpClient
|
||||
// with a cookie jar defined in APIClientModule and an interceptor to intercept all
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.app.IntentService;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mattermost.rnutils.helpers.NotificationHelper;
|
||||
import com.mattermost.turbolog.TurboLog;
|
||||
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
|
||||
|
||||
public class NotificationDismissService extends IntentService {
|
||||
|
|
@ -20,6 +20,6 @@ public class NotificationDismissService extends IntentService {
|
|||
final Bundle bundle = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
|
||||
|
||||
NotificationHelper.INSTANCE.dismissNotification(context, bundle);
|
||||
Log.i("ReactNative", "Dismiss notification");
|
||||
TurboLog.Companion.i("ReactNative", "Dismiss notification");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
|
@ -18,6 +17,7 @@ import com.facebook.react.bridge.Arguments;
|
|||
import com.facebook.react.bridge.WritableMap;
|
||||
|
||||
import com.mattermost.helpers.*;
|
||||
import com.mattermost.turbolog.TurboLog;
|
||||
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
|
||||
import com.wix.reactnativenotifications.core.notification.PushNotificationProps;
|
||||
|
||||
|
|
@ -82,22 +82,22 @@ public class NotificationReplyBroadcastReceiver extends BroadcastReceiver {
|
|||
public void resolve(@Nullable Object value) {
|
||||
if (value != null) {
|
||||
onReplySuccess(notificationId, message);
|
||||
Log.i("ReactNative", "Reply SUCCESS");
|
||||
TurboLog.Companion.i("ReactNative", "Reply SUCCESS");
|
||||
} else {
|
||||
Log.i("ReactNative", "Reply FAILED resolved without value");
|
||||
TurboLog.Companion.i("ReactNative", "Reply FAILED resolved without value");
|
||||
onReplyFailed(notificationId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reject(Throwable reason) {
|
||||
Log.i("ReactNative", String.format("Reply FAILED exception %s", reason.getMessage()));
|
||||
TurboLog.Companion.i("ReactNative", String.format("Reply FAILED exception %s", reason.getMessage()));
|
||||
onReplyFailed(notificationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reject(String code, String message) {
|
||||
Log.i("ReactNative",
|
||||
TurboLog.Companion.i("ReactNative",
|
||||
String.format("Reply FAILED status %s BODY %s", code, message)
|
||||
);
|
||||
onReplyFailed(notificationId);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.mattermost.rnbeta;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.System;
|
||||
import java.util.Objects;
|
||||
|
|
@ -12,6 +11,7 @@ import com.facebook.react.bridge.Arguments;
|
|||
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.mattermost.helpers.*;
|
||||
import com.mattermost.turbolog.TurboLog;
|
||||
|
||||
import okhttp3.Response;
|
||||
|
||||
|
|
@ -19,7 +19,7 @@ public class ReceiptDelivery {
|
|||
private static final String[] ackKeys = new String[]{"post_id", "root_id", "category", "message", "team_id", "channel_id", "channel_name", "type", "sender_id", "sender_name", "version"};
|
||||
|
||||
public static Bundle send(final String ackId, final String serverUrl, final String postId, final String type, final boolean isIdLoaded) {
|
||||
Log.i("ReactNative", String.format("Send receipt delivery ACK=%s TYPE=%s to URL=%s with ID-LOADED=%s", ackId, type, serverUrl, isIdLoaded));
|
||||
TurboLog.Companion.i("ReactNative", String.format("Send receipt delivery ACK=%s TYPE=%s to URL=%s with ID-LOADED=%s", ackId, type, serverUrl, isIdLoaded));
|
||||
WritableMap options = Arguments.createMap();
|
||||
WritableMap headers = Arguments.createMap();
|
||||
WritableMap body = Arguments.createMap();
|
||||
|
|
|
|||
7
package-lock.json
generated
7
package-lock.json
generated
|
|
@ -23,7 +23,7 @@
|
|||
"@mattermost/react-native-emm": "1.5.0",
|
||||
"@mattermost/react-native-network-client": "1.7.3",
|
||||
"@mattermost/react-native-paste-input": "0.8.0",
|
||||
"@mattermost/react-native-turbo-log": "0.4.0",
|
||||
"@mattermost/react-native-turbo-log": "github:mattermost/react-native-turbo-log#d8ddf5e7974546aff3e83b2c563907eb609ac5f4",
|
||||
"@mattermost/rnshare": "file:./libraries/@mattermost/rnshare",
|
||||
"@mattermost/rnutils": "file:./libraries/@mattermost/rnutils",
|
||||
"@msgpack/msgpack": "2.8.0",
|
||||
|
|
@ -5947,8 +5947,9 @@
|
|||
},
|
||||
"node_modules/@mattermost/react-native-turbo-log": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@mattermost/react-native-turbo-log/-/react-native-turbo-log-0.4.0.tgz",
|
||||
"integrity": "sha512-9W0t/FUTyA4mw+RJJ17TXuaPnz/FyBUSDn8poxkdrVjdpeWcIVQCbPOba3BcwDh3owx2JFbp+zGa5PmCHz6Veg==",
|
||||
"resolved": "git+ssh://git@github.com/mattermost/react-native-turbo-log.git#d8ddf5e7974546aff3e83b2c563907eb609ac5f4",
|
||||
"integrity": "sha512-ccUGRO2osFTp18ilnKagJa3wHBiaPQtGw2A5Z5+zBsLJTtbdkSQjanjgojgsllhLYj4NCi/VrVXTxks/eLusmw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
"@mattermost/react-native-emm": "1.5.0",
|
||||
"@mattermost/react-native-network-client": "1.7.3",
|
||||
"@mattermost/react-native-paste-input": "0.8.0",
|
||||
"@mattermost/react-native-turbo-log": "0.4.0",
|
||||
"@mattermost/react-native-turbo-log": "github:mattermost/react-native-turbo-log#d8ddf5e7974546aff3e83b2c563907eb609ac5f4",
|
||||
"@mattermost/rnshare": "file:./libraries/@mattermost/rnshare",
|
||||
"@mattermost/rnutils": "file:./libraries/@mattermost/rnutils",
|
||||
"@msgpack/msgpack": "2.8.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue