export.cpp 50 KB

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