当咱们下载安装好,能够经过命令行运行指定名字模拟器linux
D:\ProgramFiles\Genymobile\Genymotion\player --vm-name "Samsung Galaxy S3 - 4.1.1 - API 16 - 720x1280"android
:: 列出虚拟设备 Genymotion installer path>\genyshell -c "devices list" :: Genymotion Shell > devices list :: :: |----------------------------------------------------------------------| :: | No Genymotion virtual device running found | :: | Please, run at least one Genymotion virtual device to use this shell | :: |----------------------------------------------------------------------| :: :: Available devices: :: :: Id | Select | Status | Type | IP Address | Name :: ----+--------+---------------+----------+-----------------+--------------- :: 0 | | Off | virtual | 0.0.0.0 | Google Nexus 7 - 5.1.0 - API 22 - 800x1280 :: 1 | | Off | virtual | 0.0.0.0 | Google Nexus S - 2.3.7 - API 10 - 480x800 :: 2 | | Off | virtual | 192.168.56.101 | Samsung Galaxy Note 2 - 4.2.2 - API 17 - 720x1280 :: 3 | | Off | virtual | 0.0.0.0 | Samsung Galaxy S4 - 4.3 - API 18 - 1080x1920 :: 启动某虚拟设备 <VM id | VM name> <Genymotion installer path>\player --vm-name "<virtual device name>"
Since Genymotion 2.5.0
gmtool admin create "Google Nexus 5 - 4.4.4 - API 19 - 1080x1920" myNexus
gmtool admin start myNexusgit
当使用genymotion的控制台shell时,一些命令在免费版本不可用,一样的界面上按钮也不可用。shell
其实,官方文档就有:https://www.genymotion.com/#!/support?chapter=start-virtual-devices-command-promptwindows
另外能够参考:How to start Genymotion device with shell command?服务器
D:\ProgramFiles\Oracle\VirtualBox>VBoxManage list dhcpservers NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #10 IP: 169.254.238.100 NetworkMask: 255.255.0.0 lowerIPAddress: 169.254.238.101 upperIPAddress: 169.254.238.254 Enabled: Yes NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #11 IP: 169.254.189.100 NetworkMask: 255.255.0.0 lowerIPAddress: 169.254.189.101 upperIPAddress: 169.254.189.254 Enabled: Yes NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #9 IP: 169.254.190.100 NetworkMask: 255.255.0.0 lowerIPAddress: 169.254.190.101 upperIPAddress: 169.254.190.254 Enabled: Yes NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter IP: 192.168.56.100 NetworkMask: 255.255.255.0 lowerIPAddress: 192.168.56.101 upperIPAddress: 192.168.56.254 Enabled: Yes NetworkName: NatNetwork IP: 10.0.2.3 NetworkMask: 255.255.255.0 lowerIPAddress: 10.0.2.4 upperIPAddress: 10.0.2.254 Enabled: Yes
先禁用virtual box 的dhcp功能 VBoxManage dhcpserver remove --netname "<name>"。网络
D:\ProgramFiles\Oracle\VirtualBox>VBoxManage dhcpserver remove --netname "HostInterfaceNetworking-Vi rtualBox Host-Only Ethernet Adapter #10" D:\ProgramFiles\Oracle\VirtualBox>VBoxManage dhcpserver remove --netname "HostInterfaceNetworking-Vi rtualBox Host-Only Ethernet Adapter #11" D:\ProgramFiles\Oracle\VirtualBox>VBoxManage dhcpserver remove --netname "HostInterfaceNetworking-Vi rtualBox Host-Only Ethernet Adapter #9" D:\ProgramFiles\Oracle\VirtualBox>VBoxManage list dhcpservers NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter IP: 192.168.56.100 NetworkMask: 255.255.255.0 lowerIPAddress: 192.168.56.101 upperIPAddress: 192.168.56.254 Enabled: Yes NetworkName: NatNetwork IP: 10.0.2.3 NetworkMask: 255.255.255.0 lowerIPAddress: 10.0.2.4 upperIPAddress: 10.0.2.254 Enabled: Yes
VirtualBox Host-Only ethernet Adapterapp
VirtualBox安装后会在Windows分配一个网卡——虚拟网卡而已,在控制面板\网络和 Internet\网络链接中能够看到 VirtualBox Host-Only Network,这个网卡的IP通常是
以太网适配器VirtualBox Host-Only Network:
链接特定的DNS 后缀. . . . . . . :
本地连接IPv6 地址. . . . . . . . : fe80::9849:c1ab:2f1b:f7f2%18
IPv4 地址. . . . . . . . . . . . : 192.168.56.1
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . : less
可是这里,有VirtualBox Host-Only Ethernet Adapter适配器,可是ipconfig没有看到地址。dom
无参ipconfig调用,默认状况下,仅显示绑定到 TCP/IP 的每一个适配器的 IP 地址、子网掩码和默认网关。
D:\ProgramFiles\Oracle\VirtualBox>ipconfig Windows IP 配置 以太网适配器 以太网: 媒体状态 . . . . . . . . . . . . : 媒体已断开链接 链接特定的 DNS 后缀 . . . . . . . : 无线局域网适配器 本地链接* 2: 媒体状态 . . . . . . . . . . . . : 媒体已断开链接 链接特定的 DNS 后缀 . . . . . . . : 以太网适配器 以太网 2: 链接特定的 DNS 后缀 . . . . . . . : 本地连接 IPv6 地址. . . . . . . . : fe80::4521:6580:93a9:16dc%43 IPv4 地址 . . . . . . . . . . . . : 192.168.56.1 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 无线局域网适配器 WLAN: 链接特定的 DNS 后缀 . . . . . . . : lan 本地连接 IPv6 地址. . . . . . . . : fe80::fc82:67dc:9ef4:c27f%17 IPv4 地址 . . . . . . . . . . . . : 192.168.100.105 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : 192.168.100.1 隧道适配器 isatap.lan: 媒体状态 . . . . . . . . . . . . : 媒体已断开链接 链接特定的 DNS 后缀 . . . . . . . : lan 隧道适配器 Teredo Tunneling Pseudo-Interface: 媒体状态 . . . . . . . . . . . . : 媒体已断开链接 链接特定的 DNS 后缀 . . . . . . . : 隧道适配器 isatap.{BB4C487E-1A6F-FFFF-BBBD-FEB6DFFFFFCF}: 媒体状态 . . . . . . . . . . . . : 媒体已断开链接 链接特定的 DNS 后缀 . . . . . . . : 带参数ipconfig /all ... 显示详细信息 D:\ProgramFiles\Oracle\VirtualBox>ipconfig /all Windows IP 配置 主机名 . . . . . . . . . . . . . : DESKTOP-IRTI28J 主 DNS 后缀 . . . . . . . . . . . : 节点类型 . . . . . . . . . . . . : 混合 IP 路由已启用 . . . . . . . . . . : 否 WINS 代理已启用 . . . . . . . . . : 否 DNS 后缀搜索列表 . . . . . . . . : lan 无线局域网适配器 本地链接* 2: 媒体状态 . . . . . . . . . . . . : 媒体已断开链接 链接特定的 DNS 后缀 . . . . . . . : 描述. . . . . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter 物理地址. . . . . . . . . . . . . : FF-FF-FF-FF-BF-63 DHCP 已启用 . . . . . . . . . . . : 是 自动配置已启用. . . . . . . . . . : 是 以太网适配器 以太网 2: 链接特定的 DNS 后缀 . . . . . . . : 描述. . . . . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter 物理地址. . . . . . . . . . . . . : 08-22-27-52-94-FE DHCP 已启用 . . . . . . . . . . . : 是 自动配置已启用. . . . . . . . . . : 是 本地连接 IPv6 地址. . . . . . . . : fe80::4521:6580:93a9:16dc%43(首选) IPv4 地址 . . . . . . . . . . . . : 192.168.56.1(首选) 子网掩码 . . . . . . . . . . . . : 255.255.255.0 默认网关. . . . . . . . . . . . . : DHCPv6 IAID . . . . . . . . . . . : 721944615 DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-1D-51-2B-73-00-90-F5-F6-AE-FD DNS 服务器 . . . . . . . . . . . : fec0:0:0:ffff::1%1 fec0:0:0:ffff::2%1 fec0:0:0:ffff::3%1 TCPIP 上的 NetBIOS . . . . . . . : 已启用 无线局域网适配器 WLAN: 链接特定的 DNS 后缀 . . . . . . . : lan 描述. . . . . . . . . . . . . . . : Realtek RTL8723AE Wireless LAN 802.11n PCI-E NIC 物理地址. . . . . . . . . . . . . : FF-E3-FF-FF-FF-FF DHCP 已启用 . . . . . . . . . . . : 是 自动配置已启用. . . . . . . . . . : 是 本地连接 IPv6 地址. . . . . . . . : fe80::fc82:67dc:9ef4:c27f%17(首选) IPv4 地址 . . . . . . . . . . . . : 192.168.100.105(首选) 子网掩码 . . . . . . . . . . . . : 255.255.255.0 得到租约的时间 . . . . . . . . . : 2015年11月9日 21:44:07 租约过时的时间 . . . . . . . . . : 2015年11月10日 21:59:41 默认网关. . . . . . . . . . . . . : 192.168.100.1 DHCP 服务器 . . . . . . . . . . . : 192.168.100.1 DHCPv6 IAID . . . . . . . . . . . : 103342919 DHCPv6 客户端 DUID . . . . . . . : 00-01-01-11-1D-51-2B-73-00-90-F5-F6-AE-FD DNS 服务器 . . . . . . . . . . . : 192.168.100.1 TCPIP 上的 NetBIOS . . . . . . . : 已启用
虽然早就看到这个问题的解决有一个是取消windows的hy设置,可是总觉得分配ip和这个无关。最后不得不关掉这个设置重启机器,确实可行,机器为win10。
安装好VirtualBox出现Host-Only,启动genymotion.exe出现Host-Only #2,启动一个虚拟机出现Host-Only #3 C:\Program Files\Oracle\VirtualBox>VBoxManage list dhcpservers NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter IP: 0.0.0.0 NetworkMask: 0.0.0.0 lowerIPAddress: 0.0.0.0 upperIPAddress: 0.0.0.0 Enabled: No NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #2 IP: 192.168.191.100 NetworkMask: 15.0.0.0 lowerIPAddress: 192.168.191.101 upperIPAddress: 192.168.191.254 Enabled: Yes NetworkName: HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter #3 IP: 192.168.43.100 NetworkMask: 15.0.0.0 lowerIPAddress: 192.168.43.101 upperIPAddress: 192.168.43.254 Enabled: Yes
Genymotion Shell > phone call 110
No valid license found. This command is not available with the Free version.
You can purchase a license on https://shop.genymotion.com/ to use this command.
>>> Failed
命令行工具crack要点:
搜索字符串,nop前一个跳转,尝试命令phone call 110,patch修改OK。
To modify sensor statuses and values of a virtual device, use the commands listed below:
devices list
devices refresh
devices select
devices ping
devices factoryreset
force
at the end skips the warning message about data loss.battery getmode
battery setmode
host
: the virtual battery values reflect the host battery values (if any);manual
: the virtual battery charge level and state of charge can be manually set.battery getlevel
battery setlevel
battery getstatus
battery setstatus
discharging
: simulates that the power supply is unplugged and the battery is discharging.charging
: simulates that the power supply is plugged in and the battery is charging.notcharging
: simulates that the power supply has just been unplugged and the battery is not discharging yet.full
: simulates that the battery is fully charged.gps getstatus
gps setstatus
enabled
: the GPS signal reception is enabled;disabled
: the GPS signal reception is disabled.gps getlatitude
gps setlatitude
gps getlongitude
gps setlongitude
gps getaltitude
gps setaltitude
gps getaccuracy
gps setaccuracy
gps getbearing
gps setbearing
rotation setangle
android version
android getandroidid
This is only possible with an Indie or a Business license.
android setandroidid
random
: a random Android ID number is generated;This is only possible with an Indie or a Business license.
If several users exist on the Android system, the Android ID can only be set for the first user.
android getdeviceid
This is only possible with an Indie or a Business license.
android setdeviceid
none
: no device ID number is generated.random
: a random device ID number is generated.This is only possible with an Indie or a Business license.
network getprofile
network setprofile
none
: no network profile is enabled.no-data
: no network connection is simulated.gprs
: a GPRS network connection is simulated.edge
: an Edge network connection is simulated.3g
: a 3G network connection is simulated.4g
: a 4G network connection is simulated.4g-high-losses
: a 4G network connection with packet loss set to 10% is simulated.4g-bad-dns
: a 4G network connection with a DNS delay set to 3000ms is simulated.wifi
: a Wi-Fi network connection is simulated.电话功能
phone call <phone_number> 模拟某号码的来电
phone sms <phone_number> <message> 模拟某号码的短信
phone baseband <command> 模拟基带命令
The phone baseband
commands send raw data directly to the baseband. In this section, you will find all commands available in Genymotion Shell to directly interact with the baseband.
Commands below return results in your logcat.
gsm list
gsm call <phone_number>
gsm busy <remote_number>
gsm hold <remote_number>
gsm accept <remote_number>
gsm cancel <phone_number>
gsm data
unregistered
or off
: no network available;home
or on
: on local network, non-roaming;roaming
: on roaming network;searching
: searching networks;denied
: emergency calls only.gsm voice
unregistered
or off
: no network available;home
or on
: on local network, non-roaming;roaming
: on roaming network;searching
: searching networks;denied
: emergency calls only.gsm status
gsm signal <rssi> <ber> <rs_snr>
rssi
: the value must range from 0 to 31. Returns 99 if the value is unknown.ber
: the value must range from 0% to 7%. Returns 99 if the value is unknown.rs_snr
: the value must range from -200 to 300.cdma ssource <ssource>
nv
: the subscription is read from non-volatile RAM;ruim
: the subscription is read from RUIM.cdma prl_version <version>
sms send <phone_number> <message>
sms pdu <hexstring>
where-to-find-info-on-androids-service-call-shell-command
检查服务是否存在
$ adb shell service check phone #< ServiceName >
Service phone: found
经过adb 命令拨打电话
adb shell service call phone 2 s16 "10086" #< PhoneNumber >
adb shell service call phone 5 s16
adb shell service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText"
经过adb 命令发送短信,须要两步
adb shell am start -a android.intent.action.SENDTO -d sms:10086(发送目的号码) --es sms_body "hello"(短信内容) --ez exit_on_sent true
adb shell input keyevent 66 // 模拟发送按键
MyApp:V
adb shell am start -a android.provider.Telephony.SMS_RECEIVED
lgocat一直报告错误:12-01 14:50:50.566: E/Genymotion(323): Could not open '/sys/class/power_supply/genymotion_fake_path/present'
控制台1或其余 | 控制台2:使用watchprops命令监控变化 |
C:\Users\fangss>adb shell root@android:/ # watchprops watchprops |
|
root@android:/ # setprop genyd.battery.mode host setprop genyd.battery.mode host |
1448952348 genyd.battery.mode = 'host' 1448952350 genyd.battery.mode = 'manual' 1448952350 genyd.battery.level = '50000000' 1448952350 genyd.battery.full = '50000000' 1448952350 genyd.battery.capacity = '100' 1448952350 genyd.battery.status = 'Not charging' 1448952350 genyd.ac.online = '1' |
从界面上的电池控制对话框关闭 | 1448952364 genyd.battery.mode = 'auto' 1448952365 genyd.battery.mode = 'manual' 1448952365 genyd.battery.level = '50000000' 1448952365 genyd.battery.full = '50000000' 1448952365 genyd.battery.capacity = '100' 1448952365 genyd.battery.status = 'Not charging' 1448952365 genyd.ac.online = '1' |
一、battery getmode:Return the current battery mode of the selected virtual device. (返回当前的电池模式选择的虚拟设备。)The mode can only be(该模式仅限于):
出来有一段时间了,如今流畅度和兼容度未知,地址http://www.andyroid.net
取得系统时间
要获得目前的时间,这个却是很容易,就是 System.currentTimeMillis()。不过要注意的是,这个函式传回的是 UTC (GMT) 这个时区的时间,像台湾所在的时区是 UTC+8,你得将这个函式所传回的值再加 8 个小时,才是你要的答案。实际上,固然不用本身加,你能够借用 Calendar 这个类别来帮你。
更改系统时间
要更改系统的时间,这可就难倒我了。在 m5 SDK 上,用 SystemClock.setCurrentTimeMillis(),虽然会有警告讯息,不过系统时间仍是会被更改。到了 v0.9 SDK,这招就没效了。扫过 Android 的原始程式,他们的确是用这个函式在更改系统时间。但是在个人程式里,无论我加了那些 permission,都是给我个 Permission denied 错误。最好,只好在 这里 发文问了这个问题,有个应该是 Google 的工程师,给了下面这个答案。
User apps cannot set the time. Only the system processes can. This is for security, but also because it won't have much effect--the time is reset from the radio via network time.
看了,要在 application 这一层更改系统时间,应该是没解了。若是有人知道其余答案的,帮忙解答一下。
取得与更改系统时区
用 TimeZone.getDefault() 就能够取得当前的时区,若是你没有特别设定的话,那你取到的,都是 GMT 这个时区。看起来,至少在 Windows 平台上, Android Emulator 仍是不会正确决定当前的时区。目前我知道的惟一方法就是,在启动 Emulator 的参数上,加上 -timezone "Asia/Taipei"。透过启动 Emulator 的参数能够更改时区,那能够透过 API 来更改系统时区吗?我试过 TimeZone.setDefault(TimeZone.getTimeZone("Asia/Taipei")),也用过 System.setProperty("user.timezone", "Asia/Taipei"),没一个有效。因此看起来,也暂时无解。有谁知道如何透过 API 更改系统时区?
设置系统的时区配置
cat /data/property/persist.sys.timezone //查看当前时区配置文件
setprop persist.sys.timezone GMT //修改属性
二、开始设置修改当前系统时间
date -s "yyyymmdd.[[[hh]mm]ss]" 或System/bin/date -s "yyyymmdd.[[[hh]mm]ss]"
三、查看是否生效
date
2、用代码实现修改android 系统时间的方法
public void testDate(){
try {
Process process = Runtime.getRuntime().exec("su");
String datetime="20131023.112800"; //测试的设置的时间【时间格式 yyyyMMdd.HHmmss】
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("setprop persist.sys.timezone GMT\n");
os.writeBytes("/system/bin/date -s "+datetime+"\n");
os.writeBytes("clock -w\n");
os.writeBytes("exit\n");
os.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
android默认系统日期、时间、时区更改
作android平台,常常会遇到产品须要更改系统默认时区日期时间的问题。android更改时区相对比较容易实现,网上也有不少资料,直接设置一个属性便可,例如设置上海东八区,persist.sys.timezone=Asia/Shanghai。可是如何实现更改默认系统时间呢?
在android中,Linux内核中、rtc时钟,默认的起始日期都是1970年1月1日,那么如何把默认日期指到2012-01-01呢?笔者在实践中发现,在RTC驱动中能够很容易实现。在RTC驱动加载的时候,通常都有个probe函数须要先执行,所以在probe函数里下手最直接有效。RTC从1970-01-01开始,那固然很容易把默认值设置到2012-01-01,所须要设置的seconds也就是从1970-01-01所差的秒数,以秒为单位。所以,一旦读出来的RTC值小于咱们预想的值好比2012-01-01(1325402913)小,咱们就把它设置到这个时间点。
[cpp] view plaincopy
1. seconds = rtc_read_time();
2. printk("init PMU/RTC time to %ld \n", seconds);
3.
4. if(seconds <= 1325402913) {
5. seconds = 1325402913;/*2012-01-01*/
6. ret = rtc_set_time(seconds);
7. RTC_DBG("Init Set time: %ld, ret =0x%x\n", seconds, ret);
8. }
笔者经过结果显示,在android平台上是可行的。要设置到哪天几点几分,只要算好具体1970-01-01 00:00差的秒数便可,简单明了。这样客户、用户使用起来更方便一些。