Skip to content

Commit dc72089

Browse files
cody-signalmtang-signal
authored andcommitted
Update target SDK to 34.
1 parent 6424c6b commit dc72089

10 files changed

Lines changed: 38 additions & 13 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@
8585
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
8686
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
8787

88+
<!-- For services -->
89+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_REMOTE_MESSAGING" />
90+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
91+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
92+
<!-- For vestigial telecom integration service -->
93+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_PHONE_CALL" />
94+
8895
<application android:name=".ApplicationContext"
8996
android:icon="@mipmap/ic_launcher"
9097
android:label="@string/app_name"
@@ -1102,17 +1109,19 @@
11021109
<service
11031110
android:enabled="true"
11041111
android:name=".service.webrtc.WebRtcCallService"
1105-
android:foregroundServiceType="camera|microphone"
1112+
android:foregroundServiceType="dataSync"
11061113
android:exported="false"/>
11071114

11081115
<service
11091116
android:enabled="true"
11101117
android:exported="false"
1111-
android:name=".service.KeyCachingService" />
1118+
android:name=".service.KeyCachingService"
1119+
android:foregroundServiceType="remoteMessaging"/>
11121120

11131121
<service
11141122
android:enabled="true"
11151123
android:name=".messages.IncomingMessageObserver$ForegroundService"
1124+
android:foregroundServiceType="remoteMessaging"
11161125
android:exported="false"/>
11171126

11181127
<service
@@ -1123,6 +1132,7 @@
11231132
<service
11241133
android:name=".service.webrtc.AndroidCallConnectionService"
11251134
android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
1135+
android:foregroundServiceType="phoneCall"
11261136
android:exported="true">
11271137
<intent-filter>
11281138
<action android:name="android.telecom.ConnectionService" />
@@ -1162,14 +1172,17 @@
11621172

11631173
<service
11641174
android:name=".service.GenericForegroundService"
1175+
android:foregroundServiceType="dataSync"
11651176
android:exported="false"/>
11661177

11671178
<service
11681179
android:name=".service.AttachmentProgressService"
1180+
android:foregroundServiceType="dataSync"
11691181
android:exported="false"/>
11701182

11711183
<service
11721184
android:name=".service.BackupProgressService"
1185+
android:foregroundServiceType="dataSync"
11731186
android:exported="false"/>
11741187

11751188
<service
@@ -1178,6 +1191,7 @@
11781191

11791192
<service
11801193
android:name=".gcm.FcmFetchForegroundService"
1194+
android:foregroundServiceType="remoteMessaging"
11811195
android:exported="false"/>
11821196

11831197
<service android:name=".gcm.FcmReceiveService" android:exported="true">
@@ -1365,7 +1379,7 @@
13651379
<service
13661380
android:name="org.thoughtcrime.securesms.service.webrtc.ActiveCallManager$ActiveCallForegroundService"
13671381
android:exported="false"
1368-
android:foregroundServiceType="camera|microphone" />
1382+
android:foregroundServiceType="dataSync" />
13691383

13701384
<receiver android:name="org.thoughtcrime.securesms.service.webrtc.ActiveCallManager$ActiveCallServiceReceiver" android:exported="false">
13711385
<intent-filter>

app/src/main/java/org/thoughtcrime/securesms/PassphraseRequiredActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import androidx.annotation.IdRes;
1010
import androidx.annotation.NonNull;
1111
import androidx.annotation.Nullable;
12+
import androidx.core.content.ContextCompat;
1213
import androidx.fragment.app.Fragment;
1314

1415
import org.greenrobot.eventbus.EventBus;
@@ -295,7 +296,7 @@ public void onReceive(Context context, Intent intent) {
295296
};
296297

297298
IntentFilter filter = new IntentFilter(KeyCachingService.CLEAR_KEY_EVENT);
298-
registerReceiver(clearKeyReceiver, filter, KeyCachingService.KEY_PERMISSION, null);
299+
ContextCompat.registerReceiver(this, clearKeyReceiver, filter, KeyCachingService.KEY_PERMISSION, null, ContextCompat.RECEIVER_NOT_EXPORTED);
299300
}
300301

301302
private void removeClearKeyReceiver(Context context) {

app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,12 +3389,12 @@ class ConversationFragment :
33893389
}
33903390
}
33913391

3392-
requireActivity().registerReceiver(pinnedShortcutReceiver, IntentFilter(ACTION_PINNED_SHORTCUT))
3392+
ContextCompat.registerReceiver(requireActivity(), pinnedShortcutReceiver, IntentFilter(ACTION_PINNED_SHORTCUT), ContextCompat.RECEIVER_EXPORTED)
33933393
}
33943394

33953395
viewModel.getContactPhotoIcon(requireContext(), Glide.with(this@ConversationFragment))
33963396
.subscribe { infoCompat ->
3397-
val intent = Intent(ACTION_PINNED_SHORTCUT)
3397+
val intent = Intent(ACTION_PINNED_SHORTCUT).apply { `package` = requireContext().packageName }
33983398
val callback = PendingIntent.getBroadcast(requireContext(), 902, intent, PendingIntentFlags.mutable())
33993399
ShortcutManagerCompat.requestPinShortcut(requireContext(), infoCompat, callback.intentSender)
34003400
}

