Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/service clean up #1591

Merged
merged 7 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
<activity
android:name="org.thoughtcrime.securesms.home.HomeActivity"
android:screenOrientation="portrait"
android:launchMode="standard"
android:launchMode="singleTask"
android:theme="@style/Theme.Session.DayNight.NoActionBar" />
<activity
android:name="org.thoughtcrime.securesms.messagerequests.MessageRequestsActivity"
Expand Down Expand Up @@ -328,7 +328,6 @@
<action android:name="android.service.chooser.ChooserTargetService" />
</intent-filter>
</service>
<service android:name="org.thoughtcrime.securesms.service.GenericForegroundService" />
<receiver
android:name="org.thoughtcrime.securesms.notifications.MarkReadReceiver"
android:enabled="true"
Expand Down Expand Up @@ -440,9 +439,7 @@
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<service
android:name="org.thoughtcrime.securesms.jobmanager.KeepAliveService"
android:enabled="@bool/enable_alarm_manager" />

<uses-library
android:name="com.sec.android.app.multiwindow"
android:required="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ class HomeActivity : PassphraseRequiredActionBarActivity(),
override fun onCreate(savedInstanceState: Bundle?, isReady: Boolean) {
super.onCreate(savedInstanceState, isReady)

if (!isTaskRoot) { finish(); return }

// Set content view
binding = ActivityHomeBinding.inflate(layoutInflater)
setContentView(binding.root)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import androidx.core.app.ServiceCompat;

import org.session.libsession.utilities.ServiceUtil;
import org.session.libsession.utilities.TextSecurePreferences;
Expand Down Expand Up @@ -122,7 +123,7 @@ public void setMasterSecret(final Object masterSecret) {
KeyCachingService.masterSecret = masterSecret;

foregroundService();

new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
Expand Down Expand Up @@ -252,11 +253,18 @@ private void foregroundService() {
builder.setContentIntent(buildLaunchIntent());

stopForeground(true);

int type = 0;
if (Build.VERSION.SDK_INT >= 34) {
startForeground(SERVICE_RUNNING_ID, builder.build(), ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE);
} else {
startForeground(SERVICE_RUNNING_ID, builder.build());
type = ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE;
}

ServiceCompat.startForeground(
this,
SERVICE_RUNNING_ID,
builder.build(),
type
);
}

private PendingIntent buildLockIntent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import android.content.Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.IntentFilter
import android.content.pm.PackageManager
import android.content.pm.ServiceInfo
import android.media.AudioManager
import android.os.Build
import android.os.ResultReceiver
import android.telephony.TelephonyManager
import androidx.core.app.ServiceCompat
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.lifecycle.LifecycleService
Expand Down Expand Up @@ -723,9 +726,11 @@ class WebRtcCallService : LifecycleService(), CallManager.WebRtcListener {

private fun setCallInProgressNotification(type: Int, recipient: Recipient?) {
try {
startForeground(
ServiceCompat.startForeground(
this,
CallNotificationBuilder.WEBRTC_NOTIFICATION,
CallNotificationBuilder.getCallInProgressNotification(this, type, recipient)
CallNotificationBuilder.getCallInProgressNotification(this, type, recipient),
if (Build.VERSION.SDK_INT >= 30) ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE else 0
)
} catch (e: IllegalStateException) {
Log.e(TAG, "Failed to setCallInProgressNotification as a foreground service for type: ${type}, trying to update instead", e)
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-v26/values.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_alarm_manager">false</bool>
<bool name="enable_job_service">true</bool>
</resources>
1 change: 0 additions & 1 deletion app/src/main/res/values/values.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_alarm_manager">true</bool>
<bool name="enable_job_service">false</bool>
<attr name="searchBackgroundColor" format="color"/>
<attr name="searchIconColor" format="color|reference"/>
Expand Down
1 change: 0 additions & 1 deletion libsession/src/main/res/values/values.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_alarm_manager">true</bool>
<bool name="enable_job_service">false</bool>
<bool name="screen_security_default">true</bool>
</resources>