Skip to content

Commit afd8f6f

Browse files
committed
Remove previous permissions, fixes #326
1 parent a43374c commit afd8f6f

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/processing/mode/android/AndroidBuild.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ public File createProject(String targetID, boolean external, boolean wear)
226226
Platform.openFolder(tmpFolder);
227227
}
228228

229+
if (!external) {
230+
// If creating an export project, then the manifest might have attributes
231+
// that create trouble with gradle, so we just re-write it...
232+
// TODO: the current manifest logic is exceeded by the complexity of the mode
233+
// need to rewrite.
234+
rewriteManifest = true;
235+
}
229236
manifest = new Manifest(sketch, appComponent, mode.getFolder(), rewriteManifest);
230237
manifest.setSdkTarget(target_sdk);
231238
rewriteManifest = false;
@@ -239,7 +246,8 @@ public File createProject(String targetID, boolean external, boolean wear)
239246
sketchClassName = preprocess(srcFolder, getPackageName(), preproc, false);
240247
if (sketchClassName != null) {
241248
File tempManifest = new File(tmpFolder, "AndroidManifest.xml");
242-
manifest.writeCopy(tempManifest, sketchClassName, target.equals("debug"));
249+
250+
manifest.writeCopy(tempManifest, sketchClassName, external, target.equals("debug"));
243251

244252
writeAntProps(new File(tmpFolder, "ant.properties"));
245253
buildFile = new File(tmpFolder, "build.xml");
@@ -586,15 +594,7 @@ public File exportProject() throws IOException, SketchException {
586594
Preferences.set("android.export.build_system", buildSystem);
587595
}
588596

589-
// if (buildSystem.equals("ant")) {
590-
// // this will set debuggable to true in the manifest file
591-
// target = "debug";
592-
// } else {
593-
// // debuggable property should not set in the manifest file when building
594-
// // with gradle
595-
// target = "";
596-
// }
597-
target = "debug";
597+
this.target = "debug";
598598

599599
String targetID = getTargetID();
600600

src/processing/mode/android/Manifest.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,17 @@ public void setPermissions(String[] names) {
165165
// just remove all the old ones
166166
for (XML kid : xml.getChildren("uses-permission")) {
167167
String name = kid.getString("android:name");
168-
// Don't remove required permissions for wallpapers, watchfaces and VR.
169-
if (-1 < name.indexOf(".")) continue;
168+
// Don't remove required permissions for wallpapers, watchfaces and VR.
170169
if (appComp == AndroidBuild.WALLPAPER) {
171170
} else if (appComp == AndroidBuild.WATCHFACE) {
172171
if (name.equals("WAKE_LOCK")) continue;
173172
} else if (appComp == AndroidBuild.VR) {
174-
if (name.equals("INTERNET") ||
175-
name.equals("NFC") ||
176-
name.equals("VIBRATE") ||
177-
name.equals("READ_EXTERNAL_STORAGE") ||
178-
name.equals("WRITE_EXTERNAL_STORAGE")) continue;
173+
if (name.equals("VIBRATE") ||
174+
name.equals("READ_EXTERNAL_STORAGE")) continue;
179175
}
176+
// Don't remove non-standard permissions, such as
177+
// com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA
178+
if (-1 < name.indexOf("com.google.android")) continue;
180179
xml.removeChild(kid);
181180
}
182181
// ...and add the new kids back
@@ -186,12 +185,9 @@ public void setPermissions(String[] names) {
186185
} else if (appComp == AndroidBuild.WATCHFACE) {
187186
if (name.equals("WAKE_LOCK")) continue;
188187
} else if (appComp == AndroidBuild.VR) {
189-
if (name.equals("INTERNET") ||
190-
name.equals("NFC") ||
191-
name.equals("VIBRATE") ||
192-
name.equals("READ_EXTERNAL_STORAGE") ||
193-
name.equals("WRITE_EXTERNAL_STORAGE")) continue;
194-
}
188+
if (name.equals("VIBRATE") ||
189+
name.equals("READ_EXTERNAL_STORAGE")) continue;
190+
}
195191
XML newbie = xml.addChild("uses-permission");
196192
if (-1 < name.indexOf(".")) {
197193
// Permission string contains path
@@ -226,8 +222,8 @@ private void writeBlankManifest(final File xmlFile, final int appComp) {
226222
* Save a new version of the manifest info to the build location.
227223
* Also fill in any missing attributes that aren't yet set properly.
228224
*/
229-
protected void writeCopy(File file, String className,
230-
boolean debug) throws IOException {
225+
protected void writeCopy(File file, String className, boolean setDebugAttrib,
226+
boolean debug) throws IOException {
231227
// write a copy to the build location
232228
save(file);
233229

@@ -257,7 +253,9 @@ protected void writeCopy(File file, String className,
257253
}
258254
}
259255

260-
app.setString("android:debuggable", debug ? "true" : "false");
256+
if (setDebugAttrib) {
257+
app.setString("android:debuggable", debug ? "true" : "false");
258+
}
261259

262260
// XML activity = app.getChild("activity");
263261
// the '.' prefix is just an alias for the full package name

0 commit comments

Comments
 (0)