Spotbugs: literal string comparison

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-12-28 11:35:51 +01:00
parent deada5cf94
commit ff3dffd051
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
7 changed files with 41 additions and 32 deletions

View File

@ -367,7 +367,7 @@ public class CallActivity extends CallBaseActivity {
powerManagerUtils = new PowerManagerUtils(); powerManagerUtils = new PowerManagerUtils();
if (extras.getString("state", "").equalsIgnoreCase("resume")) { if ("resume".equalsIgnoreCase(extras.getString("state", ""))) {
setCallState(CallStatus.IN_CONVERSATION); setCallState(CallStatus.IN_CONVERSATION);
} else { } else {
setCallState(CallStatus.CONNECTING); setCallState(CallStatus.CONNECTING);

View File

@ -154,8 +154,11 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
participant.getType() == Participant.ParticipantType.GUEST || participant.getType() == Participant.ParticipantType.GUEST ||
participant.getType() == Participant.ParticipantType.GUEST_MODERATOR) { participant.getType() == Participant.ParticipantType.GUEST_MODERATOR) {
String displayName = NextcloudTalkApplication.Companion.getSharedApplication() String displayName = NextcloudTalkApplication
.getResources().getString(R.string.nc_guest); .Companion
.getSharedApplication()
.getResources()
.getString(R.string.nc_guest);
if (!TextUtils.isEmpty(participant.getDisplayName())) { if (!TextUtils.isEmpty(participant.getDisplayName())) {
displayName = participant.getDisplayName(); displayName = participant.getDisplayName();
@ -164,8 +167,11 @@ public class ParticipantItem extends AbstractFlexibleItem<ParticipantItem.Partic
ImageViewExtensionsKt.loadGuestAvatar(holder.binding.avatarView, user, displayName, false); ImageViewExtensionsKt.loadGuestAvatar(holder.binding.avatarView, user, displayName, false);
} else if (participant.getCalculatedActorType() == Participant.ActorType.USERS || } else if (participant.getCalculatedActorType() == Participant.ActorType.USERS ||
participant.getSource().equals("users")) { "users".equals(participant.getSource())) {
ImageViewExtensionsKt.loadAvatar(holder.binding.avatarView, user, participant.getCalculatedActorId(), true); ImageViewExtensionsKt.loadAvatar(holder.binding.avatarView,
user,
participant.getCalculatedActorId(),
true);
} }
Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources(); Resources resources = NextcloudTalkApplication.Companion.getSharedApplication().getResources();

View File

@ -62,8 +62,7 @@ public class AuthenticatorService extends Service {
} }
@Override @Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
throws NetworkErrorException {
return null; return null;
} }
@ -73,8 +72,7 @@ public class AuthenticatorService extends Service {
} }
@Override @Override
public Bundle hasFeatures(AccountAuthenticatorResponse response, public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) {
Account account, String[] features) {
return null; return null;
} }
@ -82,7 +80,6 @@ public class AuthenticatorService extends Service {
public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) { public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) {
return null; return null;
} }
} }
protected Authenticator getAuthenticator() { protected Authenticator getAuthenticator() {
@ -95,7 +92,7 @@ public class AuthenticatorService extends Service {
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
if (intent.getAction().equals(AccountManager.ACTION_AUTHENTICATOR_INTENT)) { if (AccountManager.ACTION_AUTHENTICATOR_INTENT.equals(intent.getAction())) {
return getAuthenticator().getIBinder(); return getAuthenticator().getIBinder();
} else { } else {
return null; return null;

View File

@ -35,14 +35,17 @@ public class DeviceUtils {
private static final String TAG = "DeviceUtils"; private static final String TAG = "DeviceUtils";
public static void ignoreSpecialBatteryFeatures() { public static void ignoreSpecialBatteryFeatures() {
if (Build.MANUFACTURER.equalsIgnoreCase("xiaomi") || Build.MANUFACTURER.equalsIgnoreCase("meizu")) { if ("xiaomi".equalsIgnoreCase(Build.MANUFACTURER) || "meizu".equalsIgnoreCase(Build.MANUFACTURER)) {
try { try {
@SuppressLint("PrivateApi") Class<?> appOpsUtilsClass = Class.forName("android.miui.AppOpsUtils"); @SuppressLint("PrivateApi") Class<?> appOpsUtilsClass = Class.forName("android.miui.AppOpsUtils");
if (appOpsUtilsClass != null) { if (appOpsUtilsClass != null) {
Method setApplicationAutoStartMethod = appOpsUtilsClass.getMethod("setApplicationAutoStart", Context Method setApplicationAutoStartMethod = appOpsUtilsClass.getMethod("setApplicationAutoStart", Context
.class, String.class, Boolean.TYPE); .class, String.class, Boolean.TYPE);
if (setApplicationAutoStartMethod != null) { if (setApplicationAutoStartMethod != null) {
Context applicationContext = NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext(); Context applicationContext = NextcloudTalkApplication
.Companion
.getSharedApplication()
.getApplicationContext();
setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext setApplicationAutoStartMethod.invoke(appOpsUtilsClass, applicationContext, applicationContext
.getPackageName(), Boolean.TRUE); .getPackageName(), Boolean.TRUE);
} }
@ -56,10 +59,10 @@ public class DeviceUtils {
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
Log.e(TAG, "InvocationTargetException"); Log.e(TAG, "InvocationTargetException");
} }
} else if (Build.MANUFACTURER.equalsIgnoreCase("huawei")) { } else if ("huawei".equalsIgnoreCase(Build.MANUFACTURER)) {
try { try {
@SuppressLint("PrivateApi") Class<?> protectAppControlClass = Class.forName("com.huawei.systemmanager.optimize.process" + @SuppressLint("PrivateApi") Class<?> protectAppControlClass = Class.forName(
".ProtectAppControl"); "com.huawei.systemmanager.optimize.process.ProtectAppControl");
if (protectAppControlClass != null) { if (protectAppControlClass != null) {
Context applicationContext = NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext(); Context applicationContext = NextcloudTalkApplication.Companion.getSharedApplication().getApplicationContext();

View File

@ -78,7 +78,7 @@ public class DatabaseStorageModule implements StorageModule {
@Override @Override
public void saveBoolean(String key, boolean value) { public void saveBoolean(String key, boolean value) {
if (key.equals("call_notifications")) { if ("call_notifications".equals(key)) {
int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4}); int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4});
ncApi.notificationCalls(ApiUtils.getCredentials(conversationUser.getUsername(), ncApi.notificationCalls(ApiUtils.getCredentials(conversationUser.getUsername(),
conversationUser.getToken()), conversationUser.getToken()),
@ -112,7 +112,7 @@ public class DatabaseStorageModule implements StorageModule {
); );
} }
if (!key.equals("conversation_lobby")) { if (!"conversation_lobby".equals(key)) {
arbitraryStorageManager.storeStorageSetting(accountIdentifier, arbitraryStorageManager.storeStorageSetting(accountIdentifier,
key, key,
Boolean.toString(value), Boolean.toString(value),
@ -124,7 +124,7 @@ public class DatabaseStorageModule implements StorageModule {
@Override @Override
public void saveString(String key, String value) { public void saveString(String key, String value) {
if (key.equals("message_expire_key")) { if ("message_expire_key".equals(key)) {
int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4}); int apiVersion = ApiUtils.getConversationApiVersion(conversationUser, new int[]{4});
String trimmedValue = value.replace("expire_", ""); String trimmedValue = value.replace("expire_", "");
@ -163,7 +163,7 @@ public class DatabaseStorageModule implements StorageModule {
} }
}); });
} else if (key.equals("message_notification_level")) { } else if ("message_notification_level".equals(key)) {
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "notification-levels")) { if (CapabilitiesUtilNew.hasSpreedFeatureCapability(conversationUser, "notification-levels")) {
if (!TextUtils.isEmpty(messageNotificationLevel) && !messageNotificationLevel.equals(value)) { if (!TextUtils.isEmpty(messageNotificationLevel) && !messageNotificationLevel.equals(value)) {
int intValue; int intValue;
@ -232,7 +232,7 @@ public class DatabaseStorageModule implements StorageModule {
@Override @Override
public boolean getBoolean(String key, boolean defaultVal) { public boolean getBoolean(String key, boolean defaultVal) {
if (key.equals("conversation_lobby")) { if ("conversation_lobby".equals(key)) {
return lobbyValue; return lobbyValue;
} else { } else {
return arbitraryStorageManager return arbitraryStorageManager
@ -244,7 +244,7 @@ public class DatabaseStorageModule implements StorageModule {
@Override @Override
public String getString(String key, String defaultVal) { public String getString(String key, String defaultVal) {
if (key.equals("message_expire_key")) { if ("message_expire_key".equals(key)) {
switch (messageExpiration) { switch (messageExpiration) {
case 2419200: case 2419200:
return "expire_2419200"; return "expire_2419200";
@ -259,7 +259,7 @@ public class DatabaseStorageModule implements StorageModule {
default: default:
return "expire_0"; return "expire_0";
} }
} else if (key.equals("message_notification_level")) { } else if ("message_notification_level".equals(key)) {
return messageNotificationLevel; return messageNotificationLevel;
} else { } else {
return arbitraryStorageManager return arbitraryStorageManager

View File

@ -171,7 +171,7 @@ public class PeerConnectionWrapper {
dataChannel.registerObserver(new MagicDataChannelObserver()); dataChannel.registerObserver(new MagicDataChannelObserver());
if (isMCUPublisher) { if (isMCUPublisher) {
peerConnection.createOffer(magicSdpObserver, mediaConstraints); peerConnection.createOffer(magicSdpObserver, mediaConstraints);
} else if (hasMCU && this.videoStreamType.equals("video")) { } else if (hasMCU && "video".equals(this.videoStreamType)) {
// If the connection type is "screen" the client sharing the screen will send an // If the connection type is "screen" the client sharing the screen will send an
// offer; offers should be requested only for videos. // offer; offers should be requested only for videos.
// "to" property is not actually needed in the "requestoffer" signaling message, but it is used to // "to" property is not actually needed in the "requestoffer" signaling message, but it is used to
@ -360,8 +360,9 @@ public class PeerConnectionWrapper {
@Override @Override
public void onStateChange() { public void onStateChange() {
if (dataChannel != null && dataChannel.state() == DataChannel.State.OPEN && if (dataChannel != null &&
dataChannel.label().equals("status")) { dataChannel.state() == DataChannel.State.OPEN &&
"status".equals(dataChannel.label())) {
sendInitialMediaStatus(); sendInitialMediaStatus();
} }
} }
@ -493,7 +494,7 @@ public class PeerConnectionWrapper {
@Override @Override
public void onDataChannel(DataChannel dataChannel) { public void onDataChannel(DataChannel dataChannel) {
if (dataChannel.label().equals("status") || dataChannel.label().equals("JanusDataChannel")) { if ("status".equals(dataChannel.label()) || "JanusDataChannel".equals(dataChannel.label())) {
PeerConnectionWrapper.this.dataChannel = dataChannel; PeerConnectionWrapper.this.dataChannel = dataChannel;
PeerConnectionWrapper.this.dataChannel.registerObserver(new MagicDataChannelObserver()); PeerConnectionWrapper.this.dataChannel.registerObserver(new MagicDataChannelObserver());
} }

View File

@ -109,8 +109,6 @@ public class WebRtcBluetoothManager {
return bluetoothState; return bluetoothState;
} }
;
/** /**
* Activates components required to detect Bluetooth devices and to enable * Activates components required to detect Bluetooth devices and to enable
* BT SCO (audio is routed via BT SCO) for the headset profile. The end * BT SCO (audio is routed via BT SCO) for the headset profile. The end
@ -502,8 +500,10 @@ public class WebRtcBluetoothManager {
Log.d(TAG, "onServiceConnected done: BT state=" + bluetoothState); Log.d(TAG, "onServiceConnected done: BT state=" + bluetoothState);
} }
/**
* Notifies the client when the proxy object has been disconnected from the service.
*/
@Override @Override
/** Notifies the client when the proxy object has been disconnected from the service. */
public void onServiceDisconnected(int profile) { public void onServiceDisconnected(int profile) {
if (profile != BluetoothProfile.HEADSET || bluetoothState == State.UNINITIALIZED) { if (profile != BluetoothProfile.HEADSET || bluetoothState == State.UNINITIALIZED) {
return; return;
@ -531,7 +531,7 @@ public class WebRtcBluetoothManager {
// change does not tell us anything about whether we're streaming // change does not tell us anything about whether we're streaming
// audio to BT over SCO. Typically received when user turns on a BT // audio to BT over SCO. Typically received when user turns on a BT
// headset while audio is active using another audio device. // headset while audio is active using another audio device.
if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) { if (BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED.equals(action)) {
final int state = final int state =
intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_DISCONNECTED); intent.getIntExtra(BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_DISCONNECTED);
Log.d(TAG, "BluetoothHeadsetBroadcastReceiver.onReceive: " Log.d(TAG, "BluetoothHeadsetBroadcastReceiver.onReceive: "
@ -543,8 +543,10 @@ public class WebRtcBluetoothManager {
scoConnectionAttempts = 0; scoConnectionAttempts = 0;
updateAudioDeviceState(); updateAudioDeviceState();
} else if (state == BluetoothHeadset.STATE_CONNECTING) { } else if (state == BluetoothHeadset.STATE_CONNECTING) {
Log.d(TAG, "+++ Bluetooth is connecting...");
// No action needed. // No action needed.
} else if (state == BluetoothHeadset.STATE_DISCONNECTING) { } else if (state == BluetoothHeadset.STATE_DISCONNECTING) {
Log.d(TAG, "+++ Bluetooth is disconnecting...");
// No action needed. // No action needed.
} else if (state == BluetoothHeadset.STATE_DISCONNECTED) { } else if (state == BluetoothHeadset.STATE_DISCONNECTED) {
// Bluetooth is probably powered off during the call. // Bluetooth is probably powered off during the call.
@ -553,7 +555,7 @@ public class WebRtcBluetoothManager {
} }
// Change in the audio (SCO) connection state of the Headset profile. // Change in the audio (SCO) connection state of the Headset profile.
// Typically received after call to startScoAudio() has finalized. // Typically received after call to startScoAudio() has finalized.
} else if (action.equals(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED)) { } else if (BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED.equals(action)) {
final int state = intent.getIntExtra( final int state = intent.getIntExtra(
BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_AUDIO_DISCONNECTED); BluetoothHeadset.EXTRA_STATE, BluetoothHeadset.STATE_AUDIO_DISCONNECTED);
Log.d(TAG, "BluetoothHeadsetBroadcastReceiver.onReceive: " Log.d(TAG, "BluetoothHeadsetBroadcastReceiver.onReceive: "