Do not forget to register permission for the application to use vibration (AndroidManifest.xml): <uses-permission android: name = "android.permission.VIBRATE" />
If the target version is Android SDK < 26, then the project will not be built in Android Studio, because the android.os.VibrationEffect module is bound there, which appeared only from this version. We’ll have to edit the Kha project template for android.
items = [('VIBRATE', 'Vibrate', 'Allows access to the vibrator'),
('INTERNET', 'Internet', 'Allows applications to open network sockets'),
('ACCESS_COARSE_LOCATION', 'Access Coarse Location', 'Allows an app to access approximate location'),
('ACCESS_NETWORK_STATE', 'Access Network State', 'Allows applications to access information about networks'),
('ACCESS_FINE_LOCATION', 'Access Fine Location', 'Allows an app to access precise location'),
('READ_EXTERNAL_STORAGE', 'Read External Storage', 'Allows an application to read from external storage.'),
('WRITE_EXTERNAL_STORAGE', 'Write External Storage', 'Allows an application to write to external storage'),
('ACCESS_WIFI_STATE', 'Access Wi-Fi State', 'Allows applications to access information about Wi-Fi networks')],
SDK version and ABIs are specified in the build.gradle file. Based on the current documentation you cannot influence it through the API, you need to complete it in Kinc (Exporters/AndroidExporter.ts), as was done here.
I understand correctly?
@E1e5en Not sure about this, but do android orientation/ accelerometer sensors need any permissions? Also, access to camera and mic is one thing, possibly for future use?
Expanding the build customization capabilities through khafile.js - Done PR.
Added the list of permissions:
items = [('ACCESS_COARSE_LOCATION ', 'Access Coarse Location', 'Allows an app to access approximate location'),
('ACCESS_NETWORK_STATE', 'Access Network State', 'Allows applications to access information about networks'),
('ACCESS_FINE_LOCATION', 'Access Fine Location', 'Allows an app to access precise location'),
('ACCESS_WIFI_STATE', 'Access Wi-Fi State', 'Allows applications to access information about Wi-Fi networks'),
('BLUETOOTH', 'Bluetooth', 'Allows applications to connect to paired bluetooth devices'),
('BLUETOOTH_ADMIN', 'Bluetooth Admin', 'Allows applications to discover and pair bluetooth devices'),
('CAMERA', 'Camera', 'Required to be able to access the camera device'),
('EXPAND_STATUS_BAR', 'Expand Status Bar', 'Allows an application to expand or collapse the status bar'),
('FOREGROUND_SERVICE', 'Foreground Service', 'Allows a regular application to use Service.startForeground'),
('GET_ACCOUNTS', 'Get Accounts', 'Allows access to the list of accounts in the Accounts Service'),
('INTERNET', 'Internet', 'Allows applications to open network sockets'),
('READ_EXTERNAL_STORAGE', 'Read External Storage', 'Allows an application to read from external storage.'),
('VIBRATE', 'Vibrate', 'Allows access to the vibrator'),
('WRITE_EXTERNAL_STORAGE', 'Write External Storage', 'Allows an application to write to external storage')],
Corrected the interface and added settings. The tab is inactive if the target platform android-hl is not selected.
Settings:
Bundle;
Orientation;
Compile Version SDK - from 26 to 30, default 29;
Min Version SDK - from 14 to 30, default 14;
Target Version SDK - from 26 to 30, default 29;
Permissions - a list of permissions, if I will duplicate entries in the list, then only unique entries will be included during export. By default, the list is empty;
Android ABI Filters - a list of platforms to build for (arm64-v8a, armeabi-v7a, x86, x86_64). By default, the list is empty. If the list is empty, then all platforms will be used (as before). More than this (as written here) you don’t need to do it by hand. HOORAY!
When adding the logical node Set Vibrate, the permission is automatically added to the list, even if the target platform android-hl has not been selected.
Questions:
The Bundle field is also used for iOS builds. Move it out of the Android Settings tab, or make it separate for Android, separate for iOS?
Pull Request to extend khafile.js has been accepted, so submodules need to be updated.
Returned the Bundle field to the previous place, since this value is used in several places, then let it be common.
Android Settings panel:
invisible until the target platform android-hl is added to the list;
inactive until the target platform android-hl is selected in the list.
Options:
Orientation;
Compile Version SDK - from 26 to 30, default 29;
Minimal Version SDK - from 14 to 30, default 14;
Target Version SDK - from 26 to 30, default 29;
Permissions - a list of permissions. If I will duplicate entries in the list, then only unique entries will be included during export. By default, the list is empty;
Android ABI Filters - a list of platforms to build for (arm64-v8a, armeabi-v7a, x86, x86_64). If I will duplicate entries in the list, then only unique entries will be included during export. By default, the list is empty. If the list is empty, then all platforms will be used (as before).
The enum (names of permissions) and the function have been added to the utils.py modules, which adds the specified value to the list of permissions. Feature added for ease of use from different locations (different logical nodes):
# Enum Permissions Name
class PermissionName(Enum):
ACCESS_COARSE_LOCATION = 'ACCESS_COARSE_LOCATION'
ACCESS_NETWORK_STATE = 'ACCESS_NETWORK_STATE'
ACCESS_FINE_LOCATION = 'ACCESS_FINE_LOCATION'
ACCESS_WIFI_STATE = 'ACCESS_WIFI_STATE'
BLUETOOTH = 'BLUETOOTH'
BLUETOOTH_ADMIN = 'BLUETOOTH_ADMIN'
CAMERA = 'CAMERA'
EXPAND_STATUS_BAR = 'EXPAND_STATUS_BAR'
FOREGROUND_SERVICE = 'FOREGROUND_SERVICE'
GET_ACCOUNTS = 'GET_ACCOUNTS'
INTERNET = 'INTERNET'
READ_EXTERNAL_STORAGE = 'READ_EXTERNAL_STORAGE'
VIBRATE = 'VIBRATE'
WRITE_EXTERNAL_STORAGE = 'WRITE_EXTERNAL_STORAGE'
# Add permission for target android
def add_permission_target_android(permission_name_enum):
wrd = bpy.data.worlds['Arm']
check = False
for item in wrd.arm_exporter_android_permission_list:
if (item.arm_android_permissions.upper() == str(permission_name_enum.value).upper()):
check = True
break
if not check:
wrd.arm_exporter_android_permission_list.add()
wrd.arm_exporter_android_permission_list[len(wrd.arm_exporter_android_permission_list) - 1].arm_android_permissions = str(permission_name_enum.value).upper()
When adding the logical node Set Vibrate, the permission is automatically added to the list, even if the target android-hl has not been added to the export list (using a function from utils.py).
# Add permission for target android
arm.utils.add_permission_target_android(arm.utils.PermissionName.VIBRATE)
The list of permissions is specified in the post earlier.