Enable automatic install of export apks for the Android editor
This commit is contained in:
parent
e3213aaef5
commit
fd6c4515f1
|
@ -49,7 +49,9 @@ void register_android_exporter() {
|
||||||
EDITOR_DEF_BASIC("export/android/debug_keystore_pass", DEFAULT_ANDROID_KEYSTORE_DEBUG_PASSWORD);
|
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));
|
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"));
|
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));
|
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"));
|
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
|
#endif
|
||||||
|
|
||||||
print_verbose("Successfully completed signing build.");
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
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
|
* If the launch policy is [LaunchPolicy.AUTO], resolve it into a specific policy based on the
|
||||||
* editor setting or device and screen metrics.
|
* 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.
|
* launch policy.
|
||||||
*/
|
*/
|
||||||
private fun resolveLaunchPolicyIfNeeded(policy: LaunchPolicy): LaunchPolicy {
|
private fun resolveLaunchPolicyIfNeeded(policy: LaunchPolicy): LaunchPolicy {
|
||||||
|
@ -453,9 +453,9 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
super.onActivityResult(requestCode, resultCode, data)
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
// Check if we got the MANAGE_EXTERNAL_STORAGE permission
|
// Check if we got the MANAGE_EXTERNAL_STORAGE permission
|
||||||
if (requestCode == PermissionsUtil.REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE) {
|
when (requestCode) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
PermissionsUtil.REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE -> {
|
||||||
if (!Environment.isExternalStorageManager()) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this,
|
this,
|
||||||
R.string.denied_storage_permission_error_msg,
|
R.string.denied_storage_permission_error_msg,
|
||||||
|
@ -463,6 +463,16 @@ abstract class BaseGodotEditor : GodotActivity() {
|
||||||
).show()
|
).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 {
|
override fun supportsFeature(featureTag: String): Boolean {
|
||||||
if (featureTag == "xr_editor") {
|
if (featureTag == "xr_editor") {
|
||||||
return isNativeXRDevice();
|
return isNativeXRDevice()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (featureTag == "horizonos") {
|
if (featureTag == "horizonos") {
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="godot_game_activity_name">Godot Play window</string>
|
<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_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>
|
<string name="pip_button_description">Button used to toggle picture-in-picture mode for the Play window</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -49,7 +49,6 @@ import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
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_ALL_PERMISSION_REQ_CODE = 1001;
|
||||||
public static final int REQUEST_SINGLE_PERMISSION_REQ_CODE = 1002;
|
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_MANAGE_EXTERNAL_STORAGE_REQ_CODE = 2002;
|
||||||
|
public static final int REQUEST_INSTALL_PACKAGES_REQ_CODE = 3002;
|
||||||
|
|
||||||
private PermissionsUtil() {
|
private PermissionsUtil() {
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,16 @@ public final class PermissionsUtil {
|
||||||
activity.startActivityForResult(intent, REQUEST_MANAGE_EXTERNAL_STORAGE_REQ_CODE);
|
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 {
|
} else {
|
||||||
PermissionInfo permissionInfo = getPermissionInfo(activity, permission);
|
PermissionInfo permissionInfo = getPermissionInfo(activity, permission);
|
||||||
int protectionLevel = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? permissionInfo.getProtection() : permissionInfo.protectionLevel;
|
int protectionLevel = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P ? permissionInfo.getProtection() : permissionInfo.protectionLevel;
|
||||||
|
@ -215,7 +225,7 @@ public final class PermissionsUtil {
|
||||||
try {
|
try {
|
||||||
manifestPermissions = getManifestPermissions(activity);
|
manifestPermissions = getManifestPermissions(activity);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, "Unable to retrieve manifest permissions", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +252,7 @@ public final class PermissionsUtil {
|
||||||
try {
|
try {
|
||||||
manifestPermissions = getManifestPermissions(context);
|
manifestPermissions = getManifestPermissions(context);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
Log.e(TAG, "Unable to retrieve manifest permissions", e);
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
if (manifestPermissions.isEmpty()) {
|
if (manifestPermissions.isEmpty()) {
|
||||||
|
|
Loading…
Reference in New Issue