app/src/main/java/org/thoughtcrime/securesms/registration/SmsRetrieverReceiver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.os.Bundle;
99

1010
import androidx.annotation.NonNull;
11+
import androidx.core.content.ContextCompat;
1112

1213
import com.google.android.gms.auth.api.phone.SmsRetriever;
1314
import com.google.android.gms.common.api.CommonStatusCodes;
@@ -34,7 +35,7 @@ public SmsRetrieverReceiver(@NonNull Application context) {
3435

3536
public void registerReceiver() {
3637
Log.d(TAG, "Registering SMS retriever receiver");
37-
context.registerReceiver(this, new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION));
38+
ContextCompat.registerReceiver(context, this, new IntentFilter(SmsRetriever.SMS_RETRIEVED_ACTION), ContextCompat.RECEIVER_EXPORTED);
3839
}
3940

4041
public void unregisterReceiver() {

app/src/main/java/org/thoughtcrime/securesms/service/webrtc/ActiveCallManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class ActiveCallManager(
274274

275275
@get:RequiresApi(30)
276276
override val serviceType: Int
277-
get() = ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
277+
get() = ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC
278278

279279
private var hangUpRtcOnDeviceCallAnswered: PhoneStateListener? = null
280280
private var notification: Notification? = null

app/src/main/java/org/thoughtcrime/securesms/service/webrtc/WebRtcCallService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private synchronized void startForegroundCompat(int notificationId, Notification
315315
}
316316

317317
if (Build.VERSION.SDK_INT >= 30) {
318-
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA | ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE);
318+
startForeground(notificationId, notification, ServiceInfo.FOREGROUND_SERVICE_TYPE_DATA_SYNC);
319319
} else {
320320
startForeground(notificationId, notification);
321321
}

app/src/main/java/org/thoughtcrime/securesms/util/AlarmSleepTimer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.os.SystemClock;
1111

1212
import androidx.core.app.AlarmManagerCompat;
13+
import androidx.core.content.ContextCompat;
1314

1415
import org.signal.core.util.PendingIntentFlags;
1516
import org.signal.core.util.logging.Log;
@@ -42,7 +43,7 @@ public void sleep(long sleepDuration) {
4243

4344
try {
4445
String actionName = buildActionName(actionId);
45-
context.registerReceiver(alarmReceiver, new IntentFilter(actionName));
46+
ContextCompat.registerReceiver(context, alarmReceiver, new IntentFilter(actionName), ContextCompat.RECEIVER_NOT_EXPORTED);
4647

4748
long startTime = System.currentTimeMillis();
4849
alarmReceiver.setAlarm(sleepDuration, actionName);
@@ -72,7 +73,9 @@ private class AlarmReceiver extends BroadcastReceiver {
7273
private static final String WAKE_UP_THREAD_ACTION = "org.thoughtcrime.securesms.util.AlarmSleepTimer.AlarmReceiver.WAKE_UP_THREAD";
7374

7475
private void setAlarm(long millis, String action) {
75-
final Intent intent = new Intent(action);
76+
final Intent intent = new Intent(action);
77+
intent.setPackage(context.getPackageName());
78+
7679
final PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntentFlags.mutable());
7780
final AlarmManager alarmManager = ServiceUtil.getAlarmManager(context);
7881

constants.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
val signalBuildToolsVersion by extra("34.0.0")
22
val signalCompileSdkVersion by extra("android-34")
3-
val signalTargetSdkVersion by extra(33)
3+
val signalTargetSdkVersion by extra(34)
44
val signalMinSdkVersion by extra(21)
55
val signalJavaVersion by extra(JavaVersion.VERSION_17)
66
val signalKotlinJvmTarget by extra("17")

core-util/src/main/java/org/signal/core/util/PendingIntentFlags.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ object PendingIntentFlags {
2323
return mutable() or PendingIntent.FLAG_CANCEL_CURRENT
2424
}
2525

26+
/**
27+
* Flag indicating that this [PendingIntent] can be used only once. After [PendingIntent.send] is called on it,
28+
* it will be automatically canceled for you and any future attempt to send through it will fail.
29+
*/
2630
@JvmStatic
2731
fun oneShot(): Int {
28-
return mutable() or PendingIntent.FLAG_ONE_SHOT
32+
return immutable() or PendingIntent.FLAG_ONE_SHOT
2933
}
3034

3135
/**

device-transfer/lib/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
<uses-permission android:name="android.permission.INTERNET" />
1010
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
1111
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
1213

1314
<application>
1415
<service
1516
android:name=".DeviceToDeviceTransferService"
1617
android:enabled="true"
18+
android:foregroundServiceType="connectedDevice"
1719
android:exported="false" />
1820
</application>
1921

0 commit comments

Comments
 (0)