1f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner/* Copyright (C) 2011 The Android Open Source Project
2f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner**
3f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** This software is licensed under the terms of the GNU General Public
4f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** License version 2, as published by the Free Software Foundation, and
5f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** may be copied, distributed, and modified under those terms.
6f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner**
7f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** This program is distributed in the hope that it will be useful,
8f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** but WITHOUT ANY WARRANTY; without even the implied warranty of
9f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner** GNU General Public License for more details.
11f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner*/
12f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner#ifndef ANDROID_MAIN_COMMON_H
13f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner#define ANDROID_MAIN_COMMON_H
14f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
15f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner#include <stdint.h>
1657b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' Turner#include "android/avd/hw-config.h"
17f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner#include "android/cmdline-option.h"
1873dd5fc7da33280597dc6302ad8116d3723ebf3eDavid 'Digit' Turner#include "android/config-file.h"
1957b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' Turner#include "android/skin/keyset.h"
2057b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' Turner#include "android/utils/compiler.h"
2157b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' Turner
2257b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' TurnerANDROID_BEGIN_HEADER
23f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
24f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner/* Common routines used by both android/main.c and android/main-ui.c */
25f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
26c5f12b935ced6c029244b1a3230edc9b7646da97David 'Digit' Turner// Reset the value of |*string| to a copy of |new_value|. This
27c5f12b935ced6c029244b1a3230edc9b7646da97David 'Digit' Turner// will free() the previous value of |*string| first.
28c5f12b935ced6c029244b1a3230edc9b7646da97David 'Digit' Turnervoid reassign_string(char** string, const char* new_value);
29c5f12b935ced6c029244b1a3230edc9b7646da97David 'Digit' Turner
30f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner/** Emulator user configuration (e.g. last window position)
31f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner **/
32f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
33755811e67c266333807571f798b62b6916611f87David 'Digit' Turnervoid user_config_init( void );
34755811e67c266333807571f798b62b6916611f87David 'Digit' Turnervoid user_config_done( void );
35f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
36755811e67c266333807571f798b62b6916611f87David 'Digit' Turnervoid user_config_get_window_pos( int *window_x, int *window_y );
37f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
38f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner#define  ONE_MB  (1024*1024)
39f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
40f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turnerunsigned convertBytesToMB( uint64_t  size );
41f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turneruint64_t convertMBToBytes( unsigned  megaBytes );
42f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
43f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turnerextern SkinKeyset*  android_keyset;
44f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turnervoid parse_keyset(const char*  keyset, AndroidOptions*  opts);
45f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turnervoid write_default_keyset( void );
46f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
47092361e19ecc2992965729538984354099eea8cbDavid 'Digit' Turner#define NETWORK_SPEED_DEFAULT  "full"
48092361e19ecc2992965729538984354099eea8cbDavid 'Digit' Turner#define NETWORK_DELAY_DEFAULT  "none"
49092361e19ecc2992965729538984354099eea8cbDavid 'Digit' Turner
50f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turnerextern const char*  skin_network_speed;
51f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turnerextern const char*  skin_network_delay;
52f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
5374d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner/* Find the skin corresponding to our options, and return an AConfig pointer
5474d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner * and the base path to load skin data from
5574d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner */
5674d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turnervoid parse_skin_files(const char*      skinDirPath,
5774d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner                      const char*      skinName,
5874d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner                      AndroidOptions*  opts,
592507cab8a78fb609461a2b9cc4708bab60fc53a4David 'Digit' Turner                      AndroidHwConfig* hwConfig,
6074d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner                      AConfig*        *skinConfig,
6174d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner                      char*           *skinPath);
6274d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner
6374d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner/* Returns the amount of pixels used by the default display. */
6474d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turnerint64_t  get_screen_pixels(AConfig*  skinConfig);
6574d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner
6674d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turnervoid init_sdl_ui(AConfig*         skinConfig,
6774d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner                 const char*      skinPath,
6874d7acec6643694132a127feb5ccadda7ea793d6David 'Digit' Turner                 AndroidOptions*  opts);
69f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner
7025eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner/* Sanitize options. This deals with a few legacy options that are now
7125eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner * handled differently. Call before anything else that needs to read
7225eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner * the options list.
7325eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner */
7425eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turnervoid sanitizeOptions( AndroidOptions* opts );
7525eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner
7683ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine/* Creates and initializes AvdInfo instance for the given options.
7783ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine * Param:
7883ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  opts - Options passed to the main()
7983ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  inAndroidBuild - Upon exit contains 0 if AvdInfo has been initialized from
8083ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *      AVD file, or 1 if AvdInfo has been initialized from the build directory.
8183ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine * Return:
8283ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  AvdInfo instance initialized for the given options.
8383ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine */
8483ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkinestruct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild);
8583ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine
8625eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner/* Populate the hwConfig fields corresponding to the kernel/disk images
8725eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner * used by the emulator. This will zero *hwConfig first.
8825eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner */
8925eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turnervoid findImagePaths( AndroidHwConfig*  hwConfig,
9025eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner                     AndroidOptions*   opts );
9125eb6557b94da066d6e137c07aeced39badf5aa6David 'Digit' Turner
9283ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine/* Updates hardware configuration for the given AVD and options.
9383ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine * Param:
9483ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  hwConfig - Hardware configuration to update.
9583ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  avd - AVD info containig paths for the hardware configuration.
9683ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  opts - Options passed to the main()
9783ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *  inAndroidBuild - 0 if AVD has been initialized from AVD file, or 1 if AVD
9883ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine *      has been initialized from the build directory.
9983ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine */
10083ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkinevoid updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd,
10183ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine                           AndroidOptions* opts, int inAndroidBuild);
10283ffd66e78d290aa054ace5e484ae3766f638390Vladimir Chtchetkine
103bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner/* Called from android/main.c to handle options specific to the standalone
104bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner * UI program. This is a no-op otherwise.
105bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner */
106bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turnervoid handle_ui_options( AndroidOptions* opts );
107bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner
108bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner/* Called from android/main.c to potentially attach to a core from the
109bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner * standalone UI program. This is a no-op otherwise.
110bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner */
111bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turnerint attach_ui_to_core( AndroidOptions* opts );
112bdb6f2dd35a4c749186e665d55d7b76375d7e71dDavid 'Digit' Turner
11357b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' TurnerANDROID_END_HEADER
11457b2a766f7af808f7670aecbe57a18373a903a0dDavid 'Digit' Turner
115f845627c83ce6ce3e306f9b6842d1e30ef89ae97David 'Digit' Turner#endif /* ANDROID_MAIN_COMMON_H */
116