Atomic类用于保证变量操作的原子性,先记录,有时间再进行研究 :-(
出现这种错误一般是输入的keystore的密钥有问题了
重新输入一下打包的密钥就可以了
ubuntu14.04编译Android4.4源码注意事项
需要安装的库(下载代码前):
sudo apt-get install curl
sudo apt-get install git
需要安装的库(编译前):
sudo apt-get install git git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev
sudo apt-get install lib32ncurses5-dev x11proto-core-dev libx11-dev
sudo apt-get install lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown
sudo apt-get install lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown
sudo apt-get install lib32readline-gplv2-dev
sudo apt-get install libxml2-utils
使用adb获取Android系统版本号
使用adb shell getprop即可获得Android系统的版本号,如下:
1 2 3 |
获取系统版本:adb shell getprop ro.build.version.release 获取系统api版本:adb shell getprop ro.build.version.sdk |
另外直接执行adb shell getprop还可以获得更多的系统属性,如下是我机器显示的结果:
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
[alsa.mixer.capture.headset]: [Capture] [alsa.mixer.capture.master]: [Capture] [alsa.mixer.playback.headset]: [Headphone] [alsa.mixer.playback.master]: [Playback] [alsa.mixer.playback.speaker]: [Playback] [back_camera_name]: [adv7180_decoder] [back_camera_orient]: [0] [camera.disable_zsl_mode]: [1] [dalvik.vm.dexopt-flags]: [m=y] [dalvik.vm.heapgrowthlimit]: [64m] [dalvik.vm.heapmaxfree]: [8m] [dalvik.vm.heapminfree]: [512k] [dalvik.vm.heapsize]: [384m] [dalvik.vm.heapstartsize]: [8m] [dalvik.vm.heaptargetutilization]: [0.75] [dalvik.vm.jniopts]: [warnonly] [dalvik.vm.stack-trace-file]: [/data/anr/traces.txt] [debug.egl.hw]: [1] [debug.force_rtl]: [0] [debug.sf.enable_hgl]: [1] [debug.sf.showfps]: [0] [dev.bootcomplete]: [1] [dhcp.wlan0.dns1]: [192.168.8.5] [dhcp.wlan0.dns2]: [114.114.114.114] [dhcp.wlan0.dns3]: [] [dhcp.wlan0.dns4]: [] [dhcp.wlan0.domain]: [] [dhcp.wlan0.gateway]: [192.168.23.1] [dhcp.wlan0.ipaddress]: [192.168.23.100] [dhcp.wlan0.leasetime]: [86400] [dhcp.wlan0.mask]: [255.255.255.0] [dhcp.wlan0.mtu]: [] [dhcp.wlan0.pid]: [1440] [dhcp.wlan0.reason]: [REBOOT] [dhcp.wlan0.result]: [ok] [dhcp.wlan0.server]: [192.168.23.1] [dhcp.wlan0.vendorInfo]: [] [front_camera_name]: [uvc] [front_camera_orient]: [0] [gsm.current.phone-type]: [1] [gsm.network.type]: [Unknown] [gsm.operator.alpha]: [] [gsm.operator.iso-country]: [] [gsm.operator.isroaming]: [false] [gsm.operator.numeric]: [] [gsm.ril.delay]: [15] [gsm.sim.state]: [NOT_READY] [hw.backlight.dev]: [pwm-backlight.0] [hw.bluetooth]: [0] [hwc.enable_dither]: [1] [hwc.stretch.filter]: [1] [init.svc.adbd]: [running] [init.svc.blueletd]: [running] [init.svc.bootanim]: [stopped] [init.svc.console]: [running] [init.svc.debuggerd]: [running] [init.svc.dhcpcd_wlan0]: [running] [init.svc.drm]: [running] [init.svc.healthd]: [running] [init.svc.installd]: [running] [init.svc.keystore]: [running] [init.svc.magd]: [stopped] [init.svc.mcu_server]: [running] [init.svc.media]: [running] [init.svc.netd]: [running] [init.svc.ril-daemon]: [running] [init.svc.sdcard]: [running] [init.svc.servicemanager]: [running] [init.svc.surfaceflinger]: [running] [init.svc.tw8836]: [stopped] [init.svc.ueventd]: [running] [init.svc.vold]: [running] [init.svc.watchdogd]: [running] [init.svc.wifi_mac]: [stopped] [init.svc.wpa_supplicant]: [running] [init.svc.zygote]: [running] [media.omxgm.enable-player]: [1] [media.omxgm.enable-record]: [1] [media.omxgm.enable-scan]: [1] [media.wfd.video-bitrate]: [adaptive] [net.bt.name]: [Android] [net.change]: [net.dns2] [net.dns1]: [192.168.8.5] [net.dns2]: [114.114.114.114] [net.hostname]: [android-4e5bb95fd128e923] [net.qtaguid_enabled]: [1] [net.tcp.buffersize.default]: [4096,87380,110208,4096,16384,110208] [net.tcp.buffersize.edge]: [4093,26280,35040,4096,16384,35040] [net.tcp.buffersize.ethernet]: [524288,2097152,4194304,524288,2097152,4194304] [net.tcp.buffersize.evdo]: [4094,87380,262144,4096,16384,262144] [net.tcp.buffersize.gprs]: [4092,8760,11680,4096,8760,11680] [net.tcp.buffersize.hsdpa]: [4094,87380,262144,4096,16384,262144] [net.tcp.buffersize.hspa]: [4094,87380,262144,4096,16384,262144] [net.tcp.buffersize.hspap]: [4094,87380,1220608,4096,16384,1220608] [net.tcp.buffersize.hsupa]: [4094,87380,262144,4096,16384,262144] [net.tcp.buffersize.lte]: [524288,1048576,2097152,262144,524288,1048576] [net.tcp.buffersize.umts]: [4094,87380,110208,4096,16384,110208] [net.tcp.buffersize.wifi]: [524288,1048576,2097152,262144,524288,1048576] [persist.sampling_profiler]: [1] [persist.sys.country]: [CN] [persist.sys.dalvik.vm.lib]: [libdvm.so] [persist.sys.language]: [zh] [persist.sys.localevar]: [] [persist.sys.profiler_ms]: [0] [persist.sys.usb.config]: [mtp,adb] [ro.FSL_AAC_PARSER]: [1] [ro.FSL_ASF_PARSER]: [0] [ro.FSL_AVI_PARSER]: [1] [ro.FSL_FLAC_PARSER]: [1] [ro.FSL_FLV_PARSER]: [1] [ro.FSL_MKV_PARSER]: [1] [ro.FSL_MPG2_PARSER]: [1] [ro.FSL_REAL_PARSER]: [0] [ro.adb.secure]: [1] [ro.allow.mock.location]: [1] [ro.baseband]: [unknown] [ro.board.platform]: [imx6] [ro.boot.console]: [ttymxc3] [ro.boot.hardware]: [freescale] [ro.boot.selinux]: [disabled] [ro.boot.serialno]: [0a05a1d4e6b61f90] [ro.bootloader]: [unknown] [ro.bootmode]: [unknown] [ro.build.characteristics]: [tablet] [ro.build.date.utc]: [1508731143] [ro.build.date]: [2017年 10月 23日 星期一 11:59:03 CST] [ro.build.description]: [sabreauto_6q-eng 4.4.3 2.0.0-rc2 20150123 dev-keys] [ro.build.display.id]: [sabreauto_6q-eng 4.4.3 2.0.0-rc2 20150123 dev-keys] [ro.build.fingerprint]: [Freescale/sabreauto_6q/sabreauto_6q:4.4.3/2.0.0-rc2/20150123:eng/dev-keys] [ro.build.host]: [chinatsp] [ro.build.id]: [2.0.0-rc2] [ro.build.product]: [sabreauto_6q] [ro.build.tags]: [dev-keys] [ro.build.type]: [eng] [ro.build.user]: [xuganggen] [ro.build.version.codename]: [REL] [ro.build.version.incremental]: [20150123] [ro.build.version.release]: [4.4.3] [ro.build.version.sdk]: [19] [ro.carrier]: [unknown] [ro.config.alarm_alert]: [Alarm_Classic.ogg] [ro.config.notification_sound]: [OnTheHunt.ogg] [ro.crypto.state]: [unencrypted] [ro.debuggable]: [1] [ro.factorytest]: [0] [ro.hardware.lightsensor]: [/sys/class/i2c-dev/i2c-1/device/1-0044/] [ro.hardware]: [freescale] [ro.kernel.android.checkjni]: [1] [ro.lightsensor.threshold]: [20] [ro.opengles.version]: [196608] [ro.product.board]: [SABREAUTO] [ro.product.brand]: [Freescale] [ro.product.cpu.abi2]: [armeabi] [ro.product.cpu.abi]: [armeabi-v7a] [ro.product.device]: [sabreauto_6q] [ro.product.locale.language]: [en] [ro.product.locale.region]: [US] [ro.product.manufacturer]: [Freescale] [ro.product.model]: [SABREAUTO-MX6Q] [ro.product.name]: [sabreauto_6q] [ro.revision]: [0] [ro.ril.wake_lock_timeout]: [300] [ro.runtime.firstboot]: [86414407] [ro.secure]: [0] [ro.serialno]: [0a05a1d4e6b61f90] [ro.sf.hwrotation]: [0] [ro.sf.lcd_density]: [160] [ro.tether.denied]: [false] [ro.wifi.channels]: [] [ro.zygote.disable_gl_preload]: [true] [rw.VIDEO_RENDER_NAME]: [video_render.surface] [service.bootanim.exit]: [1] [sys.boot_completed]: [1] [sys.emulated.battery]: [1] [sys.interactive]: [active] [sys.settings_global_version]: [2] [sys.sysctl.extra_free_kbytes]: [16200] [sys.usb.config]: [mtp,adb] [sys.usb.state]: [mtp,adb] [system_init.startsurfaceflinger]: [0] [vold.post_fs_data_done]: [1] [wifi.ap.interface]: [wlan0] [wifi.interface]: [wlan0] [wlan.driver.status]: [ok] [wlan.interface]: [wlan0] |
Java实现回形遍历的代码
本来以为这样的回形是有规律可循的,但是找了好长时间没找到,看来只能用遍历了。
x,y的使用有些乱,读者自己理一下吧
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 |
private String huiXingBianLi(){ final int FLAG_RIGHT = 0; final int FLAG_DOWN = 1; final int FLAG_LEFT = 2; final int FLAG_UP = 3; String resultStr = ""; int flag = FLAG_RIGHT; final int countx = 10; final int county = 11; int x = 0, y = 0; int minx = 0, maxx = county - 1, miny = 1, maxy = countx - 1; int[][] result = new int[countx][county]; int i = 0; while(i < countx * county){ result[y][x] = ++i; if(flag == FLAG_RIGHT){ if(x >= maxx){ maxx--; y++; flag = FLAG_DOWN; continue; }else{ x++; } } if(flag == FLAG_DOWN){ if(y >= maxy){ maxy--; x--; flag = FLAG_LEFT; continue; }else{ y++; } } if(flag == FLAG_LEFT){ if(x <= minx){ minx++; y--; flag = FLAG_UP; continue; }else{ x--; } } if(flag == FLAG_UP){ if(y <= miny){ miny++; x++; flag = FLAG_RIGHT; continue; }else{ y--; } } } resultStr = ""; for(int i1=0; i1 < countx ; i1++){ for(int j1 = 0; j1 < county ; j1++){ if(j1 == 0){ resultStr += String.format(" %03d", result[i1][j1]); }else { resultStr += "..." + String.format("%03d", result[i1][j1]); } } resultStr += "\n"; } return resultStr; } |
结果展示:
1 2 3 4 5 6 7 8 9 10 |
001...002...003...004...005...006...007...008...009...010...011 038...039...040...041...042...043...044...045...046...047...012 037...068...069...070...071...072...073...074...075...048...013 036...067...090...091...092...093...094...095...076...049...014 035...066...089...104...105...106...107...096...077...050...015 034...065...088...103...110...109...108...097...078...051...016 033...064...087...102...101...100...099...098...079...052...017 032...063...086...085...084...083...082...081...080...053...018 031...062...061...060...059...058...057...056...055...054...019 030...029...028...027...026...025...024...023...022...021...020 |
使用adb获取android设备中的服务列表
我们可以使用adb shell dumpsys 来查看android设备中的相关服务信息,dumpsys后的参数为相关服务的名称。
比较常用的如:
1 2 3 |
adb shell dumpsys activity adb shell dumpsys alarm |
那么我们如何查看其他我们可以dump的服务名称呢?答案是使用如下的命令即可获得android设备中的所有运行的服务列表
1 |
adb shell service list |
如下,是在我三星手机上运行命令获得的服务列表:
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 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
0 penableservice: [] 1 hermesservice: [com.samsung.android.hermes.IKerykeion] 2 sip: [android.net.sip.ISipService] 3 phone: [com.android.internal.telephony.ITelephony] 4 isms: [com.android.internal.telephony.ISms] 5 iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo] 6 simphonebook: [com.android.internal.telephony.IIccPhoneBook] 7 handset: [com.gsma.services.utils.IHandset] 8 offhostservice: [com.gsma.services.nfc.IOffHostService] 9 secontroller: [com.gsma.services.nfc.ISEController] 10 nfccontroller: [com.gsma.services.nfc.INfcController] 11 com.broadcom.nfc.Factory: [com.broadcom.nfc.INfcFactory] 12 nfc: [android.nfc.INfcAdapter] 13 telecom: [com.android.internal.telecom.ITelecomService] 14 isub: [com.android.internal.telephony.ISub] 15 sec_analytics: [com.sec.analytics.data.collection.serviceif.IDataCollectionManager] 16 edmnativehelper: [mdm.edmnativehelperservice] 17 imms: [com.android.internal.telephony.IMms] 18 lpnet: [android.os.ILpnetManager] 19 media_projection: [android.media.projection.IMediaProjectionManager] 20 voip: [android.os.IVoIPInterface] 21 launcherapps: [android.content.pm.ILauncherApps] 22 fingerprint: [android.service.fingerprint.IFingerprintService] 23 trust: [android.app.trust.ITrustManager] 24 media_router: [android.media.IMediaRouterService] 25 media_session: [android.media.session.ISessionManager] 26 restrictions: [android.content.IRestrictionsManager] 27 print: [android.print.IPrintManager] 28 assetatlas: [android.view.IAssetAtlas] 29 dreams: [android.service.dreams.IDreamManager] 30 commontime_management: [] 31 samplingprofiler: [] 32 quickconnect: [com.samsung.android.quickconnect.IQuickConnectManager] 33 spengestureservice: [com.samsung.android.smartclip.ISpenGestureService] 34 mDNIe: [com.samsung.android.mdnie.IMdnieManager] 35 diskstats: [] 36 SecExternalDisplayService: [android.os.ISecExternalDisplayService] 37 voiceinteraction: [com.android.internal.app.IVoiceInteractionManagerService] 38 appwidget: [com.android.internal.appwidget.IAppWidgetService] 39 backup: [android.app.backup.IBackupManager] 40 jobscheduler: [android.app.job.IJobScheduler] 41 uimode: [android.app.IUiModeManager] 42 serial: [android.hardware.ISerialManager] 43 usb: [android.hardware.usb.IUsbManager] 44 DockObserver: [] 45 audio: [android.media.IAudioService] 46 wallpaper: [android.app.IWallpaperManager] 47 dropbox: [com.android.internal.os.IDropBoxManagerService] 48 search: [android.app.ISearchManager] 49 country_detector: [android.location.ICountryDetector] 50 location: [android.location.ILocationManager] 51 devicestoragemonitor: [] 52 notification: [android.app.INotificationManager] 53 updatelock: [android.os.IUpdateLock] 54 servicediscovery: [android.net.nsd.INsdManager] 55 sb_service: [com.samsung.android.smartbonding.ISmartBondingService] 56 connectivity: [android.net.IConnectivityManager] 57 rttmanager: [android.net.wifi.IRttManager] 58 wifiscanner: [android.net.wifi.IWifiScanner] 59 msapwifi: [android.net.wifi.IMsapWifiManager] 60 wifi: [android.net.wifi.IWifiManager] 61 wifip2p: [android.net.wifi.p2p.IWifiP2pManager] 62 netpolicy: [android.net.INetworkPolicyManager] 63 netstats: [android.net.INetworkStatsService] 64 network_score: [android.net.INetworkScoreService] 65 textservices: [com.android.internal.textservice.ITextServicesManager] 66 ABTPersistenceService: [com.absolute.android.persistence.IABTPersistence] 67 network_management: [android.os.INetworkManagementService] 68 clipboardEx: [android.sec.clipboard.IClipboardService] 69 clipboard: [android.content.IClipboard] 70 statusbar: [com.android.internal.statusbar.IStatusBarService] 71 enterprise_policy: [android.app.enterprise.IEnterpriseDeviceManager] 72 knox_timakeystore_policy: [com.sec.enterprise.knox.keystore.ITimaKeystore] 73 enterprise_billing_policy: [com.sec.enterprise.knox.billing.IEnterpriseBillingPolicy] 74 mum_container_policy: [com.sec.enterprise.knox.container.IKnoxContainerManager] 75 remoteinjection: [android.app.enterprise.remotecontrol.IRemoteInjection] 76 phone_restriction_policy: [android.app.enterprise.IPhoneRestrictionPolicy] 77 wifi_policy: [android.app.enterprise.IWifiPolicy] 78 application_policy: [android.app.enterprise.IApplicationPolicy] 79 enterprise_license_policy: [android.app.enterprise.license.IEnterpriseLicense] 80 log_manager_service: [android.app.enterprise.ILogManager] 81 sdp: [android.service.sdp.ISdpManagerService] 82 harmony_eas_service: [android.content.IHarmonyEAS] 83 device_policy: [android.app.admin.IDevicePolicyManager] 84 lock_settings: [com.android.internal.widget.ILockSettings] 85 mount: [IMountService] 86 cover: [com.samsung.android.cover.ICoverManager] 87 motion_recognition: [com.samsung.android.motion.IMotionRecognitionService] 88 accessibility: [android.view.accessibility.IAccessibilityManager] 89 input_method: [com.android.internal.view.IInputMethodManager] 90 rcp: [android.os.IRCPManager] 91 bluetooth_secure_mode_manager: [android.bluetooth.IBluetoothSecureManagerService] 92 bluetooth_manager: [android.bluetooth.IBluetoothManager] 93 tactileassist: [android.os.ITactileAssistService] 94 input: [android.hardware.input.IInputManager] 95 window: [android.view.IWindowManager] 96 multiwindow_facade: [com.samsung.android.multiwindow.IMultiWindowFacade] 97 barbeam: [android.app.IBarBeamService] 98 scontext: [android.hardware.scontext.ISContextService] 99 context_aware: [com.samsung.android.contextaware.manager.IContextAwareService] 100 alarm: [android.app.IAlarmManager] 101 consumer_ir: [android.hardware.IConsumerIrService] 102 samsung.smartfaceservice: [com.samsung.android.smartface.ISmartFaceService] 103 CustomFrequencyManagerService: [android.os.ICustomFrequencyManager] 104 CCM: [] 105 cepproxyks: [com.samsung.android.cepproxyks.ISCEPKeystoreService] 106 TUI: [] 107 tima: [android.service.tima.ITimaService] 108 vibrator: [android.os.IVibratorService] 109 sedenial: [android.service.ISEDenialService] 110 ReactiveService: [com.samsung.android.service.reactive.IReactiveService] 111 DirEncryptService: [IDirEncryptService] 112 content: [android.content.IContentService] 113 account: [android.accounts.IAccountManager] 114 persona: [android.os.IPersonaManager] 115 SEAMService: [com.sec.enterprise.knox.seams.ISEAMS] 116 entropy: [] 117 telephony.registry: [com.android.internal.telephony.ITelephonyRegistry] 118 scheduling_policy: [android.os.ISchedulingPolicyService] 119 webviewupdate: [android.webkit.IWebViewUpdateService] 120 usagestats: [android.app.usage.IUsageStatsManager] 121 battery: [] 122 hardware: [android.os.IHardwareService] 123 permission: [android.os.IPermissionController] 124 cpuinfo: [] 125 dbinfo: [] 126 gfxinfo: [] 127 meminfo: [] 128 procstats: [com.android.internal.app.IProcessStats] 129 activity: [android.app.IActivityManager] 130 user: [android.os.IUserManager] 131 package: [android.content.pm.IPackageManager] 132 persona_policy: [android.content.pm.IPersonaPolicyManager] 133 display: [android.hardware.display.IDisplayManager] 134 power: [android.os.IPowerManager] 135 appops: [com.android.internal.app.IAppOpsService] 136 batterystats: [com.android.internal.app.IBatteryStats] 137 sensorservice: [android.gui.SensorServer] 138 mdm.remotedesktop: [mdm.samsung.IRemoteDesktopService] 139 media.sound_trigger_hw: [android.hardware.ISoundTriggerHwService] 140 media.transcoder: [android.media.ITranscoderService] 141 media.audio_policy: [android.media.IAudioPolicyService] 142 listen.service: [com.qualcomm.listen.IListenService] 143 media.camera: [android.hardware.ICameraService] 144 media.player: [android.media.IMediaPlayerService] 145 media.audio_flinger: [android.media.IAudioFlinger] 146 android.security.keystore: [android.security.keystore] 147 SurfaceFlinger: [android.ui.ISurfaceComposer] 148 sensorhubservice: [android.gui.SensorHubServer] 149 display.qservice: [android.display.IQService] 150 drm.drmManager: [drm.IDrmManagerService] 151 batteryproperties: [android.os.IBatteryPropertiesRegistrar] 152 com.samsung.android.jam.IAndroidShm: [com.samsung.android.jam.IAndroidShm] 153 com.samsung.android.jam.IAPAService: [com.samsung.android.jam.IAPAService] 154 com.samsung.android.jam.IJackService: [com.samsung.android.jam.IJackService] 155 TvoutService_C: [android.hardware.ISecExternalDisplayService] |
使用adb查看android设备的屏幕尺寸
使用以下命令可以查看android设备的屏幕尺寸
1 2 3 |
adb shell dumpsys window displays adb shell wm size |
如果两个命令都不能执行就只能自己写程序来获得尺寸了
adb shell input命令使用说明
1 2 3 4 5 6 7 |
usage: input ... input text <string> input keyevent <key code number or name> input [touchscreen|touchpad] tap <x> <y> input [touchscreen|touchpad] swipe <x1> <y1> <x2> <y2> input trackball press input trackball roll <dx> <dy> |
1. adb shell input text
1 |
adb shell input text bcoder.com |
貌似不能输入中文
2. adb shell input keyevent
1 2 3 4 |
//模拟按下数字0键 adb shell input keyevent "KEYCODE_0" //模拟按下返回键 adb shell input keyevent 4 |
3. adb shell input [touchscreen|touchpad] tap x y
1 |
adb shell input touchscreen tap 110 66 |
4. adb shell input [touchscreen|touchpad] swipe x1 y1 x2 y2
1 |
adb shell input touchscreen swipe 450 66 110 66 |
5. adb shell input trackball press
6. adb shell input trackball roll <dx> <dy>
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 |
0 --> "KEYCODE_UNKNOWN" 1 --> "KEYCODE_MENU" 2 --> "KEYCODE_SOFT_RIGHT" 3 --> "KEYCODE_HOME" 4 --> "KEYCODE_BACK" 5 --> "KEYCODE_CALL" 6 --> "KEYCODE_ENDCALL" 7 --> "KEYCODE_0" 8 --> "KEYCODE_1" 9 --> "KEYCODE_2" 10 --> "KEYCODE_3" 11 --> "KEYCODE_4" 12 --> "KEYCODE_5" 13 --> "KEYCODE_6" 14 --> "KEYCODE_7" 15 --> "KEYCODE_8" 16 --> "KEYCODE_9" 17 --> "KEYCODE_STAR" 18 --> "KEYCODE_POUND" 19 --> "KEYCODE_DPAD_UP" 20 --> "KEYCODE_DPAD_DOWN" 21 --> "KEYCODE_DPAD_LEFT" 22 --> "KEYCODE_DPAD_RIGHT" 23 --> "KEYCODE_DPAD_CENTER" 24 --> "KEYCODE_VOLUME_UP" 25 --> "KEYCODE_VOLUME_DOWN" 26 --> "KEYCODE_POWER" 27 --> "KEYCODE_CAMERA" 28 --> "KEYCODE_CLEAR" 29 --> "KEYCODE_A" 30 --> "KEYCODE_B" 31 --> "KEYCODE_C" 32 --> "KEYCODE_D" 33 --> "KEYCODE_E" 34 --> "KEYCODE_F" 35 --> "KEYCODE_G" 36 --> "KEYCODE_H" 37 --> "KEYCODE_I" 38 --> "KEYCODE_J" 39 --> "KEYCODE_K" 40 --> "KEYCODE_L" 41 --> "KEYCODE_M" 42 --> "KEYCODE_N" 43 --> "KEYCODE_O" 44 --> "KEYCODE_P" 45 --> "KEYCODE_Q" 46 --> "KEYCODE_R" 47 --> "KEYCODE_S" 48 --> "KEYCODE_T" 49 --> "KEYCODE_U" 50 --> "KEYCODE_V" 51 --> "KEYCODE_W" 52 --> "KEYCODE_X" 53 --> "KEYCODE_Y" 54 --> "KEYCODE_Z" 55 --> "KEYCODE_COMMA" 56 --> "KEYCODE_PERIOD" 57 --> "KEYCODE_ALT_LEFT" 58 --> "KEYCODE_ALT_RIGHT" 59 --> "KEYCODE_SHIFT_LEFT" 60 --> "KEYCODE_SHIFT_RIGHT" 61 --> "KEYCODE_TAB" 62 --> "KEYCODE_SPACE" 63 --> "KEYCODE_SYM" 64 --> "KEYCODE_EXPLORER" 65 --> "KEYCODE_ENVELOPE" 66 --> "KEYCODE_ENTER" 67 --> "KEYCODE_DEL" 68 --> "KEYCODE_GRAVE" 69 --> "KEYCODE_MINUS" 70 --> "KEYCODE_EQUALS" 71 --> "KEYCODE_LEFT_BRACKET" 72 --> "KEYCODE_RIGHT_BRACKET" 73 --> "KEYCODE_BACKSLASH" 74 --> "KEYCODE_SEMICOLON" 75 --> "KEYCODE_APOSTROPHE" 76 --> "KEYCODE_SLASH" 77 --> "KEYCODE_AT" 78 --> "KEYCODE_NUM" 79 --> "KEYCODE_HEADSETHOOK" 80 --> "KEYCODE_FOCUS" 81 --> "KEYCODE_PLUS" 82 --> "KEYCODE_MENU" 83 --> "KEYCODE_NOTIFICATION" 84 --> "KEYCODE_SEARCH" 85 --> "TAG_LAST_KEYCODE" |
使用adb对android手机进行截图
使用如下命令,可以对android手机进行截图
adb shell screencap -p /sdcard/screen.png
adb shell /system/bin/screencap -p /sdcard/screenshot.png
命令执行后,截图存放在手机的/sdcard下的screen.png
使用adb pull可以将图片拷贝到本地电脑中
adb pull /sdcard/screen.png d:\
不支持图片旋转、压缩等选项,如需对图片自动化处理需要借用第三方命令行软件
MonkeyRunner的python脚本中input无法结束的解决办法
在monkeyrunner执行python脚本的input函数时,输入内容按回车后,input命令无法结束,后面的脚本无法执行,这是jython中的一个bug,对应的版本是jython-standalone-2.5.3.jar。
解决办法是下载jython-standalone-2.5.4-rc1.jar,不能下载太高版本,比如jythone2.7,与2.5.3所使用的环境不一致,可能会无法运行。
jython-standalone-2.5.3.jar所在的目录为: {android sdk根目录}\tools\lib,下载新版本后把jython-standalone-2.5.3.jar删除,把jython-standalone-2.5.4-rc1.jar拷贝到此目录即可。下载地址如下:
http://www.jython.org/downloads.html