summaryrefslogtreecommitdiffstats
path: root/platform/android/java/lib
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-11-04 21:52:08 -0600
committerThaddeus Crews <repiteo@outlook.com>2024-11-04 21:52:08 -0600
commitb00e1cbf743dcb6a2b7f6bd14e348a1a7cf3d403 (patch)
treed081348283115d67dd12d73d1e6611c283b67968 /platform/android/java/lib
parent88d9903f6d94ad3303247f9f53b37668c9b6057f (diff)
parentaf2423ba4d04ed85a5be82db70a76bab60f137dd (diff)
downloadredot-engine-b00e1cbf743dcb6a2b7f6bd14e348a1a7cf3d403.tar.gz
Merge pull request #97631 from m4gr3d/prompt_apk_install_after_generation
[Android editor] Enable automatic install of exported apks for the Android editor
Diffstat (limited to 'platform/android/java/lib')
-rw-r--r--platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
index c44a6dd472..885873e46d 100644
--- a/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
+++ b/platform/android/java/lib/src/org/godotengine/godot/utils/PermissionsUtil.java
@@ -49,7 +49,6 @@ import androidx.core.content.ContextCompat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -66,6 +65,7 @@ public final class PermissionsUtil {
public static final int REQUEST_ALL_PERMISSION_REQ_CODE = 1001;
public static final int REQUEST_SINGLE_PERMISSION_REQ_CODE = 1002;
public static final int REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE = 2002;
+ public static final int REQUEST_INSTALL_PACKAGES_REQ_CODE = 3002;
private PermissionsUtil() {
}
@@ -105,6 +105,16 @@ public final class PermissionsUtil {
activity.startActivityForResult(intent, REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE);
}
}
+ } else if (permission.equals(Manifest.permission.REQUEST_INSTALL_PACKAGES)) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !activity.getPackageManager().canRequestPackageInstalls()) {
+ try {
+ Intent intent = new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES);
+ intent.setData(Uri.parse(String.format("package:%s", activity.getPackageName())));
+ activity.startActivityForResult(intent, REQUEST_INSTALL_PACKAGES_REQ_CODE);
+ } catch (Exception e) {
+ Log.e(TAG, "Unable to request permission " + Manifest.permission.REQUEST_INSTALL_PACKAGES);
+ }
+ }
} else {
PermissionInfo permissionInfo = getPermissionInfo(activity, permission);
int protectionLevel = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? permissionInfo.getProtection() : permissionInfo.protectionLevel;
@@ -215,7 +225,7 @@ public final class PermissionsUtil {
try {
manifestPermissions = getManifestPermissions(activity);
} catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
+ Log.e(TAG, "Unable to retrieve manifest permissions", e);
return false;
}
@@ -242,7 +252,7 @@ public final class PermissionsUtil {
try {
manifestPermissions = getManifestPermissions(context);
} catch (PackageManager.NameNotFoundException e) {
- e.printStackTrace();
+ Log.e(TAG, "Unable to retrieve manifest permissions", e);
return new String[0];
}
if (manifestPermissions.isEmpty()) {