Pebble: Allow installation of aplite apps on diorite

This commit is contained in:
Andreas Shimokawa 2016-06-16 00:59:15 +02:00
parent b79b94809a
commit 9f61458790
1 changed files with 22 additions and 10 deletions

View File

@ -96,23 +96,35 @@ public class PBWReader {
String platformDir = ""; String platformDir = "";
if (!uri.toString().endsWith(".pbz")) { if (!uri.toString().endsWith(".pbz")) {
platformDir = platform + "/";
/* /*
* for aplite and basalt it is possible to install 2.x apps which have no subfolder * for aplite and basalt it is possible to install 2.x apps which have no subfolder
* we still prefer the subfolders if present. * we still prefer the subfolders if present.
* chalk needs to be its subfolder * chalk needs to be its subfolder
*/ */
if (platform.equals("aplite") || platform.equals("basalt") || platform.equals("diorite")) { String[] platformDirs;
boolean hasPlatformDir = false; 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)); InputStream afin = new BufferedInputStream(cr.openInputStream(uri));
ZipInputStream zis = new ZipInputStream(afin); ZipInputStream zis = new ZipInputStream(afin);
ZipEntry ze; ZipEntry ze;
try { try {
while ((ze = zis.getNextEntry()) != null) { while ((ze = zis.getNextEntry()) != null) {
if (ze.getName().startsWith(platformDir)) { if (ze.getName().startsWith(dir)) {
hasPlatformDir = true; platformDir = dir;
break; break;
} }
} }
@ -120,13 +132,13 @@ public class PBWReader {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if (!hasPlatformDir) {
platformDir = "";
}
}
} }
if (platform.equals("chalk") && platformDir.equals("")) {
return;
}
}
LOG.info("using platformdir: '" + platformDir + "'");
String appName = null; String appName = null;
String appCreator = null; String appCreator = null;
String appVersion = null; String appVersion = null;