blob: 38efbd529c6bc323c2a67921f97ff6ba55d43024 [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
26/** Emulator user configuration (e.g. last window position)
27 **/
28
David 'Digit' Turner755811e2011-02-07 13:38:25 +010029void user_config_init( void );
30void user_config_done( void );
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010031
David 'Digit' Turner755811e2011-02-07 13:38:25 +010032void user_config_get_window_pos( int *window_x, int *window_y );
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010033
34#define ONE_MB (1024*1024)
35
36unsigned convertBytesToMB( uint64_t size );
37uint64_t convertMBToBytes( unsigned megaBytes );
38
39extern SkinKeyset* android_keyset;
40void parse_keyset(const char* keyset, AndroidOptions* opts);
41void write_default_keyset( void );
42
David 'Digit' Turner092361e2011-03-01 13:14:18 +010043#define NETWORK_SPEED_DEFAULT "full"
44#define NETWORK_DELAY_DEFAULT "none"
45
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010046extern const char* skin_network_speed;
47extern const char* skin_network_delay;
48
David 'Digit' Turner74d7ace2011-02-02 13:21:03 +010049/* Find the skin corresponding to our options, and return an AConfig pointer
50 * and the base path to load skin data from
51 */
52void parse_skin_files(const char* skinDirPath,
53 const char* skinName,
54 AndroidOptions* opts,
David 'Digit' Turner2507cab2011-02-10 16:29:17 +010055 AndroidHwConfig* hwConfig,
David 'Digit' Turner74d7ace2011-02-02 13:21:03 +010056 AConfig* *skinConfig,
57 char* *skinPath);
58
59/* Returns the amount of pixels used by the default display. */
60int64_t get_screen_pixels(AConfig* skinConfig);
61
62void init_sdl_ui(AConfig* skinConfig,
63 const char* skinPath,
64 AndroidOptions* opts);
David 'Digit' Turnerf8456272011-02-02 12:34:14 +010065
David 'Digit' Turner25eb6552011-02-25 15:07:11 +010066/* 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 */
70void sanitizeOptions( AndroidOptions* opts );
71
Vladimir Chtchetkine83ffd662011-02-11 12:40:59 -080072/* 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 */
80struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild);
81
David 'Digit' Turner25eb6552011-02-25 15:07:11 +010082/* Populate the hwConfig fields corresponding to the kernel/disk images
83 * used by the emulator. This will zero *hwConfig first.
84 */
85void findImagePaths( AndroidHwConfig* hwConfig,
86 AndroidOptions* opts );
87
Vladimir Chtchetkine83ffd662011-02-11 12:40:59 -080088/* 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 */
96void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd,
97 AndroidOptions* opts, int inAndroidBuild);
98
David 'Digit' Turnerbdb6f2d2011-02-23 15:57:25 +010099/* Called from android/main.c to handle options specific to the standalone
100 * UI program. This is a no-op otherwise.
101 */
102void 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 */
107int attach_ui_to_core( AndroidOptions* opts );
108
David 'Digit' Turner57b2a762014-07-11 13:55:21 +0200109ANDROID_END_HEADER
110
David 'Digit' Turnerf8456272011-02-02 12:34:14 +0100111#endif /* ANDROID_MAIN_COMMON_H */