main-common.h revision 092361e19ecc2992965729538984354099eea8cb
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> 16#include "android/cmdline-option.h" 17#include "android/skin/keyset.h" 18#include "android/config.h" 19#include "android/avd/hw-config.h" 20 21/* Common routines used by both android/main.c and android/main-ui.c */ 22 23/** Emulator user configuration (e.g. last window position) 24 **/ 25 26void user_config_init( void ); 27void user_config_done( void ); 28 29void user_config_get_window_pos( int *window_x, int *window_y ); 30 31#define ONE_MB (1024*1024) 32 33unsigned convertBytesToMB( uint64_t size ); 34uint64_t convertMBToBytes( unsigned megaBytes ); 35 36extern SkinKeyset* android_keyset; 37void parse_keyset(const char* keyset, AndroidOptions* opts); 38void write_default_keyset( void ); 39 40#define NETWORK_SPEED_DEFAULT "full" 41#define NETWORK_DELAY_DEFAULT "none" 42 43extern const char* skin_network_speed; 44extern const char* skin_network_delay; 45 46/* Find the skin corresponding to our options, and return an AConfig pointer 47 * and the base path to load skin data from 48 */ 49void parse_skin_files(const char* skinDirPath, 50 const char* skinName, 51 AndroidOptions* opts, 52 AndroidHwConfig* hwConfig, 53 AConfig* *skinConfig, 54 char* *skinPath); 55 56/* Returns the amount of pixels used by the default display. */ 57int64_t get_screen_pixels(AConfig* skinConfig); 58 59void init_sdl_ui(AConfig* skinConfig, 60 const char* skinPath, 61 AndroidOptions* opts); 62 63/* Creates and initializes AvdInfo instance for the given options. 64 * Param: 65 * opts - Options passed to the main() 66 * inAndroidBuild - Upon exit contains 0 if AvdInfo has been initialized from 67 * AVD file, or 1 if AvdInfo has been initialized from the build directory. 68 * Return: 69 * AvdInfo instance initialized for the given options. 70 */ 71struct AvdInfo* createAVD(AndroidOptions* opts, int* inAndroidBuild); 72 73/* Updates hardware configuration for the given AVD and options. 74 * Param: 75 * hwConfig - Hardware configuration to update. 76 * avd - AVD info containig paths for the hardware configuration. 77 * opts - Options passed to the main() 78 * inAndroidBuild - 0 if AVD has been initialized from AVD file, or 1 if AVD 79 * has been initialized from the build directory. 80 */ 81void updateHwConfigFromAVD(AndroidHwConfig* hwConfig, struct AvdInfo* avd, 82 AndroidOptions* opts, int inAndroidBuild); 83 84/* Called from android/main.c to handle options specific to the standalone 85 * UI program. This is a no-op otherwise. 86 */ 87void handle_ui_options( AndroidOptions* opts ); 88 89/* Called from android/main.c to potentially attach to a core from the 90 * standalone UI program. This is a no-op otherwise. 91 */ 92int attach_ui_to_core( AndroidOptions* opts ); 93 94#endif /* ANDROID_MAIN_COMMON_H */ 95