mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Pebble: make watchapp installation available on FW 3.x without the need for setting an option
This commit is contained in:
parent
9dd2f039f2
commit
6fede31bdf
@ -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<GBDeviceApp> cachedApps = getCachedApps();
|
||||
for (GBDeviceApp app : cachedApps) {
|
||||
appList.add(app);
|
||||
}
|
||||
List<GBDeviceApp> cachedApps = getCachedApps();
|
||||
for (GBDeviceApp app : cachedApps) {
|
||||
appList.add(app);
|
||||
}
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
*
|
||||
* <p/>
|
||||
* 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);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class MiBandFWInstallHandler implements InstallHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartInstall() {
|
||||
public void onStartInstall(GBDevice device) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user