1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 01:55:50 +01:00

Huawei: Cleanup of the HuaweiSupportProvider

Removes a lot of duplicate TODOs that mostly clutter the overview.

Also includes a couple of changes to please the linter.
This commit is contained in:
Martin.JM 2024-11-24 16:37:35 +01:00 committed by José Rebelo
parent ee8eeaf16f
commit 8bfbc07a45

View File

@ -50,7 +50,6 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCameraRemote;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceMusicData;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huawei.HuaweiCoordinator;
@ -195,6 +194,8 @@ import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
public class HuaweiSupportProvider { public class HuaweiSupportProvider {
private static final Logger LOG = LoggerFactory.getLogger(HuaweiSupportProvider.class); private static final Logger LOG = LoggerFactory.getLogger(HuaweiSupportProvider.class);
// TODO: Potentially use translatable messages for the toast messages
private class SyncState { private class SyncState {
private boolean activitySync = false; private boolean activitySync = false;
private boolean workoutSync = false; private boolean workoutSync = false;
@ -482,7 +483,7 @@ public class HuaweiSupportProvider {
RequestCallback finalizeReq = new RequestCallback() { RequestCallback finalizeReq = new RequestCallback() {
@Override @Override
public void call() { public void call() {
int status = (int) deviceStatusReq.status; int status = deviceStatusReq.status;
if (status == -0x01 || status == 0x00 || status == 0x01) { if (status == -0x01 || status == 0x00 || status == 0x01) {
initializeDeviceDealHiChain(linkParamsReq); initializeDeviceDealHiChain(linkParamsReq);
} else { } else {
@ -503,7 +504,7 @@ public class HuaweiSupportProvider {
} }
} catch (IOException e) { } catch (IOException e) {
GB.toast(context, "Status of authenticating to Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Status of authenticating to Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
e.printStackTrace(); LOG.error("Status of authenticating to Huawei device failed", e);
} }
} }
@ -544,7 +545,7 @@ public class HuaweiSupportProvider {
public void call() { public void call() {
if (securityNegoReq.authType == 0x0186A0 || isHiChain3(securityNegoReq.authType)) { if (securityNegoReq.authType == 0x0186A0 || isHiChain3(securityNegoReq.authType)) {
LOG.debug("HiChain mode"); LOG.debug("HiChain mode");
initializeDeviceHiChainMode(securityNegoReq.authType); initializeDeviceHiChainMode();
} else if (securityNegoReq.authType == 0x01 || securityNegoReq.authType == 0x02) { } else if (securityNegoReq.authType == 0x01 || securityNegoReq.authType == 0x02) {
LOG.debug("HiChain Lite mode"); LOG.debug("HiChain Lite mode");
// Keep track the gadget is connected // Keep track the gadget is connected
@ -559,14 +560,14 @@ public class HuaweiSupportProvider {
initializeDeviceNormalMode(linkParamsReq); initializeDeviceNormalMode(linkParamsReq);
} }
} catch (IOException e) { } catch (IOException e) {
// TODO: use translatable string GB.toast(context, "Init deal with HiChain of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
GB.toast(context, "init Deal with HiChain of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); LOG.error("Init deal with HiChain of Huawei device failed", e);
LOG.error("Step of authenticating to Huawei device failed", e);
} }
} }
protected void initializeDeviceNotify() { protected void initializeDeviceNotify() {
} //TODO // TODO: Implement
}
RequestCallback configureReq = new RequestCallback() { RequestCallback configureReq = new RequestCallback() {
@Override @Override
@ -597,7 +598,7 @@ public class HuaweiSupportProvider {
} }
}; };
protected void initializeDeviceHiChainMode(int authType) { protected void initializeDeviceHiChainMode() {
try { try {
GetHiChainRequest hiChainReq = new GetHiChainRequest(this, firstConnection); GetHiChainRequest hiChainReq = new GetHiChainRequest(this, firstConnection);
hiChainReq.setFinalizeReq(configureReq); hiChainReq.setFinalizeReq(configureReq);
@ -608,8 +609,8 @@ public class HuaweiSupportProvider {
} else } else
hiChainReq.doPerform(); hiChainReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
GB.toast(context, "init HiCHain Mode of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "HiChain Mode init of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
e.printStackTrace(); LOG.error("HiChain Mode init of Huawei device failed", e);
} }
} }
@ -631,8 +632,8 @@ public class HuaweiSupportProvider {
authReq.doPerform(); authReq.doPerform();
} }
} catch (IOException e) { } catch (IOException e) {
GB.toast(context, "init HiCHainLite Mode Mode of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "HiChainLite mode init of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
e.printStackTrace(); LOG.error("HiChainLite mode init of Huawei device failed", e);
} }
} }
@ -652,10 +653,9 @@ public class HuaweiSupportProvider {
} }
authReq.doPerform(); authReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
GB.toast(context, "init Normal Mode of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Normal mode init of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
e.printStackTrace(); LOG.error("Normal mode init of Huawei device failed", e);
} }
} }
protected void initializeDeviceConfigure() { protected void initializeDeviceConfigure() {
@ -706,7 +706,6 @@ public class HuaweiSupportProvider {
initRequestQueue.get(0).doPerform(); initRequestQueue.get(0).doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Final initialization of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Final initialization of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Final initialization of Huawei device failed", e); LOG.error("Final initialization of Huawei device failed", e);
} }
@ -730,6 +729,9 @@ public class HuaweiSupportProvider {
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(deviceMac); SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(deviceMac);
String authKey = sharedPrefs.getString("authkey", null); String authKey = sharedPrefs.getString("authkey", null);
// TODO: Handle null key - maybe error out of the entire connection?
return GB.hexStringToByteArray(authKey); return GB.hexStringToByteArray(authKey);
} }
@ -791,7 +793,7 @@ public class HuaweiSupportProvider {
androidID = sharedPrefs.getString(DeviceSettingsPreferenceConst.PREF_FAKE_ANDROID_ID, null); androidID = sharedPrefs.getString(DeviceSettingsPreferenceConst.PREF_FAKE_ANDROID_ID, null);
if (androidID == null || androidID.isEmpty()) { if (androidID == null || androidID.isEmpty()) {
androidID = StringUtils.bytesToHex(HuaweiCrypto.generateNonce()); androidID = StringUtils.bytesToHex(HuaweiCrypto.generateNonce());
LOG.debug("Created androidID: " + androidID); LOG.debug("Created androidID: {}", androidID);
SharedPreferences.Editor editor = sharedPrefs.edit(); SharedPreferences.Editor editor = sharedPrefs.edit();
editor.putString(DeviceSettingsPreferenceConst.PREF_FAKE_ANDROID_ID, androidID); editor.putString(DeviceSettingsPreferenceConst.PREF_FAKE_ANDROID_ID, androidID);
editor.apply(); editor.apply();
@ -904,9 +906,8 @@ public class HuaweiSupportProvider {
initRequestQueue.get(0).doPerform(); initRequestQueue.get(0).doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Translatable string
GB.toast("Initialize dynamic services of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast("Initialize dynamic services of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Initializing dynamic services failed", e); LOG.error("Initializing dynamic services of Huawei device failed", e);
} }
} }
@ -926,13 +927,13 @@ public class HuaweiSupportProvider {
List<Alarm> alarms = DBHelper.getAlarms(gbDevice); List<Alarm> alarms = DBHelper.getAlarms(gbDevice);
DeviceCoordinator coordinator = this.gbDevice.getDeviceCoordinator(); DeviceCoordinator coordinator = this.gbDevice.getDeviceCoordinator();
int supportedNumAlarms = coordinator.getAlarmSlotCount(gbDevice); int supportedNumAlarms = coordinator.getAlarmSlotCount(gbDevice);
if (alarms.size() == 0) { if (alarms.isEmpty()) {
try (DBHandler db = GBApplication.acquireDB()) { try (DBHandler db = GBApplication.acquireDB()) {
DaoSession daoSession = db.getDaoSession(); DaoSession daoSession = db.getDaoSession();
Device device = DBHelper.getDevice(gbDevice, daoSession); Device device = DBHelper.getDevice(gbDevice, daoSession);
User user = DBHelper.getUser(daoSession); User user = DBHelper.getUser(daoSession);
for (int position = 0; position < supportedNumAlarms; position++) { for (int position = 0; position < supportedNumAlarms; position++) {
LOG.info("adding missing alarm at position " + position); LOG.info("Adding missing alarm at position {}", position);
DBHelper.store(createDefaultAlarm(device, user, position)); DBHelper.store(createDefaultAlarm(device, user, position));
} }
} catch (Exception e) { } catch (Exception e) {
@ -970,7 +971,6 @@ public class HuaweiSupportProvider {
try { try {
getSmartAlarmList.doPerform(); getSmartAlarmList.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Error sending smart alarm list request", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Error sending smart alarm list request", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Error sending smart alarm list request", e); LOG.error("Error sending smart alarm list request", e);
} }
@ -978,7 +978,6 @@ public class HuaweiSupportProvider {
@Override @Override
public void handleException(Request.ResponseParseException e) { public void handleException(Request.ResponseParseException e) {
// TODO: Use translatable string
GB.toast(context, "Error parsing event list", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Error parsing event list", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Error parsing event list", e); LOG.error("Error parsing event list", e);
} }
@ -986,7 +985,6 @@ public class HuaweiSupportProvider {
try { try {
getEventAlarmList.doPerform(); getEventAlarmList.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Error sending event alarm list request", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Error sending event alarm list request", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Error sending event alarm list request", e); LOG.error("Error sending event alarm list request", e);
} }
@ -1003,7 +1001,6 @@ public class HuaweiSupportProvider {
DBHelper.store(alarm); DBHelper.store(alarm);
} }
} catch (Exception e) { } catch (Exception e) {
// TODO: Use translatable string
GB.toast(context, "Error saving alarms", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Error saving alarms", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Error saving alarms", e); LOG.error("Error saving alarms", e);
} }
@ -1154,34 +1151,28 @@ public class HuaweiSupportProvider {
break; break;
} }
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Configuration of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Configuration of Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Configuration of Huawei device failed", e); LOG.error("Configuration of Huawei device failed", e);
// TODO: handle this?
} }
} }
public void onFetchRecordedData(int dataTypes) { public void onFetchRecordedData(int dataTypes) {
if (gbDevice.isBusy()) { if (gbDevice.isBusy()) {
LOG.warn("Device is already busy with " + gbDevice.getBusyTask() + ", so won't fetch data now."); LOG.warn("Device is already busy with {}, so won't fetch data now.", gbDevice.getBusyTask());
// TODO: better way of letting user know? // TODO: better way of letting user know?
// TODO: use string that can be translated
GB.toast("Device is already busy with " + gbDevice.getBusyTask() + ", so won't fetch data now.", Toast.LENGTH_LONG, 0); GB.toast("Device is already busy with " + gbDevice.getBusyTask() + ", so won't fetch data now.", Toast.LENGTH_LONG, 0);
return; return;
} }
// TODO: An exception during the parsing can leave GB thinking that the sync is not yet // TODO: Add support for retrieving multiple activity types with one call - maybe with a queue?
// finished, but it won't ever complete because of the parsing exception
// Maybe this can be fixed with an exception handler from the callback? If then
// called from the ResponseManager, it may not be too much work to implement.
if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0) { if ((dataTypes & RecordedDataTypes.TYPE_ACTIVITY) != 0) {
fetchActivityData(); fetchActivityData();
} else if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS) { } else if (dataTypes == RecordedDataTypes.TYPE_GPS_TRACKS) {
fetchWorkoutData(); fetchWorkoutData();
} else { } else {
// TODO: tell user
LOG.warn("Recorded data type {} not implemented yet.", dataTypes); LOG.warn("Recorded data type {} not implemented yet.", dataTypes);
GB.toast("Recoded data type " + dataTypes + " not implemented yet", Toast.LENGTH_SHORT, GB.WARN);
} }
// Get the battery level as well // Get the battery level as well
@ -1299,6 +1290,8 @@ public class HuaweiSupportProvider {
} }
private void fetchActivityDataP2P() { private void fetchActivityDataP2P() {
// TODO: Add sync state support for this
HuaweiP2PDataDictionarySyncService P2PSyncService = HuaweiP2PDataDictionarySyncService.getRegisteredInstance(huaweiP2PManager); HuaweiP2PDataDictionarySyncService P2PSyncService = HuaweiP2PDataDictionarySyncService.getRegisteredInstance(huaweiP2PManager);
if (P2PSyncService != null && getHuaweiCoordinator().supportsTemperature()) { if (P2PSyncService != null && getHuaweiCoordinator().supportsTemperature()) {
P2PSyncService.sendSyncRequest(400012, new HuaweiP2PDataDictionarySyncService.DictionarySyncCallback() { P2PSyncService.sendSyncRequest(400012, new HuaweiP2PDataDictionarySyncService.DictionarySyncCallback() {
@ -1362,12 +1355,10 @@ public class HuaweiSupportProvider {
final GetWorkoutCountRequest getWorkoutCountRequest; final GetWorkoutCountRequest getWorkoutCountRequest;
if (isBLE()) { if (isBLE()) {
nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder leBuilder = createLeTransactionBuilder("FetchWorkoutData"); nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder leBuilder = createLeTransactionBuilder("FetchWorkoutData");
// TODO: maybe use a different string from the other synchronization
leBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction(gbDevice, context.getString(R.string.busy_task_fetch_activity_data), context)); leBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction(gbDevice, context.getString(R.string.busy_task_fetch_activity_data), context));
getWorkoutCountRequest = new GetWorkoutCountRequest(this, leBuilder, start, end); getWorkoutCountRequest = new GetWorkoutCountRequest(this, leBuilder, start, end);
} else { } else {
nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder brBuilder = createBrTransactionBuilder("FetchWorkoutData"); nodomain.freeyourgadget.gadgetbridge.service.btbr.TransactionBuilder brBuilder = createBrTransactionBuilder("FetchWorkoutData");
// TODO: maybe use a different string from the other synchronization
brBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.SetDeviceBusyAction(gbDevice, context.getString(R.string.busy_task_fetch_activity_data), context)); brBuilder.add(new nodomain.freeyourgadget.gadgetbridge.service.btbr.actions.SetDeviceBusyAction(gbDevice, context.getString(R.string.busy_task_fetch_activity_data), context));
getWorkoutCountRequest = new GetWorkoutCountRequest(this, brBuilder, start, end); getWorkoutCountRequest = new GetWorkoutCountRequest(this, brBuilder, start, end);
} }
@ -1398,7 +1389,6 @@ public class HuaweiSupportProvider {
sendFactoryResetReq.doPerform(); sendFactoryResetReq.doPerform();
} }
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Factory resetting Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Factory resetting Huawei device failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Factory resetting Huawei device failed", e); LOG.error("Factory resetting Huawei device failed", e);
} }
@ -1418,7 +1408,6 @@ public class HuaweiSupportProvider {
// SetWearMessagePushRequest setWearMessagePushReq = new SetWearMessagePushRequest(this); // SetWearMessagePushRequest setWearMessagePushReq = new SetWearMessagePushRequest(this);
// setWearMessagePushReq.doPerform(); // setWearMessagePushReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Setting notification failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Setting notification failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Setting notification failed", e); LOG.error("Setting notification failed", e);
} }
@ -1454,7 +1443,6 @@ public class HuaweiSupportProvider {
SetDateFormatRequest setDateFormatReq = new SetDateFormatRequest(this); SetDateFormatRequest setDateFormatReq = new SetDateFormatRequest(this);
setDateFormatReq.doPerform(); setDateFormatReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure date format", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure date format", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure date format", e); LOG.error("Failed to configure date format", e);
} }
@ -1464,7 +1452,6 @@ public class HuaweiSupportProvider {
try { try {
new SetTimeRequest(this, true).doPerform(); new SetTimeRequest(this, true).doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure time", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure time", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure time", e); LOG.error("Failed to configure time", e);
} }
@ -1487,7 +1474,6 @@ public class HuaweiSupportProvider {
smartAlarmReq.doPerform(); smartAlarmReq.doPerform();
eventAlarmReq.doPerform(); eventAlarmReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure alarms", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure alarms", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure alarms", e); LOG.error("Failed to configure alarms", e);
} }
@ -1613,9 +1599,9 @@ public class HuaweiSupportProvider {
} }
public void addTotalFitnessData(int steps, int calories, int distance) { public void addTotalFitnessData(int steps, int calories, int distance) {
LOG.debug("FITNESS total steps: " + steps); LOG.debug("FITNESS total steps: {}", steps);
LOG.debug("FITNESS total calories: " + calories); // TODO: May actually be kilocalories LOG.debug("FITNESS total calories: {}", calories); // TODO: May actually be kilocalories
LOG.debug("FITNESS total distance: " + distance + " m"); LOG.debug("FITNESS total distance: {} m", distance);
// TODO: potentially do more with this, maybe through realtime data? // TODO: potentially do more with this, maybe through realtime data?
} }
@ -1890,7 +1876,7 @@ public class HuaweiSupportProvider {
} }
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Failed to select last timestsmp value to database", e); LOG.error("Failed to select last timestamp value to database", e);
} }
return lastTimestamp; return lastTimestamp;
} }
@ -1901,7 +1887,6 @@ public class HuaweiSupportProvider {
SetWearLocationRequest setWearLocationReq = new SetWearLocationRequest(this); SetWearLocationRequest setWearLocationReq = new SetWearLocationRequest(this);
setWearLocationReq.doPerform(); setWearLocationReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure Wear Location", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure Wear Location", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure Wear Location", e); LOG.error("Failed to configure Wear Location", e);
} }
@ -1913,7 +1898,6 @@ public class HuaweiSupportProvider {
GetBatteryLevelRequest batteryLevelReq = new GetBatteryLevelRequest(this); GetBatteryLevelRequest batteryLevelReq = new GetBatteryLevelRequest(this);
batteryLevelReq.doPerform(); batteryLevelReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to get battery Level", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to get battery Level", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to get battery Level", e); LOG.error("Failed to get battery Level", e);
} }
@ -1939,7 +1923,6 @@ public class HuaweiSupportProvider {
setDnd(); setDnd();
} }
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure Activate on Rotate", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure Activate on Rotate", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure Activate on Rotate", e); LOG.error("Failed to configure Activate on Rotate", e);
} }
@ -1950,7 +1933,6 @@ public class HuaweiSupportProvider {
SetNavigateOnRotateRequest setNavigateOnRotateReq = new SetNavigateOnRotateRequest(this); SetNavigateOnRotateRequest setNavigateOnRotateReq = new SetNavigateOnRotateRequest(this);
setNavigateOnRotateReq.doPerform(); setNavigateOnRotateReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure Navigate on Rotate", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure Navigate on Rotate", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure Navigate on Rotate", e); LOG.error("Failed to configure Navigate on Rotate", e);
} }
@ -1961,7 +1943,6 @@ public class HuaweiSupportProvider {
SetActivityReminderRequest setActivityReminderReq = new SetActivityReminderRequest(this); SetActivityReminderRequest setActivityReminderReq = new SetActivityReminderRequest(this);
setActivityReminderReq.doPerform(); setActivityReminderReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure Activity reminder", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure Activity reminder", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure Activity reminder", e); LOG.error("Failed to configure Activity reminder", e);
} }
@ -1972,7 +1953,6 @@ public class HuaweiSupportProvider {
SetTruSleepRequest setTruSleepReq = new SetTruSleepRequest(this); SetTruSleepRequest setTruSleepReq = new SetTruSleepRequest(this);
setTruSleepReq.doPerform(); setTruSleepReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure truSleep", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure truSleep", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure truSleep", e); LOG.error("Failed to configure truSleep", e);
} }
@ -1983,7 +1963,6 @@ public class HuaweiSupportProvider {
SetTemperatureUnitSetting setTemperatureUnitSetting = new SetTemperatureUnitSetting(this); SetTemperatureUnitSetting setTemperatureUnitSetting = new SetTemperatureUnitSetting(this);
setTemperatureUnitSetting.doPerform(); setTemperatureUnitSetting.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set temperature unit", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set temperature unit", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure TemperatureUnitSetting", e); LOG.error("Failed to configure TemperatureUnitSetting", e);
} }
@ -1994,7 +1973,6 @@ public class HuaweiSupportProvider {
SetSkinTemperatureMeasurement skinTemperatureMeasurement = new SetSkinTemperatureMeasurement(this); SetSkinTemperatureMeasurement skinTemperatureMeasurement = new SetSkinTemperatureMeasurement(this);
skinTemperatureMeasurement.doPerform(); skinTemperatureMeasurement.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to configure continuous skin temperature measurement", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to configure continuous skin temperature measurement", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to configure SkinTemperatureMeasurement", e); LOG.error("Failed to configure SkinTemperatureMeasurement", e);
} }
@ -2007,7 +1985,6 @@ public class HuaweiSupportProvider {
sendDndDeleteReq.nextRequest(sendDndAddReq); sendDndDeleteReq.nextRequest(sendDndAddReq);
sendDndDeleteReq.doPerform(); sendDndDeleteReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set DND", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set DND", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to set DND", e); LOG.error("Failed to set DND", e);
} }
@ -2018,7 +1995,6 @@ public class HuaweiSupportProvider {
SetWearMessagePushRequest setWearMessagePushReq = new SetWearMessagePushRequest(this); SetWearMessagePushRequest setWearMessagePushReq = new SetWearMessagePushRequest(this);
setWearMessagePushReq.doPerform(); setWearMessagePushReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Setting DND not wear failed", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Setting DND not wear failed", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Setting DND not wear failed", e); LOG.error("Setting DND not wear failed", e);
} }
@ -2030,7 +2006,6 @@ public class HuaweiSupportProvider {
SetDisconnectNotification req = new SetDisconnectNotification(this); SetDisconnectNotification req = new SetDisconnectNotification(this);
req.doPerform(); req.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set disconnect notification", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set disconnect notification", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to set disconnect notification", e); LOG.error("Failed to set disconnect notification", e);
} }
@ -2041,7 +2016,6 @@ public class HuaweiSupportProvider {
SetAutomaticHeartrateRequest req = new SetAutomaticHeartrateRequest(this); SetAutomaticHeartrateRequest req = new SetAutomaticHeartrateRequest(this);
req.doPerform(); req.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set automatic heart rate", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set automatic heart rate", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to set automatic heart rate", e); LOG.error("Failed to set automatic heart rate", e);
} }
@ -2052,7 +2026,6 @@ public class HuaweiSupportProvider {
SetAutomaticSpoRequest req = new SetAutomaticSpoRequest(this); SetAutomaticSpoRequest req = new SetAutomaticSpoRequest(this);
req.doPerform(); req.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set automatic SpO", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set automatic SpO", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to set automatic SpO", e); LOG.error("Failed to set automatic SpO", e);
} }
@ -2064,7 +2037,6 @@ public class HuaweiSupportProvider {
DebugRequest req = new DebugRequest(this); DebugRequest req = new DebugRequest(this);
req.doPerform(); req.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to send debug request", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to send debug request", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to send debug request", e); LOG.error("Failed to send debug request", e);
} }
@ -2076,7 +2048,6 @@ public class HuaweiSupportProvider {
StopFindPhoneRequest stopFindPhoneRequest = new StopFindPhoneRequest(this); StopFindPhoneRequest stopFindPhoneRequest = new StopFindPhoneRequest(this);
stopFindPhoneRequest.doPerform(); stopFindPhoneRequest.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to send stop find phone request", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to send stop find phone request", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to send stop find phone request", e); LOG.error("Failed to send stop find phone request", e);
} }
@ -2087,7 +2058,6 @@ public class HuaweiSupportProvider {
SetLanguageSettingRequest setLocaleReq = new SetLanguageSettingRequest(this); SetLanguageSettingRequest setLocaleReq = new SetLanguageSettingRequest(this);
setLocaleReq.doPerform(); setLocaleReq.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set language settings request", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set language settings request", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to set language settings request", e); LOG.error("Failed to set language settings request", e);
} }
@ -2118,7 +2088,6 @@ public class HuaweiSupportProvider {
try { try {
sendGpsDataRequest.doPerform(); sendGpsDataRequest.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to send GPS data", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to send GPS data", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to send GPS data", e); LOG.error("Failed to send GPS data", e);
} }
@ -2126,7 +2095,7 @@ public class HuaweiSupportProvider {
} }
public void onInstallApp(Uri uri) { public void onInstallApp(Uri uri) {
LOG.info("enter onAppInstall uri: " + uri); LOG.info("enter onAppInstall uri: {}", uri);
HuaweiFwHelper huaweiFwHelper = new HuaweiFwHelper(uri, getContext()); HuaweiFwHelper huaweiFwHelper = new HuaweiFwHelper(uri, getContext());
HuaweiUploadManager.FileUploadInfo fileInfo = new HuaweiUploadManager.FileUploadInfo(); HuaweiUploadManager.FileUploadInfo fileInfo = new HuaweiUploadManager.FileUploadInfo();
@ -2264,16 +2233,13 @@ public class HuaweiSupportProvider {
if (event == GBDeviceEventCameraRemote.Event.OPEN_CAMERA) { if (event == GBDeviceEventCameraRemote.Event.OPEN_CAMERA) {
// Somehow a delay is necessary for the watch // Somehow a delay is necessary for the watch
new Handler(GBApplication.getContext().getMainLooper()).postDelayed( new Handler(GBApplication.getContext().getMainLooper()).postDelayed(
new Runnable() { () -> {
@Override SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent = new SendCameraRemoteSetupEvent(HuaweiSupportProvider.this, CameraRemote.CameraRemoteSetup.Request.Event.CAMERA_STARTED);
public void run() { try {
SendCameraRemoteSetupEvent sendCameraRemoteSetupEvent = new SendCameraRemoteSetupEvent(HuaweiSupportProvider.this, CameraRemote.CameraRemoteSetup.Request.Event.CAMERA_STARTED); sendCameraRemoteSetupEvent.doPerform();
try { } catch (IOException e) {
sendCameraRemoteSetupEvent.doPerform(); GB.toast("Failed to send open camera request", Toast.LENGTH_SHORT, GB.ERROR, e);
} catch (IOException e) { LOG.error("Failed to send open camera request", e);
GB.toast("Failed to send open camera request", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to send open camera request", e);
}
} }
}, },
3000 3000
@ -2298,7 +2264,6 @@ public class HuaweiSupportProvider {
try { try {
sendSetContactsRequest.doPerform(); sendSetContactsRequest.doPerform();
} catch (IOException e) { } catch (IOException e) {
// TODO: Use translatable string
GB.toast(context, "Failed to set contacts", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to set contacts", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to send set contacts request", e); LOG.error("Failed to send set contacts request", e);
} }
@ -2437,7 +2402,6 @@ public class HuaweiSupportProvider {
filename filename
); );
} catch (IOException e) { } catch (IOException e) {
// TODO: Translatable string
GB.toast(context, "Could not open Workout GPS file to write to", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Could not open Workout GPS file to write to", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Could not open Workout GPS file to write to", e); LOG.error("Could not open Workout GPS file to write to", e);
return; return;
@ -2448,7 +2412,6 @@ public class HuaweiSupportProvider {
try { try {
exporter.performExport(track, targetFile); exporter.performExport(track, targetFile);
} catch (IOException | ActivityTrackExporter.GPXTrackEmptyException e) { } catch (IOException | ActivityTrackExporter.GPXTrackEmptyException e) {
// TODO: Translatable string
GB.toast(context, "Failed to export Workout GPX file", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to export Workout GPX file", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to export Workout GPX file", e); LOG.error("Failed to export Workout GPX file", e);
return; return;
@ -2456,7 +2419,6 @@ public class HuaweiSupportProvider {
Long databaseId = fileRequest.getDatabaseId(); Long databaseId = fileRequest.getDatabaseId();
if (databaseId == null) { if (databaseId == null) {
// TODO: Translatable string
GB.toast(context, "Cannot link GPX to workout", Toast.LENGTH_SHORT, GB.ERROR); GB.toast(context, "Cannot link GPX to workout", Toast.LENGTH_SHORT, GB.ERROR);
LOG.error("Cannot link GPX to workout"); LOG.error("Cannot link GPX to workout");
return; return;
@ -2468,7 +2430,6 @@ public class HuaweiSupportProvider {
sample.setGpxFileLocation(targetFile.getAbsolutePath()); sample.setGpxFileLocation(targetFile.getAbsolutePath());
sample.update(); sample.update();
} catch (Exception e) { } catch (Exception e) {
// TODO: Translatable string
GB.toast(context, "Failed to save Workout GPX file location", Toast.LENGTH_SHORT, GB.ERROR, e); GB.toast(context, "Failed to save Workout GPX file location", Toast.LENGTH_SHORT, GB.ERROR, e);
LOG.error("Failed to save Workout GPX file location", e); LOG.error("Failed to save Workout GPX file location", e);
return; return;