From 6fede31bdfee27e8da8a0dbc2be9d6c466ad64a1 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 17 Aug 2015 18:07:47 +0200 Subject: [PATCH] Pebble: make watchapp installation available on FW 3.x without the need for setting an option --- .../gadgetbridge/activities/AppManagerActivity.java | 13 +++---------- .../activities/FwAppInstallerActivity.java | 2 +- .../gadgetbridge/devices/InstallHandler.java | 6 +++--- .../devices/miband/MiBandFWInstallHandler.java | 2 +- .../devices/pebble/PBWInstallHandler.java | 8 ++------ .../service/devices/pebble/PebbleIoThread.java | 4 +--- 6 files changed, 11 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java index 256854172..32292a772 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java @@ -5,9 +5,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.SharedPreferences; import android.os.Bundle; -import android.preference.PreferenceManager; import android.support.v4.app.NavUtils; import android.support.v4.content.LocalBroadcastManager; import android.view.ContextMenu; @@ -25,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAppAdapter; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; @@ -105,13 +102,9 @@ public class AppManagerActivity extends Activity { registerForContextMenu(appListView); - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(GBApplication.getContext()); - - if (sharedPrefs.getBoolean("pebble_force_untested", false)) { - List cachedApps = getCachedApps(); - for (GBDeviceApp app : cachedApps) { - appList.add(app); - } + List cachedApps = getCachedApps(); + for (GBDeviceApp app : cachedApps) { + appList.add(app); } IntentFilter filter = new IntentFilter(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java index f214340c4..9f85914d1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/FwAppInstallerActivity.java @@ -101,7 +101,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity @Override public void onClick(View v) { setInstallEnabled(false); - installHandler.onStartInstall(); + installHandler.onStartInstall(device); Intent startIntent = new Intent(FwAppInstallerActivity.this, DeviceCommunicationService.class); startIntent.setAction(DeviceCommunicationService.ACTION_INSTALL); startIntent.putExtra("uri", uri); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/InstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/InstallHandler.java index 1d42a2bb2..c2d152da1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/InstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/InstallHandler.java @@ -19,16 +19,16 @@ public interface InstallHandler { * Checks whether the installation of the 'element' on the device is possible * and configures the InstallActivity accordingly (sets helpful texts, * enables/disables the "Install" button, etc. - * + *

* Note: may only be called if #isValid previously returned true. * * @param installActivity the activity to interact with - * @param device the device to which the element shall be installed + * @param device the device to which the element shall be installed */ void validateInstallation(InstallActivity installActivity, GBDevice device); /** * Allows device specivic code to be execute just before the installation starts */ - void onStartInstall(); + void onStartInstall(GBDevice device); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWInstallHandler.java index 6697b387d..4c282e781 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWInstallHandler.java @@ -53,7 +53,7 @@ public class MiBandFWInstallHandler implements InstallHandler { } @Override - public void onStartInstall() { + public void onStartInstall(GBDevice device) { } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java index 3fe5fadaa..f7043c104 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWInstallHandler.java @@ -1,14 +1,11 @@ package nodomain.freeyourgadget.gadgetbridge.devices.pebble; import android.content.Context; -import android.content.SharedPreferences; import android.net.Uri; -import android.preference.PreferenceManager; import java.io.File; import java.io.IOException; -import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; @@ -59,13 +56,12 @@ public class PBWInstallHandler implements InstallHandler { } @Override - public void onStartInstall() { + public void onStartInstall(GBDevice device) { if (mPBWReader.isFirmware()) { return; } - SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(GBApplication.getContext()); - if (!sharedPrefs.getBoolean("pebble_force_untested", false)) { + if (!device.getFirmwareVersion().startsWith("v3")) { return; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index 1d229fa02..a268d5866 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -45,7 +45,6 @@ public class PebbleIoThread extends GBDeviceIoThread { private boolean mIsConnected = false; private boolean mIsInstalling = false; private int mConnectionAttempts = 0; - private boolean mForceUntested = false; private PBWReader mPBWReader = null; private int mAppInstallToken = -1; private ZipInputStream mZis = null; @@ -86,7 +85,6 @@ public class PebbleIoThread extends GBDeviceIoThread { SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); mPebbleProtocol.setForceProtocol(sharedPrefs.getBoolean("pebble_force_protocol", false)); - mForceUntested = sharedPrefs.getBoolean("pebble_force_untested", false); gbDevice.setState(GBDevice.State.CONNECTED); gbDevice.sendDeviceUpdateIntent(getContext()); @@ -409,7 +407,7 @@ public class PebbleIoThread extends GBDeviceIoThread { writeInstallApp(mPebbleProtocol.encodeGetTime()); } else { GBDeviceApp app = mPBWReader.getGBDeviceApp(); - if (mPebbleProtocol.isFw3x && mForceUntested) { + if (mPebbleProtocol.isFw3x) { if (appId == 0) { // only install metadata - not the binaries write(mPebbleProtocol.encodeInstallMetadata(app.getUUID(), app.getName(), mPBWReader.getAppVersion(), mPBWReader.getSdkVersion(), mPBWReader.getIconId()));