mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-24 16:21:16 +02:00
Refactoring: Merge Pebble app/fw installer activity and Miband firmware update Activity
This commit is contained in:
parent
c3853c7735
commit
9f591ef8b5
@ -60,24 +60,67 @@
|
||||
android:value=".ControlCenter" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".pebble.PebbleAppInstallerActivity"
|
||||
android:label="@string/title_activity_appinstaller">
|
||||
android:name=".activities.FwAppInstallerActivity"
|
||||
android:label="@string/title_activity_fw_app_insaller">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".AppManagerActivity" />
|
||||
|
||||
android:value="nodomain.freeyourgadget.gadgetbridge.ControlCenter" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="*/*" /> <!-- needed for android 5 -->
|
||||
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
|
||||
<!-- as seen on openkeychain repo: https://github.com/open-keychain/open-keychain/blob/master/OpenKeychain/src/main/AndroidManifest.xml -->
|
||||
|
||||
<data android:pathPattern=".*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
|
||||
<!-- as seen on openkeychain repo: https://github.com/open-keychain/open-keychain/blob/master/OpenKeychain/src/main/AndroidManifest.xml -->
|
||||
|
||||
<data android:pathPattern=".*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbw" />
|
||||
|
||||
<data android:pathPattern=".*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbz" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.pbz" />
|
||||
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<service
|
||||
android:name=".externalevents.NotificationListener"
|
||||
android:label="@string/app_name"
|
||||
@ -203,36 +246,6 @@
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="nodomain.freeyourgadget.gadgetbridge.activities.ConfigureAlarms" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".miband.FwUpgrade"
|
||||
android:label="@string/title_activity_fw_upgrade">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value="nodomain.freeyourgadget.gadgetbridge.ControlCenter" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
|
||||
<data android:mimeType="*/*" /> <!-- needed for android 5 -->
|
||||
|
||||
<data android:host="*" />
|
||||
<data android:scheme="file" />
|
||||
|
||||
<!-- as seen on openkeychain repo: https://github.com/open-keychain/open-keychain/blob/master/OpenKeychain/src/main/AndroidManifest.xml -->
|
||||
|
||||
<data android:pathPattern=".*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\..*\\.fw" />
|
||||
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -22,7 +22,6 @@ import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.DeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.DeviceHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.pebble;
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
@ -19,19 +19,25 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.ControlCenter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.miband.MiBandFWHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.pebble.PBWReader;
|
||||
|
||||
|
||||
public class PebbleAppInstallerActivity extends Activity {
|
||||
public class FwAppInstallerActivity extends Activity {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PebbleAppInstallerActivity.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FwAppInstallerActivity.class);
|
||||
|
||||
TextView debugTextView;
|
||||
TextView fwAppInstallTextView;
|
||||
Button installButton;
|
||||
|
||||
// FIXME: abstraction for these would make code cleaner in this class
|
||||
private PBWReader mPBWReader = null;
|
||||
private MiBandFWHelper mFwReader = null;
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@ -40,7 +46,7 @@ public class PebbleAppInstallerActivity extends Activity {
|
||||
finish();
|
||||
} else if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
|
||||
GBDevice dev = intent.getParcelableExtra("device");
|
||||
if (mPBWReader != null) {
|
||||
if (dev.getType() == DeviceType.PEBBLE && mPBWReader != null) {
|
||||
if (mPBWReader.isFirmware()) {
|
||||
String hwRevision = mPBWReader.getHWRevision();
|
||||
if (hwRevision != null && hwRevision.equals(dev.getHardwareVersion()) && dev.isConnected()) {
|
||||
@ -51,6 +57,8 @@ public class PebbleAppInstallerActivity extends Activity {
|
||||
} else {
|
||||
installButton.setEnabled(dev.isConnected());
|
||||
}
|
||||
} else if (dev.getType() == DeviceType.MIBAND && mFwReader != null) {
|
||||
installButton.setEnabled(dev.isInitialized());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,7 +70,7 @@ public class PebbleAppInstallerActivity extends Activity {
|
||||
setContentView(R.layout.activity_appinstaller);
|
||||
getActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
debugTextView = (TextView) findViewById(R.id.debugTextView);
|
||||
fwAppInstallTextView = (TextView) findViewById(R.id.debugTextView);
|
||||
installButton = (Button) findViewById(R.id.installButton);
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ControlCenter.ACTION_QUIT);
|
||||
@ -71,19 +79,33 @@ public class PebbleAppInstallerActivity extends Activity {
|
||||
|
||||
final Uri uri = getIntent().getData();
|
||||
mPBWReader = new PBWReader(uri, getApplicationContext());
|
||||
GBDeviceApp app = mPBWReader.getGBDeviceApp();
|
||||
if (mPBWReader.isValid()) {
|
||||
GBDeviceApp app = mPBWReader.getGBDeviceApp();
|
||||
|
||||
if (mPBWReader.isFirmware()) {
|
||||
debugTextView.setText(getString(R.string.firmware_install_warning, mPBWReader.getHWRevision()));
|
||||
if (mPBWReader.isFirmware()) {
|
||||
fwAppInstallTextView.setText(getString(R.string.firmware_install_warning, mPBWReader.getHWRevision()));
|
||||
|
||||
} else if (app != null) {
|
||||
debugTextView.setText(getString(R.string.app_install_info, app.getName(), app.getVersion(), app.getCreator()));
|
||||
} else if (app != null) {
|
||||
fwAppInstallTextView.setText(getString(R.string.app_install_info, app.getName(), app.getVersion(), app.getCreator()));
|
||||
}
|
||||
} else {
|
||||
mPBWReader = null;
|
||||
mFwReader = new MiBandFWHelper(uri, getApplicationContext());
|
||||
|
||||
fwAppInstallTextView.setText(getString(R.string.fw_upgrade_notice, mFwReader.getHumanFirmwareVersion()));
|
||||
|
||||
if (mFwReader.isFirmwareWhitelisted()) {
|
||||
fwAppInstallTextView.append(" " + getString(R.string.miband_firmware_known));
|
||||
} else {
|
||||
fwAppInstallTextView.append(" " + getString(R.string.miband_firmware_unknown_warning) + " " +
|
||||
getString(R.string.miband_firmware_suggest_whitelist, mFwReader.getFirmwareVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
installButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent startIntent = new Intent(PebbleAppInstallerActivity.this, BluetoothCommunicationService.class);
|
||||
Intent startIntent = new Intent(FwAppInstallerActivity.this, BluetoothCommunicationService.class);
|
||||
startIntent.setAction(BluetoothCommunicationService.ACTION_INSTALL);
|
||||
startIntent.putExtra("uri", uri.toString());
|
||||
startService(startIntent);
|
@ -2,7 +2,6 @@ package nodomain.freeyourgadget.gadgetbridge.charts;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.SampleProvider;
|
||||
|
||||
public class ActivityKind {
|
||||
|
@ -1,7 +1,5 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.charts;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
|
||||
public class SleepUtils {
|
||||
public static final float Y_VALUE_DEEP_SLEEP = 0.01f;
|
||||
public static final float Y_VALUE_LIGHT_SLEEP = 0.016f;
|
||||
|
@ -107,11 +107,12 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper {
|
||||
|
||||
/**
|
||||
* Adds the a new sample to the database
|
||||
*
|
||||
* @param timestamp the timestamp of the same, second-based!
|
||||
* @param provider the SampleProvider ID
|
||||
* @param provider the SampleProvider ID
|
||||
* @param intensity the sample's raw intensity value
|
||||
* @param steps the sample's steps value
|
||||
* @param kind the raw activity kind of the sample
|
||||
* @param steps the sample's steps value
|
||||
* @param kind the raw activity kind of the sample
|
||||
*/
|
||||
public void addGBActivitySample(int timestamp, byte provider, short intensity, byte steps, byte kind) {
|
||||
try (SQLiteDatabase db = this.getWritableDatabase()) {
|
||||
@ -145,7 +146,7 @@ public class ActivityDatabaseHandler extends SQLiteOpenHelper {
|
||||
* @param timestamp_from
|
||||
* @param timestamp_to
|
||||
* @param activityTypes ORed combination of #TYPE_DEEP_SLEEP, #TYPE_LIGHT_SLEEP, #TYPE_ACTIVITY
|
||||
* @param provider the producer of the samples to be sought
|
||||
* @param provider the producer of the samples to be sought
|
||||
* @return
|
||||
*/
|
||||
private ArrayList<ActivitySample> getGBActivitySamples(int timestamp_from, int timestamp_to, int activityTypes, SampleProvider provider) {
|
||||
|
@ -1,106 +0,0 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.miband;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BluetoothCommunicationService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.ControlCenter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
|
||||
|
||||
/*
|
||||
TODO: This could be moved to activities package and merged with pebble/PebbleAppInstallerActivity.java
|
||||
*/
|
||||
|
||||
public class FwUpgrade extends Activity {
|
||||
|
||||
|
||||
TextView fwUpgradeTextView;
|
||||
Button installButton;
|
||||
|
||||
private MiBandFWHelper mFwReader = null;
|
||||
private GBDevice dev;
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(ControlCenter.ACTION_QUIT)) {
|
||||
finish();
|
||||
} else if (action.equals(GBDevice.ACTION_DEVICE_CHANGED)) {
|
||||
dev = intent.getParcelableExtra("device");
|
||||
if(dev.getType() == DeviceType.MIBAND) {
|
||||
if (dev.isInitialized() && mFwReader != null) {
|
||||
installButton.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_fw_upgrade);
|
||||
|
||||
fwUpgradeTextView = (TextView) findViewById(R.id.fwUpgradeTextView);
|
||||
installButton = (Button) findViewById(R.id.installButton);
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(ControlCenter.ACTION_QUIT);
|
||||
filter.addAction(GBDevice.ACTION_DEVICE_CHANGED);
|
||||
LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver, filter);
|
||||
|
||||
final Uri uri = getIntent().getData();
|
||||
mFwReader = new MiBandFWHelper(uri, getApplicationContext());
|
||||
|
||||
fwUpgradeTextView.setText(getString(R.string.fw_upgrade_notice, mFwReader.getHumanFirmwareVersion()));
|
||||
|
||||
if (mFwReader.isFirmwareWhitelisted()) {
|
||||
fwUpgradeTextView.append(" " + getString(R.string.miband_firmware_known));
|
||||
}else {
|
||||
fwUpgradeTextView.append(" " + getString(R.string.miband_firmware_unknown_warning) + " " +
|
||||
getString(R.string.miband_firmware_suggest_whitelist, mFwReader.getFirmwareVersion()));
|
||||
}
|
||||
|
||||
installButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent startIntent = new Intent(FwUpgrade.this, BluetoothCommunicationService.class);
|
||||
startIntent.setAction(BluetoothCommunicationService.ACTION_INSTALL);
|
||||
startIntent.putExtra("uri", uri.toString());
|
||||
startService(startIntent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
@ -18,14 +18,14 @@ public class MiBandFWHelper {
|
||||
private final ContentResolver cr;
|
||||
private byte[] fw;
|
||||
|
||||
private final int firmwareVersionBuild = 1056;
|
||||
private final int firmwareVersionBuild = 1056;
|
||||
private final int firmwareVersionRevision = 1057;
|
||||
private final int firmwareVersionMinor = 1058;
|
||||
private final int firmwareVersionMajor = 1059;
|
||||
private final int firmwareVersionMinor = 1058;
|
||||
private final int firmwareVersionMajor = 1059;
|
||||
|
||||
private final int[] whitelistedFirmwareVersion = {
|
||||
16779534, // 1.0.9.14 tested by developer
|
||||
16779547 //1.0.9.27 testd by developer
|
||||
16779534, // 1.0.9.14 tested by developer
|
||||
16779547 //1.0.9.27 testd by developer
|
||||
};
|
||||
|
||||
public MiBandFWHelper(Uri uri, Context context) {
|
||||
@ -45,7 +45,7 @@ public class MiBandFWHelper {
|
||||
this.fw = null;
|
||||
}
|
||||
|
||||
if (fw[firmwareVersionMajor] != 1 ) {
|
||||
if (fw[firmwareVersionMajor] != 1) {
|
||||
LOG.error("Firmware major version should be 1, probably this isn't a MiBand firmware.");
|
||||
this.fw = null;
|
||||
}
|
||||
@ -53,14 +53,14 @@ public class MiBandFWHelper {
|
||||
}
|
||||
|
||||
public int getFirmwareVersion() {
|
||||
if(fw == null) {
|
||||
if (fw == null) {
|
||||
return -1;
|
||||
}
|
||||
return (fw[firmwareVersionMajor] << 24) | (fw[firmwareVersionMinor] << 16) | (fw[firmwareVersionRevision] << 8) | fw[firmwareVersionBuild];
|
||||
}
|
||||
|
||||
public String getHumanFirmwareVersion() {
|
||||
if(fw == null) {
|
||||
if (fw == null) {
|
||||
return "UNK";
|
||||
}
|
||||
return String.format(Locale.US, "%d.%d.%d.%d", fw[firmwareVersionMajor], fw[firmwareVersionMinor], fw[firmwareVersionRevision], fw[firmwareVersionBuild]);
|
||||
@ -83,8 +83,8 @@ public class MiBandFWHelper {
|
||||
public int getCRC16(byte[] seq) {
|
||||
int crc = 0xFFFF;
|
||||
|
||||
for (int j = 0; j < seq.length ; j++) {
|
||||
crc = ((crc >>> 8) | (crc << 8) )& 0xffff;
|
||||
for (int j = 0; j < seq.length; j++) {
|
||||
crc = ((crc >>> 8) | (crc << 8)) & 0xffff;
|
||||
crc ^= (seq[j] & 0xff);//byte to int, trunc sign
|
||||
crc ^= ((crc & 0xff) >> 4);
|
||||
crc ^= (crc << 12) & 0xffff;
|
||||
@ -94,4 +94,4 @@ public class MiBandFWHelper {
|
||||
return crc;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class MiBandSampleProvider implements SampleProvider {
|
||||
return ActivityKind.TYPE_ACTIVITY;
|
||||
default:
|
||||
// case TYPE_UNKNOWN: // fall through
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
return ActivityKind.TYPE_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBAlarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
|
||||
@ -543,7 +542,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
int oldFwVersion = mDeviceInfo.getFirmwareVersion();
|
||||
int checksum = (Integer.decode("0x" + mMacOctets[4]) << 8 | Integer.decode("0x" + mMacOctets[5])) ^ mFwHelper.getCRC16(mFwHelper.getFw());
|
||||
|
||||
sendFirmwareInfo(oldFwVersion,newFwVersion, mFwHelper.getFw().length, checksum);
|
||||
sendFirmwareInfo(oldFwVersion, newFwVersion, mFwHelper.getFw().length, checksum);
|
||||
sendFirmwareData(mFwHelper.getFw());
|
||||
onReboot();
|
||||
|
||||
@ -900,7 +899,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
firmwareProgress += packetLength;
|
||||
|
||||
if ((i > 0) && (i % 50 == 0)) {
|
||||
if(!sendFirmwareSync()) {
|
||||
if (!sendFirmwareSync()) {
|
||||
LOG.error("Firmware sync failed");
|
||||
return;
|
||||
}
|
||||
@ -918,9 +917,9 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
firmwareProgress += len % packetLength;
|
||||
}
|
||||
|
||||
LOG.info("Firmware update progress:" + firmwareProgress +" total lenL:"+ len + " progress:" + firmwareProgress/len);
|
||||
LOG.info("Firmware update progress:" + firmwareProgress + " total lenL:" + len + " progress:" + firmwareProgress / len);
|
||||
|
||||
if(!sendFirmwareSync()) {
|
||||
if (!sendFirmwareSync()) {
|
||||
LOG.error("Firmware sync failed");
|
||||
return;
|
||||
}
|
||||
@ -942,7 +941,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
|
||||
private boolean sendFirmwareSync() {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("send firmware sync");
|
||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[] {MiBandService.COMMAND_SYNC});
|
||||
builder.write(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_CONTROL_POINT), new byte[]{MiBandService.COMMAND_SYNC});
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to send firmware sync to MI", ex);
|
||||
|
@ -5,6 +5,7 @@ import nodomain.freeyourgadget.gadgetbridge.charts.ActivityKind;
|
||||
public interface ActivitySample {
|
||||
/**
|
||||
* Returns the provider of the data.
|
||||
*
|
||||
* @return who created the sample data
|
||||
*/
|
||||
SampleProvider getProvider();
|
||||
@ -21,6 +22,7 @@ public interface ActivitySample {
|
||||
|
||||
/**
|
||||
* Returns the activity kind value as recorded by the SampleProvider
|
||||
*
|
||||
* @see ActivityKind
|
||||
*/
|
||||
int getKind();
|
||||
|
@ -12,7 +12,6 @@ import java.util.SimpleTimeZone;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
|
@ -44,7 +44,7 @@ public class MorpheuzSampleProvider implements SampleProvider {
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(short rawIntensity) {
|
||||
return rawIntensity/movementDivisor;
|
||||
return rawIntensity / movementDivisor;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,6 @@ import java.util.SimpleTimeZone;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||
|
@ -47,6 +47,7 @@ public class PBWReader {
|
||||
private GBDeviceApp app;
|
||||
private ArrayList<PebbleInstallable> pebbleInstallables;
|
||||
private boolean isFirmware = false;
|
||||
private boolean isValid = false;
|
||||
private String hwRevision = null;
|
||||
|
||||
public PBWReader(Uri uri, Context context) {
|
||||
@ -102,12 +103,14 @@ public class PBWReader {
|
||||
byte type = entry.getValue();
|
||||
pebbleInstallables.add(new PebbleInstallable(name, size, (int) crc, type));
|
||||
LOG.info("found file to install: " + name);
|
||||
isValid = true;
|
||||
} catch (JSONException e) {
|
||||
// not fatal
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
// no JSON at all that is a problem
|
||||
isValid = false;
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
@ -132,9 +135,11 @@ public class PBWReader {
|
||||
if (appName != null && appCreator != null && appVersion != null) {
|
||||
// FIXME: dont assume WATCHFACE
|
||||
app = new GBDeviceApp(uuid, appName, appCreator, appVersion, GBDeviceApp.Type.WATCHFACE);
|
||||
isValid = true;
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
isValid = false;
|
||||
e.printStackTrace();
|
||||
break;
|
||||
}
|
||||
@ -146,10 +151,14 @@ public class PBWReader {
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isFirmware() {
|
||||
public boolean isFirmware() {
|
||||
return isFirmware;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public GBDeviceApp getGBDeviceApp() {
|
||||
return app;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.pebble.PebbleAppInstallerActivity">
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.activities.FwAppInstallerActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/debugTextView"
|
||||
|
@ -1,21 +0,0 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="nodomain.freeyourgadget.gadgetbridge.miband.FwUpgrade">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/fwUpgradeTextView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/appinstaller_install"
|
||||
android:id="@+id/installButton"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:enabled="false" />
|
||||
</RelativeLayout>
|
@ -18,8 +18,12 @@
|
||||
<string name="title_activity_appmanager">App Manager</string>
|
||||
<string name="appmananger_app_delete">Delete</string>
|
||||
|
||||
<!-- Strings related to AppInstaller -->
|
||||
<string name="title_activity_appinstaller">App Installer</string>
|
||||
<!-- Strings related to FwAppInstaller -->
|
||||
<string name="title_activity_fw_app_insaller">FW/App installer</string>
|
||||
<string name="fw_upgrade_notice">You are about to install firmware %s instead of the one currently on your MiBand.</string>
|
||||
<string name="miband_firmware_known">This firmware has been tested and is known to be compatible with GadgetBridge.</string>
|
||||
<string name="miband_firmware_unknown_warning">"This firmware is untested and may not be compatible with GadgetBridge. You are not encouraged to flash it to your MiBand. "</string>
|
||||
<string name="miband_firmware_suggest_whitelist">If you still want to proceed and things continue to work properly afterwards, please tell the GadgetBridge developers to whitelist firmware version: %s</string>
|
||||
|
||||
<!-- Strings related to Settings -->
|
||||
<string name="title_activity_settings">Settings</string>
|
||||
@ -153,9 +157,4 @@
|
||||
<string name="user_feedback_miband_set_alarms_ok">Alarms sent to device!</string>
|
||||
<string name="chart_no_data_synchronize">No data. Synchronize device?</string>
|
||||
<string name="user_feedback_miband_activity_data_transfer">About to transfer %1$s of data starting from %2$s</string>
|
||||
<string name="title_activity_fw_upgrade">FwUpgrade</string>
|
||||
<string name="fw_upgrade_notice">You are about to install firmware %s instead of the one currently on your MiBand.</string>
|
||||
<string name="miband_firmware_known">This firmware has been tested and is known to be compatible with GadgetBridge.</string>
|
||||
<string name="miband_firmware_unknown_warning">"This firmware is untested and may not be compatible with GadgetBridge. You are not encouraged to flash it to your MiBand. "</string>
|
||||
<string name="miband_firmware_suggest_whitelist">If you still want to proceed and things continue to work properly afterwards, please tell the GadgetBridge developers to whitelist firmware version: %s</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user