aboutsummaryrefslogtreecommitdiffstats
path: root/android/protocol/core-commands-qemu.c
blob: 76b3abb90dfcf3defc6d02798a25ff48164bef66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* Copyright (C) 2010 The Android Open Source Project
**
** This software is licensed under the terms of the GNU General Public
** License version 2, as published by the Free Software Foundation, and
** may be copied, distributed, and modified under those terms.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
*/

/*
 * Contains implementation of the API for calling into the Core with the UI
 * control commands for standalone (monolithic) emulator.
 */

#include "android/android.h"
#include "android/globals.h"
#include "android/hw-sensors.h"
#include "telephony/modem_driver.h"
#include "android-trace.h"
#include "audio/audio.h"
#include "android/protocol/core-commands-api.h"

/* Implemented in vl-android.c */
extern char* qemu_find_file(int type, const char* filename);

int
corecmd_set_coarse_orientation(AndroidCoarseOrientation orient)
{
    android_sensors_set_coarse_orientation(orient);
    return 0;
}

int
corecmd_toggle_network()
{
    qemu_net_disable = !qemu_net_disable;
    if (android_modem) {
        amodem_set_data_registration(
                android_modem,
        qemu_net_disable ? A_REGISTRATION_UNREGISTERED
            : A_REGISTRATION_HOME);
    }
    return 0;
}

int corecmd_trace_control(int start)
{
    if (start) {
        start_tracing();
    } else {
        stop_tracing();
    }
    return 0;
}

int corecmd_is_network_disabled()
{
    return qemu_net_disable;
}

int
corecmd_get_netspeed(int index, NetworkSpeed** netspeed)
{
    if (index >= android_netspeeds_count ||
        android_netspeeds[index].name == NULL) {
        return -1;
    }
    *netspeed = (NetworkSpeed*)malloc(sizeof(NetworkSpeed));
    memcpy(*netspeed, &android_netspeeds[index], sizeof(NetworkSpeed));
    return 0;
}

int
corecmd_get_netdelay(int index, NetworkLatency** netdelay)
{
    if (index >= android_netdelays_count ||
        android_netdelays[index].name == NULL) {
        return -1;
    }
    *netdelay = (NetworkLatency*)malloc(sizeof(NetworkLatency));
    memcpy(*netdelay, &android_netdelays[index], sizeof(NetworkLatency));
    return 0;
}

int
corecmd_get_qemu_path(int type,
                      const char* filename,
                      char* path,
                      size_t path_buf_size)
{
    char* filepath = qemu_find_file(type, filename);
    if (filepath == NULL) {
        return -1;
    }
    strncpy(path, filepath, path_buf_size);
    path[path_buf_size - 1] = '\0';
    qemu_free(filepath);
    return 0;
}

int
corecmd_get_hw_lcd_density(void)
{
    return android_hw->hw_lcd_density;
}