Skip to content

Commit 4277e21

Browse files
committed
adds android:exported and removes uses-sdk from existing manifest file
1 parent 6967381 commit 4277e21

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

mode/src/processing/mode/android/Manifest.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,33 @@ protected void load(boolean forceNew) {
323323
if (manifestFile.exists()) {
324324
try {
325325
xml = new XML(manifestFile);
326-
326+
327327
XML app = xml.getChild("application");
328328
String icon = app.getString("android:icon");
329329
if (icon.equals("@drawable/icon")) {
330330
// Manifest file generated with older version of the mode, replace icon and save
331331
app.setString("android:icon", "@mipmap/ic_launcher");
332332
if (!forceNew) save();
333-
}
334-
333+
}
334+
335+
XML activity = app.getChild("activity");
336+
XML service = app.getChild("service");
337+
if (activity.getString("android:name").equals(".MainActivity")) {
338+
addExportedAttrib(activity);
339+
if (!forceNew) save();
340+
}
341+
if (service.getString("android:name").equals(".MainService")) {
342+
addExportedAttrib(service);
343+
if (!forceNew) save();
344+
}
345+
346+
XML usesSDK = xml.getChild("uses-sdk");
347+
if (usesSDK != null) {
348+
// Manifest file generated with older version of the mode, uses-sdk is no longer needed in manifest
349+
xml.removeChild(usesSDK);
350+
if (!forceNew) save();
351+
}
352+
335353
} catch (Exception e) {
336354
e.printStackTrace();
337355
System.err.println("Problem reading AndroidManifest.xml, creating a new version");
@@ -394,6 +412,13 @@ protected void load(boolean forceNew) {
394412
}
395413
}
396414

415+
protected void addExportedAttrib(XML child) {
416+
if (!child.hasAttribute("android:exported")) {
417+
// Manifest file generated with older version of the mode, missing android:exported attributed
418+
child.setString("android:exported", "true");
419+
}
420+
}
421+
397422
protected void save() {
398423
save(getManifestFile());
399424
}

0 commit comments

Comments
 (0)