blob: 53c9029462450812dcf1fb9162b01fcb1ac20ff8 [file] [log] [blame]
David 'Digit' Turnerf8456272011-02-02 12:34:14 +01001/* 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' Turner2507cab2011-02-10 16:29:17 +010016#include "android/avd/hw-config.h"
David 'Digit' Turner57b2a762014-07-11 13:55:21 +020017#include "android/cmdline-option.h"
18#include "android/config-file.h"
19#include "android/skin/keyset.h"
20#include "android/utils/compiler.h"
21
22ANDROID_BEGIN_HEADER
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010023
24/* Common routines used by both android/main.c and android/main-ui.c */
25
David 'Digit' Turnerc5f12b92014-07-11 13:59:57 +020026// Reset the value of |*string| to a copy of |new_value|. This
27// will free() the previous value of |*string| first.
28void reassign_string(char** string, const char* new_value);
29
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010030/** Emulator user configuration (e.g. last window position)
31 **/
32
David 'Digit' Turner755811e2011-02-07 13:38:25 +010033void user_config_init( void );
34void user_config_done( void );
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010035
David 'Digit' Turner755811e2011-02-07 13:38:25 +010036void user_config_get_window_pos( int *window_x, int *window_y );
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010037
38#define ONE_MB (1024*1024)
39
40unsigned convertBytesToMB( uint64_t size );
41uint64_t convertMBToBytes( unsigned megaBytes );
42
43extern SkinKeyset* android_keyset;
44void parse_keyset(const char* keyset, AndroidOptions* opts);
45void write_default_keyset( void );
46
David 'Digit' Turner092361e2011-03-01 13:14:18 +010047#define NETWORK_SPEED_DEFAULT "full"
48#define NETWORK_DELAY_DEFAULT "none"
49
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010050extern const char* skin_network_speed;
51extern const char* skin_network_delay;
52
David 'Digit' Turner74d7ace2011-02-02 13:21:03 +010053/* Find the skin corresponding to our options, and return an AConfig pointer
54 * and the base path to load skin data from
55 */
56void parse_skin_files(const char* skinDirPath,
57 const char* skinName,
58 AndroidOptions* opts,
David 'Digit' Turner2507cab2011-02-10 16:29:17 +010059 AndroidHwConfig* hwConfig,
David 'Digit' Turner74d7ace2011-02-02 13:21:03 +010060 AConfig* *skinConfig,
61 char* *skinPath);
62
63/* Returns the amount of pixels used by the default display. */
64int64_t get_screen_pixels(AConfig* skinConfig);
65
66void init_sdl_ui(AConfig* skinConfig,
67 const char* skinPath,
68 AndroidOptions* opts);
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010069
David 'Digit' Turner25eb6552011-02-25 15:07:11 +010070/* 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 */
74void sanitizeOptions( AndroidOptions* opts );
75
Vladimir Chtchetkine83ffd662011-02-11 12:40:59 -080076/* 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 */
84struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild);
85
David 'Digit' Turner25eb6552011-02-25 15:07:11 +010086/* Populate the hwConfig fields corresponding to the kernel/disk images
87 * used by the emulator. This will zero *hwConfig first.
88 */
89void findImagePaths( AndroidHwConfig* hwConfig,
90 AndroidOptions* opts );
91
Vladimir Chtchetkine83ffd662011-02-11 12:40:59 -080092/* 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 */
100void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd,
101 AndroidOptions* opts, int inAndroidBuild);
102
David 'Digit' Turnerbdb6f2d2011-02-23 15:57:25 +0100103/* Called from android/main.c to handle options specific to the standalone
104 * UI program. This is a no-op otherwise.
105 */
106void 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 */
111int attach_ui_to_core( AndroidOptions* opts );
112
David 'Digit' Turner57b2a762014-07-11 13:55:21 +0200113ANDROID_END_HEADER
114
David 'Digit' Turnerf8456272011-02-02 12:34:14 +0100115#endif /* ANDROID_MAIN_COMMON_H */