Update target SDK to 34.

This commit is contained in:
Cody Henthorne 2024-07-30 14:08:23 -04:00 committed by mtang-signal
parent 6424c6bc99
commit dc7208922c
10 changed files with 38 additions and 13 deletions

View file

@ -85,6 +85,13 @@
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
<!-- For services -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<!-- For vestigial telecom integration service -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
<application android:name=".ApplicationContext"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@ -1102,17 +1109,19 @@
<service
android:enabled="true"
android:name=".service.webrtc.WebRtcCallService"
android:foregroundServiceType="camera|microphone"
android:foregroundServiceType="dataSync"
android:exported="false"/>
<service
android:enabled="true"
android:exported="false"
android:name=".service.KeyCachingService" />
android:name=".service.KeyCachingService"
android:foregroundServiceType="remoteMessaging"/>
<service
android:enabled="true"
android:name=".messages.IncomingMessageObserver$ForegroundService"
android:foregroundServiceType="remoteMessaging"
android:exported="false"/>
<service
@ -1123,6 +1132,7 @@
<service
android:name=".service.webrtc.AndroidCallConnectionService"
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
android:foregroundServiceType="phoneCall"
android:exported="true">
<intent-filter>
<action android:name="android.telecom.ConnectionService" />
@ -1162,14 +1172,17 @@
<service
android:name=".service.GenericForegroundService"
android:foregroundServiceType="dataSync"
android:exported="false"/>
<service
android:name=".service.AttachmentProgressService"
android:foregroundServiceType="dataSync"
android:exported="false"/>
<service
android:name=".service.BackupProgressService"
android:foregroundServiceType="dataSync"
android:exported="false"/>
<service
@ -1178,6 +1191,7 @@
<service
android:name=".gcm.FcmFetchForegroundService"
android:foregroundServiceType="remoteMessaging"
android:exported="false"/>
<service android:name=".gcm.FcmReceiveService" android:exported="true">
@ -1365,7 +1379,7 @@
<service
android:name="org.thoughtcrime.securesms.service.webrtc.ActiveCallManager$ActiveCallForegroundService"
android:exported="false"
android:foregroundServiceType="camera|microphone" />
android:foregroundServiceType="dataSync" />
<receiver android:name="org.thoughtcrime.securesms.service.webrtc.ActiveCallManager$ActiveCallServiceReceiver" android:exported="false">
<intent-filter>

View file

@ -9,6 +9,7 @@ import android.os.Bundle;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import org.greenrobot.eventbus.EventBus;
@ -295,7 +296,7 @@ public abstract class PassphraseRequiredActivity extends BaseActivity implements
};
IntentFilter filter = new IntentFilter(KeyCachingService.CLEAR_KEY_EVENT);
registerReceiver(clearKeyReceiver, filter, KeyCachingService.KEY_PERMISSION, null);
ContextCompat.registerReceiver(this, clearKeyReceiver, filter, KeyCachingService.KEY_PERMISSION, null, ContextCompat.RECEIVER_NOT_EXPORTED);
}
private void removeClearKeyReceiver(Context context) {

View file

@ -3389,12 +3389,12 @@ class ConversationFragment :
}
}
requireActivity().registerReceiver(pinnedShortcutReceiver, IntentFilter(ACTION_PINNED_SHORTCUT))
ContextCompat.registerReceiver(requireActivity(), pinnedShortcutReceiver, IntentFilter(ACTION_PINNED_SHORTCUT), ContextCompat.RECEIVER_EXPORTED)
}
viewModel.getContactPhotoIcon(requireContext(), Glide.with(this@ConversationFragment))
.subscribe { infoCompat ->
val intent = Intent(ACTION_PINNED_SHORTCUT)
val intent = Intent(ACTION_PINNED_SHORTCUT).apply { `package` = requireContext().packageName }
val callback = PendingIntent.getBroadcast(requireContext(), 902, intent, PendingIntentFlags.mutable())
ShortcutManagerCompat.requestPinShortcut(requireContext(), infoCompat, callback.intentSender)
}

View file

@ -8,6 +8,7 @@ import android.content.IntentFilter;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import com.google.android.gms.auth.api.phone.SmsRetriever;
import com.google.android.gms.common.api.CommonStatusCodes;
@ -34,7 +35,7 @@ public class SmsRetrieverReceiver extends BroadcastReceiver {
public void registerReceiver() {
Log.d(TAG, "Registering SMS retriever receiver");
context.registerReceiver(this, new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION));
ContextCompat.registerReceiver(context, this, new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION), ContextCompat.RECEIVER_EXPORTED);
}
public void unregisterReceiver() {

View file

@ -274,7 +274,7 @@ class ActiveCallManager(
@get:RequiresApi(30)
override val serviceType: Int
get() = ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
get() = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
private var hangUpRtcOnDeviceCallAnswered: PhoneStateListener? = null
private var notification: Notification? = null

View file

@ -315,7 +315,7 @@ public final class WebRtcCallService extends Service implements SignalAudioManag
}
if (Build.VERSION.SDK_INT >= 30) {
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE);
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
} else {
startForeground(notificationId, notification);
}

View file

@ -10,6 +10,7 @@ import android.os.Build;
import android.os.SystemClock;
import androidx.core.app.AlarmManagerCompat;
import androidx.core.content.ContextCompat;
import org.signal.core.util.PendingIntentFlags;
import org.signal.core.util.logging.Log;
@ -42,7 +43,7 @@ public class AlarmSleepTimer implements SleepTimer {
try {
String actionName = buildActionName(actionId);
context.registerReceiver(alarmReceiver, new IntentFilter(actionName));
ContextCompat.registerReceiver(context, alarmReceiver, new IntentFilter(actionName), ContextCompat.RECEIVER_NOT_EXPORTED);
long startTime = System.currentTimeMillis();
alarmReceiver.setAlarm(sleepDuration, actionName);
@ -72,7 +73,9 @@ public class AlarmSleepTimer implements SleepTimer {
private static final String WAKE_UP_THREAD_ACTION = "org.thoughtcrime.securesms.util.AlarmSleepTimer.AlarmReceiver.WAKE_UP_THREAD";
private void setAlarm(long millis, String action) {
final Intent intent = new Intent(action);
final Intent intent = new Intent(action);
intent.setPackage(context.getPackageName());
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntentFlags.mutable());
final AlarmManager alarmManager = ServiceUtil.getAlarmManager(context);

View file

@ -1,6 +1,6 @@
val signalBuildToolsVersion by extra("34.0.0")
val signalCompileSdkVersion by extra("android-34")
val signalTargetSdkVersion by extra(33)
val signalTargetSdkVersion by extra(34)
val signalMinSdkVersion by extra(21)
val signalJavaVersion by extra(JavaVersion.VERSION_17)
val signalKotlinJvmTarget by extra("17")

View file

@ -23,9 +23,13 @@ object PendingIntentFlags {
return mutable() or PendingIntent.FLAG_CANCEL_CURRENT
}
/**
* Flag indicating that this [PendingIntent] can be used only once. After [PendingIntent.send] is called on it,
* it will be automatically canceled for you and any future attempt to send through it will fail.
*/
@JvmStatic
fun oneShot(): Int {
return mutable() or PendingIntent.FLAG_ONE_SHOT
return immutable() or PendingIntent.FLAG_ONE_SHOT
}
/**

View file

@ -9,11 +9,13 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
<application>
<service
android:name=".DeviceToDeviceTransferService"
android:enabled="true"
android:foregroundServiceType="connectedDevice"
android:exported="false" />
</application>