mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 21:22:48 +00:00
Enable automatic install of export apks for the Android editor
This commit is contained in:
parent
08f9cba0fb
commit
af2423ba4d
@ -49,7 +49,9 @@ void register_android_exporter() {
|
||||
EDITOR_DEF_BASIC("export/android/debug_keystore_pass", DEFAULT_ANDROID_KEYSTORE_DEBUG_PASSWORD);
|
||||
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/debug_keystore_pass", PROPERTY_HINT_PASSWORD));
|
||||
|
||||
#ifndef ANDROID_ENABLED
|
||||
#ifdef ANDROID_ENABLED
|
||||
EDITOR_DEF_BASIC("export/android/install_exported_apk", true);
|
||||
#else
|
||||
EDITOR_DEF_BASIC("export/android/java_sdk_path", OS::get_singleton()->get_environment("JAVA_HOME"));
|
||||
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/java_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
|
||||
EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->get_environment("ANDROID_HOME"));
|
||||
|
@ -2887,6 +2887,14 @@ Error EditorExportPlatformAndroid::sign_apk(const Ref<EditorExportPreset> &p_pre
|
||||
#endif
|
||||
|
||||
print_verbose("Successfully completed signing build.");
|
||||
|
||||
#ifdef ANDROID_ENABLED
|
||||
bool prompt_apk_install = EDITOR_GET("export/android/install_exported_apk");
|
||||
if (prompt_apk_install) {
|
||||
OS_Android::get_singleton()->shell_open(apk_path);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
|
@ -390,7 +390,7 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
* If the launch policy is [LaunchPolicy.AUTO], resolve it into a specific policy based on the
|
||||
* editor setting or device and screen metrics.
|
||||
*
|
||||
* If the launch policy is [LaunchPolicy.PIP] but PIP is not supported, fallback to the default
|
||||
* If the launch policy is [LaunchPolicy.SAME_AND_LAUNCH_IN_PIP_MODE] but PIP is not supported, fallback to the default
|
||||
* launch policy.
|
||||
*/
|
||||
private fun resolveLaunchPolicyIfNeeded(policy: LaunchPolicy): LaunchPolicy {
|
||||
@ -453,9 +453,9 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
// Check if we got the MANAGE_EXTERNAL_STORAGE permission
|
||||
if (requestCode == PermissionsUtil.REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
if (!Environment.isExternalStorageManager()) {
|
||||
when (requestCode) {
|
||||
PermissionsUtil.REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
|
||||
Toast.makeText(
|
||||
this,
|
||||
R.string.denied_storage_permission_error_msg,
|
||||
@ -463,6 +463,16 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
PermissionsUtil.REQUEST_INSTALL_PACKAGES_REQ_CODE -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !packageManager.canRequestPackageInstalls()) {
|
||||
Toast.makeText(
|
||||
this,
|
||||
R.string.denied_install_packages_permission_error_msg,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -514,7 +524,7 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||
|
||||
override fun supportsFeature(featureTag: String): Boolean {
|
||||
if (featureTag == "xr_editor") {
|
||||
return isNativeXRDevice();
|
||||
return isNativeXRDevice()
|
||||
}
|
||||
|
||||
if (featureTag == "horizonos") {
|
||||
|
@ -2,5 +2,6 @@
|
||||
<resources>
|
||||
<string name="godot_game_activity_name">Godot Play window</string>
|
||||
<string name="denied_storage_permission_error_msg">Missing storage access permission!</string>
|
||||
<string name="denied_install_packages_permission_error_msg">Missing install packages permission!</string>
|
||||
<string name="pip_button_description">Button used to toggle picture-in-picture mode for the Play window</string>
|
||||
</resources>
|
||||
|
@ -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()) {
|
||||
|
@ -21,4 +21,4 @@ target_include_directories(${PROJECT_NAME}
|
||||
${ANDROID_ROOT_DIR}
|
||||
${OPENXR_INCLUDE_DIR})
|
||||
|
||||
add_definitions(-DUNIX_ENABLED -DVULKAN_ENABLED -DANDROID_ENABLED -DGLES3_ENABLED -DTOOLS_ENABLED)
|
||||
add_definitions(-DUNIX_ENABLED -DVULKAN_ENABLED -DANDROID_ENABLED -DGLES3_ENABLED -DTOOLS_ENABLED -DDEBUG_ENABLED)
|
||||
|
Loading…
Reference in New Issue
Block a user