bump targetSdk to 32

This commit is contained in:
Daniel Gultsch 2022-07-10 12:34:02 +02:00
parent d41020ccf3
commit 50ba165746
6 changed files with 142 additions and 62 deletions

View file

@ -86,11 +86,11 @@ ext {
android { android {
namespace 'eu.siacs.conversations' namespace 'eu.siacs.conversations'
compileSdkVersion 31 compileSdkVersion 32
defaultConfig { defaultConfig {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 32
versionCode 42034 versionCode 42034
versionName "2.10.8" versionName "2.10.8"
archivesBaseName += "-$versionName" archivesBaseName += "-$versionName"

View file

@ -26,7 +26,8 @@
<activity <activity
android:name=".ui.ImportBackupActivity" android:name=".ui.ImportBackupActivity"
android:label="@string/restore_backup" android:label="@string/restore_backup"
android:launchMode="singleTask"> android:launchMode="singleTask"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />

View file

@ -83,7 +83,9 @@
<service android:name=".services.XmppConnectionService" /> <service android:name=".services.XmppConnectionService" />
<receiver android:name=".services.EventReceiver"> <receiver
android:name=".services.EventReceiver"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" /> <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
@ -107,6 +109,7 @@
android:label="@string/title_activity_show_location" /> android:label="@string/title_activity_show_location" />
<activity <activity
android:name=".ui.ConversationActivity" android:name=".ui.ConversationActivity"
android:exported="true"
android:theme="@style/SplashTheme"> android:theme="@style/SplashTheme">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -127,6 +130,7 @@
android:windowSoftInputMode="stateAlwaysHidden" /> android:windowSoftInputMode="stateAlwaysHidden" />
<activity <activity
android:name=".ui.UriHandlerActivity" android:name=".ui.UriHandlerActivity"
android:exported="true"
android:label="@string/app_name"> android:label="@string/app_name">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
@ -166,6 +170,7 @@
</activity> </activity>
<activity <activity
android:name=".ui.StartConversationActivity" android:name=".ui.StartConversationActivity"
android:exported="true"
android:label="@string/title_activity_start_conversation" android:label="@string/title_activity_start_conversation"
android:launchMode="singleTop"> android:launchMode="singleTop">
<intent-filter> <intent-filter>
@ -174,6 +179,7 @@
</activity> </activity>
<activity <activity
android:name=".ui.SettingsActivity" android:name=".ui.SettingsActivity"
android:exported="true"
android:label="@string/title_activity_settings"> android:label="@string/title_activity_settings">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@ -192,6 +198,7 @@
<activity <activity
android:name=".ui.ChooseAccountForProfilePictureActivity" android:name=".ui.ChooseAccountForProfilePictureActivity"
android:enabled="false" android:enabled="false"
android:exported="true"
android:label="@string/choose_account"> android:label="@string/choose_account">
<intent-filter android:label="@string/set_profile_picture"> <intent-filter android:label="@string/set_profile_picture">
<action android:name="android.intent.action.ATTACH_DATA" /> <action android:name="android.intent.action.ATTACH_DATA" />
@ -225,6 +232,7 @@
android:label="@string/group_chat_avatar" /> android:label="@string/group_chat_avatar" />
<activity <activity
android:name=".ui.ShareWithActivity" android:name=".ui.ShareWithActivity"
android:exported="true"
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTop"> android:launchMode="singleTop">
@ -261,10 +269,6 @@
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value="eu.siacs.conversations.ui.SettingsActivity" /> android:value="eu.siacs.conversations.ui.SettingsActivity" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.PREFERENCE" />
</intent-filter>
</activity> </activity>
<activity <activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity" android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
@ -279,6 +283,7 @@
<service android:name=".services.ImportBackupService" /> <service android:name=".services.ImportBackupService" />
<service <service
android:name=".services.ContactChooserTargetService" android:name=".services.ContactChooserTargetService"
android:exported="true"
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE"> android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
<intent-filter> <intent-filter>
<action android:name="android.service.chooser.ChooserTargetService" /> <action android:name="android.service.chooser.ChooserTargetService" />
@ -302,6 +307,7 @@
<activity <activity
android:name=".ui.ShortcutActivity" android:name=".ui.ShortcutActivity"
android:exported="true"
android:label="@string/contact"> android:label="@string/contact">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.CREATE_SHORTCUT" /> <action android:name="android.intent.action.CREATE_SHORTCUT" />

View file

@ -1,5 +1,7 @@
package eu.siacs.conversations.services; package eu.siacs.conversations.services;
import static eu.siacs.conversations.utils.Compatibility.s;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationChannelGroup; import android.app.NotificationChannelGroup;
@ -625,7 +627,9 @@ public class NotificationService {
mXmppConnectionService, mXmppConnectionService,
requestCode, requestCode,
fullScreenIntent, fullScreenIntent,
PendingIntent.FLAG_UPDATE_CURRENT); s()
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
public void cancelIncomingCallNotification() { public void cancelIncomingCallNotification() {
@ -759,7 +763,7 @@ public class NotificationService {
&& conversations != null && conversations != null
&& conversations.size() && conversations.size()
== 1; // if this check is changed to > 0 catchup messages will == 1; // if this check is changed to > 0 catchup messages will
// create one notification per conversation // create one notification per conversation
if (notifications.size() == 0) { if (notifications.size() == 0) {
cancel(NOTIFICATION_ID); cancel(NOTIFICATION_ID);
@ -835,9 +839,7 @@ public class NotificationService {
} else { } else {
mBuilder.setLocalOnly(true); mBuilder.setLocalOnly(true);
} }
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
mBuilder.setCategory(Notification.CATEGORY_MESSAGE);
}
mBuilder.setPriority( mBuilder.setPriority(
notify notify
? (headsup ? (headsup
@ -1280,7 +1282,9 @@ public class NotificationService {
mXmppConnectionService, mXmppConnectionService,
generateRequestCode(message.getConversation(), 18), generateRequestCode(message.getConversation(), 18),
intent, intent,
PendingIntent.FLAG_UPDATE_CURRENT); s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
} }
return null; return null;
@ -1299,13 +1303,17 @@ public class NotificationService {
mXmppConnectionService, mXmppConnectionService,
generateRequestCode(conversationUuid, 8), generateRequestCode(conversationUuid, 8),
viewConversationIntent, viewConversationIntent,
PendingIntent.FLAG_UPDATE_CURRENT); s()
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} else { } else {
return PendingIntent.getActivity( return PendingIntent.getActivity(
mXmppConnectionService, mXmppConnectionService,
generateRequestCode(conversationUuid, 10), generateRequestCode(conversationUuid, 10),
viewConversationIntent, viewConversationIntent,
PendingIntent.FLAG_UPDATE_CURRENT); s()
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
} }
@ -1332,9 +1340,20 @@ public class NotificationService {
if (conversation != null) { if (conversation != null) {
intent.putExtra("uuid", conversation.getUuid()); intent.putExtra("uuid", conversation.getUuid());
return PendingIntent.getService( return PendingIntent.getService(
mXmppConnectionService, generateRequestCode(conversation, 20), intent, 0); mXmppConnectionService,
generateRequestCode(conversation, 20),
intent,
s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
return PendingIntent.getService(mXmppConnectionService, 0, intent, 0); return PendingIntent.getService(
mXmppConnectionService,
0,
intent,
s()
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private PendingIntent createReplyIntent( private PendingIntent createReplyIntent(
@ -1348,7 +1367,12 @@ public class NotificationService {
intent.putExtra("last_message_uuid", lastMessageUuid); intent.putExtra("last_message_uuid", lastMessageUuid);
final int id = generateRequestCode(conversation, dismissAfterReply ? 12 : 14); final int id = generateRequestCode(conversation, dismissAfterReply ? 12 : 14);
return PendingIntent.getService( return PendingIntent.getService(
mXmppConnectionService, id, intent, PendingIntent.FLAG_UPDATE_CURRENT); mXmppConnectionService,
id,
intent,
s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private PendingIntent createReadPendingIntent(Conversation conversation) { private PendingIntent createReadPendingIntent(Conversation conversation) {
@ -1360,7 +1384,9 @@ public class NotificationService {
mXmppConnectionService, mXmppConnectionService,
generateRequestCode(conversation, 16), generateRequestCode(conversation, 16),
intent, intent,
PendingIntent.FLAG_UPDATE_CURRENT); s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private PendingIntent createCallAction(String sessionId, final String action, int requestCode) { private PendingIntent createCallAction(String sessionId, final String action, int requestCode) {
@ -1369,7 +1395,12 @@ public class NotificationService {
intent.setPackage(mXmppConnectionService.getPackageName()); intent.setPackage(mXmppConnectionService.getPackageName());
intent.putExtra(RtpSessionActivity.EXTRA_SESSION_ID, sessionId); intent.putExtra(RtpSessionActivity.EXTRA_SESSION_ID, sessionId);
return PendingIntent.getService( return PendingIntent.getService(
mXmppConnectionService, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT); mXmppConnectionService,
requestCode,
intent,
s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private PendingIntent createSnoozeIntent(Conversation conversation) { private PendingIntent createSnoozeIntent(Conversation conversation) {
@ -1381,19 +1412,33 @@ public class NotificationService {
mXmppConnectionService, mXmppConnectionService,
generateRequestCode(conversation, 22), generateRequestCode(conversation, 22),
intent, intent,
PendingIntent.FLAG_UPDATE_CURRENT); s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private PendingIntent createTryAgainIntent() { private PendingIntent createTryAgainIntent() {
final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class); final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class);
intent.setAction(XmppConnectionService.ACTION_TRY_AGAIN); intent.setAction(XmppConnectionService.ACTION_TRY_AGAIN);
return PendingIntent.getService(mXmppConnectionService, 45, intent, 0); return PendingIntent.getService(
mXmppConnectionService,
45,
intent,
s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private PendingIntent createDismissErrorIntent() { private PendingIntent createDismissErrorIntent() {
final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class); final Intent intent = new Intent(mXmppConnectionService, XmppConnectionService.class);
intent.setAction(XmppConnectionService.ACTION_DISMISS_ERROR_NOTIFICATIONS); intent.setAction(XmppConnectionService.ACTION_DISMISS_ERROR_NOTIFICATIONS);
return PendingIntent.getService(mXmppConnectionService, 69, intent, 0); return PendingIntent.getService(
mXmppConnectionService,
69,
intent,
s()
? PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT);
} }
private boolean wasHighlightedOrPrivate(final Message message) { private boolean wasHighlightedOrPrivate(final Message message) {
@ -1538,15 +1583,9 @@ public class NotificationService {
} }
} }
mBuilder.setDeleteIntent(createDismissErrorIntent()); mBuilder.setDeleteIntent(createDismissErrorIntent());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mBuilder.setVisibility(Notification.VISIBILITY_PRIVATE);
mBuilder.setVisibility(Notification.VISIBILITY_PRIVATE); mBuilder.setSmallIcon(R.drawable.ic_warning_white_24dp);
mBuilder.setSmallIcon(R.drawable.ic_warning_white_24dp); mBuilder.setLocalOnly(true);
} else {
mBuilder.setSmallIcon(R.drawable.ic_stat_alert_warning);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
mBuilder.setLocalOnly(true);
}
mBuilder.setPriority(Notification.PRIORITY_LOW); mBuilder.setPriority(Notification.PRIORITY_LOW);
final Intent intent; final Intent intent;
if (AccountUtils.MANAGE_ACCOUNT_ACTIVITY != null) { if (AccountUtils.MANAGE_ACCOUNT_ACTIVITY != null) {
@ -1558,7 +1597,12 @@ public class NotificationService {
} }
mBuilder.setContentIntent( mBuilder.setContentIntent(
PendingIntent.getActivity( PendingIntent.getActivity(
mXmppConnectionService, 145, intent, PendingIntent.FLAG_UPDATE_CURRENT)); mXmppConnectionService,
145,
intent,
s()
? PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
: PendingIntent.FLAG_UPDATE_CURRENT));
if (Compatibility.runsTwentySix()) { if (Compatibility.runsTwentySix()) {
mBuilder.setChannelId("error"); mBuilder.setChannelId("error");
} }

View file

@ -36,6 +36,7 @@ import android.preference.PreferenceManager;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.security.KeyChain; import android.security.KeyChain;
import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener;
import android.telephony.TelephonyCallback;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -1203,9 +1204,10 @@ public class XmppConnectionService extends Service {
private void setupPhoneStateListener() { private void setupPhoneStateListener() {
final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); final TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) { if (telephonyManager == null || Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); return;
} }
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
} }
public boolean isPhoneInCall() { public boolean isPhoneInCall() {
@ -1402,7 +1404,16 @@ public class XmppConnectionService extends Service {
final Intent intent = new Intent(this, EventReceiver.class); final Intent intent = new Intent(this, EventReceiver.class);
intent.setAction("ping"); intent.setAction("ping");
try { try {
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, requestCode, intent, 0); final PendingIntent pendingIntent;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
pendingIntent =
PendingIntent.getBroadcast(
this, requestCode, intent, PendingIntent.FLAG_IMMUTABLE);
} else {
pendingIntent =
PendingIntent.getBroadcast(
this, requestCode, intent, 0);
}
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent); alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake, pendingIntent);
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.e(Config.LOGTAG, "unable to schedule alarm for ping", e); Log.e(Config.LOGTAG, "unable to schedule alarm for ping", e);

View file

@ -1,5 +1,7 @@
package eu.siacs.conversations.utils; package eu.siacs.conversations.utils;
import static eu.siacs.conversations.services.EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -24,23 +26,26 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.ui.SettingsActivity; import eu.siacs.conversations.ui.SettingsActivity;
import eu.siacs.conversations.ui.SettingsFragment; import eu.siacs.conversations.ui.SettingsFragment;
import static eu.siacs.conversations.services.EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE;
public class Compatibility { public class Compatibility {
private static final List<String> UNUSED_SETTINGS_POST_TWENTYSIX = Arrays.asList( private static final List<String> UNUSED_SETTINGS_POST_TWENTYSIX =
"led", Arrays.asList(
"notification_ringtone", "led",
"notification_headsup", "notification_ringtone",
"vibrate_on_notification" "notification_headsup",
); "vibrate_on_notification");
private static final List<String> UNUESD_SETTINGS_PRE_TWENTYSIX = Collections.singletonList( private static final List<String> UNUESD_SETTINGS_PRE_TWENTYSIX =
"message_notification_settings" Collections.singletonList("message_notification_settings");
);
public static boolean hasStoragePermission(Context context) { public static boolean hasStoragePermission(Context context) {
return Build.VERSION.SDK_INT < Build.VERSION_CODES.M || ContextCompat.checkSelfPermission(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED; return Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| ContextCompat.checkSelfPermission(
context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED;
}
public static boolean s() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.S;
} }
private static boolean runsTwentyFour() { private static boolean runsTwentyFour() {
@ -66,20 +71,22 @@ public class Compatibility {
private static boolean targetsTwentySix(Context context) { private static boolean targetsTwentySix(Context context) {
try { try {
final PackageManager packageManager = context.getPackageManager(); final PackageManager packageManager = context.getPackageManager();
final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); final ApplicationInfo applicationInfo =
packageManager.getApplicationInfo(context.getPackageName(), 0);
return applicationInfo == null || applicationInfo.targetSdkVersion >= 26; return applicationInfo == null || applicationInfo.targetSdkVersion >= 26;
} catch (PackageManager.NameNotFoundException | RuntimeException e) { } catch (PackageManager.NameNotFoundException | RuntimeException e) {
return true; //when in doubt return true; // when in doubt
} }
} }
private static boolean targetsTwentyFour(Context context) { private static boolean targetsTwentyFour(Context context) {
try { try {
final PackageManager packageManager = context.getPackageManager(); final PackageManager packageManager = context.getPackageManager();
final ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); final ApplicationInfo applicationInfo =
packageManager.getApplicationInfo(context.getPackageName(), 0);
return applicationInfo == null || applicationInfo.targetSdkVersion >= 24; return applicationInfo == null || applicationInfo.targetSdkVersion >= 24;
} catch (PackageManager.NameNotFoundException | RuntimeException e) { } catch (PackageManager.NameNotFoundException | RuntimeException e) {
return true; //when in doubt return true; // when in doubt
} }
} }
@ -92,14 +99,23 @@ public class Compatibility {
} }
public static boolean keepForegroundService(Context context) { public static boolean keepForegroundService(Context context) {
return runsAndTargetsTwentySix(context) || getBooleanPreference(context, SettingsActivity.KEEP_FOREGROUND_SERVICE, R.bool.enable_foreground_service); return runsAndTargetsTwentySix(context)
|| getBooleanPreference(
context,
SettingsActivity.KEEP_FOREGROUND_SERVICE,
R.bool.enable_foreground_service);
} }
public static void removeUnusedPreferences(SettingsFragment settingsFragment) { public static void removeUnusedPreferences(SettingsFragment settingsFragment) {
List<PreferenceCategory> categories = Arrays.asList( List<PreferenceCategory> categories =
(PreferenceCategory) settingsFragment.findPreference("notification_category"), Arrays.asList(
(PreferenceCategory) settingsFragment.findPreference("advanced")); (PreferenceCategory)
for (String key : (runsTwentySix() ? UNUSED_SETTINGS_POST_TWENTYSIX : UNUESD_SETTINGS_PRE_TWENTYSIX)) { settingsFragment.findPreference("notification_category"),
(PreferenceCategory) settingsFragment.findPreference("advanced"));
for (String key :
(runsTwentySix()
? UNUSED_SETTINGS_POST_TWENTYSIX
: UNUESD_SETTINGS_PRE_TWENTYSIX)) {
Preference preference = settingsFragment.findPreference(key); Preference preference = settingsFragment.findPreference(key);
if (preference != null) { if (preference != null) {
for (PreferenceCategory category : categories) { for (PreferenceCategory category : categories) {
@ -111,7 +127,8 @@ public class Compatibility {
} }
if (Compatibility.runsTwentySix()) { if (Compatibility.runsTwentySix()) {
if (targetsTwentySix(settingsFragment.getContext())) { if (targetsTwentySix(settingsFragment.getContext())) {
Preference preference = settingsFragment.findPreference(SettingsActivity.KEEP_FOREGROUND_SERVICE); Preference preference =
settingsFragment.findPreference(SettingsActivity.KEEP_FOREGROUND_SERVICE);
if (preference != null) { if (preference != null) {
for (PreferenceCategory category : categories) { for (PreferenceCategory category : categories) {
if (category != null) { if (category != null) {
@ -132,11 +149,12 @@ public class Compatibility {
context.startService(intent); context.startService(intent);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.d(Config.LOGTAG, context.getClass().getSimpleName() + " was unable to start service"); Log.d(
Config.LOGTAG,
context.getClass().getSimpleName() + " was unable to start service");
} }
} }
@SuppressLint("UnsupportedChromeOsCameraSystemFeature") @SuppressLint("UnsupportedChromeOsCameraSystemFeature")
public static boolean hasFeatureCamera(final Context context) { public static boolean hasFeatureCamera(final Context context) {
final PackageManager packageManager = context.getPackageManager(); final PackageManager packageManager = context.getPackageManager();