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 | |
David 'Digit' Turner | c5f12b9 | 2014-07-11 13:59:57 +0200 | [diff] [blame] | 26 | // Reset the value of |*string| to a copy of |new_value|. This |
| 27 | // will free() the previous value of |*string| first. |
| 28 | void reassign_string(char** string, const char* new_value); |
| 29 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 30 | /** Emulator user configuration (e.g. last window position) |
| 31 | **/ |
| 32 | |
David 'Digit' Turner | 755811e | 2011-02-07 13:38:25 +0100 | [diff] [blame] | 33 | void user_config_init( void ); |
| 34 | void user_config_done( void ); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 35 | |
David 'Digit' Turner | 755811e | 2011-02-07 13:38:25 +0100 | [diff] [blame] | 36 | 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] | 37 | |
| 38 | #define ONE_MB (1024*1024) |
| 39 | |
| 40 | unsigned convertBytesToMB( uint64_t size ); |
| 41 | uint64_t convertMBToBytes( unsigned megaBytes ); |
| 42 | |
| 43 | extern SkinKeyset* android_keyset; |
| 44 | void parse_keyset(const char* keyset, AndroidOptions* opts); |
| 45 | void write_default_keyset( void ); |
| 46 | |
David 'Digit' Turner | 092361e | 2011-03-01 13:14:18 +0100 | [diff] [blame] | 47 | #define NETWORK_SPEED_DEFAULT "full" |
| 48 | #define NETWORK_DELAY_DEFAULT "none" |
| 49 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 50 | extern const char* skin_network_speed; |
| 51 | extern const char* skin_network_delay; |
| 52 | |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 53 | /* Find the skin corresponding to our options, and return an AConfig pointer |
| 54 | * and the base path to load skin data from |
| 55 | */ |
| 56 | void parse_skin_files(const char* skinDirPath, |
| 57 | const char* skinName, |
| 58 | AndroidOptions* opts, |
David 'Digit' Turner | 2507cab | 2011-02-10 16:29:17 +0100 | [diff] [blame] | 59 | AndroidHwConfig* hwConfig, |
David 'Digit' Turner | 74d7ace | 2011-02-02 13:21:03 +0100 | [diff] [blame] | 60 | AConfig* *skinConfig, |
| 61 | char* *skinPath); |
| 62 | |
| 63 | /* Returns the amount of pixels used by the default display. */ |
| 64 | int64_t get_screen_pixels(AConfig* skinConfig); |
| 65 | |
| 66 | void init_sdl_ui(AConfig* skinConfig, |
| 67 | const char* skinPath, |
| 68 | AndroidOptions* opts); |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 69 | |
David 'Digit' Turner | 25eb655 | 2011-02-25 15:07:11 +0100 | [diff] [blame] | 70 | /* Sanitize options. This deals with a few legacy options that are now |
| 71 | * handled differently. Call before anything else that needs to read |
| 72 | * the options list. |
| 73 | */ |
| 74 | void sanitizeOptions( AndroidOptions* opts ); |
| 75 | |
Vladimir Chtchetkine | 83ffd66 | 2011-02-11 12:40:59 -0800 | [diff] [blame] | 76 | /* Creates and initializes AvdInfo instance for the given options. |
| 77 | * Param: |
| 78 | * opts - Options passed to the main() |
| 79 | * inAndroidBuild - Upon exit contains 0 if AvdInfo has been initialized from |
| 80 | * AVD file, or 1 if AvdInfo has been initialized from the build directory. |
| 81 | * Return: |
| 82 | * AvdInfo instance initialized for the given options. |
| 83 | */ |
| 84 | struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild); |
| 85 | |
David 'Digit' Turner | 25eb655 | 2011-02-25 15:07:11 +0100 | [diff] [blame] | 86 | /* Populate the hwConfig fields corresponding to the kernel/disk images |
| 87 | * used by the emulator. This will zero *hwConfig first. |
| 88 | */ |
| 89 | void findImagePaths( AndroidHwConfig* hwConfig, |
| 90 | AndroidOptions* opts ); |
| 91 | |
Vladimir Chtchetkine | 83ffd66 | 2011-02-11 12:40:59 -0800 | [diff] [blame] | 92 | /* Updates hardware configuration for the given AVD and options. |
| 93 | * Param: |
| 94 | * hwConfig - Hardware configuration to update. |
| 95 | * avd - AVD info containig paths for the hardware configuration. |
| 96 | * opts - Options passed to the main() |
| 97 | * inAndroidBuild - 0 if AVD has been initialized from AVD file, or 1 if AVD |
| 98 | * has been initialized from the build directory. |
| 99 | */ |
| 100 | void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd, |
| 101 | AndroidOptions* opts, int inAndroidBuild); |
| 102 | |
David 'Digit' Turner | bdb6f2d | 2011-02-23 15:57:25 +0100 | [diff] [blame] | 103 | /* Called from android/main.c to handle options specific to the standalone |
| 104 | * UI program. This is a no-op otherwise. |
| 105 | */ |
| 106 | void handle_ui_options( AndroidOptions* opts ); |
| 107 | |
| 108 | /* Called from android/main.c to potentially attach to a core from the |
| 109 | * standalone UI program. This is a no-op otherwise. |
| 110 | */ |
| 111 | int attach_ui_to_core( AndroidOptions* opts ); |
| 112 | |
David 'Digit' Turner | 57b2a76 | 2014-07-11 13:55:21 +0200 | [diff] [blame] | 113 | ANDROID_END_HEADER |
| 114 | |
David 'Digit' Turner | f845627 | 2011-02-02 12:34:14 +0100 | [diff] [blame] | 115 | #endif /* ANDROID_MAIN_COMMON_H */ |