export.cpp 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840
  1. /*************************************************************************/
  2. /* export.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "export.h"
  31. #include "editor/editor_import_export.h"
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_settings.h"
  34. #include "globals.h"
  35. #include "io/marshalls.h"
  36. #include "io/zip_io.h"
  37. #include "os/file_access.h"
  38. #include "os/os.h"
  39. #include "platform/android/logo.gen.h"
  40. #include "version.h"
  41. #include <string.h>
  42. static const char *android_perms[] = {
  43. "ACCESS_CHECKIN_PROPERTIES",
  44. "ACCESS_COARSE_LOCATION",
  45. "ACCESS_FINE_LOCATION",
  46. "ACCESS_LOCATION_EXTRA_COMMANDS",
  47. "ACCESS_MOCK_LOCATION",
  48. "ACCESS_NETWORK_STATE",
  49. "ACCESS_SURFACE_FLINGER",
  50. "ACCESS_WIFI_STATE",
  51. "ACCOUNT_MANAGER",
  52. "ADD_VOICEMAIL",
  53. "AUTHENTICATE_ACCOUNTS",
  54. "BATTERY_STATS",
  55. "BIND_ACCESSIBILITY_SERVICE",
  56. "BIND_APPWIDGET",
  57. "BIND_DEVICE_ADMIN",
  58. "BIND_INPUT_METHOD",
  59. "BIND_NFC_SERVICE",
  60. "BIND_NOTIFICATION_LISTENER_SERVICE",
  61. "BIND_PRINT_SERVICE",
  62. "BIND_REMOTEVIEWS",
  63. "BIND_TEXT_SERVICE",
  64. "BIND_VPN_SERVICE",
  65. "BIND_WALLPAPER",
  66. "BLUETOOTH",
  67. "BLUETOOTH_ADMIN",
  68. "BLUETOOTH_PRIVILEGED",
  69. "BRICK",
  70. "BROADCAST_PACKAGE_REMOVED",
  71. "BROADCAST_SMS",
  72. "BROADCAST_STICKY",
  73. "BROADCAST_WAP_PUSH",
  74. "CALL_PHONE",
  75. "CALL_PRIVILEGED",
  76. "CAMERA",
  77. "CAPTURE_AUDIO_OUTPUT",
  78. "CAPTURE_SECURE_VIDEO_OUTPUT",
  79. "CAPTURE_VIDEO_OUTPUT",
  80. "CHANGE_COMPONENT_ENABLED_STATE",
  81. "CHANGE_CONFIGURATION",
  82. "CHANGE_NETWORK_STATE",
  83. "CHANGE_WIFI_MULTICAST_STATE",
  84. "CHANGE_WIFI_STATE",
  85. "CLEAR_APP_CACHE",
  86. "CLEAR_APP_USER_DATA",
  87. "CONTROL_LOCATION_UPDATES",
  88. "DELETE_CACHE_FILES",
  89. "DELETE_PACKAGES",
  90. "DEVICE_POWER",
  91. "DIAGNOSTIC",
  92. "DISABLE_KEYGUARD",
  93. "DUMP",
  94. "EXPAND_STATUS_BAR",
  95. "FACTORY_TEST",
  96. "FLASHLIGHT",
  97. "FORCE_BACK",
  98. "GET_ACCOUNTS",
  99. "GET_PACKAGE_SIZE",
  100. "GET_TASKS",
  101. "GET_TOP_ACTIVITY_INFO",
  102. "GLOBAL_SEARCH",
  103. "HARDWARE_TEST",
  104. "INJECT_EVENTS",
  105. "INSTALL_LOCATION_PROVIDER",
  106. "INSTALL_PACKAGES",
  107. "INSTALL_SHORTCUT",
  108. "INTERNAL_SYSTEM_WINDOW",
  109. "INTERNET",
  110. "KILL_BACKGROUND_PROCESSES",
  111. "LOCATION_HARDWARE",
  112. "MANAGE_ACCOUNTS",
  113. "MANAGE_APP_TOKENS",
  114. "MANAGE_DOCUMENTS",
  115. "MASTER_CLEAR",
  116. "MEDIA_CONTENT_CONTROL",
  117. "MODIFY_AUDIO_SETTINGS",
  118. "MODIFY_PHONE_STATE",
  119. "MOUNT_FORMAT_FILESYSTEMS",
  120. "MOUNT_UNMOUNT_FILESYSTEMS",
  121. "NFC",
  122. "PERSISTENT_ACTIVITY",
  123. "PROCESS_OUTGOING_CALLS",
  124. "READ_CALENDAR",
  125. "READ_CALL_LOG",
  126. "READ_CONTACTS",
  127. "READ_EXTERNAL_STORAGE",
  128. "READ_FRAME_BUFFER",
  129. "READ_HISTORY_BOOKMARKS",
  130. "READ_INPUT_STATE",
  131. "READ_LOGS",
  132. "READ_PHONE_STATE",
  133. "READ_PROFILE",
  134. "READ_SMS",
  135. "READ_SOCIAL_STREAM",
  136. "READ_SYNC_SETTINGS",
  137. "READ_SYNC_STATS",
  138. "READ_USER_DICTIONARY",
  139. "REBOOT",
  140. "RECEIVE_BOOT_COMPLETED",
  141. "RECEIVE_MMS",
  142. "RECEIVE_SMS",
  143. "RECEIVE_WAP_PUSH",
  144. "RECORD_AUDIO",
  145. "REORDER_TASKS",
  146. "RESTART_PACKAGES",
  147. "SEND_RESPOND_VIA_MESSAGE",
  148. "SEND_SMS",
  149. "SET_ACTIVITY_WATCHER",
  150. "SET_ALARM",
  151. "SET_ALWAYS_FINISH",
  152. "SET_ANIMATION_SCALE",
  153. "SET_DEBUG_APP",
  154. "SET_ORIENTATION",
  155. "SET_POINTER_SPEED",
  156. "SET_PREFERRED_APPLICATIONS",
  157. "SET_PROCESS_LIMIT",
  158. "SET_TIME",
  159. "SET_TIME_ZONE",
  160. "SET_WALLPAPER",
  161. "SET_WALLPAPER_HINTS",
  162. "SIGNAL_PERSISTENT_PROCESSES",
  163. "STATUS_BAR",
  164. "SUBSCRIBED_FEEDS_READ",
  165. "SUBSCRIBED_FEEDS_WRITE",
  166. "SYSTEM_ALERT_WINDOW",
  167. "TRANSMIT_IR",
  168. "UNINSTALL_SHORTCUT",
  169. "UPDATE_DEVICE_STATS",
  170. "USE_CREDENTIALS",
  171. "USE_SIP",
  172. "VIBRATE",
  173. "WAKE_LOCK",
  174. "WRITE_APN_SETTINGS",
  175. "WRITE_CALENDAR",
  176. "WRITE_CALL_LOG",
  177. "WRITE_CONTACTS",
  178. "WRITE_EXTERNAL_STORAGE",
  179. "WRITE_GSERVICES",
  180. "WRITE_HISTORY_BOOKMARKS",
  181. "WRITE_PROFILE",
  182. "WRITE_SECURE_SETTINGS",
  183. "WRITE_SETTINGS",
  184. "WRITE_SMS",
  185. "WRITE_SOCIAL_STREAM",
  186. "WRITE_SYNC_SETTINGS",
  187. "WRITE_USER_DICTIONARY",
  188. NULL
  189. };
  190. class EditorExportPlatformAndroid : public EditorExportPlatform {
  191. OBJ_TYPE(EditorExportPlatformAndroid, EditorExportPlatform);
  192. enum {
  193. MAX_USER_PERMISSIONS = 20,
  194. SCREEN_SMALL = 0,
  195. SCREEN_NORMAL = 1,
  196. SCREEN_LARGE = 2,
  197. SCREEN_XLARGE = 3,
  198. SCREEN_MAX = 4
  199. };
  200. String custom_release_package;
  201. String custom_debug_package;
  202. int version_code;
  203. String version_name;
  204. String package;
  205. String name;
  206. String icon;
  207. String cmdline;
  208. bool _signed;
  209. bool apk_expansion;
  210. bool remove_prev;
  211. bool use_32_fb;
  212. bool immersive;
  213. bool export_arm;
  214. bool export_x86;
  215. String apk_expansion_salt;
  216. String apk_expansion_pkey;
  217. int orientation;
  218. String release_keystore;
  219. String release_password;
  220. String release_username;
  221. struct APKExportData {
  222. zipFile apk;
  223. EditorProgress *ep;
  224. };
  225. struct Device {
  226. String id;
  227. String name;
  228. String description;
  229. };
  230. Vector<Device> devices;
  231. bool devices_changed;
  232. Mutex *device_lock;
  233. Thread *device_thread;
  234. Ref<ImageTexture> logo;
  235. Set<String> perms;
  236. String user_perms[MAX_USER_PERMISSIONS];
  237. bool screen_support[SCREEN_MAX];
  238. volatile bool quit_request;
  239. static void _device_poll_thread(void *ud);
  240. String get_package_name();
  241. String get_project_name() const;
  242. void _fix_manifest(Vector<uint8_t> &p_manifest, bool p_give_internet);
  243. void _fix_resources(Vector<uint8_t> &p_manifest);
  244. static Error save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total);
  245. static bool _should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data);
  246. protected:
  247. bool _set(const StringName &p_name, const Variant &p_value);
  248. bool _get(const StringName &p_name, Variant &r_ret) const;
  249. void _get_property_list(List<PropertyInfo> *p_list) const;
  250. public:
  251. virtual String get_name() const { return "Android"; }
  252. virtual ImageCompression get_image_compression() const { return IMAGE_COMPRESSION_ETC1; }
  253. virtual Ref<Texture> get_logo() const { return logo; }
  254. virtual bool poll_devices();
  255. virtual int get_device_count() const;
  256. virtual String get_device_name(int p_device) const;
  257. virtual String get_device_info(int p_device) const;
  258. virtual Error run(int p_device, int p_flags = 0);
  259. virtual bool requires_password(bool p_debug) const { return !p_debug; }
  260. virtual String get_binary_extension() const { return "apk"; }
  261. virtual Error export_project(const String &p_path, bool p_debug, int p_flags = 0);
  262. virtual bool can_export(String *r_error = NULL) const;
  263. EditorExportPlatformAndroid();
  264. ~EditorExportPlatformAndroid();
  265. };
  266. bool EditorExportPlatformAndroid::_set(const StringName &p_name, const Variant &p_value) {
  267. String n = p_name;
  268. if (n == "one_click_deploy/clear_previous_install")
  269. remove_prev = p_value;
  270. else if (n == "custom_package/debug")
  271. custom_debug_package = p_value;
  272. else if (n == "custom_package/release")
  273. custom_release_package = p_value;
  274. else if (n == "version/code")
  275. version_code = p_value;
  276. else if (n == "version/name")
  277. version_name = p_value;
  278. else if (n == "command_line/extra_args")
  279. cmdline = p_value;
  280. else if (n == "package/unique_name")
  281. package = p_value;
  282. else if (n == "package/name")
  283. name = p_value;
  284. else if (n == "package/icon")
  285. icon = p_value;
  286. else if (n == "package/signed")
  287. _signed = p_value;
  288. else if (n == "architecture/arm")
  289. export_arm = p_value;
  290. else if (n == "architecture/x86")
  291. export_x86 = p_value;
  292. else if (n == "screen/use_32_bits_view")
  293. use_32_fb = p_value;
  294. else if (n == "screen/immersive_mode")
  295. immersive = p_value;
  296. else if (n == "screen/orientation")
  297. orientation = p_value;
  298. else if (n == "screen/support_small")
  299. screen_support[SCREEN_SMALL] = p_value;
  300. else if (n == "screen/support_normal")
  301. screen_support[SCREEN_NORMAL] = p_value;
  302. else if (n == "screen/support_large")
  303. screen_support[SCREEN_LARGE] = p_value;
  304. else if (n == "screen/support_xlarge")
  305. screen_support[SCREEN_XLARGE] = p_value;
  306. else if (n == "keystore/release")
  307. release_keystore = p_value;
  308. else if (n == "keystore/release_user")
  309. release_username = p_value;
  310. else if (n == "keystore/release_password")
  311. release_password = p_value;
  312. else if (n == "apk_expansion/enable")
  313. apk_expansion = p_value;
  314. else if (n == "apk_expansion/SALT")
  315. apk_expansion_salt = p_value;
  316. else if (n == "apk_expansion/public_key")
  317. apk_expansion_pkey = p_value;
  318. else if (n.begins_with("permissions/")) {
  319. String what = n.get_slicec('/', 1).to_upper();
  320. bool state = p_value;
  321. if (state)
  322. perms.insert(what);
  323. else
  324. perms.erase(what);
  325. } else if (n.begins_with("user_permissions/")) {
  326. int which = n.get_slicec('/', 1).to_int();
  327. ERR_FAIL_INDEX_V(which, MAX_USER_PERMISSIONS, false);
  328. user_perms[which] = p_value;
  329. } else
  330. return false;
  331. return true;
  332. }
  333. bool EditorExportPlatformAndroid::_get(const StringName &p_name, Variant &r_ret) const {
  334. String n = p_name;
  335. if (n == "one_click_deploy/clear_previous_install")
  336. r_ret = remove_prev;
  337. else if (n == "custom_package/debug")
  338. r_ret = custom_debug_package;
  339. else if (n == "custom_package/release")
  340. r_ret = custom_release_package;
  341. else if (n == "version/code")
  342. r_ret = version_code;
  343. else if (n == "version/name")
  344. r_ret = version_name;
  345. else if (n == "command_line/extra_args")
  346. r_ret = cmdline;
  347. else if (n == "package/unique_name")
  348. r_ret = package;
  349. else if (n == "package/name")
  350. r_ret = name;
  351. else if (n == "package/icon")
  352. r_ret = icon;
  353. else if (n == "package/signed")
  354. r_ret = _signed;
  355. else if (n == "architecture/arm")
  356. r_ret = export_arm;
  357. else if (n == "architecture/x86")
  358. r_ret = export_x86;
  359. else if (n == "screen/use_32_bits_view")
  360. r_ret = use_32_fb;
  361. else if (n == "screen/immersive_mode")
  362. r_ret = immersive;
  363. else if (n == "screen/orientation")
  364. r_ret = orientation;
  365. else if (n == "screen/support_small")
  366. r_ret = screen_support[SCREEN_SMALL];
  367. else if (n == "screen/support_normal")
  368. r_ret = screen_support[SCREEN_NORMAL];
  369. else if (n == "screen/support_large")
  370. r_ret = screen_support[SCREEN_LARGE];
  371. else if (n == "screen/support_xlarge")
  372. r_ret = screen_support[SCREEN_XLARGE];
  373. else if (n == "keystore/release")
  374. r_ret = release_keystore;
  375. else if (n == "keystore/release_user")
  376. r_ret = release_username;
  377. else if (n == "keystore/release_password")
  378. r_ret = release_password;
  379. else if (n == "apk_expansion/enable")
  380. r_ret = apk_expansion;
  381. else if (n == "apk_expansion/SALT")
  382. r_ret = apk_expansion_salt;
  383. else if (n == "apk_expansion/public_key")
  384. r_ret = apk_expansion_pkey;
  385. else if (n.begins_with("permissions/")) {
  386. String what = n.get_slicec('/', 1).to_upper();
  387. r_ret = perms.has(what);
  388. } else if (n.begins_with("user_permissions/")) {
  389. int which = n.get_slicec('/', 1).to_int();
  390. ERR_FAIL_INDEX_V(which, MAX_USER_PERMISSIONS, false);
  391. r_ret = user_perms[which];
  392. } else
  393. return false;
  394. return true;
  395. }
  396. void EditorExportPlatformAndroid::_get_property_list(List<PropertyInfo> *p_list) const {
  397. p_list->push_back(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"));
  398. p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "apk"));
  399. p_list->push_back(PropertyInfo(Variant::STRING, "custom_package/release", PROPERTY_HINT_GLOBAL_FILE, "apk"));
  400. p_list->push_back(PropertyInfo(Variant::STRING, "command_line/extra_args"));
  401. p_list->push_back(PropertyInfo(Variant::INT, "version/code", PROPERTY_HINT_RANGE, "1,65535,1"));
  402. p_list->push_back(PropertyInfo(Variant::STRING, "version/name"));
  403. p_list->push_back(PropertyInfo(Variant::STRING, "package/unique_name"));
  404. p_list->push_back(PropertyInfo(Variant::STRING, "package/name"));
  405. p_list->push_back(PropertyInfo(Variant::STRING, "package/icon", PROPERTY_HINT_FILE, "png"));
  406. p_list->push_back(PropertyInfo(Variant::BOOL, "package/signed"));
  407. p_list->push_back(PropertyInfo(Variant::BOOL, "architecture/arm"));
  408. p_list->push_back(PropertyInfo(Variant::BOOL, "architecture/x86"));
  409. p_list->push_back(PropertyInfo(Variant::BOOL, "screen/use_32_bits_view"));
  410. p_list->push_back(PropertyInfo(Variant::BOOL, "screen/immersive_mode"));
  411. p_list->push_back(PropertyInfo(Variant::INT, "screen/orientation", PROPERTY_HINT_ENUM, "Landscape,Portrait"));
  412. p_list->push_back(PropertyInfo(Variant::BOOL, "screen/support_small"));
  413. p_list->push_back(PropertyInfo(Variant::BOOL, "screen/support_normal"));
  414. p_list->push_back(PropertyInfo(Variant::BOOL, "screen/support_large"));
  415. p_list->push_back(PropertyInfo(Variant::BOOL, "screen/support_xlarge"));
  416. p_list->push_back(PropertyInfo(Variant::STRING, "keystore/release", PROPERTY_HINT_GLOBAL_FILE, "keystore"));
  417. p_list->push_back(PropertyInfo(Variant::STRING, "keystore/release_user"));
  418. p_list->push_back(PropertyInfo(Variant::STRING, "keystore/release_password"));
  419. p_list->push_back(PropertyInfo(Variant::BOOL, "apk_expansion/enable"));
  420. p_list->push_back(PropertyInfo(Variant::STRING, "apk_expansion/SALT"));
  421. p_list->push_back(PropertyInfo(Variant::STRING, "apk_expansion/public_key", PROPERTY_HINT_MULTILINE_TEXT));
  422. const char **perms = android_perms;
  423. while (*perms) {
  424. p_list->push_back(PropertyInfo(Variant::BOOL, "permissions/" + String(*perms).to_lower()));
  425. perms++;
  426. }
  427. for (int i = 0; i < MAX_USER_PERMISSIONS; i++) {
  428. p_list->push_back(PropertyInfo(Variant::STRING, "user_permissions/" + itos(i)));
  429. }
  430. //p_list->push_back( PropertyInfo( Variant::INT, "resources/pack_mode", PROPERTY_HINT_ENUM,"Copy,Single Exec.,Pack (.pck),Bundles (Optical)"));
  431. }
  432. static String _parse_string(const uint8_t *p_bytes, bool p_utf8) {
  433. uint32_t offset = 0;
  434. uint32_t len = decode_uint16(&p_bytes[offset]);
  435. if (p_utf8) {
  436. //don't know how to read extended utf8, this will have to be for now
  437. len >>= 8;
  438. }
  439. offset += 2;
  440. //printf("len %i, unicode: %i\n",len,int(p_utf8));
  441. if (p_utf8) {
  442. Vector<uint8_t> str8;
  443. str8.resize(len + 1);
  444. for (int i = 0; i < len; i++) {
  445. str8[i] = p_bytes[offset + i];
  446. }
  447. str8[len] = 0;
  448. String str;
  449. str.parse_utf8((const char *)str8.ptr());
  450. return str;
  451. } else {
  452. String str;
  453. for (int i = 0; i < len; i++) {
  454. CharType c = decode_uint16(&p_bytes[offset + i * 2]);
  455. if (c == 0)
  456. break;
  457. str += String::chr(c);
  458. }
  459. return str;
  460. }
  461. }
  462. void EditorExportPlatformAndroid::_fix_resources(Vector<uint8_t> &p_manifest) {
  463. const int UTF8_FLAG = 0x00000100;
  464. print_line("*******************GORRRGLE***********************");
  465. uint32_t header = decode_uint32(&p_manifest[0]);
  466. uint32_t filesize = decode_uint32(&p_manifest[4]);
  467. uint32_t string_block_len = decode_uint32(&p_manifest[16]);
  468. uint32_t string_count = decode_uint32(&p_manifest[20]);
  469. uint32_t string_flags = decode_uint32(&p_manifest[28]);
  470. const uint32_t string_table_begins = 40;
  471. Vector<String> string_table;
  472. //printf("stirng block len: %i\n",string_block_len);
  473. //printf("stirng count: %i\n",string_count);
  474. //printf("flags: %x\n",string_flags);
  475. for (int i = 0; i < string_count; i++) {
  476. uint32_t offset = decode_uint32(&p_manifest[string_table_begins + i * 4]);
  477. offset += string_table_begins + string_count * 4;
  478. String str = _parse_string(&p_manifest[offset], string_flags & UTF8_FLAG);
  479. if (str.begins_with("godot-project-name")) {
  480. if (str == "godot-project-name") {
  481. //project name
  482. str = get_project_name();
  483. } else {
  484. String lang = str.substr(str.find_last("-") + 1, str.length()).replace("-", "_");
  485. String prop = "application/name_" + lang;
  486. if (Globals::get_singleton()->has(prop)) {
  487. str = Globals::get_singleton()->get(prop);
  488. } else {
  489. str = get_project_name();
  490. }
  491. }
  492. }
  493. string_table.push_back(str);
  494. }
  495. //write a new string table, but use 16 bits
  496. Vector<uint8_t> ret;
  497. ret.resize(string_table_begins + string_table.size() * 4);
  498. for (int i = 0; i < string_table_begins; i++) {
  499. ret[i] = p_manifest[i];
  500. }
  501. int ofs = 0;
  502. for (int i = 0; i < string_table.size(); i++) {
  503. encode_uint32(ofs, &ret[string_table_begins + i * 4]);
  504. ofs += string_table[i].length() * 2 + 2 + 2;
  505. }
  506. ret.resize(ret.size() + ofs);
  507. uint8_t *chars = &ret[ret.size() - ofs];
  508. for (int i = 0; i < string_table.size(); i++) {
  509. String s = string_table[i];
  510. encode_uint16(s.length(), chars);
  511. chars += 2;
  512. for (int j = 0; j < s.length(); j++) {
  513. encode_uint16(s[j], chars);
  514. chars += 2;
  515. }
  516. encode_uint16(0, chars);
  517. chars += 2;
  518. }
  519. //pad
  520. while (ret.size() % 4)
  521. ret.push_back(0);
  522. //change flags to not use utf8
  523. encode_uint32(string_flags & ~0x100, &ret[28]);
  524. //change length
  525. encode_uint32(ret.size() - 12, &ret[16]);
  526. //append the rest...
  527. int rest_from = 12 + string_block_len;
  528. int rest_to = ret.size();
  529. int rest_len = (p_manifest.size() - rest_from);
  530. ret.resize(ret.size() + (p_manifest.size() - rest_from));
  531. for (int i = 0; i < rest_len; i++) {
  532. ret[rest_to + i] = p_manifest[rest_from + i];
  533. }
  534. //finally update the size
  535. encode_uint32(ret.size(), &ret[4]);
  536. p_manifest = ret;
  537. //printf("end\n");
  538. }
  539. String EditorExportPlatformAndroid::get_project_name() const {
  540. String aname;
  541. if (this->name != "") {
  542. aname = this->name;
  543. } else {
  544. aname = Globals::get_singleton()->get("application/name");
  545. }
  546. if (aname == "") {
  547. aname = _MKSTR(VERSION_NAME);
  548. }
  549. return aname;
  550. }
  551. void EditorExportPlatformAndroid::_fix_manifest(Vector<uint8_t> &p_manifest, bool p_give_internet) {
  552. const int CHUNK_AXML_FILE = 0x00080003;
  553. const int CHUNK_RESOURCEIDS = 0x00080180;
  554. const int CHUNK_STRINGS = 0x001C0001;
  555. const int CHUNK_XML_END_NAMESPACE = 0x00100101;
  556. const int CHUNK_XML_END_TAG = 0x00100103;
  557. const int CHUNK_XML_START_NAMESPACE = 0x00100100;
  558. const int CHUNK_XML_START_TAG = 0x00100102;
  559. const int CHUNK_XML_TEXT = 0x00100104;
  560. const int UTF8_FLAG = 0x00000100;
  561. Vector<String> string_table;
  562. uint32_t ofs = 0;
  563. uint32_t header = decode_uint32(&p_manifest[ofs]);
  564. uint32_t filesize = decode_uint32(&p_manifest[ofs + 4]);
  565. ofs += 8;
  566. // print_line("FILESIZE: "+itos(filesize)+" ACTUAL: "+itos(p_manifest.size()));
  567. uint32_t string_count;
  568. uint32_t styles_count;
  569. uint32_t string_flags;
  570. uint32_t string_data_offset;
  571. uint32_t styles_offset;
  572. uint32_t string_table_begins;
  573. uint32_t string_table_ends;
  574. Vector<uint8_t> stable_extra;
  575. while (ofs < p_manifest.size()) {
  576. uint32_t chunk = decode_uint32(&p_manifest[ofs]);
  577. uint32_t size = decode_uint32(&p_manifest[ofs + 4]);
  578. switch (chunk) {
  579. case CHUNK_STRINGS: {
  580. int iofs = ofs + 8;
  581. string_count = decode_uint32(&p_manifest[iofs]);
  582. styles_count = decode_uint32(&p_manifest[iofs + 4]);
  583. uint32_t string_flags = decode_uint32(&p_manifest[iofs + 8]);
  584. string_data_offset = decode_uint32(&p_manifest[iofs + 12]);
  585. styles_offset = decode_uint32(&p_manifest[iofs + 16]);
  586. /*
  587. printf("string count: %i\n",string_count);
  588. printf("flags: %i\n",string_flags);
  589. printf("sdata ofs: %i\n",string_data_offset);
  590. printf("styles ofs: %i\n",styles_offset);
  591. */
  592. uint32_t st_offset = iofs + 20;
  593. string_table.resize(string_count);
  594. uint32_t string_end = 0;
  595. string_table_begins = st_offset;
  596. for (int i = 0; i < string_count; i++) {
  597. uint32_t string_at = decode_uint32(&p_manifest[st_offset + i * 4]);
  598. string_at += st_offset + string_count * 4;
  599. ERR_EXPLAIN("Unimplemented, can't read utf8 string table.");
  600. ERR_FAIL_COND(string_flags & UTF8_FLAG);
  601. if (string_flags & UTF8_FLAG) {
  602. } else {
  603. uint32_t len = decode_uint16(&p_manifest[string_at]);
  604. Vector<CharType> ucstring;
  605. ucstring.resize(len + 1);
  606. for (int j = 0; j < len; j++) {
  607. uint16_t c = decode_uint16(&p_manifest[string_at + 2 + 2 * j]);
  608. ucstring[j] = c;
  609. }
  610. string_end = MAX(string_at + 2 + 2 * len, string_end);
  611. ucstring[len] = 0;
  612. string_table[i] = ucstring.ptr();
  613. }
  614. // print_line("String "+itos(i)+": "+string_table[i]);
  615. }
  616. for (int i = string_end; i < (ofs + size); i++) {
  617. stable_extra.push_back(p_manifest[i]);
  618. }
  619. // printf("stable extra: %i\n",int(stable_extra.size()));
  620. string_table_ends = ofs + size;
  621. // print_line("STABLE SIZE: "+itos(size)+" ACTUAL: "+itos(string_table_ends));
  622. } break;
  623. case CHUNK_XML_START_TAG: {
  624. int iofs = ofs + 8;
  625. uint32_t line = decode_uint32(&p_manifest[iofs]);
  626. uint32_t nspace = decode_uint32(&p_manifest[iofs + 8]);
  627. uint32_t name = decode_uint32(&p_manifest[iofs + 12]);
  628. uint32_t check = decode_uint32(&p_manifest[iofs + 16]);
  629. String tname = string_table[name];
  630. // printf("NSPACE: %i\n",nspace);
  631. //printf("NAME: %i (%s)\n",name,tname.utf8().get_data());
  632. //printf("CHECK: %x\n",check);
  633. uint32_t attrcount = decode_uint32(&p_manifest[iofs + 20]);
  634. iofs += 28;
  635. //printf("ATTRCOUNT: %x\n",attrcount);
  636. for (int i = 0; i < attrcount; i++) {
  637. uint32_t attr_nspace = decode_uint32(&p_manifest[iofs]);
  638. uint32_t attr_name = decode_uint32(&p_manifest[iofs + 4]);
  639. uint32_t attr_value = decode_uint32(&p_manifest[iofs + 8]);
  640. uint32_t attr_flags = decode_uint32(&p_manifest[iofs + 12]);
  641. uint32_t attr_resid = decode_uint32(&p_manifest[iofs + 16]);
  642. String value;
  643. if (attr_value != 0xFFFFFFFF)
  644. value = string_table[attr_value];
  645. else
  646. value = "Res #" + itos(attr_resid);
  647. String attrname = string_table[attr_name];
  648. String nspace;
  649. if (attr_nspace != 0xFFFFFFFF)
  650. nspace = string_table[attr_nspace];
  651. else
  652. nspace = "";
  653. //printf("ATTR %i NSPACE: %i\n",i,attr_nspace);
  654. //printf("ATTR %i NAME: %i (%s)\n",i,attr_name,attrname.utf8().get_data());
  655. //printf("ATTR %i VALUE: %i (%s)\n",i,attr_value,value.utf8().get_data());
  656. //printf("ATTR %i FLAGS: %x\n",i,attr_flags);
  657. //printf("ATTR %i RESID: %x\n",i,attr_resid);
  658. //replace project information
  659. if (tname == "manifest" && attrname == "package") {
  660. print_line("FOUND package");
  661. string_table[attr_value] = get_package_name();
  662. }
  663. //print_line("tname: "+tname);
  664. //print_line("nspace: "+nspace);
  665. //print_line("attrname: "+attrname);
  666. if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionCode") {
  667. print_line("FOUND versionCode");
  668. encode_uint32(version_code, &p_manifest[iofs + 16]);
  669. }
  670. if (tname == "manifest" && /*nspace=="android" &&*/ attrname == "versionName") {
  671. print_line("FOUND versionName");
  672. if (attr_value == 0xFFFFFFFF) {
  673. WARN_PRINT("Version name in a resource, should be plaintext")
  674. } else
  675. string_table[attr_value] = version_name;
  676. }
  677. if (tname == "activity" && /*nspace=="android" &&*/ attrname == "screenOrientation") {
  678. encode_uint32(orientation == 0 ? 0 : 1, &p_manifest[iofs + 16]);
  679. /*
  680. print_line("FOUND screen orientation");
  681. if (attr_value==0xFFFFFFFF) {
  682. WARN_PRINT("Version name in a resource, should be plaintext")
  683. } else {
  684. string_table[attr_value]=(orientation==0?"landscape":"portrait");
  685. }*/
  686. }
  687. if (tname == "uses-permission" && /*nspace=="android" &&*/ attrname == "name") {
  688. if (value.begins_with("godot.custom")) {
  689. int which = value.get_slice(".", 2).to_int();
  690. if (which >= 0 && which < MAX_USER_PERMISSIONS && user_perms[which].strip_edges() != "") {
  691. string_table[attr_value] = user_perms[which].strip_edges();
  692. }
  693. } else if (value.begins_with("godot.")) {
  694. String perm = value.get_slice(".", 1);
  695. if (perms.has(perm) || (p_give_internet && perm == "INTERNET")) {
  696. print_line("PERM: " + perm);
  697. string_table[attr_value] = "android.permission." + perm;
  698. }
  699. }
  700. }
  701. if (tname == "supports-screens") {
  702. if (attrname == "smallScreens") {
  703. encode_uint32(screen_support[SCREEN_SMALL] ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
  704. } else if (attrname == "normalScreens") {
  705. encode_uint32(screen_support[SCREEN_NORMAL] ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
  706. } else if (attrname == "largeScreens") {
  707. encode_uint32(screen_support[SCREEN_LARGE] ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
  708. } else if (attrname == "xlargeScreens") {
  709. encode_uint32(screen_support[SCREEN_XLARGE] ? 0xFFFFFFFF : 0, &p_manifest[iofs + 16]);
  710. }
  711. }
  712. iofs += 20;
  713. }
  714. } break;
  715. }
  716. //printf("chunk %x: size: %d\n",chunk,size);
  717. ofs += size;
  718. }
  719. //printf("end\n");
  720. //create new andriodmanifest binary
  721. Vector<uint8_t> ret;
  722. ret.resize(string_table_begins + string_table.size() * 4);
  723. for (int i = 0; i < string_table_begins; i++) {
  724. ret[i] = p_manifest[i];
  725. }
  726. ofs = 0;
  727. for (int i = 0; i < string_table.size(); i++) {
  728. encode_uint32(ofs, &ret[string_table_begins + i * 4]);
  729. ofs += string_table[i].length() * 2 + 2 + 2;
  730. //print_line("ofs: "+itos(i)+": "+itos(ofs));
  731. }
  732. ret.resize(ret.size() + ofs);
  733. uint8_t *chars = &ret[ret.size() - ofs];
  734. for (int i = 0; i < string_table.size(); i++) {
  735. String s = string_table[i];
  736. //print_line("savint string :"+s);
  737. encode_uint16(s.length(), chars);
  738. chars += 2;
  739. for (int j = 0; j < s.length(); j++) { //include zero?
  740. encode_uint16(s[j], chars);
  741. chars += 2;
  742. }
  743. encode_uint16(0, chars);
  744. chars += 2;
  745. }
  746. for (int i = 0; i < stable_extra.size(); i++) {
  747. ret.push_back(stable_extra[i]);
  748. }
  749. while (ret.size() % 4)
  750. ret.push_back(0);
  751. uint32_t new_stable_end = ret.size();
  752. uint32_t extra = (p_manifest.size() - string_table_ends);
  753. ret.resize(new_stable_end + extra);
  754. for (int i = 0; i < extra; i++)
  755. ret[new_stable_end + i] = p_manifest[string_table_ends + i];
  756. while (ret.size() % 4)
  757. ret.push_back(0);
  758. encode_uint32(ret.size(), &ret[4]); //update new file size
  759. encode_uint32(new_stable_end - 8, &ret[12]); //update new string table size
  760. //print_line("file size: "+itos(ret.size()));
  761. p_manifest = ret;
  762. #if 0
  763. uint32_t header[9];
  764. for(int i=0;i<9;i++) {
  765. header[i]=decode_uint32(&p_manifest[i*4]);
  766. }
  767. //print_line("STO: "+itos(header[3]));
  768. uint32_t st_offset=9*4;
  769. //ERR_FAIL_COND(header[3]!=0x24)
  770. uint32_t string_count=header[4];
  771. string_table.resize(string_count);
  772. for(int i=0;i<string_count;i++) {
  773. uint32_t string_at = decode_uint32(&p_manifest[st_offset+i*4]);
  774. string_at+=st_offset+string_count*4;
  775. uint32_t len = decode_uint16(&p_manifest[string_at]);
  776. Vector<CharType> ucstring;
  777. ucstring.resize(len+1);
  778. for(int j=0;j<len;j++) {
  779. uint16_t c=decode_uint16(&p_manifest[string_at+2+2*j]);
  780. ucstring[j]=c;
  781. }
  782. ucstring[len]=0;
  783. string_table[i]=ucstring.ptr();
  784. }
  785. #endif
  786. }
  787. Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total) {
  788. APKExportData *ed = (APKExportData *)p_userdata;
  789. String dst_path = p_path;
  790. dst_path = dst_path.replace_first("res://", "assets/");
  791. zipOpenNewFileInZip(ed->apk,
  792. dst_path.utf8().get_data(),
  793. NULL,
  794. NULL,
  795. 0,
  796. NULL,
  797. 0,
  798. NULL,
  799. _should_compress_asset(p_path, p_data) ? Z_DEFLATED : 0,
  800. Z_DEFAULT_COMPRESSION);
  801. zipWriteInFileInZip(ed->apk, p_data.ptr(), p_data.size());
  802. zipCloseFileInZip(ed->apk);
  803. ed->ep->step("File: " + p_path, 3 + p_file * 100 / p_total);
  804. return OK;
  805. }
  806. bool EditorExportPlatformAndroid::_should_compress_asset(const String &p_path, const Vector<uint8_t> &p_data) {
  807. /*
  808. * By not compressing files with little or not benefit in doing so,
  809. * a performance gain is expected at runtime. Moreover, if the APK is
  810. * zip-aligned, assets stored as they are can be efficiently read by
  811. * Android by memory-mapping them.
  812. */
  813. // -- Unconditional uncompress to mimic AAPT plus some other
  814. static const char *unconditional_compress_ext[] = {
  815. // From https://github.com/android/platform_frameworks_base/blob/master/tools/aapt/Package.cpp
  816. // These formats are already compressed, or don't compress well:
  817. ".jpg", ".jpeg", ".png", ".gif",
  818. ".wav", ".mp2", ".mp3", ".ogg", ".aac",
  819. ".mpg", ".mpeg", ".mid", ".midi", ".smf", ".jet",
  820. ".rtttl", ".imy", ".xmf", ".mp4", ".m4a",
  821. ".m4v", ".3gp", ".3gpp", ".3g2", ".3gpp2",
  822. ".amr", ".awb", ".wma", ".wmv",
  823. // Godot-specific:
  824. ".webp", // Same reasoning as .png
  825. ".cfb", // Don't let small config files slow-down startup
  826. // Trailer for easier processing
  827. NULL
  828. };
  829. for (const char **ext = unconditional_compress_ext; *ext; ++ext) {
  830. if (p_path.to_lower().ends_with(String(*ext))) {
  831. return false;
  832. }
  833. }
  834. // -- Compressed resource?
  835. if (p_data.size() >= 4 && p_data[0] == 'R' && p_data[1] == 'S' && p_data[2] == 'C' && p_data[3] == 'C') {
  836. // Already compressed
  837. return false;
  838. }
  839. // --- TODO: Decide on texture resources according to their image compression setting
  840. return true;
  841. }
  842. Error EditorExportPlatformAndroid::export_project(const String &p_path, bool p_debug, int p_flags) {
  843. String src_apk;
  844. EditorProgress ep("export", "Exporting for Android", 105);
  845. if (p_debug)
  846. src_apk = custom_debug_package;
  847. else
  848. src_apk = custom_release_package;
  849. if (src_apk == "") {
  850. String err;
  851. if (p_debug) {
  852. src_apk = find_export_template("android_debug.apk", &err);
  853. } else {
  854. src_apk = find_export_template("android_release.apk", &err);
  855. }
  856. if (src_apk == "") {
  857. EditorNode::add_io_error(err);
  858. return ERR_FILE_NOT_FOUND;
  859. }
  860. }
  861. FileAccess *src_f = NULL;
  862. zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
  863. ep.step("Creating APK", 0);
  864. unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io);
  865. if (!pkg) {
  866. EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk);
  867. return ERR_FILE_NOT_FOUND;
  868. }
  869. ERR_FAIL_COND_V(!pkg, ERR_CANT_OPEN);
  870. int ret = unzGoToFirstFile(pkg);
  871. zlib_filefunc_def io2 = io;
  872. FileAccess *dst_f = NULL;
  873. io2.opaque = &dst_f;
  874. String unaligned_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport-unaligned.apk";
  875. zipFile unaligned_apk = zipOpen2(unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2);
  876. while (ret == UNZ_OK) {
  877. //get filename
  878. unz_file_info info;
  879. char fname[16384];
  880. ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
  881. bool skip = false;
  882. String file = fname;
  883. Vector<uint8_t> data;
  884. data.resize(info.uncompressed_size);
  885. //read
  886. unzOpenCurrentFile(pkg);
  887. unzReadCurrentFile(pkg, data.ptr(), data.size());
  888. unzCloseCurrentFile(pkg);
  889. //write
  890. if (file == "AndroidManifest.xml") {
  891. _fix_manifest(data, p_flags & (EXPORT_DUMB_CLIENT | EXPORT_REMOTE_DEBUG));
  892. }
  893. if (file == "resources.arsc") {
  894. _fix_resources(data);
  895. }
  896. if (file == "res/drawable/icon.png") {
  897. bool found = false;
  898. if (this->icon != "" && this->icon.ends_with(".png")) {
  899. FileAccess *f = FileAccess::open(this->icon, FileAccess::READ);
  900. if (f) {
  901. data.resize(f->get_len());
  902. f->get_buffer(data.ptr(), data.size());
  903. memdelete(f);
  904. found = true;
  905. }
  906. }
  907. if (!found) {
  908. String appicon = Globals::get_singleton()->get("application/icon");
  909. if (appicon != "" && appicon.ends_with(".png")) {
  910. FileAccess *f = FileAccess::open(appicon, FileAccess::READ);
  911. if (f) {
  912. data.resize(f->get_len());
  913. f->get_buffer(data.ptr(), data.size());
  914. memdelete(f);
  915. }
  916. }
  917. }
  918. }
  919. if (file == "lib/x86/libgodot_android.so" && !export_x86) {
  920. skip = true;
  921. }
  922. if (file.match("lib/armeabi*/libgodot_android.so") && !export_arm) {
  923. skip = true;
  924. }
  925. if (file.begins_with("META-INF") && _signed) {
  926. skip = true;
  927. }
  928. print_line("ADDING: " + file);
  929. if (!skip) {
  930. // Respect decision on compression made by AAPT for the export template
  931. const bool uncompressed = info.compression_method == 0;
  932. zipOpenNewFileInZip(unaligned_apk,
  933. file.utf8().get_data(),
  934. NULL,
  935. NULL,
  936. 0,
  937. NULL,
  938. 0,
  939. NULL,
  940. uncompressed ? 0 : Z_DEFLATED,
  941. Z_DEFAULT_COMPRESSION);
  942. zipWriteInFileInZip(unaligned_apk, data.ptr(), data.size());
  943. zipCloseFileInZip(unaligned_apk);
  944. }
  945. ret = unzGoToNextFile(pkg);
  946. }
  947. ep.step("Adding Files..", 1);
  948. Error err = OK;
  949. Vector<String> cl = cmdline.strip_edges().split(" ");
  950. for (int i = 0; i < cl.size(); i++) {
  951. if (cl[i].strip_edges().length() == 0) {
  952. cl.remove(i);
  953. i--;
  954. }
  955. }
  956. gen_export_flags(cl, p_flags);
  957. if (p_flags & EXPORT_DUMB_CLIENT) {
  958. /*String host = EditorSettings::get_singleton()->get("file_server/host");
  959. int port = EditorSettings::get_singleton()->get("file_server/post");
  960. String passwd = EditorSettings::get_singleton()->get("file_server/password");
  961. cl.push_back("-rfs");
  962. cl.push_back(host+":"+itos(port));
  963. if (passwd!="") {
  964. cl.push_back("-rfs_pass");
  965. cl.push_back(passwd);
  966. }*/
  967. } else {
  968. //all files
  969. if (apk_expansion) {
  970. String apkfname = "main." + itos(version_code) + "." + get_package_name() + ".obb";
  971. String fullpath = p_path.get_base_dir().plus_file(apkfname);
  972. FileAccess *pf = FileAccess::open(fullpath, FileAccess::WRITE);
  973. if (!pf) {
  974. EditorNode::add_io_error("Could not write expansion package file: " + apkfname);
  975. return OK;
  976. }
  977. err = save_pack(pf);
  978. memdelete(pf);
  979. cl.push_back("-use_apk_expansion");
  980. cl.push_back("-apk_expansion_md5");
  981. cl.push_back(FileAccess::get_md5(fullpath));
  982. cl.push_back("-apk_expansion_key");
  983. cl.push_back(apk_expansion_pkey.strip_edges());
  984. } else {
  985. APKExportData ed;
  986. ed.ep = &ep;
  987. ed.apk = unaligned_apk;
  988. err = export_project_files(save_apk_file, &ed, false);
  989. }
  990. }
  991. if (use_32_fb)
  992. cl.push_back("-use_depth_32");
  993. if (immersive)
  994. cl.push_back("-use_immersive");
  995. if (cl.size()) {
  996. //add comandline
  997. Vector<uint8_t> clf;
  998. clf.resize(4);
  999. encode_uint32(cl.size(), &clf[0]);
  1000. for (int i = 0; i < cl.size(); i++) {
  1001. CharString txt = cl[i].utf8();
  1002. int base = clf.size();
  1003. clf.resize(base + 4 + txt.length());
  1004. encode_uint32(txt.length(), &clf[base]);
  1005. copymem(&clf[base + 4], txt.ptr(), txt.length());
  1006. print_line(itos(i) + " param: " + cl[i]);
  1007. }
  1008. zipOpenNewFileInZip(unaligned_apk,
  1009. "assets/_cl_",
  1010. NULL,
  1011. NULL,
  1012. 0,
  1013. NULL,
  1014. 0,
  1015. NULL,
  1016. 0, // No compress (little size gain and potentially slower startup)
  1017. Z_DEFAULT_COMPRESSION);
  1018. zipWriteInFileInZip(unaligned_apk, clf.ptr(), clf.size());
  1019. zipCloseFileInZip(unaligned_apk);
  1020. }
  1021. zipClose(unaligned_apk, NULL);
  1022. unzClose(pkg);
  1023. if (err) {
  1024. return err;
  1025. }
  1026. if (_signed) {
  1027. String jarsigner = EditorSettings::get_singleton()->get("android/jarsigner");
  1028. if (!FileAccess::exists(jarsigner)) {
  1029. EditorNode::add_io_error("'jarsigner' could not be found.\nPlease supply a path in the editor settings.\nResulting apk is unsigned.");
  1030. return OK;
  1031. }
  1032. String keystore;
  1033. String password;
  1034. String user;
  1035. if (p_debug) {
  1036. keystore = EditorSettings::get_singleton()->get("android/debug_keystore");
  1037. password = EditorSettings::get_singleton()->get("android/debug_keystore_pass");
  1038. user = EditorSettings::get_singleton()->get("android/debug_keystore_user");
  1039. ep.step("Signing Debug APK..", 103);
  1040. } else {
  1041. keystore = release_keystore;
  1042. password = release_password;
  1043. user = release_username;
  1044. ep.step("Signing Release APK..", 103);
  1045. }
  1046. if (!FileAccess::exists(keystore)) {
  1047. EditorNode::add_io_error("Could not find keystore, unable to export.");
  1048. return ERR_FILE_CANT_OPEN;
  1049. }
  1050. List<String> args;
  1051. args.push_back("-digestalg");
  1052. args.push_back("SHA1");
  1053. args.push_back("-sigalg");
  1054. args.push_back("MD5withRSA");
  1055. String tsa_url = EditorSettings::get_singleton()->get("android/timestamping_authority_url");
  1056. if (tsa_url != "") {
  1057. args.push_back("-tsa");
  1058. args.push_back(tsa_url);
  1059. }
  1060. args.push_back("-verbose");
  1061. args.push_back("-keystore");
  1062. args.push_back(keystore);
  1063. args.push_back("-storepass");
  1064. args.push_back(password);
  1065. args.push_back(unaligned_path);
  1066. args.push_back(user);
  1067. int retval;
  1068. int err = OS::get_singleton()->execute(jarsigner, args, true, NULL, NULL, &retval);
  1069. if (retval) {
  1070. EditorNode::add_io_error("'jarsigner' returned with error #" + itos(retval));
  1071. return ERR_CANT_CREATE;
  1072. }
  1073. ep.step("Verifying APK..", 104);
  1074. args.clear();
  1075. args.push_back("-verify");
  1076. args.push_back(unaligned_path);
  1077. args.push_back("-verbose");
  1078. err = OS::get_singleton()->execute(jarsigner, args, true, NULL, NULL, &retval);
  1079. if (retval) {
  1080. EditorNode::add_io_error("'jarsigner' verification of APK failed. Make sure to use jarsigner from Java 6.");
  1081. return ERR_CANT_CREATE;
  1082. }
  1083. }
  1084. // Let's zip-align (must be done after signing)
  1085. static const int ZIP_ALIGNMENT = 4;
  1086. ep.step("Aligning APK..", 105);
  1087. unzFile tmp_unaligned = unzOpen2(unaligned_path.utf8().get_data(), &io);
  1088. if (!tmp_unaligned) {
  1089. EditorNode::add_io_error("Could not find temp unaligned APK.");
  1090. return ERR_FILE_NOT_FOUND;
  1091. }
  1092. ERR_FAIL_COND_V(!tmp_unaligned, ERR_CANT_OPEN);
  1093. ret = unzGoToFirstFile(tmp_unaligned);
  1094. io2 = io;
  1095. dst_f = NULL;
  1096. io2.opaque = &dst_f;
  1097. zipFile final_apk = zipOpen2(p_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2);
  1098. // Take files from the unaligned APK and write them out to the aligned one
  1099. // in raw mode, i.e. not uncompressing and recompressing, aligning them as needed,
  1100. // following what is done in https://github.com/android/platform_build/blob/master/tools/zipalign/ZipAlign.cpp
  1101. int bias = 0;
  1102. while (ret == UNZ_OK) {
  1103. unz_file_info info;
  1104. memset(&info, 0, sizeof(info));
  1105. char fname[16384];
  1106. char extra[16384];
  1107. ret = unzGetCurrentFileInfo(tmp_unaligned, &info, fname, 16384, extra, 16384 - ZIP_ALIGNMENT, NULL, 0);
  1108. String file = fname;
  1109. Vector<uint8_t> data;
  1110. data.resize(info.compressed_size);
  1111. // read
  1112. int method, level;
  1113. unzOpenCurrentFile2(tmp_unaligned, &method, &level, 1); // raw read
  1114. long file_offset = unzGetCurrentFileZStreamPos64(tmp_unaligned);
  1115. unzReadCurrentFile(tmp_unaligned, data.ptr(), data.size());
  1116. unzCloseCurrentFile(tmp_unaligned);
  1117. // align
  1118. int padding = 0;
  1119. if (!info.compression_method) {
  1120. // Uncompressed file => Align
  1121. long new_offset = file_offset + bias;
  1122. padding = (ZIP_ALIGNMENT - (new_offset % ZIP_ALIGNMENT)) % ZIP_ALIGNMENT;
  1123. }
  1124. memset(extra + info.size_file_extra, 0, padding);
  1125. // write
  1126. zipOpenNewFileInZip2(final_apk,
  1127. file.utf8().get_data(),
  1128. NULL,
  1129. extra,
  1130. info.size_file_extra + padding,
  1131. NULL,
  1132. 0,
  1133. NULL,
  1134. method,
  1135. level,
  1136. 1); // raw write
  1137. zipWriteInFileInZip(final_apk, data.ptr(), data.size());
  1138. zipCloseFileInZipRaw(final_apk, info.uncompressed_size, info.crc);
  1139. bias += padding;
  1140. ret = unzGoToNextFile(tmp_unaligned);
  1141. }
  1142. zipClose(final_apk, NULL);
  1143. unzClose(tmp_unaligned);
  1144. if (err) {
  1145. return err;
  1146. }
  1147. return OK;
  1148. }
  1149. bool EditorExportPlatformAndroid::poll_devices() {
  1150. bool dc = devices_changed;
  1151. devices_changed = false;
  1152. return dc;
  1153. }
  1154. int EditorExportPlatformAndroid::get_device_count() const {
  1155. device_lock->lock();
  1156. int dc = devices.size();
  1157. device_lock->unlock();
  1158. return dc;
  1159. }
  1160. String EditorExportPlatformAndroid::get_device_name(int p_device) const {
  1161. ERR_FAIL_INDEX_V(p_device, devices.size(), "");
  1162. device_lock->lock();
  1163. String s = devices[p_device].name;
  1164. device_lock->unlock();
  1165. return s;
  1166. }
  1167. String EditorExportPlatformAndroid::get_device_info(int p_device) const {
  1168. ERR_FAIL_INDEX_V(p_device, devices.size(), "");
  1169. device_lock->lock();
  1170. String s = devices[p_device].description;
  1171. device_lock->unlock();
  1172. return s;
  1173. }
  1174. void EditorExportPlatformAndroid::_device_poll_thread(void *ud) {
  1175. EditorExportPlatformAndroid *ea = (EditorExportPlatformAndroid *)ud;
  1176. while (!ea->quit_request) {
  1177. String adb = EditorSettings::get_singleton()->get("android/adb");
  1178. if (FileAccess::exists(adb)) {
  1179. String devices;
  1180. List<String> args;
  1181. args.push_back("devices");
  1182. int ec;
  1183. Error err = OS::get_singleton()->execute(adb, args, true, NULL, &devices, &ec);
  1184. Vector<String> ds = devices.split("\n");
  1185. Vector<String> ldevices;
  1186. for (int i = 1; i < ds.size(); i++) {
  1187. String d = ds[i];
  1188. int dpos = d.find("device");
  1189. if (dpos == -1)
  1190. continue;
  1191. d = d.substr(0, dpos).strip_edges();
  1192. // print_line("found devuce: "+d);
  1193. ldevices.push_back(d);
  1194. }
  1195. ea->device_lock->lock();
  1196. bool different = false;
  1197. if (devices.size() != ldevices.size()) {
  1198. different = true;
  1199. } else {
  1200. for (int i = 0; i < ea->devices.size(); i++) {
  1201. if (ea->devices[i].id != ldevices[i]) {
  1202. different = true;
  1203. break;
  1204. }
  1205. }
  1206. }
  1207. if (different) {
  1208. Vector<Device> ndevices;
  1209. for (int i = 0; i < ldevices.size(); i++) {
  1210. Device d;
  1211. d.id = ldevices[i];
  1212. for (int j = 0; j < ea->devices.size(); j++) {
  1213. if (ea->devices[j].id == ldevices[i]) {
  1214. d.description = ea->devices[j].description;
  1215. d.name = ea->devices[j].name;
  1216. }
  1217. }
  1218. if (d.description == "") {
  1219. //in the oven, request!
  1220. args.clear();
  1221. args.push_back("-s");
  1222. args.push_back(d.id);
  1223. args.push_back("shell");
  1224. args.push_back("cat");
  1225. args.push_back("/system/build.prop");
  1226. int ec;
  1227. String dp;
  1228. Error err = OS::get_singleton()->execute(adb, args, true, NULL, &dp, &ec);
  1229. Vector<String> props = dp.split("\n");
  1230. String vendor;
  1231. String device;
  1232. d.description + "Device ID: " + d.id + "\n";
  1233. for (int j = 0; j < props.size(); j++) {
  1234. String p = props[j];
  1235. if (p.begins_with("ro.product.model=")) {
  1236. device = p.get_slice("=", 1).strip_edges();
  1237. } else if (p.begins_with("ro.product.brand=")) {
  1238. vendor = p.get_slice("=", 1).strip_edges().capitalize();
  1239. } else if (p.begins_with("ro.build.display.id=")) {
  1240. d.description += "Build: " + p.get_slice("=", 1).strip_edges() + "\n";
  1241. } else if (p.begins_with("ro.build.version.release=")) {
  1242. d.description += "Release: " + p.get_slice("=", 1).strip_edges() + "\n";
  1243. } else if (p.begins_with("ro.product.cpu.abi=")) {
  1244. d.description += "CPU: " + p.get_slice("=", 1).strip_edges() + "\n";
  1245. } else if (p.begins_with("ro.product.manufacturer=")) {
  1246. d.description += "Manufacturer: " + p.get_slice("=", 1).strip_edges() + "\n";
  1247. } else if (p.begins_with("ro.board.platform=")) {
  1248. d.description += "Chipset: " + p.get_slice("=", 1).strip_edges() + "\n";
  1249. } else if (p.begins_with("ro.opengles.version=")) {
  1250. uint32_t opengl = p.get_slice("=", 1).to_int();
  1251. d.description += "OpenGL: " + itos(opengl >> 16) + "." + itos((opengl >> 8) & 0xFF) + "." + itos((opengl)&0xFF) + "\n";
  1252. }
  1253. }
  1254. d.name = vendor + " " + device;
  1255. // print_line("name: "+d.name);
  1256. // print_line("description: "+d.description);
  1257. }
  1258. ndevices.push_back(d);
  1259. }
  1260. ea->devices = ndevices;
  1261. ea->devices_changed = true;
  1262. }
  1263. ea->device_lock->unlock();
  1264. }
  1265. uint64_t wait = 3000000;
  1266. uint64_t time = OS::get_singleton()->get_ticks_usec();
  1267. while (OS::get_singleton()->get_ticks_usec() - time < wait) {
  1268. OS::get_singleton()->delay_usec(1000);
  1269. if (ea->quit_request)
  1270. break;
  1271. }
  1272. }
  1273. if (EditorSettings::get_singleton()->get("android/shutdown_adb_on_exit")) {
  1274. String adb = EditorSettings::get_singleton()->get("android/adb");
  1275. if (!FileAccess::exists(adb)) {
  1276. return; //adb not configured
  1277. }
  1278. List<String> args;
  1279. args.push_back("kill-server");
  1280. OS::get_singleton()->execute(adb, args, true);
  1281. };
  1282. }
  1283. Error EditorExportPlatformAndroid::run(int p_device, int p_flags) {
  1284. ERR_FAIL_INDEX_V(p_device, devices.size(), ERR_INVALID_PARAMETER);
  1285. device_lock->lock();
  1286. EditorProgress ep("run", "Running on " + devices[p_device].name, 3);
  1287. String adb = EditorSettings::get_singleton()->get("android/adb");
  1288. if (adb == "") {
  1289. EditorNode::add_io_error("ADB executable not configured in settings, can't run.");
  1290. device_lock->unlock();
  1291. return ERR_UNCONFIGURED;
  1292. }
  1293. //export_temp
  1294. ep.step("Exporting APK", 0);
  1295. bool use_adb_over_usb = bool(EDITOR_DEF("android/use_remote_debug_over_adb", true));
  1296. if (use_adb_over_usb) {
  1297. p_flags |= EXPORT_REMOTE_DEBUG_LOCALHOST;
  1298. }
  1299. String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk";
  1300. Error err = export_project(export_to, true, p_flags);
  1301. if (err) {
  1302. device_lock->unlock();
  1303. return err;
  1304. }
  1305. List<String> args;
  1306. int rv;
  1307. if (remove_prev) {
  1308. ep.step("Uninstalling..", 1);
  1309. print_line("Uninstalling previous version: " + devices[p_device].name);
  1310. args.push_back("-s");
  1311. args.push_back(devices[p_device].id);
  1312. args.push_back("uninstall");
  1313. args.push_back(get_package_name());
  1314. err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
  1315. #if 0
  1316. if (err || rv!=0) {
  1317. EditorNode::add_io_error("Could not install to device.");
  1318. device_lock->unlock();
  1319. return ERR_CANT_CREATE;
  1320. }
  1321. #endif
  1322. }
  1323. print_line("Installing into device (please wait..): " + devices[p_device].name);
  1324. ep.step("Installing to Device (please wait..)..", 2);
  1325. args.clear();
  1326. args.push_back("-s");
  1327. args.push_back(devices[p_device].id);
  1328. args.push_back("install");
  1329. args.push_back("-r");
  1330. args.push_back(export_to);
  1331. err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
  1332. if (err || rv != 0) {
  1333. EditorNode::add_io_error("Could not install to device.");
  1334. device_lock->unlock();
  1335. return ERR_CANT_CREATE;
  1336. }
  1337. if (use_adb_over_usb) {
  1338. args.clear();
  1339. args.push_back("reverse");
  1340. args.push_back("--remove-all");
  1341. err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
  1342. int port = Globals::get_singleton()->get("network/debug_port");
  1343. args.clear();
  1344. args.push_back("reverse");
  1345. args.push_back("tcp:" + itos(port));
  1346. args.push_back("tcp:" + itos(port));
  1347. err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
  1348. print_line("Reverse result: " + itos(rv));
  1349. int fs_port = EditorSettings::get_singleton()->get("file_server/port");
  1350. args.clear();
  1351. args.push_back("reverse");
  1352. args.push_back("tcp:" + itos(fs_port));
  1353. args.push_back("tcp:" + itos(fs_port));
  1354. err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
  1355. print_line("Reverse result2: " + itos(rv));
  1356. }
  1357. ep.step("Running on Device..", 3);
  1358. args.clear();
  1359. args.push_back("-s");
  1360. args.push_back(devices[p_device].id);
  1361. args.push_back("shell");
  1362. args.push_back("am");
  1363. args.push_back("start");
  1364. args.push_back("--user 0");
  1365. args.push_back("-a");
  1366. args.push_back("android.intent.action.MAIN");
  1367. args.push_back("-n");
  1368. args.push_back(get_package_name() + "/org.godotengine.godot.Godot");
  1369. err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv);
  1370. if (err || rv != 0) {
  1371. EditorNode::add_io_error("Could not execute ondevice.");
  1372. device_lock->unlock();
  1373. return ERR_CANT_CREATE;
  1374. }
  1375. device_lock->unlock();
  1376. return OK;
  1377. }
  1378. String EditorExportPlatformAndroid::get_package_name() {
  1379. String pname = package;
  1380. String basename = Globals::get_singleton()->get("application/name");
  1381. basename = basename.to_lower();
  1382. String name;
  1383. bool first = true;
  1384. for (int i = 0; i < basename.length(); i++) {
  1385. CharType c = basename[i];
  1386. if (c >= '0' && c <= '9' && first) {
  1387. continue;
  1388. }
  1389. if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
  1390. name += String::chr(c);
  1391. first = false;
  1392. }
  1393. }
  1394. if (name == "")
  1395. name = "noname";
  1396. pname = pname.replace("$genname", name);
  1397. return pname;
  1398. }
  1399. EditorExportPlatformAndroid::EditorExportPlatformAndroid() {
  1400. version_code = 1;
  1401. version_name = "1.0";
  1402. package = "org.godotengine.$genname";
  1403. name = "";
  1404. _signed = true;
  1405. apk_expansion = false;
  1406. device_lock = Mutex::create();
  1407. quit_request = false;
  1408. orientation = 0;
  1409. remove_prev = true;
  1410. use_32_fb = true;
  1411. immersive = true;
  1412. export_arm = true;
  1413. export_x86 = false;
  1414. device_thread = Thread::create(_device_poll_thread, this);
  1415. devices_changed = true;
  1416. Image img(_android_logo);
  1417. logo = Ref<ImageTexture>(memnew(ImageTexture));
  1418. logo->create_from_image(img);
  1419. for (int i = 0; i < 4; i++)
  1420. screen_support[i] = true;
  1421. }
  1422. bool EditorExportPlatformAndroid::can_export(String *r_error) const {
  1423. bool valid = true;
  1424. String adb = EditorSettings::get_singleton()->get("android/adb");
  1425. String err;
  1426. if (!FileAccess::exists(adb)) {
  1427. valid = false;
  1428. err += "ADB executable not configured in editor settings.\n";
  1429. }
  1430. String js = EditorSettings::get_singleton()->get("android/jarsigner");
  1431. if (!FileAccess::exists(js)) {
  1432. valid = false;
  1433. err += "OpenJDK 6 jarsigner not configured in editor settings.\n";
  1434. }
  1435. String dk = EditorSettings::get_singleton()->get("android/debug_keystore");
  1436. if (!FileAccess::exists(dk)) {
  1437. valid = false;
  1438. err += "Debug Keystore not configured in editor settings.\n";
  1439. }
  1440. if (!exists_export_template("android_debug.apk") || !exists_export_template("android_release.apk")) {
  1441. valid = false;
  1442. err += "No export templates found.\nDownload and install export templates.\n";
  1443. }
  1444. if (custom_debug_package != "" && !FileAccess::exists(custom_debug_package)) {
  1445. valid = false;
  1446. err += "Custom debug package not found.\n";
  1447. }
  1448. if (custom_release_package != "" && !FileAccess::exists(custom_release_package)) {
  1449. valid = false;
  1450. err += "Custom release package not found.\n";
  1451. }
  1452. if (apk_expansion) {
  1453. //if (apk_expansion_salt=="") {
  1454. // valid=false;
  1455. // err+="Invalid SALT for apk expansion.\n";
  1456. //}
  1457. if (apk_expansion_pkey == "") {
  1458. valid = false;
  1459. err += "Invalid public key for apk expansion.\n";
  1460. }
  1461. }
  1462. if (r_error)
  1463. *r_error = err;
  1464. return valid;
  1465. }
  1466. EditorExportPlatformAndroid::~EditorExportPlatformAndroid() {
  1467. quit_request = true;
  1468. Thread::wait_to_finish(device_thread);
  1469. memdelete(device_lock);
  1470. memdelete(device_thread);
  1471. }
  1472. void register_android_exporter() {
  1473. String exe_ext = OS::get_singleton()->get_name() == "Windows" ? "exe" : "";
  1474. EDITOR_DEF("android/adb", "");
  1475. EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "android/adb", PROPERTY_HINT_GLOBAL_FILE, exe_ext));
  1476. EDITOR_DEF("android/jarsigner", "");
  1477. EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "android/jarsigner", PROPERTY_HINT_GLOBAL_FILE, exe_ext));
  1478. EDITOR_DEF("android/debug_keystore", "");
  1479. EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "android/debug_keystore", PROPERTY_HINT_GLOBAL_FILE, "keystore"));
  1480. EDITOR_DEF("android/debug_keystore_user", "androiddebugkey");
  1481. EDITOR_DEF("android/debug_keystore_pass", "android");
  1482. //EDITOR_DEF("android/release_keystore","");
  1483. //EDITOR_DEF("android/release_username","");
  1484. //EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,"android/release_keystore",PROPERTY_HINT_GLOBAL_FILE,"*.keystore"));
  1485. EDITOR_DEF("android/timestamping_authority_url", "");
  1486. EDITOR_DEF("android/use_remote_debug_over_adb", false);
  1487. EDITOR_DEF("android/shutdown_adb_on_exit", true);
  1488. Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>(memnew(EditorExportPlatformAndroid));
  1489. EditorImportExport::get_singleton()->add_export_platform(exporter);
  1490. }