fix and annotate null handling in some core classes

This commit is contained in:
Thomas Kuehne
2025-06-21 09:36:05 +02:00
committed by José Rebelo
parent 7f5b672504
commit e00261cac6
33 changed files with 148 additions and 15 deletions
@@ -64,6 +64,7 @@ public abstract class Logging {
}
}
@Nullable
public String getLogPath() {
if (fileLogger != null)
return fileLogger.getFile();
@@ -58,7 +58,7 @@ public class PebbleContentProvider extends ContentProvider {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
if (GBDevice.ACTION_DEVICE_CHANGED.equals(action)) {
mGBDevice = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
}
}
@@ -19,6 +19,8 @@ package nodomain.freeyourgadget.gadgetbridge.database.schema;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,13 +69,14 @@ public class SchemaMigration {
}
}
@Nullable
private DBUpdateScript getUpdateScript(SQLiteDatabase db, int version) {
try {
Class<?> updateClass = getClass().getClassLoader().loadClass(getClass().getPackage().getName() + "." + classNamePrefix + version);
return (DBUpdateScript) updateClass.newInstance();
} catch (ClassNotFoundException e) {
return null;
} catch (InstantiationException | IllegalAccessException e) {
} catch (NullPointerException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Error instantiating DBUpdate class for version " + version, e);
}
}
@@ -103,6 +103,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
*
* @return Pattern
*/
@Nullable
protected Pattern getSupportedDeviceName() {
return null;
}
@@ -224,31 +225,37 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
@Nullable
public SampleProvider<? extends ActivitySample> getSampleProvider(final GBDevice device, final DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends StressSample> getStressSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends BodyEnergySample> getBodyEnergySampleProvider(final GBDevice device, final DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends HrvSummarySample> getHrvSummarySampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends HrvValueSample> getHrvValueSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public Vo2MaxSampleProvider<? extends Vo2MaxSample> getVo2MaxSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@@ -276,46 +283,55 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
@Nullable
public TimeSampleProvider<? extends TemperatureSample> getTemperatureSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends Spo2Sample> getSpo2SampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<CyclingSample> getCyclingSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends HeartRateSample> getHeartRateMaxSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends HeartRateSample> getHeartRateRestingSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends HeartRateSample> getHeartRateManualSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends PaiSample> getPaiSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends RespiratoryRateSample> getRespiratoryRateSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@Override
@Nullable
public TimeSampleProvider<? extends WeightSample> getWeightSampleProvider(GBDevice device, DaoSession session) {
return null;
}
@@ -326,6 +342,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
@Nullable
public TimeSampleProvider<? extends SleepScoreSample> getSleepScoreProvider(final GBDevice device, final DaoSession session) {
return null;
}
@@ -365,6 +382,7 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
@Nullable
public File getAppCacheDir() throws IOException {
return null;
}
@@ -382,11 +400,13 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
}
@Override
@Nullable
public String getAppCacheSortFilename() {
return null;
}
@Override
@Nullable
public String getAppFileExtension() {
return null;
}
@@ -827,11 +847,13 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
return new int[0];
}
@Nullable
@Override
public DeviceSpecificSettingsCustomizer getDeviceSpecificSettingsCustomizer(GBDevice device) {
return null;
}
@Nullable
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {
return null;
@@ -3,6 +3,7 @@ package nodomain.freeyourgadget.gadgetbridge.devices;
import android.content.Context;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@@ -12,6 +13,7 @@ public interface DeviceCardAction {
String getDescription(final GBDevice device, final Context context);
@Nullable
default String getLabel(final GBDevice device, final Context context) {
return null;
}
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -74,6 +75,9 @@ public class DeviceManager {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action == null) {
return;
}
switch (action) {
case ACTION_REFRESH_DEVICELIST: // fall through
case BluetoothDevice.ACTION_BOND_STATE_CHANGED:
@@ -88,7 +92,7 @@ public class DeviceManager {
break;
case GBDevice.ACTION_DEVICE_CHANGED:
GBDevice dev = intent.getParcelableExtra(GBDevice.EXTRA_DEVICE);
if (dev.getAddress() != null) {
if (dev != null && dev.getAddress() != null) {
int index = deviceList.indexOf(dev); // search by address
if (index >= 0) {
deviceList.get(index).copyFromDevice(dev);
@@ -177,6 +181,7 @@ public class DeviceManager {
return Collections.unmodifiableList(deviceList);
}
@Nullable
public GBDevice getDeviceByAddress(String address){
for(GBDevice device : deviceList){
if(device.getAddress().compareToIgnoreCase(address) == 0){
@@ -64,6 +64,10 @@ public class BluetoothConnectReceiver extends BroadcastReceiver {
return;
}
final SharedPreferences deviceSpecificPreferences = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress());
if (deviceSpecificPreferences == null) {
LOG.warn("no preferences found for connecting device {}", device.getAddress());
return;
}
boolean reactToConnection = deviceSpecificPreferences.getBoolean(GBPrefs.DEVICE_CONNECT_BACK, false);
reactToConnection |= gbDevice.getState() == GBDevice.State.WAITING_FOR_RECONNECT;
reactToConnection |= gbDevice.getState() == GBDevice.State.WAITING_FOR_SCAN;
@@ -43,7 +43,7 @@ public class BluetoothPairingRequestReceiver extends BroadcastReceiver {
String action = intent.getAction();
if (!action.equals(BluetoothDevice.ACTION_PAIRING_REQUEST)) {
if (!BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)) {
return;
}
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
@@ -51,7 +51,7 @@ public class PebbleReceiver extends BroadcastReceiver {
}
String messageType = intent.getStringExtra("messageType");
if (!messageType.equals("PEBBLE_ALERT")) {
if (!"PEBBLE_ALERT".equals(messageType)) {
LOG.info("non PEBBLE_ALERT message type not supported");
return;
}
@@ -50,9 +50,9 @@ public class PhoneCallReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
TelephonyManager tm = (TelephonyManager) context.getSystemService(Service.TELEPHONY_SERVICE);
if (intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) {
if ("android.intent.action.NEW_OUTGOING_CALL".equals(intent.getAction())) {
mSavedNumber = intent.getExtras().getString("android.intent.extra.PHONE_NUMBER");
} else if (intent.getAction().equals("nodomain.freeyourgadget.gadgetbridge.MUTE_CALL")) {
} else if ("nodomain.freeyourgadget.gadgetbridge.MUTE_CALL".equals(intent.getAction())) {
// Handle the mute request only if the phone is currently ringing
if (mLastState != TelephonyManager.CALL_STATE_RINGING)
return;
@@ -508,6 +508,7 @@ public class GBDevice implements Parcelable {
* @param key the extra info key
* @return the extra info value if set, null otherwise
*/
@Nullable
public Object getExtraInfo(String key) {
if (mExtraInfos == null) {
return null;
@@ -652,6 +653,7 @@ public class GBDevice implements Parcelable {
return !getDeviceInfos().isEmpty();
}
@Nullable
public ItemWithDetails getDeviceInfo(String name) {
for (ItemWithDetails item : getDeviceInfos()) {
if (name.equals(item.getName())) {
@@ -18,6 +18,8 @@ package nodomain.freeyourgadget.gadgetbridge.model;
import android.content.Context;
import androidx.annotation.Nullable;
import java.util.List;
import nodomain.freeyourgadget.gadgetbridge.adapter.ActivitySummariesAdapter;
@@ -33,6 +35,7 @@ public class ActivitySummaryItems {
this.itemsAdapter = new ActivitySummariesAdapter(context, device, activityKindFilter, dateFromFilter, dateToFilter, nameContainsFilter, deviceFilter, itemsFilter);
}
@Nullable
public BaseActivitySummary getItem(int position) {
if (position == 0) return null;
current_position = position;
@@ -43,6 +46,7 @@ public class ActivitySummaryItems {
return itemsAdapter.getPosition(item);
}
@Nullable
public BaseActivitySummary getNextItem() {
// last one is empty to avoid items behind fab
if (current_position + 2 < itemsAdapter.getItemCount()) {
@@ -52,6 +56,7 @@ public class ActivitySummaryItems {
return null;
}
@Nullable
public BaseActivitySummary getPrevItem() {
if (current_position - 1 >= 1) { //0 is empty item for summary dashboard
current_position -= 1;
@@ -72,6 +72,7 @@ public class Weather {
saveToCache();
}
@Nullable
public JSONObject createReconstructedOWMWeatherReply() {
final WeatherSpec weatherSpec = getWeatherSpec();
if (weatherSpec == null) {
@@ -29,6 +29,8 @@ import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -53,6 +55,7 @@ public class DeviceSupportFactory {
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
}
@Nullable
public synchronized DeviceSupport createDeviceSupport(GBDevice device) throws GBException {
DeviceSupport deviceSupport;
String deviceAddress = device.getAddress();
@@ -78,6 +81,7 @@ public class DeviceSupportFactory {
return null;
}
@Nullable
private DeviceSupport createClassNameDeviceSupport(GBDevice device) throws GBException {
String className = device.getAddress();
try {
@@ -115,6 +119,7 @@ public class DeviceSupportFactory {
}
}
@Nullable
private DeviceSupport createBTDeviceSupport(final GBDevice gbDevice) throws GBException {
if (mBtAdapter != null && mBtAdapter.isEnabled()) {
try {
@@ -29,6 +29,7 @@ import android.bluetooth.BluetoothGattService;
import android.content.Context;
import androidx.annotation.CallSuper;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
@@ -296,6 +297,7 @@ public abstract class AbstractBTLEDeviceSupport extends AbstractDeviceSupport im
* @return the characteristic for the given UUID or <code>null</code>
* @see #addSupportedService(UUID)
*/
@Nullable
public BluetoothGattCharacteristic getCharacteristic(UUID uuid) {
synchronized (characteristicsMonitor) {
if (mAvailableCharacteristics == null) {
@@ -27,6 +27,8 @@ import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattService;
import android.content.Context;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import java.io.IOException;
@@ -358,6 +360,7 @@ public abstract class AbstractBTLEMultiDeviceSupport extends AbstractDeviceSuppo
* @return the characteristic for the given UUID or <code>null</code>
* @see #addSupportedService(UUID, int)
*/
@Nullable
public BluetoothGattCharacteristic getCharacteristic(UUID uuid, int deviceIdx) {
validateDeviceIndex(deviceIdx);
@@ -18,6 +18,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.btle;
import androidx.annotation.Nullable;
import java.nio.charset.StandardCharsets;
import java.time.ZonedDateTime;
import java.util.Calendar;
@@ -453,6 +455,7 @@ public class BLETypeConversions {
}
/// compatible with FORMAT_FLOAT in {@link android.bluetooth.BluetoothGattCharacteristic#getFloatValue(int, int)}
@Nullable
public static Float toFloat32(byte[] bytes, int offset) {
if ((offset + 4) > bytes.length) {
return null;
@@ -472,6 +475,7 @@ public class BLETypeConversions {
}
/// compatible with {@link android.bluetooth.BluetoothGattCharacteristic#getStringValue(int)}
@Nullable
public static String getStringValue(final byte[] bytes, final int offset) {
if (bytes == null || offset > bytes.length) {
return null;
@@ -19,6 +19,8 @@ package nodomain.freeyourgadget.gadgetbridge.service.serial;
import android.location.Location;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.UUID;
@@ -45,102 +47,128 @@ public abstract class GBDeviceProtocol {
mDevice = device;
}
@Nullable
public byte[] encodeNotification(NotificationSpec notificationSpec) {
return null;
}
@Nullable
public byte[] encodeDeleteNotification(int id) {
return null;
}
@Nullable
public byte[] encodeSetTime() {
return null;
}
@Nullable
public byte[] encodeSetCallState(String number, String name, int command) {
return null;
}
@Nullable
public byte[] encodeSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
return null;
}
@Nullable
public byte[] encodeSetMusicInfo(String artist, String album, String track, int duration, int trackCount, int trackNr) {
return null;
}
@Nullable
public byte[] encodeVolume(float volume) {
return null;
}
@Nullable
public byte[] encodeSetMusicState(byte state, int position, int playRate, byte shuffle, byte repeat) {
return null;
}
@Nullable
public byte[] encodeFirmwareVersionReq() {
return null;
}
@Nullable
public byte[] encodeAppInfoReq() {
return null;
}
@Nullable
public byte[] encodeScreenshotReq() {
return null;
}
@Nullable
public byte[] encodeAppDelete(UUID uuid) {
return null;
}
@Nullable
public byte[] encodeAppStart(UUID uuid, boolean start) {
return null;
}
@Nullable
public byte[] encodeAppReorder(UUID[] uuids) {
return null;
}
@Nullable
public byte[] encodeSynchronizeActivityData() {
return null;
}
@Nullable
public byte[] encodeReset(int flags) {
return null;
}
@Nullable
public byte[] encodeFindDevice(boolean start) {
return null;
}
@Nullable
public byte[] encodeFindPhone(boolean start) {
return null;
}
@Nullable
public byte[] encodeEnableRealtimeSteps(boolean enable) {
return null;
}
@Nullable
public byte[] encodeEnableHeartRateSleepSupport(boolean enable) {
return null;
}
@Nullable
public byte[] encodeEnableRealtimeHeartRateMeasurement(boolean enable) { return null; }
@Nullable
public byte[] encodeAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
return null;
}
@Nullable
public byte[] encodeDeleteCalendarEvent(byte type, long id) {
return null;
}
@Nullable
public byte[] encodeSendConfiguration(String config) {
return null;
}
@Nullable
public byte[] encodeTestNewFunction() { return null; }
@Nullable
public GBDeviceEvent[] decodeResponse(byte[] responseData) {
return null;
}
@@ -149,34 +177,42 @@ public abstract class GBDeviceProtocol {
return mDevice;
}
@Nullable
public byte[] encodeSendWeather(WeatherSpec weatherSpec) {
return null;
}
@Nullable
public byte[] encodeLedColor(int color) {
return null;
}
@Nullable
public byte[] encodePowerOff() {
return null;
}
@Nullable
public byte[] encodeSetAlarms(ArrayList<? extends Alarm> alarms) {
return null;
}
@Nullable
public byte[] encodeReminders(ArrayList<? extends Reminder> reminders) {
return null;
}
@Nullable
public byte[] encodeWorldClocks(ArrayList<? extends WorldClock> clocks) {
return null;
}
@Nullable
public byte[] encodeFmFrequency(float frequency) {
return null;
}
@Nullable
public byte[] encodeGpsLocation(Location location) {
return null;
}
@@ -18,6 +18,7 @@
package nodomain.freeyourgadget.gadgetbridge.util;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.ArrayList;
import java.util.Calendar;
@@ -60,6 +61,7 @@ public class AlarmUtils {
* @param device
* @param position
*/
@Nullable
public static Alarm createDefaultAlarm(GBDevice gbDevice, int position) {
try (DBHandler db = GBApplication.acquireDB()) {
DaoSession daoSession = db.getDaoSession();
@@ -66,6 +66,7 @@ public class AndroidUtils {
* @param uuids an array of {@link ParcelUuid} elements
* @return a {@link ParcelUuid} array instance with the same contents
*/
@Nullable
public static ParcelUuid[] toParcelUuids(Parcelable[] uuids) {
if (uuids == null) {
return null;
@@ -341,6 +342,7 @@ public class AndroidUtils {
GBApplication.getContext().startActivity(launchIntent);
}
@Nullable
public static PowerManager.WakeLock acquirePartialWakeLock(Context context, String tag, long timeout) {
try {
PowerManager powermanager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
@@ -17,6 +17,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.util;
import androidx.annotation.Nullable;
import java.util.Collection;
public class ArrayUtils {
@@ -58,6 +60,7 @@ public class ArrayUtils {
* @return null if the given collection is null, otherwise an array of the same size as the collection
* @throws NullPointerException when an element of the collection is null
*/
@Nullable
public static int[] toIntArray(Collection<Integer> values) {
if (values == null) {
return null;
@@ -20,6 +20,8 @@ package nodomain.freeyourgadget.gadgetbridge.util;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
public interface BondingInterface {
@@ -39,6 +41,7 @@ public interface BondingInterface {
**/
void unregisterBroadcastReceivers();
@Nullable
default String getMacAddress() {
GBDeviceCandidate candidate = getCurrentTarget();
if (candidate != null) {
@@ -47,6 +47,7 @@ import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RequiresPermission;
@@ -560,7 +561,7 @@ public class BondingUtil {
LOG.debug("Unpair - {} associations", associations.size());
for (AssociationInfo association : associations) {
MacAddress devAddress = association.getDeviceMacAddress();
String devMac = devAddress.toString();
String devMac = (devAddress == null) ? null : devAddress.toString();
if (mac.equalsIgnoreCase(devMac)) {
boolean removed = false;
@@ -671,6 +672,7 @@ public class BondingUtil {
return removed;
}
@Nullable
public static BluetoothAdapter getBluetoothAdapter(Context context) {
if (context == null) {
LOG.error("getBluetoothAdapter - context is null");
@@ -700,6 +702,7 @@ public class BondingUtil {
return null;
}
@Nullable
public static CompanionDeviceManager getCompanionDeviceManager(Context context) {
if (context == null) {
LOG.error("getCompanionDeviceManager - context is null");
@@ -31,10 +31,11 @@ import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -45,7 +46,6 @@ import java.util.List;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
@@ -68,6 +68,7 @@ public class DeviceHelper {
private final HashMap<String, DeviceType> deviceTypeCache = new HashMap<>();
@Nullable
public GBDevice findAvailableDevice(String deviceAddress, Context context) {
Set<GBDevice> availableDevices = getAvailableDevices(context);
for (GBDevice availableDevice : availableDevices) {
@@ -34,6 +34,8 @@
package nodomain.freeyourgadget.gadgetbridge.util;
import androidx.annotation.Nullable;
public class ECDH_B163 {
static final int CURVE_DEGREE = 163;
@@ -497,6 +499,7 @@ public class ECDH_B163 {
}
// these are wrappers around the above C-style methods for Gadgetbridge to use
@Nullable
public static byte[] ecdh_generate_public(byte[] privateEC) {
byte[] pubKey = new byte[ECC_PUB_KEY_SIZE];
if (ecdh_generate_keys(pubKey, privateEC)) {
@@ -505,6 +508,7 @@ public class ECDH_B163 {
return null;
}
@Nullable
public static byte[] ecdh_generate_shared(byte[] privateEC, byte[] remotePublicEC) {
byte[] sharedKey = new byte[ECC_PUB_KEY_SIZE];
if (ecdh_shared_secret(privateEC, remotePublicEC, sharedKey)) {
@@ -27,6 +27,7 @@ import android.location.Location;
import android.location.LocationManager;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import java.text.ParseException;
@@ -34,9 +35,7 @@ import java.time.LocalTime;
import java.util.Date;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
public class GBPrefs extends Prefs {
@@ -98,6 +97,7 @@ public class GBPrefs extends Prefs {
return getString(USER_NAME, USER_NAME_DEFAULT);
}
@Nullable
public Date getUserBirthday() {
String date = getString(USER_BIRTHDAY, null);
if (date == null) {
@@ -19,6 +19,8 @@ package nodomain.freeyourgadget.gadgetbridge.util;
import android.util.Pair;
import androidx.annotation.Nullable;
import java.util.Iterator;
import java.util.LinkedList;
@@ -46,6 +48,7 @@ public class LimitedQueue<K, V> {
}
}
@Nullable
synchronized public V lookup(final K id) {
for (final Pair<K, V> entry : list) {
if (id.equals(entry.first)) {
@@ -55,6 +58,7 @@ public class LimitedQueue<K, V> {
return null;
}
@Nullable
synchronized public K lookupByValue(final V value){
for (final Pair<K, V> entry : list) {
if (value.equals(entry.second)) {
@@ -20,6 +20,8 @@ package nodomain.freeyourgadget.gadgetbridge.util;
import android.graphics.Color;
import android.util.SparseArray;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -118,6 +120,7 @@ public class PebbleUtils {
return new File(FileUtils.getExternalFilesDir(), "pbw-cache");
}
@Nullable
public static JSONObject getAppConfigurationKeys(UUID uuid) {
try {
File destDir = getPbwCacheDir();
@@ -24,7 +24,6 @@ import android.content.Intent;
import android.content.MutableContextWrapper;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -37,6 +36,7 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -128,6 +128,7 @@ public class WebViewSingleton {
super(looper);
}
@Nullable
private String getCharsetFromHeaders(String contentType) {
if (contentType != null && contentType.toLowerCase().trim().contains("charset=")) {
String[] parts = contentType.toLowerCase().trim().split("=");
@@ -21,6 +21,8 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONException;
import org.slf4j.Logger;
@@ -36,6 +38,7 @@ public class WidgetPreferenceStorage {
boolean isWidgetInPrefs = false;
String PREFS_WIDGET_SETTINGS = "widget_settings";
@Nullable
public String getSavedDeviceAddress(Context context, int appWidgetId) {
String savedDeviceAddress = null;
@@ -152,6 +155,7 @@ public class WidgetPreferenceStorage {
GB.toast("Saved app widget preferences: " + savedWidgetsPreferencesDataArray, Toast.LENGTH_SHORT, GB.INFO);
}
@Nullable
public GBDevice getDeviceForWidget(int appWidgetId) {
Context context = GBApplication.getContext();
if (!(context instanceof GBApplication)) {
@@ -166,6 +170,7 @@ public class WidgetPreferenceStorage {
return null;
}
@Nullable
private GBDevice getDeviceByMAC(Context appContext, String HwAddress) {
GBApplication gbApp = (GBApplication) appContext;
List<? extends GBDevice> devices = gbApp.getDeviceManager().getDevices();
@@ -26,6 +26,8 @@ import android.provider.CalendarContract.Instances;
import android.provider.ContactsContract;
import android.text.format.Time;
import androidx.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,13 +37,11 @@ import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
@@ -246,6 +246,7 @@ public class CalendarManager {
return birthdays;
}
@Nullable
private LocalDate parseBirthday(final String birthdayStr) {
final LocalDate birthday;
final LocalDate now = LocalDate.now();
@@ -16,6 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.util.language.impl;
import androidx.annotation.Nullable;
import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -174,6 +176,7 @@ public class BengaliTransliterator implements Transliterator {
private final static Pattern bengaliRegex = Pattern.compile(pattern);
@Nullable
private static String getVal(String key) {
if (key != null) {
String comp = composites.get(key);
@@ -1,5 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.util.maps;
import androidx.annotation.Nullable;
import org.mapsforge.map.rendertheme.XmlRenderTheme;
import org.mapsforge.map.rendertheme.XmlRenderThemeMenuCallback;
import org.mapsforge.map.rendertheme.XmlThemeResourceProvider;
@@ -34,6 +36,7 @@ public enum MapTheme implements XmlRenderTheme {
return getClass().getResourceAsStream(this.path);
}
@Nullable
@Override
public XmlThemeResourceProvider getResourceProvider() {
return null;