feat(android): fixed screen sharing for Android 33 (#14359)

* feat(android): fixed screen sharing for Android 33
pull/14364/head jitsi-meet_9279
Calinteodor 1 year ago committed by GitHub
parent 895afbab65
commit a98eef7eb3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      android/build.gradle
  2. 27
      android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetMediaProjectionService.java
  3. 12
      android/sdk/src/main/java/org/jitsi/meet/sdk/JitsiMeetOngoingConferenceService.java
  4. 1
      android/sdk/src/main/java/org/jitsi/meet/sdk/OngoingNotification.java
  5. 8
      react/features/base/tracks/actions.native.ts

@ -19,9 +19,9 @@ buildscript {
ext {
kotlinVersion = "1.7.0"
buildToolsVersion = "33.0.2"
compileSdkVersion = 34
compileSdkVersion = 33
minSdkVersion = 24
targetSdkVersion = 34
targetSdkVersion = 33
supportLibVersion = "28.0.0"
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.

@ -28,6 +28,8 @@ import android.os.IBinder;
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
import java.util.Random;
/**
* This class implements an Android {@link Service}, a foreground one specifically, and it's
@ -39,6 +41,8 @@ import org.jitsi.meet.sdk.log.JitsiMeetLogger;
public class JitsiMeetMediaProjectionService extends Service {
private static final String TAG = JitsiMeetMediaProjectionService.class.getSimpleName();
static final int NOTIFICATION_ID = new Random().nextInt(99999) + 10000;
public static void launch(Context context) {
OngoingNotification.createOngoingConferenceNotificationChannel();
@ -70,30 +74,27 @@ public class JitsiMeetMediaProjectionService extends Service {
}
@Override
public void onCreate() {
super.onCreate();
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Notification notification = OngoingNotification.buildOngoingConferenceNotification(null);
if (notification == null) {
stopSelf();
JitsiMeetLogger.w(TAG + " Couldn't start service, notification is null");
return START_NOT_STICKY;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(OngoingNotification.NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION);
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION);
} else {
startForeground(OngoingNotification.NOTIFICATION_ID, notification);
startForeground(NOTIFICATION_ID, notification);
}
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
return START_NOT_STICKY;
}

@ -33,6 +33,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import org.jitsi.meet.sdk.log.JitsiMeetLogger;
import java.util.HashMap;
import java.util.Random;
/**
* This class implements an Android {@link Service}, a foreground one specifically, and it's
@ -52,6 +53,9 @@ public class JitsiMeetOngoingConferenceService extends Service
private boolean isAudioMuted;
static final int NOTIFICATION_ID = new Random().nextInt(99999) + 10000;
public static void launch(Context context, HashMap<String, Object> extraData) {
OngoingNotification.createOngoingConferenceNotificationChannel();
@ -96,9 +100,9 @@ public class JitsiMeetOngoingConferenceService extends Service
JitsiMeetLogger.w(TAG + " Couldn't start service, notification is null");
} else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
startForeground(OngoingNotification.NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
startForeground(NOTIFICATION_ID, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK);
} else {
startForeground(OngoingNotification.NOTIFICATION_ID, notification);
startForeground(NOTIFICATION_ID, notification);
}
}
@ -136,7 +140,7 @@ public class JitsiMeetOngoingConferenceService extends Service
JitsiMeetLogger.w(TAG + " Couldn't start service, notification is null");
} else {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(OngoingNotification.NOTIFICATION_ID, notification);
notificationManager.notify(NOTIFICATION_ID, notification);
}
}
@ -222,7 +226,7 @@ public class JitsiMeetOngoingConferenceService extends Service
JitsiMeetLogger.w(TAG + " Couldn't update service, notification is null");
} else {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(OngoingNotification.NOTIFICATION_ID, notification);
notificationManager.notify(NOTIFICATION_ID, notification);
JitsiMeetLogger.i(TAG + " audio muted changed");
}

@ -41,7 +41,6 @@ import java.util.Random;
class OngoingNotification {
private static final String TAG = OngoingNotification.class.getSimpleName();
static final int NOTIFICATION_ID = new Random().nextInt(99999) + 10000;
private static long startingTime = 0;
static void createOngoingConferenceNotificationChannel() {

@ -33,12 +33,12 @@ export function toggleScreensharing(enabled: boolean, _ignore1?: boolean, _ignor
if (enabled) {
const isSharing = isLocalVideoTrackDesktop(state);
if (!isSharing) {
_startScreenSharing(dispatch, state);
if (isSharing) {
Platform.OS === 'android' && JitsiMeetMediaProjectionModule.abort();
} else {
Platform.OS === 'android' && JitsiMeetMediaProjectionModule.launch();
_startScreenSharing(dispatch, state);
}
Platform.OS === 'android' && JitsiMeetMediaProjectionModule.abort();
} else {
dispatch(setScreenshareMuted(true));
dispatch(setVideoMuted(false, VIDEO_MUTISM_AUTHORITY.SCREEN_SHARE));

Loading…
Cancel
Save