From 9f61458790d1f1ab7fe496ac7f5dd114f34e3355 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 16 Jun 2016 00:59:15 +0200 Subject: [PATCH] Pebble: Allow installation of aplite apps on diorite --- .../devices/pebble/PBWReader.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java index 8248d257..9e613a23 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PBWReader.java @@ -96,23 +96,35 @@ public class PBWReader { String platformDir = ""; if (!uri.toString().endsWith(".pbz")) { - platformDir = platform + "/"; - /* * for aplite and basalt it is possible to install 2.x apps which have no subfolder * we still prefer the subfolders if present. * chalk needs to be its subfolder */ - if (platform.equals("aplite") || platform.equals("basalt") || platform.equals("diorite")) { - boolean hasPlatformDir = false; + String[] platformDirs; + switch (platform) { + case "basalt": + platformDirs = new String[]{"basalt/"}; + break; + case "chalk": + platformDirs = new String[]{"chalk/"}; + break; + case "diorite": + platformDirs = new String[]{"diorite/", "aplite/"}; + break; + default: + platformDirs = new String[]{"aplite/"}; + } + + for (String dir : platformDirs) { InputStream afin = new BufferedInputStream(cr.openInputStream(uri)); ZipInputStream zis = new ZipInputStream(afin); ZipEntry ze; try { while ((ze = zis.getNextEntry()) != null) { - if (ze.getName().startsWith(platformDir)) { - hasPlatformDir = true; + if (ze.getName().startsWith(dir)) { + platformDir = dir; break; } } @@ -120,13 +132,13 @@ public class PBWReader { } catch (IOException e) { e.printStackTrace(); } + } - if (!hasPlatformDir) { - platformDir = ""; - } + if (platform.equals("chalk") && platformDir.equals("")) { + return; } } - + LOG.info("using platformdir: '" + platformDir + "'"); String appName = null; String appCreator = null; String appVersion = null;