Skip to content

Commit

Permalink
feat(react-native-sdk/android): added extra logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinteodor committed Dec 23, 2024
1 parent 315ec10 commit 627dcbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jitsi.meet.sdk.log.JitsiMeetLogger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;

Expand Down Expand Up @@ -113,13 +114,14 @@ public boolean onRequestPermissionsResult(int i, String[] strings, int[] results
if (permissionsArray.length > 0) {
try {
currentActivity.requestPermissions(permissionsArray, PERMISSIONS_REQUEST_CODE);
JitsiMeetLogger.w(TAG + " Requesting permissions: " + Arrays.toString(permissionsArray));
} catch (Exception e) {
JitsiMeetLogger.e(e, "Error requesting permissions");
listener.onRequestPermissionsResult(PERMISSIONS_REQUEST_CODE, permissionsArray, new int[0]);
}
} else {
doLaunch(context, currentActivity);
JitsiMeetLogger.w(TAG + " Service launched");
JitsiMeetLogger.w(TAG + " No permissions needed, launching service");
}
}

Expand All @@ -131,11 +133,15 @@ public static void abort(Context context) {
@Override
public void onCreate() {
super.onCreate();
JitsiMeetLogger.w(TAG + " Building ongoing conference notification");

Notification notification = RNOngoingNotification.buildOngoingConferenceNotification(this);
if (notification == null) {
stopSelf();
JitsiMeetLogger.w(TAG + " Couldn't start service, notification is null");
} else {
JitsiMeetLogger.w(TAG + " Starting service in foreground with notification");

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE);
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.Q) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class RNOngoingNotification {
private static final String TAG = RNOngoingNotification.class.getSimpleName();

static void createOngoingConferenceNotificationChannel(Activity currentActivity) {
JitsiMeetLogger.w(TAG + " Checking Android version and activity context");

if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
JitsiMeetLogger.w(TAG + " Android version is lower than Oreo, skipping notification channel creation");
return;
}
if (currentActivity == null) {
Expand All @@ -50,7 +53,7 @@ static void createOngoingConferenceNotificationChannel(Activity currentActivity)
= notificationManager.getNotificationChannel("OngoingConferenceChannel");

if (channel != null) {
// The channel was already created, no need to do it again.
JitsiMeetLogger.w(TAG + " Notification channel already exists");
return;
}

Expand All @@ -60,13 +63,16 @@ static void createOngoingConferenceNotificationChannel(Activity currentActivity)
channel.setShowBadge(false);

notificationManager.createNotificationChannel(channel);
JitsiMeetLogger.w(TAG + " Notification channel created successfully");
}
static Notification buildOngoingConferenceNotification(Context context) {
if (context == null) {
JitsiMeetLogger.w(TAG + " Cannot create notification: no current context");
return null;
}

JitsiMeetLogger.w(TAG + " Creating notification with context: " + context);

NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "OngoingConferenceChannel");

builder
Expand Down

0 comments on commit 627dcbf

Please sign in to comment.