Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract finding permissions into its own function #8

Merged
merged 1 commit into from
Jun 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,29 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
return OK;
}

Vector<String> _get_permissions(const Ref<EditorExportPreset> &p_preset, bool p_give_internet) {
Vector<String> perms;
const char **aperms = android_perms;
while (*aperms) {
bool enabled = p_preset->get("permissions/" + String(*aperms).to_lower());
if (enabled)
perms.push_back("android.permission." + String(*aperms));
aperms++;
}
PoolStringArray user_perms = p_preset->get("permissions/custom_permissions");
for (int i = 0; i < user_perms.size(); i++) {
String user_perm = user_perms[i].strip_edges();
if (!user_perm.empty()) {
perms.push_back(user_perm);
}
}
if (p_give_internet) {
if (perms.find("android.permission.INTERNET") == -1)
perms.push_back("android.permission.INTERNET");
}
return perms;
}

Error _fix_manifest_plaintext(const Ref<EditorExportPreset> &p_preset, String &manifest_path, bool p_give_internet) {
//TODO: replicate the functionality of _fix_manifest by editing the plaintext AndroidManifest.xml file
return OK;
Expand Down Expand Up @@ -846,30 +869,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

String plugins_names = get_plugins_names(get_enabled_plugins(p_preset));

Vector<String> perms;

const char **aperms = android_perms;
while (*aperms) {

bool enabled = p_preset->get("permissions/" + String(*aperms).to_lower());
if (enabled)
perms.push_back("android.permission." + String(*aperms));
aperms++;
}

PoolStringArray user_perms = p_preset->get("permissions/custom_permissions");

for (int i = 0; i < user_perms.size(); i++) {
String user_perm = user_perms[i].strip_edges();
if (!user_perm.empty()) {
perms.push_back(user_perm);
}
}

if (p_give_internet) {
if (perms.find("android.permission.INTERNET") == -1)
perms.push_back("android.permission.INTERNET");
}
Vector<String> perms = _get_permissions(p_preset, p_give_internet);

while (ofs < (uint32_t)p_manifest.size()) {

Expand Down