David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 1 | /* Copyright (C) 2011 The Android Open Source Project |
| 2 | ** |
| 3 | ** This software is licensed under the terms of the GNU General Public |
| 4 | ** License version 2, as published by the Free Software Foundation, and |
| 5 | ** may be copied, distributed, and modified under those terms. |
| 6 | ** |
| 7 | ** This program is distributed in the hope that it will be useful, |
| 8 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | ** GNU General Public License for more details. |
| 11 | */ |
| 12 | #ifndef ANDROID_MAIN_COMMON_H |
| 13 | #define ANDROID_MAIN_COMMON_H |
| 14 | |
| 15 | #include <stdint.h> |
David 'Digit' Turner | 2507cab | 2011-02-10 16:29:17 +0100 | [diff] [blame] | 16 | #include "android/avd/hw-config.h" |
David 'Digit' Turner | 57b2a76 | 2014-07-11 13:55:21 +0200 | [diff] [blame^] | 17 | #include "android/cmdline-option.h" |
| 18 | #include "android/config-file.h" |
| 19 | #include "android/skin/keyset.h" |
| 20 | #include "android/utils/compiler.h" |
| 21 | |
| 22 | ANDROID_BEGIN_HEADER |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 23 | |
| 24 | /* Common routines used by both android/main.c and android/main-ui.c */ |
| 25 | |
| 26 | /** Emulator user configuration (e.g. last window position) |
| 27 | **/ |
| 28 | |
David 'Digit' Turner | 755811e | 2011-02-07 13:38:25 +0100 | [diff] [blame] | 29 | void user_config_init( void ); |
| 30 | void user_config_done( void ); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 31 | |
David 'Digit' Turner | 755811e | 2011-02-07 13:38:25 +0100 | [diff] [blame] | 32 | void user_config_get_window_pos( int *window_x, int *window_y ); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 33 | |
| 34 | #define ONE_MB (1024*1024) |
| 35 | |
| 36 | unsigned convertBytesToMB( uint64_t size ); |
| 37 | uint64_t convertMBToBytes( unsigned megaBytes ); |
| 38 | |
| 39 | extern SkinKeyset* android_keyset; |
| 40 | void parse_keyset(const char* keyset, AndroidOptions* opts); |
| 41 | void write_default_keyset( void ); |
| 42 | |
David 'Digit' Turner | 092361e | 2011-03-01 13:14:18 +0100 | [diff] [blame] | 43 | #define NETWORK_SPEED_DEFAULT "full" |
| 44 | #define NETWORK_DELAY_DEFAULT "none" |
| 45 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 46 | extern const char* skin_network_speed; |
| 47 | extern const char* skin_network_delay; |
| 48 | |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 49 | /* Find the skin corresponding to our options, and return an AConfig pointer |
| 50 | * and the base path to load skin data from |
| 51 | */ |
| 52 | void parse_skin_files(const char* skinDirPath, |
| 53 | const char* skinName, |
| 54 | AndroidOptions* opts, |
David 'Digit' Turner | 2507cab | 2011-02-10 16:29:17 +0100 | [diff] [blame] | 55 | AndroidHwConfig* hwConfig, |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 56 | AConfig* *skinConfig, |
| 57 | char* *skinPath); |
| 58 | |
| 59 | /* Returns the amount of pixels used by the default display. */ |
| 60 | int64_t get_screen_pixels(AConfig* skinConfig); |
| 61 | |
| 62 | void init_sdl_ui(AConfig* skinConfig, |
| 63 | const char* skinPath, |
| 64 | AndroidOptions* opts); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 65 | |
David 'Digit' Turner | 25eb655 | 2011-02-25 15:07:11 +0100 | [diff] [blame] | 66 | /* Sanitize options. This deals with a few legacy options that are now |
| 67 | * handled differently. Call before anything else that needs to read |
| 68 | * the options list. |
| 69 | */ |
| 70 | void sanitizeOptions( AndroidOptions* opts ); |
| 71 | |
Vladimir Chtchetkine | 83ffd66 | 2011-02-11 12:40:59 -0800 | [diff] [blame] | 72 | /* Creates and initializes AvdInfo instance for the given options. |
| 73 | * Param: |
| 74 | * opts - Options passed to the main() |
| 75 | * inAndroidBuild - Upon exit contains 0 if AvdInfo has been initialized from |
| 76 | * AVD file, or 1 if AvdInfo has been initialized from the build directory. |
| 77 | * Return: |
| 78 | * AvdInfo instance initialized for the given options. |
| 79 | */ |
| 80 | struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild); |
| 81 | |
David 'Digit' Turner | 25eb655 | 2011-02-25 15:07:11 +0100 | [diff] [blame] | 82 | /* Populate the hwConfig fields corresponding to the kernel/disk images |
| 83 | * used by the emulator. This will zero *hwConfig first. |
| 84 | */ |
| 85 | void findImagePaths( AndroidHwConfig* hwConfig, |
| 86 | AndroidOptions* opts ); |
| 87 | |
Vladimir Chtchetkine | 83ffd66 | 2011-02-11 12:40:59 -0800 | [diff] [blame] | 88 | /* Updates hardware configuration for the given AVD and options. |
| 89 | * Param: |
| 90 | * hwConfig - Hardware configuration to update. |
| 91 | * avd - AVD info containig paths for the hardware configuration. |
| 92 | * opts - Options passed to the main() |
| 93 | * inAndroidBuild - 0 if AVD has been initialized from AVD file, or 1 if AVD |
| 94 | * has been initialized from the build directory. |
| 95 | */ |
| 96 | void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd, |
| 97 | AndroidOptions* opts, int inAndroidBuild); |
| 98 | |
David 'Digit' Turner | bdb6f2d | 2011-02-23 15:57:25 +0100 | [diff] [blame] | 99 | /* Called from android/main.c to handle options specific to the standalone |
| 100 | * UI program. This is a no-op otherwise. |
| 101 | */ |
| 102 | void handle_ui_options( AndroidOptions* opts ); |
| 103 | |
| 104 | /* Called from android/main.c to potentially attach to a core from the |
| 105 | * standalone UI program. This is a no-op otherwise. |
| 106 | */ |
| 107 | int attach_ui_to_core( AndroidOptions* opts ); |
| 108 | |
David 'Digit' Turner | 57b2a76 | 2014-07-11 13:55:21 +0200 | [diff] [blame^] | 109 | ANDROID_END_HEADER |
| 110 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 111 | #endif /* ANDROID_MAIN_COMMON_H */ |