mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-15 12:17:33 +01:00
updated some requests, still dunno why some files time out...
This commit is contained in:
parent
06d7568249
commit
25a67b2ebb
@ -47,12 +47,14 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
public class ConfigActivity extends AbstractGBActivity {
|
public class ConfigActivity extends AbstractGBActivity {
|
||||||
PackageAdapter adapter;
|
PackageAdapter adapter;
|
||||||
@ -131,8 +133,14 @@ public class ConfigActivity extends AbstractGBActivity {
|
|||||||
|
|
||||||
ListView appList = findViewById(R.id.qhybrid_appList);
|
ListView appList = findViewById(R.id.qhybrid_appList);
|
||||||
|
|
||||||
|
try {
|
||||||
helper = new PackageConfigHelper(getApplicationContext());
|
helper = new PackageConfigHelper(getApplicationContext());
|
||||||
list = helper.getSettings();
|
list = helper.getNotificationConfigurations();
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error getting configurations", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
list = new ArrayList<>();
|
||||||
|
}
|
||||||
list.add(null);
|
list.add(null);
|
||||||
appList.setAdapter(adapter = new PackageAdapter(this, R.layout.qhybrid_package_settings_item, list));
|
appList.setAdapter(adapter = new PackageAdapter(this, R.layout.qhybrid_package_settings_item, list));
|
||||||
appList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
appList.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
||||||
@ -152,7 +160,13 @@ public class ConfigActivity extends AbstractGBActivity {
|
|||||||
public void onFinish(boolean success, NotificationConfiguration config) {
|
public void onFinish(boolean success, NotificationConfiguration config) {
|
||||||
setControl(false, null);
|
setControl(false, null);
|
||||||
if (success) {
|
if (success) {
|
||||||
helper.saveConfig(config);
|
try {
|
||||||
|
helper.saveNotificationConfiguration(config);
|
||||||
|
LocalBroadcastManager.getInstance(ConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_NOTIFICATION_CONFIG_CHANGED));
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error saving notification", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
}
|
||||||
refreshList();
|
refreshList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +187,13 @@ public class ConfigActivity extends AbstractGBActivity {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "delete": {
|
case "delete": {
|
||||||
helper.deleteConfig((NotificationConfiguration) adapterView.getItemAtPosition(i));
|
try {
|
||||||
|
helper.deleteNotificationConfiguration((NotificationConfiguration) adapterView.getItemAtPosition(i));
|
||||||
|
LocalBroadcastManager.getInstance(ConfigActivity.this).sendBroadcast(new Intent(QHybridSupport.QHYBRID_COMMAND_NOTIFICATION_CONFIG_CHANGED));
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error deleting setting", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
}
|
||||||
refreshList();
|
refreshList();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -331,7 +351,12 @@ public class ConfigActivity extends AbstractGBActivity {
|
|||||||
|
|
||||||
private void refreshList() {
|
private void refreshList() {
|
||||||
list.clear();
|
list.clear();
|
||||||
list.addAll(helper.getSettings());
|
try {
|
||||||
|
list.addAll(helper.getNotificationConfigurations());
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error getting configurations", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
}
|
||||||
list.add(null);
|
list.add(null);
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
@ -339,7 +364,6 @@ public class ConfigActivity extends AbstractGBActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
helper.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,7 +29,7 @@ public class NotificationConfiguration implements Serializable {
|
|||||||
this.vibration = vibration;
|
this.vibration = vibration;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationConfiguration(short min, short hour, String packageName, String appName, boolean respectSilentMode, PlayNotificationRequest.VibrationType vibration, long id) {
|
public NotificationConfiguration(short min, short hour, String packageName, String appName, boolean respectSilentMode, PlayNotificationRequest.VibrationType vibration, long id) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.hour = hour;
|
this.hour = hour;
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
|
@ -8,10 +8,14 @@ import android.util.Log;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.DBOpenHelper;
|
import nodomain.freeyourgadget.gadgetbridge.database.DBOpenHelper;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
public class PackageConfigHelper extends DBOpenHelper {
|
public class PackageConfigHelper {
|
||||||
public static final String DB_NAME = "qhybridNotifications.db";
|
public static final String DB_NAME = "qhybridNotifications.db";
|
||||||
public static final String DB_ID = "id";
|
public static final String DB_ID = "id";
|
||||||
public static final String DB_TABLE = "notifications";
|
public static final String DB_TABLE = "notifications";
|
||||||
@ -22,16 +26,12 @@ public class PackageConfigHelper extends DBOpenHelper {
|
|||||||
public static final String DB_HOUR = "hourDegrees";
|
public static final String DB_HOUR = "hourDegrees";
|
||||||
public static final String DB_RESPECT_SILENT = "respectSilent";
|
public static final String DB_RESPECT_SILENT = "respectSilent";
|
||||||
|
|
||||||
SQLiteDatabase database;
|
|
||||||
|
|
||||||
|
public PackageConfigHelper(Context context) throws GBException {
|
||||||
public PackageConfigHelper(Context context) {
|
|
||||||
super(context, DB_NAME, null);
|
|
||||||
this.database = getWritableDatabase();
|
|
||||||
initDB();
|
initDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveConfig(NotificationConfiguration settings){
|
public void saveNotificationConfiguration(NotificationConfiguration settings) throws GBException {
|
||||||
ContentValues values = new ContentValues(6);
|
ContentValues values = new ContentValues(6);
|
||||||
values.put(DB_PACKAGE, settings.getPackageName());
|
values.put(DB_PACKAGE, settings.getPackageName());
|
||||||
values.put(DB_APPNAME, settings.getAppName());
|
values.put(DB_APPNAME, settings.getAppName());
|
||||||
@ -40,16 +40,25 @@ public class PackageConfigHelper extends DBOpenHelper {
|
|||||||
values.put(DB_VIBRATION, settings.getVibration().getValue());
|
values.put(DB_VIBRATION, settings.getVibration().getValue());
|
||||||
values.put(DB_RESPECT_SILENT, settings.getRespectSilentMode());
|
values.put(DB_RESPECT_SILENT, settings.getRespectSilentMode());
|
||||||
|
|
||||||
|
SQLiteDatabase database = GBApplication.acquireDB().getDatabase();
|
||||||
|
|
||||||
if(settings.getId() == -1) {
|
if(settings.getId() == -1) {
|
||||||
settings.setId(database.insert(DB_TABLE, null, values));
|
settings.setId(database.insert(DB_TABLE, null, values));
|
||||||
}else{
|
}else{
|
||||||
database.update(DB_TABLE, values, DB_ID + "=?", new String[]{String.valueOf(settings.getId())});
|
database.update(DB_TABLE, values, DB_ID + "=?", new String[]{String.valueOf(settings.getId())});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GBApplication.releaseDB();
|
||||||
//LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent());
|
//LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<NotificationConfiguration> getSettings(){
|
public ArrayList<NotificationConfiguration> getNotificationConfigurations() throws GBException {
|
||||||
|
SQLiteDatabase database = GBApplication.acquireDB().getDatabase();
|
||||||
|
|
||||||
Cursor cursor = database.query(DB_TABLE, new String[]{"*"}, null, null, null, null, null);
|
Cursor cursor = database.query(DB_TABLE, new String[]{"*"}, null, null, null, null, null);
|
||||||
|
|
||||||
|
GBApplication.releaseDB();
|
||||||
|
|
||||||
int size = cursor.getCount();
|
int size = cursor.getCount();
|
||||||
ArrayList<NotificationConfiguration> list = new ArrayList<>(size);
|
ArrayList<NotificationConfiguration> list = new ArrayList<>(size);
|
||||||
if(size > 0){
|
if(size > 0){
|
||||||
@ -78,9 +87,15 @@ public class PackageConfigHelper extends DBOpenHelper {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotificationConfiguration getSetting(String appName){
|
public NotificationConfiguration getNotificationConfiguration(String appName) throws GBException {
|
||||||
if(appName == null) return null;
|
if(appName == null) return null;
|
||||||
|
|
||||||
|
SQLiteDatabase database = GBApplication.acquireDB().getDatabase();
|
||||||
|
|
||||||
Cursor c = database.query(DB_TABLE, new String[]{"*"}, DB_APPNAME + "=?", new String[]{appName}, null, null, null);
|
Cursor c = database.query(DB_TABLE, new String[]{"*"}, DB_APPNAME + "=?", new String[]{appName}, null, null, null);
|
||||||
|
|
||||||
|
GBApplication.releaseDB();
|
||||||
|
|
||||||
if(c.getCount() == 0){
|
if(c.getCount() == 0){
|
||||||
c.close();
|
c.close();
|
||||||
return null;
|
return null;
|
||||||
@ -99,7 +114,9 @@ public class PackageConfigHelper extends DBOpenHelper {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDB(){
|
private void initDB() throws GBException {
|
||||||
|
SQLiteDatabase database = GBApplication.acquireDB().getDatabase();
|
||||||
|
|
||||||
database.execSQL("CREATE TABLE IF NOT EXISTS notifications(" +
|
database.execSQL("CREATE TABLE IF NOT EXISTS notifications(" +
|
||||||
DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
|
DB_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
|
||||||
DB_PACKAGE + " TEXT, " +
|
DB_PACKAGE + " TEXT, " +
|
||||||
@ -108,17 +125,18 @@ public class PackageConfigHelper extends DBOpenHelper {
|
|||||||
DB_APPNAME + " TEXT," +
|
DB_APPNAME + " TEXT," +
|
||||||
DB_RESPECT_SILENT + " INTEGER," +
|
DB_RESPECT_SILENT + " INTEGER," +
|
||||||
DB_HOUR + " INTEGER DEFAULT -1);");
|
DB_HOUR + " INTEGER DEFAULT -1);");
|
||||||
|
|
||||||
|
GBApplication.releaseDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void deleteNotificationConfiguration(NotificationConfiguration packageSettings) throws GBException {
|
||||||
public void close(){
|
|
||||||
super.close();
|
|
||||||
database.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deleteConfig(NotificationConfiguration packageSettings) {
|
|
||||||
Log.d("DB", "deleting id " + packageSettings.getId());
|
Log.d("DB", "deleting id " + packageSettings.getId());
|
||||||
if(packageSettings.getId() == -1) return;
|
if(packageSettings.getId() == -1) return;
|
||||||
this.database.delete(DB_TABLE, DB_ID + "=?", new String[]{String.valueOf(packageSettings.getId())});
|
|
||||||
|
SQLiteDatabase database = GBApplication.acquireDB().getDatabase();
|
||||||
|
|
||||||
|
database.delete(DB_TABLE, DB_ID + "=?", new String[]{String.valueOf(packageSettings.getId())});
|
||||||
|
|
||||||
|
GBApplication.releaseDB();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -23,9 +24,12 @@ import java.util.List;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractGBActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
|
|
||||||
@ -39,7 +43,14 @@ public class QHybridAppChoserActivity extends AbstractGBActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_qhybrid_app_choser);
|
setContentView(R.layout.activity_qhybrid_app_choser);
|
||||||
|
|
||||||
|
try {
|
||||||
helper = new PackageConfigHelper(getApplicationContext());
|
helper = new PackageConfigHelper(getApplicationContext());
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error getting database helper", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final ListView appList = findViewById(R.id.qhybrid_appChooserList);
|
final ListView appList = findViewById(R.id.qhybrid_appChooserList);
|
||||||
final PackageManager manager = getPackageManager();
|
final PackageManager manager = getPackageManager();
|
||||||
@ -78,7 +89,6 @@ public class QHybridAppChoserActivity extends AbstractGBActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
helper.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setControl(boolean control) {
|
private void setControl(boolean control) {
|
||||||
@ -111,7 +121,12 @@ public class QHybridAppChoserActivity extends AbstractGBActivity {
|
|||||||
public void onFinish(boolean success, NotificationConfiguration config) {
|
public void onFinish(boolean success, NotificationConfiguration config) {
|
||||||
setControl(false);
|
setControl(false);
|
||||||
if(success){
|
if(success){
|
||||||
helper.saveConfig(config);
|
try {
|
||||||
|
helper.saveNotificationConfiguration(config);
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error saving configuration", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import java.util.UUID;
|
|||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
||||||
@ -54,6 +55,7 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
|
|
||||||
public static final String QHYBRID_EVENT_SETTINGS_UPDATED = "nodomain.freeyourgadget.gadgetbridge.Q_SETTINGS_UPDATED";
|
public static final String QHYBRID_EVENT_SETTINGS_UPDATED = "nodomain.freeyourgadget.gadgetbridge.Q_SETTINGS_UPDATED";
|
||||||
public static final String QHYBRID_EVENT_FILE_UPLOADED = "nodomain.freeyourgadget.gadgetbridge.Q_FILE_UPLOADED";
|
public static final String QHYBRID_EVENT_FILE_UPLOADED = "nodomain.freeyourgadget.gadgetbridge.Q_FILE_UPLOADED";
|
||||||
|
public static final String QHYBRID_COMMAND_NOTIFICATION_CONFIG_CHANGED = "nodomain.freeyourgadget.gadgetbridge.Q_NOTIFICATION_CONFIG_CHANGED";
|
||||||
|
|
||||||
public static final String QHYBRID_EVENT_BUTTON_PRESS = "nodomain.freeyourgadget.gadgetbridge.Q_BUTTON_PRESSED";
|
public static final String QHYBRID_EVENT_BUTTON_PRESS = "nodomain.freeyourgadget.gadgetbridge.Q_BUTTON_PRESSED";
|
||||||
|
|
||||||
@ -93,9 +95,20 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
commandFilter.addAction(QHYBRID_COMMAND_NOTIFICATION);
|
commandFilter.addAction(QHYBRID_COMMAND_NOTIFICATION);
|
||||||
commandFilter.addAction(QHYBRID_COMMAND_UPDATE_SETTINGS);
|
commandFilter.addAction(QHYBRID_COMMAND_UPDATE_SETTINGS);
|
||||||
commandFilter.addAction(QHYBRID_COMMAND_OVERWRITE_BUTTONS);
|
commandFilter.addAction(QHYBRID_COMMAND_OVERWRITE_BUTTONS);
|
||||||
|
commandFilter.addAction(QHYBRID_COMMAND_NOTIFICATION_CONFIG_CHANGED);
|
||||||
LocalBroadcastManager.getInstance(getContext()).registerReceiver(commandReceiver, commandFilter);
|
LocalBroadcastManager.getInstance(getContext()).registerReceiver(commandReceiver, commandFilter);
|
||||||
|
|
||||||
|
try {
|
||||||
helper = new PackageConfigHelper(GBApplication.getContext());
|
helper = new PackageConfigHelper(GBApplication.getContext());
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("erroe getting database", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
try {
|
||||||
|
throw e;
|
||||||
|
} catch (GBException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IntentFilter globalFilter = new IntentFilter();
|
IntentFilter globalFilter = new IntentFilter();
|
||||||
globalFilter.addAction(QHYBRID_ACTION_SET_ACTIVITY_HAND);
|
globalFilter.addAction(QHYBRID_ACTION_SET_ACTIVITY_HAND);
|
||||||
@ -130,8 +143,6 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
|
|
||||||
loadTimeOffset();
|
loadTimeOffset();
|
||||||
|
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +159,13 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
//new Exception().printStackTrace();
|
//new Exception().printStackTrace();
|
||||||
String packageName = notificationSpec.sourceName;
|
String packageName = notificationSpec.sourceName;
|
||||||
|
|
||||||
NotificationConfiguration config = helper.getSetting(packageName);
|
NotificationConfiguration config = null;
|
||||||
|
try {
|
||||||
|
config = helper.getNotificationConfiguration(packageName);
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error getting notification configuration", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
}
|
||||||
if (config == null) return;
|
if (config == null) return;
|
||||||
|
|
||||||
Log.d("Service", "handling notification");
|
Log.d("Service", "handling notification");
|
||||||
@ -160,9 +177,9 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
|
|
||||||
boolean enforceActivityHandNotification = config.getHour() == -1 && config.getMin() == -1;
|
boolean enforceActivityHandNotification = config.getHour() == -1 && config.getMin() == -1;
|
||||||
|
|
||||||
// showNotificationsByAllActive(enforceActivityHandNotification);
|
|
||||||
|
|
||||||
playNotification(config);
|
playNotification(config);
|
||||||
|
|
||||||
|
showNotificationsByAllActive(enforceActivityHandNotification);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -190,9 +207,14 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
|
|
||||||
public double calculateNotificationProgress() {
|
public double calculateNotificationProgress() {
|
||||||
HashMap<NotificationConfiguration, Boolean> configs = new HashMap<>(0);
|
HashMap<NotificationConfiguration, Boolean> configs = new HashMap<>(0);
|
||||||
for (NotificationConfiguration config : helper.getSettings()) {
|
try {
|
||||||
|
for (NotificationConfiguration config : helper.getNotificationConfigurations()) {
|
||||||
configs.put(config, false);
|
configs.put(config, false);
|
||||||
}
|
}
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
GB.toast("error getting notification configs", Toast.LENGTH_SHORT, GB.ERROR, e);
|
||||||
|
}
|
||||||
|
|
||||||
double notificationProgress = 0;
|
double notificationProgress = 0;
|
||||||
|
|
||||||
@ -353,8 +375,8 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
switch (intent.getAction()) {
|
switch (intent.getAction()) {
|
||||||
case QHYBRID_ACTION_SET_ACTIVITY_HAND: {
|
case QHYBRID_ACTION_SET_ACTIVITY_HAND: {
|
||||||
try {
|
try {
|
||||||
Object extra = intent.getExtras().get("EXTRA_PROGRESS");
|
String extra = String.valueOf(intent.getExtras().get("EXTRA_PROGRESS"));
|
||||||
float progress = (float) extra;
|
float progress = Float.parseFloat(extra);
|
||||||
watchAdapter.setActivityHand(progress);
|
watchAdapter.setActivityHand(progress);
|
||||||
|
|
||||||
watchAdapter.playNotification(new NotificationConfiguration(
|
watchAdapter.playNotification(new NotificationConfiguration(
|
||||||
@ -437,6 +459,10 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
watchAdapter.overwriteButtons();
|
watchAdapter.overwriteButtons();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QHYBRID_COMMAND_NOTIFICATION_CONFIG_CHANGED: {
|
||||||
|
watchAdapter.syncNotificationSettings();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,7 +19,7 @@ public abstract class WatchAdapter {
|
|||||||
return this.deviceSupport;
|
return this.deviceSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Context getContext(){
|
public Context getContext(){
|
||||||
return getDeviceSupport().getContext();
|
return getDeviceSupport().getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ public abstract class WatchAdapter {
|
|||||||
public abstract void releaseHandsControl();
|
public abstract void releaseHandsControl();
|
||||||
public abstract void setStepGoal(int stepGoal);
|
public abstract void setStepGoal(int stepGoal);
|
||||||
public abstract void setVibrationStrength(short strength);
|
public abstract void setVibrationStrength(short strength);
|
||||||
|
public abstract void syncNotificationSettings();
|
||||||
public abstract void onTestNewFunction();
|
public abstract void onTestNewFunction();
|
||||||
|
|
||||||
public abstract boolean supportsExtendedVibration();
|
public abstract boolean supportsExtendedVibration();
|
||||||
|
@ -5,13 +5,17 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.PackageConfigHelper;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.WatchAdapter;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.WatchAdapter;
|
||||||
@ -23,8 +27,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fos
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FilePutRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FilePutRequest;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.NotificationFilterPutRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.NotificationFilterPutRequest;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.PlayNotificationRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.PlayNotificationRequest;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.PrepareFilesRequestOrWhatever;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.AnimationRequest;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.AnimationRequest;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.MoveHandsRequest;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.ReleaseHandsControlRequest;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.RequestHandControlRequest;
|
||||||
|
|
||||||
public class FossilWatchAdapter extends WatchAdapter {
|
public class FossilWatchAdapter extends WatchAdapter {
|
||||||
private Queue<Request> requestQueue = new ArrayDeque<>();
|
private Queue<Request> requestQueue = new ArrayDeque<>();
|
||||||
@ -41,8 +47,44 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
playPairingAnimation();
|
playPairingAnimation();
|
||||||
queueWrite(new PrepareFilesRequestOrWhatever());
|
// queueWrite(new PrepareFilesRequestOrWhatever());
|
||||||
|
queueWrite(new ConfigurationGetRequest(this));
|
||||||
|
|
||||||
|
/*queueWrite(new Request() {
|
||||||
|
@Override
|
||||||
|
public byte[] getStartSequence() {
|
||||||
|
return new byte[]{0x01, (byte)0xF1, 0x28};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
queueWrite(new Request() {
|
||||||
|
@Override
|
||||||
|
public byte[] getStartSequence() {
|
||||||
|
return new byte[]{0x09, (byte) 0xFF, (byte) 0xFF};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getRequestUUID() {
|
||||||
|
return UUID.fromString("3dda0003-957f-7d4a-34a6-74696673696d");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
queueWrite(new Request() {
|
||||||
|
@Override
|
||||||
|
public byte[] getStartSequence() {
|
||||||
|
return new byte[]{(byte) 0x02, (byte) 0x09 , (byte) 0x0C , (byte) 0x00 , (byte) 0x0C , (byte) 0x00 , (byte) 0x2D , (byte) 0x00 , (byte) 0x58 , (byte) 0x02};
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
/*queueWrite(new Request() {
|
||||||
|
@Override
|
||||||
|
public byte[] getStartSequence() {
|
||||||
|
return new byte[]{0x02, 0x17, 0x01};
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
syncNotificationSettings();
|
||||||
|
|
||||||
|
getDeviceSupport().getDevice().setState(GBDevice.State.INITIALIZED);
|
||||||
|
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -52,6 +94,10 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playNotification(NotificationConfiguration config) {
|
public void playNotification(NotificationConfiguration config) {
|
||||||
|
if(config.getPackageName() == null){
|
||||||
|
log("package name in notification not set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
queueWrite(new PlayNotificationRequest(config.getPackageName(), this));
|
queueWrite(new PlayNotificationRequest(config.getPackageName(), this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,12 +132,13 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHands(short hour, short minute) {
|
public void setHands(short hour, short minute) {
|
||||||
|
queueWrite(new MoveHandsRequest(false, minute, hour, (short) -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void vibrate(nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest.VibrationType vibration) {
|
|
||||||
|
|
||||||
|
|
||||||
|
public void vibrate(nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest.VibrationType vibration) {
|
||||||
|
// queueWrite(new nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest(vibration, -1, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -99,14 +146,15 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void requestHandsControl() {
|
public void requestHandsControl() {
|
||||||
|
queueWrite(new RequestHandControlRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseHandsControl() {
|
public void releaseHandsControl() {
|
||||||
|
queueWrite(new ReleaseHandsControlRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -126,19 +174,27 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void syncNotificationSettings() {
|
||||||
|
log("syncing notification settings...");
|
||||||
|
try {
|
||||||
|
PackageConfigHelper helper = new PackageConfigHelper(getContext());
|
||||||
|
ArrayList<NotificationConfiguration> configurations = helper.getNotificationConfigurations();
|
||||||
|
if(configurations.size() == 1) configurations.add(configurations.get(0));
|
||||||
|
|
||||||
|
queueWrite(new NotificationFilterPutRequest(configurations, this));
|
||||||
|
} catch (GBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
NotificationConfiguration c = new NotificationConfiguration(
|
try {
|
||||||
(short) 0x77,
|
queueWrite(new NotificationFilterPutRequest(new PackageConfigHelper(getContext()).getNotificationConfigurations() ,this));
|
||||||
(short) 0x77,
|
} catch (GBException e) {
|
||||||
(short) 0xFF,
|
e.printStackTrace();
|
||||||
nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest.VibrationType.WHATEVER
|
}
|
||||||
);
|
|
||||||
c.setPackageName("com.whatsapp");
|
|
||||||
queueWrite(new NotificationFilterPutRequest(
|
|
||||||
new NotificationConfiguration[]{c, c},
|
|
||||||
this
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -179,12 +235,25 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFetchActivityData() {
|
public void onFetchActivityData() {
|
||||||
queueWrite(new ConfigurationGetRequest(this));
|
NotificationConfiguration config = new NotificationConfiguration((short) 0, (short) 0, (short) 0, null);
|
||||||
|
config.setPackageName("org.telegram.messenger");
|
||||||
|
playNotification(config);
|
||||||
|
// queueWrite(new ConfigurationGetRequest(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||||
switch (characteristic.getUuid().toString()) {
|
switch (characteristic.getUuid().toString()) {
|
||||||
|
case "3dda0002-957f-7d4a-34a6-74696673696d": {
|
||||||
|
if(fileGetRequest == null && fileLookupRequest == null && filePutRequest == null){
|
||||||
|
try {
|
||||||
|
queueWrite(requestQueue.remove());
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
log("requestsQueue empty");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "3dda0004-957f-7d4a-34a6-74696673696d":
|
case "3dda0004-957f-7d4a-34a6-74696673696d":
|
||||||
case "3dda0003-957f-7d4a-34a6-74696673696d": {
|
case "3dda0003-957f-7d4a-34a6-74696673696d": {
|
||||||
if (filePutRequest != null) {
|
if (filePutRequest != null) {
|
||||||
@ -192,10 +261,12 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
filePutRequest.handleResponse(characteristic);
|
filePutRequest.handleResponse(characteristic);
|
||||||
|
|
||||||
if (filePutRequest.isFinished()) {
|
if (filePutRequest.isFinished()) {
|
||||||
|
log("filePutRequets finished");
|
||||||
filePutRequest = null;
|
filePutRequest = null;
|
||||||
try {
|
try {
|
||||||
queueWrite(requestQueue.remove());
|
queueWrite(requestQueue.remove());
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
|
log("requestsQueue empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fileGetRequest != null) {
|
} else if (fileGetRequest != null) {
|
||||||
@ -209,10 +280,12 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (requestFinished) {
|
if (requestFinished) {
|
||||||
|
log("fileGetRequest finished");
|
||||||
fileGetRequest = null;
|
fileGetRequest = null;
|
||||||
try {
|
try {
|
||||||
queueWrite(requestQueue.remove());
|
queueWrite(requestQueue.remove());
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
|
log("requestsQueue empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fileLookupRequest != null) {
|
} else if (fileLookupRequest != null) {
|
||||||
@ -226,29 +299,48 @@ public class FossilWatchAdapter extends WatchAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (requestFinished) {
|
if (requestFinished) {
|
||||||
|
log("fileLookupRequest finished");
|
||||||
fileLookupRequest = null;
|
fileLookupRequest = null;
|
||||||
try {
|
try {
|
||||||
queueWrite(requestQueue.remove());
|
queueWrite(requestQueue.remove());
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
|
log("requestsQueue empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
queueWrite(requestQueue.remove());
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
log("requestsQueue empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void log(String message){
|
||||||
|
Log.d("FossilWatchAdapter", message);
|
||||||
|
}
|
||||||
|
|
||||||
public void queueWrite(Request request) {
|
public void queueWrite(Request request) {
|
||||||
|
if(request.isBasicRequest()){
|
||||||
|
try {
|
||||||
|
queueWrite(requestQueue.remove());
|
||||||
|
}catch (NoSuchElementException e){}
|
||||||
|
}else {
|
||||||
if (filePutRequest != null || fileGetRequest != null || fileLookupRequest != null) {
|
if (filePutRequest != null || fileGetRequest != null || fileLookupRequest != null) {
|
||||||
Log.d("FossilWatchAdapter", "queing request");
|
Log.d("FossilWatchAdapter", "queing request: " + request.getName());
|
||||||
requestQueue.add(request);
|
requestQueue.add(request);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
log("executing request directly: " + request.getName());
|
||||||
|
|
||||||
if (request instanceof FilePutRequest) filePutRequest = (FilePutRequest) request;
|
if (request instanceof FilePutRequest) filePutRequest = (FilePutRequest) request;
|
||||||
else if (request instanceof FileGetRequest) fileGetRequest = (FileGetRequest) request;
|
else if (request instanceof FileGetRequest) fileGetRequest = (FileGetRequest) request;
|
||||||
else if (request instanceof FileLookupRequest)
|
else if (request instanceof FileLookupRequest)
|
||||||
fileLookupRequest = (FileLookupRequest) request;
|
fileLookupRequest = (FileLookupRequest) request;
|
||||||
|
}
|
||||||
|
|
||||||
new TransactionBuilder(request.getClass().getSimpleName()).write(getDeviceSupport().getCharacteristic(request.getRequestUUID()), request.getRequestData()).queue(getDeviceSupport().getQueue());
|
new TransactionBuilder(request.getClass().getSimpleName()).write(getDeviceSupport().getCharacteristic(request.getRequestUUID()), request.getRequestData()).queue(getDeviceSupport().getQueue());
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,9 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
|||||||
requestQueue.add(new SetCurrentStepCountRequest((int) (999999 * getDeviceSupport().calculateNotificationProgress())));
|
requestQueue.add(new SetCurrentStepCountRequest((int) (999999 * getDeviceSupport().calculateNotificationProgress())));
|
||||||
|
|
||||||
queueWrite(new GetCurrentStepCountRequest());
|
queueWrite(new GetCurrentStepCountRequest());
|
||||||
|
|
||||||
|
getDeviceSupport().getDevice().setState(GBDevice.State.INITIALIZED);
|
||||||
|
getDeviceSupport().getDevice().sendDeviceUpdateIntent(getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -384,6 +387,11 @@ public class MisfitWatchAdapter extends WatchAdapter {
|
|||||||
queueWrite(new SetVibrationStrengthRequest(strength));
|
queueWrite(new SetVibrationStrengthRequest(strength));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void syncNotificationSettings() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTestNewFunction() {
|
public void onTestNewFunction() {
|
||||||
|
|
||||||
|
@ -49,6 +49,10 @@ public abstract class Request {
|
|||||||
Log.d(getName(), message);
|
Log.d(getName(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBasicRequest(){
|
||||||
|
return this.getRequestUUID().toString().equals("3dda0002-957f-7d4a-34a6-74696673696d");
|
||||||
|
}
|
||||||
|
|
||||||
public boolean expectsResponse(){
|
public boolean expectsResponse(){
|
||||||
return this.data[0] == 1;
|
return this.data[0] == 1;
|
||||||
}
|
}
|
||||||
|
@ -30,5 +30,7 @@ public class ConfigurationGetRequest extends FileLookupAndGetRequest {
|
|||||||
device.addDeviceInfo(new GenericItem(QHybridSupport.ITEM_STEP_COUNT, String.valueOf(((ConfigurationPutRequest.CurrentStepCountConfigItem) item).getValue())));
|
device.addDeviceInfo(new GenericItem(QHybridSupport.ITEM_STEP_COUNT, String.valueOf(((ConfigurationPutRequest.CurrentStepCountConfigItem) item).getValue())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.sendDeviceUpdateIntent(getAdapter().getContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public class ConfigurationPutRequest extends FilePutRequest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short getId() {
|
public short getId() {
|
||||||
return 0;
|
return this.configId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,7 @@ public class FileLookupRequest extends Request {
|
|||||||
|
|
||||||
private byte[] fileData;
|
private byte[] fileData;
|
||||||
|
|
||||||
private boolean finished = false;
|
protected boolean finished = false;
|
||||||
|
|
||||||
public FileLookupRequest(byte fileType, FossilWatchAdapter adapter) {
|
public FileLookupRequest(byte fileType, FossilWatchAdapter adapter) {
|
||||||
this.fileType = fileType;
|
this.fileType = fileType;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
import android.bluetooth.BluetoothGattCharacteristic;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
@ -12,6 +13,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.CRC32C;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.CRC32C;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.Request;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.Request;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||||
|
|
||||||
public abstract class FilePutRequest extends Request {
|
public abstract class FilePutRequest extends Request {
|
||||||
public enum UploadState{INITIALIZED, UPLOADING, CLOSING, UPLOADED, ERROR}
|
public enum UploadState{INITIALIZED, UPLOADING, CLOSING, UPLOADED, ERROR}
|
||||||
@ -165,6 +167,24 @@ public abstract class FilePutRequest extends Request {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 9: {
|
||||||
|
GB.toast("timeout writing file", Toast.LENGTH_SHORT, GB.ERROR);
|
||||||
|
|
||||||
|
ByteBuffer buffer2 = ByteBuffer.allocate(3);
|
||||||
|
buffer2.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
buffer2.put((byte) 4);
|
||||||
|
buffer2.putShort(this.handle);
|
||||||
|
|
||||||
|
new TransactionBuilder("file close")
|
||||||
|
.write(
|
||||||
|
adapter.getDeviceSupport().getCharacteristic(UUID.fromString("3dda0003-957f-7d4a-34a6-74696673696d")),
|
||||||
|
buffer2.array()
|
||||||
|
)
|
||||||
|
.queue(adapter.getDeviceSupport().getQueue());
|
||||||
|
|
||||||
|
this.state = UploadState.CLOSING;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fo
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
||||||
@ -12,6 +13,11 @@ public class NotificationFilterPutRequest extends FilePutRequest {
|
|||||||
super((short) 0x0C00, createFile(configs), adapter);
|
super((short) 0x0C00, createFile(configs), adapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public NotificationFilterPutRequest(ArrayList<NotificationConfiguration> configs, FossilWatchAdapter adapter) {
|
||||||
|
super((short) 0x0C00, createFile(configs.toArray(new NotificationConfiguration[0])), adapter);
|
||||||
|
}
|
||||||
|
|
||||||
private static byte[] createFile(NotificationConfiguration[] configs){
|
private static byte[] createFile(NotificationConfiguration[] configs){
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(configs.length * 27);
|
ByteBuffer buffer = ByteBuffer.allocate(configs.length * 27);
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
@ -39,7 +45,7 @@ public class NotificationFilterPutRequest extends FilePutRequest {
|
|||||||
buffer.putShort(config.getHour())
|
buffer.putShort(config.getHour())
|
||||||
.putShort(config.getMin())
|
.putShort(config.getMin())
|
||||||
.putShort(config.getSubEye())
|
.putShort(config.getSubEye())
|
||||||
.putShort((short) 1000);
|
.putShort((short) 5000);
|
||||||
|
|
||||||
buffer.put(PacketID.VIBRATION.id);
|
buffer.put(PacketID.VIBRATION.id);
|
||||||
buffer.put((byte) 1);
|
buffer.put((byte) 1);
|
||||||
|
@ -17,7 +17,7 @@ public class PlayNotificationRequest extends FilePutRequest {
|
|||||||
private static byte[] createFile(String packageName){
|
private static byte[] createFile(String packageName){
|
||||||
CRC32 crc = new CRC32();
|
CRC32 crc = new CRC32();
|
||||||
crc.update(packageName.getBytes());
|
crc.update(packageName.getBytes());
|
||||||
return createFile("", "", "", (int)crc.getValue());
|
return createFile(packageName, packageName, packageName, (int)crc.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] createFile(String title, String sender, String message, int packageCrc) {
|
private static byte[] createFile(String title, String sender, String message, int packageCrc) {
|
||||||
|
@ -8,7 +8,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.Req
|
|||||||
public class PlayNotificationRequest extends Request {
|
public class PlayNotificationRequest extends Request {
|
||||||
|
|
||||||
public enum VibrationType{
|
public enum VibrationType{
|
||||||
WHATEVER(4),
|
|
||||||
SINGLE_SHORT(3),
|
SINGLE_SHORT(3),
|
||||||
DOUBLE_SHORT(2),
|
DOUBLE_SHORT(2),
|
||||||
TRIPLE_SHORT(1),
|
TRIPLE_SHORT(1),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user