Skip to content

Commit b79c344

Browse files
committed
handle non-standard permissions
1 parent cde8eba commit b79c344

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/processing/mode/android/AndroidBuild.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,8 +1438,14 @@ private void writeResXMLWatchFace(final File xmlFolder) {
14381438
private String generatePermissionsString(final String[] permissions) {
14391439
String permissionsStr = "";
14401440
for (String p: permissions) {
1441-
permissionsStr += (0 < permissionsStr.length()?",":"") +
1442-
(p.indexOf("permission") == -1?"Manifest.permission.":"") + p;
1441+
permissionsStr += (0 < permissionsStr.length() ? "," : "");
1442+
if (p.indexOf("permission") == -1) {
1443+
permissionsStr += "Manifest.permission." + p;
1444+
} else if (p.indexOf("Manifest.permission") == 0) {
1445+
permissionsStr += p;
1446+
} else {
1447+
permissionsStr += "\"" + p + "\"";
1448+
}
14431449
}
14441450
permissionsStr = "{" + permissionsStr + "}";
14451451
return permissionsStr;

src/processing/mode/android/Manifest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,15 @@ public String[] getPermissions() {
137137
String[] names = new String[count];
138138
for (int i = 0; i < count; i++) {
139139
String tmp = elements[i].getString("android:name");
140-
int idx = tmp.lastIndexOf(".");
141-
names[i] = tmp.substring(idx + 1);
140+
if (tmp.indexOf("android.permission") == 0) {
141+
// Standard permission, remove perfix
142+
int idx = tmp.lastIndexOf(".");
143+
names[i] = tmp.substring(idx + 1);
144+
} else {
145+
// Non-standard permission (for example, wearables)
146+
// Store entire name.
147+
names[i] = tmp;
148+
}
142149
}
143150
return names;
144151
}
@@ -175,7 +182,12 @@ public void setPermissions(String[] names) {
175182
name.equals("android.permission.WRITE_EXTERNAL_STORAGE")) continue;
176183
}
177184
XML newbie = xml.addChild("uses-permission");
178-
newbie.setString("android:name", PERMISSION_PREFIX + name);
185+
if (-1 < name.indexOf(".")) {
186+
// Permission string contains path
187+
newbie.setString("android:name", name);
188+
} else {
189+
newbie.setString("android:name", PERMISSION_PREFIX + name);
190+
}
179191
}
180192
save();
181193
}

0 commit comments

Comments
 (0)