mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-03 17:02:13 +01:00
Pebble: cache installed pbw files on sdcard if force untested option is set
This will be needed for FW 3.x on demand installations.
This commit is contained in:
parent
0be251e83d
commit
5a8c9a9180
@ -98,6 +98,7 @@ public class FwAppInstallerActivity extends Activity implements InstallActivity
|
||||
installButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
installHandler.onStartInstall();
|
||||
Intent startIntent = new Intent(FwAppInstallerActivity.this, DeviceCommunicationService.class);
|
||||
startIntent.setAction(DeviceCommunicationService.ACTION_INSTALL);
|
||||
startIntent.putExtra("uri", uri);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.activities;
|
||||
|
||||
public interface InstallActivity {
|
||||
public void setInfoText(String text);
|
||||
public void setInstallEnabled(boolean enable);
|
||||
void setInfoText(String text);
|
||||
void setInstallEnabled(boolean enable);
|
||||
}
|
||||
|
@ -26,4 +26,9 @@ public interface InstallHandler {
|
||||
* @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();
|
||||
}
|
||||
|
@ -52,6 +52,11 @@ public class MiBandFWInstallHandler implements InstallHandler {
|
||||
installActivity.setInstallEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartInstall() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return helper != null;
|
||||
}
|
||||
|
@ -1,14 +1,21 @@
|
||||
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;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
|
||||
public class PBWInstallHandler implements InstallHandler {
|
||||
|
||||
@ -51,7 +58,30 @@ public class PBWInstallHandler implements InstallHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartInstall() {
|
||||
if (mPBWReader.isFirmware()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(GBApplication.getContext());
|
||||
if (!sharedPrefs.getBoolean("pebble_force_untested", false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GBDeviceApp app = mPBWReader.getGBDeviceApp();
|
||||
File pbwFile = new File(mPBWReader.getUri().getPath());
|
||||
try {
|
||||
File destDir = new File(FileUtils.getExternalFilesDir() + "/pbw-cache");
|
||||
destDir.mkdirs();
|
||||
FileUtils.copyFile(pbwFile, new File(destDir + "/" + app.getUUID().toString() + ".pbw"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return mPBWReader.isValid();
|
||||
}
|
||||
|
||||
}
|
@ -200,4 +200,8 @@ public class PBWReader {
|
||||
public String getHWRevision() {
|
||||
return hwRevision;
|
||||
}
|
||||
|
||||
public Uri getUri() {
|
||||
return uri;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user