CN103761096A - 基于IBinder机制实现的自动输入方法及装置 - Google Patents

基于IBinder机制实现的自动输入方法及装置 Download PDF

Info

Publication number
CN103761096A
CN103761096A CN201410030702.4A CN201410030702A CN103761096A CN 103761096 A CN103761096 A CN 103761096A CN 201410030702 A CN201410030702 A CN 201410030702A CN 103761096 A CN103761096 A CN 103761096A
Authority
CN
China
Prior art keywords
input
ibinder
module
service
obtains
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201410030702.4A
Other languages
English (en)
Other versions
CN103761096B (zh
Inventor
杨远波
李鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201410030702.4A priority Critical patent/CN103761096B/zh
Publication of CN103761096A publication Critical patent/CN103761096A/zh
Application granted granted Critical
Publication of CN103761096B publication Critical patent/CN103761096B/zh
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Input From Keyboards Or The Like (AREA)
  • Telephonic Communication Services (AREA)

Abstract

本发明公开了一种基于IBinder机制实现的自动输入方法及装置,所述方法包括激活当前的Acitivity,使目标编辑框控件获得焦点;在IME服务中实现静态方法;在通用IService服务中实现IBinder接口;在IBinder接口中获得自定义类的this指针;在自定义类中构造输入方法;通过输入方法接收来自外界的输入内容;在输入方法中调用静态方法获得IME服务的实例ICS;在实例ICS非空时,获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC;将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。本发明方法提升了自动化测试效率与精准度。

Description

基于IBinder机制实现的自动输入方法及装置
技术领域
本发明涉及一种Android系统的自动化测试过程中实现编辑框自动输入的方法及系统,尤其是一种基于IBinder机制实现的自动输入方法及系统。属于Android系统的自动化测试技术领域。
背景技术
随着移动终端的普及,人们对移动终端的需求也越来越多、越来越高,对于移动终端制造商而言,移动终端的测试也越来越复杂,随之而出现的是越来越多的自动化测试工具,如中国专利申请号为201110066300.6的发明专利申请,公开了“一种基于Android的自动化测试方法”,其技术特点是通过集成Android内部shell指令原理调用Android的monkey方法,实现在手机侧的通过设备模拟人工操作,形成可靠的软件稳定性测试体系,将各种测试程序进行编码,测试时通过调用各个测试程序进行,提高测试效率,解决了现有技术需借助计算机进行测试且需人工监视导致效率低的问题,针对的是测试上存在的问题,并没有涉及到自动化测试自动输入的相关问题。
而目前市面上的自动化测试工具,在自动化测试输入的过程中,主要有两种方式:一种是基于Instrumentation的自动输入;另一种是基于输入法的自动输入;但这两种方式在自动输入过程中都存在局限与缺陷:基于Instrumentation的测试工具无法跨应用(跨进程)输入;基于输入法的自动输入需要模拟人的点击、选词、取词等操作,速度慢、不准确。
发明内容
本发明的目的是为了解决上述现有技术的缺陷,提供一种可以提升自动化测试效率与精准度基于IBinder机制实现的自动输入方法。
本发明的另一目的在于提供一种基于IBinder机制实现的自动输入装置。
本发明的目的可以通过采取如下技术方案达到:
基于IBinder机制实现的自动输入方法,其特征在于:所述方法在Android系统的自动化测试过程中实现,包括以下步骤:
S1、激活当前的Acitivity窗口,使目标编辑框控件获得焦点;
S2、在IME服务InputChineseService中实现静态方法getInstance;
S3、在通用IService服务中实现IBinder接口;
S4、在IBinder接口中获得自定义类RemoteBinder的this指针;
S5、在自定义类RemoteBinder中构造输入方法SendRemoteInfo;
S6、通过输入方法SendRemoteInfo接收来自外界的输入内容;
S7、在输入方法SendRemoteInfo中调用静态方法getInstance获得InputChineseService的实例ICS;
S8、判断实例ICS是否为空,若是,在静态方法getInstance中返回自身的引用;若否,获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC;
S9、将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。
具体的,步骤S2所述IME服务InputChineseService从输入法服务类InputMethodService继承。
具体的,步骤S3所述通用IService服务从Service组件继承。
具体的,步骤S8所述获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC通过调用ICS的公有方法getCurrentInputConnection获取。
具体的,所述输入方法SendRemoteInfo接收的输入内容为中文、英文或符号。
本发明的另一目的可以通过采取如下技术方案达到:
基于IBinder机制实现的自动输入装置,其特征在于:所述装置在Android系统的自动化测试过程中实现,包括:
激活模块,用于激活当前的Acitivity窗口,使目标编辑框控件获得焦点;
静态方法实现模块,用于IME服务InputChineseService中实现静态方法getInstance;
IBinder接口实现模块,用于在通用IService服务中实现IBinder接口;
自定义类的this指针获得模块,用于在IBinder接口中获得自定义类RemoteBinder的this指针;
输入方法构造模块,用于在自定义类RemoteBinder中构造输入方法SendRemoteInfo;
输入内容接收模块,用于通过输入方法SendRemoteInfo接收来自外界的输入内容;
实例ICS获得模块,用于在输入方法SendRemoteInfo中调用静态方法getInstance获得InputChineseService的实例ICS;
判断模块,用于判断实例ICS是否为空,若是,在静态方法getInstance中返回自身的引用;若否,获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC;
内容传递模块,用于将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。
具体的,所述静态方法实现模块、实例ICS获得模块和判断模块中的IME服务InputChineseService从输入法服务类InputMethodService继承。
具体的,所述IBinder接口实现模块和自定义类的this指针获得模块中的通用IService服务从Service组件继承。
具体的,所述判断模块中的获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC通过调用ICS的公有方法getCurrentInputConnection获取。
具体的,所述输入方法构造模块、输入内容接收模块和实例ICS获得模块中的输入方法SendRemoteInfo接收的输入内容为中文、英文或符号。
本发明相对于现有技术具有如下的有益效果:
本发明方法及装置将IME(Input Method Editor,输入法编辑器)与Service的IBinder机制(IBinder接口是能进行远程操作对象的一个基接口,定义了为在提供进程间和跨进程间的调用时提供高性能的轻量级远程调用的核心部分,该接口描述了与远程对象进行交互的抽象协议)结合,解决基于Instrumentation的测试工具无法跨应用(跨进程)输入和基于输入法的自动输入速度慢、不准确的问题,提升了自动化测试效率与精准度。
附图说明
图1为本发明实施例的基于IBinder机制实现的自动输入方法的流程示意图。
图2为本发明实施例的基于IBinder机制实现的自动输入装置结构框图。
具体实施方式
实施例1:
在设备的Android系统中,键盘事件由WindowManagerService(窗口管理服务)统一管理,然后以消息的形式分发给应用程序;Android系统启动的时候,SystemServer首先会启动WindowManagerService,接着WindowManagerService通过启动InputManager(输入管理器)来监控键盘事件。当InputManager监控到键盘输入事件时,它需要把这个键盘消息分发给当前激活的Activity窗口,此时,当前激活的Activity窗口需要主动注册一个接收键盘消息的连接通道到InputManager中去,InputManager才能把这个键盘消息分发给它处理。在整个IMF(Input Method Framework,输入法框架)中,InputMethodManager(输入法管理类)是其中的核心API,负责与应用程序的交互与调度,核心思想是获得此消息的连接通道IC(InputConnection)。
如图1所示,本实施例的基于IBinder机制实现的自动输入方法,具体包括以下步骤:
S1、激活当前的Acitivity窗口,使目标编辑框控件获得焦点;
S2、从InputMethodService(输入法服务类)继承一个IME(Input Method Editor,输入法编辑器)服务InputChineseService,在InputChineseService中实现静态方法getInstance,如下:
Figure BDA0000460233020000041
S3、从Service组件继承通用IService服务,实现IBinder接口;
S4、在IBinder接口中获得自定义类RemoteBinder的this指针;
S5、在自定义类RemoteBinder中构造输入方法SendRemoteInfo(String CH_EN),如下:
Figure BDA0000460233020000042
S6、通过输入方法SendRemoteInfo接收来自外界的输入内容;
S7、在输入方法SendRemoteInfo中调用静态方法getInstance获得InputChineseService的实例ICS;
S8、判断实例ICS是否为空,若是,在静态方法getInstance中返回自身的引用;若否,调用ICS的公有方法getCurrentInputConnection获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC(InputConnection);
S9、将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。
实施例2:
如图2所示,本实施例的基于IBinder机制实现的自动输入装置包括激活模块、静态方法实现模块、IBinder接口实现模块、自定义类的this指针获得模块、输入方法构造模块、输入内容接收模块、实例ICS获得模块、判断模块和内容传递模块,其中:
激活模块,用于激活当前的Acitivity窗口,使目标编辑框控件获得焦点;
静态方法实现模块,用于在IME服务InputChineseService中实现静态方法getInstance;所述IME服务InputChineseService从输入法服务类InputMethodService继承;
IBinder接口实现模块,用于在通用IService服务中实现IBinder接口;所述通用IService服务从Service组件继承
自定义类的this指针获得模块,用于在IBinder接口中获得自定义类RemoteBinder的this指针;
输入方法构造模块,用于在自定义类RemoteBinder中构造输入方法SendRemoteInfo;
输入内容接收模块,用于通过输入方法SendRemoteInfo接收来自外界的输入内容;所述输入方法SendRemoteInfo接收的输入内容为中文、英文或符号;
实例ICS获得模块,用于在输入方法SendRemoteInfo中调用静态方法getInstance获得InputChineseService的实例ICS;
判断模块,用于判断实例ICS是否为空,若是,在静态方法getInstance中返回自身的引用;若否,调用ICS的公有方法getCurrentInputConnection获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC;
内容传递模块,用于将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。
本实施例中使用Android系统的设备可以是手机、电子书、PDA、人机交互终端或其他具有显示功能的手持式终端设备。
另外,本领域普通技术人员可以理解实现上述各实施例方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,相应的程序可以存储于一计算机可读取存储介质中,所述的存储介质,如ROM/RAM、磁盘或光盘等。
以上所述,仅为本发明专利较佳的实施例,但本发明专利的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明专利所公开的范围内,根据本发明专利的技术方案及其发明专利构思加以等同替换或改变,都属于本发明专利的保护范围。

Claims (10)

1.基于IBinder机制实现的自动输入方法,其特征在于:所述方法在Android系统的自动化测试过程中实现,包括以下步骤:
S1、激活当前的Acitivity窗口,使目标编辑框控件获得焦点;
S2、在IME服务InputChineseService中实现静态方法getInstance;
S3、在通用IService服务中实现IBinder接口;
S4、在IBinder接口中获得自定义类RemoteBinder的this指针;
S5、在自定义类RemoteBinder中构造输入方法SendRemoteInfo;
S6、通过输入方法SendRemoteInfo接收来自外界的输入内容;
S7、在输入方法SendRemoteInfo中调用静态方法getInstance获得InputChineseService的实例ICS;
S8、判断实例ICS是否为空,若是,在静态方法getInstance中返回自身的引用;若否,获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC;
S9、将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。
2.根据权利要求1所述的基于IBinder机制实现的自动输入方法,其特征在于:步骤S2所述IME服务InputChineseService从输入法服务类InputMethodService继承。
3.根据权利要求1所述的基于IBinder机制实现的自动输入方法,其特征在于:步骤S3所述通用IService服务从Service组件继承。
4.根据权利要求1所述的基于IBinder机制实现的自动输入方法,其特征在于:步骤S8所述获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC通过调用ICS的公有方法getCurrentInputConnection获取。
5.根据权利要求1所述的基于IBinder机制实现的自动输入方法,其特征在于:所述输入方法SendRemoteInfo接收的输入内容为中文、英文或符号。
6.基于IBinder机制实现的自动输入装置,其特征在于:所述装置在Android系统的自动化测试过程中实现,包括:
激活模块,用于激活当前的Acitivity窗口,使目标编辑框控件获得焦点;
静态方法实现模块,用于IME服务InputChineseService中实现静态方法getInstance;
IBinder接口实现模块,用于在通用IService服务中实现IBinder接口;
自定义类的this指针获得模块,用于在IBinder接口中获得自定义类RemoteBinder的this指针;
输入方法构造模块,用于在自定义类RemoteBinder中构造输入方法SendRemoteInfo;
输入内容接收模块,用于通过输入方法SendRemoteInfo接收来自外界的输入内容;
实例ICS获得模块,用于在输入方法SendRemoteInfo中调用静态方法getInstance获得InputChineseService的实例ICS;
判断模块,用于判断实例ICS是否为空,若是,在静态方法getInstance中返回自身的引用;若否,获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC;
内容传递模块,用于将接收到的内容传递给消息连接通道IC的commitText函数提交至当前获得焦点的编辑框控件,完成输入。
7.根据权利要求6所述的基于IBinder机制实现的自动输入装置,其特征在于:所述静态方法实现模块、实例ICS获得模块和判断模块中的IME服务InputChineseService从输入法服务类InputMethodService继承。
8.根据权利要求6所述的基于IBinder机制实现的自动输入装置,其特征在于:所述IBinder接口实现模块和自定义类的this指针获得模块中的通用IService服务从Service组件继承。
9.根据权利要求6所述的基于IBinder机制实现的自动输入装置,其特征在于:所述判断模块中的获取实例ICS与当前获得焦点的编辑框控件的消息连接通道IC通过调用ICS的公有方法getCurrentInputConnection获取。
10.根据权利要求6所述的基于IBinder机制实现的自动输入装置,其特征在于:所述输入方法构造模块、输入内容接收模块和实例ICS获得模块中的输入方法SendRemoteInfo接收的输入内容为中文、英文或符号。
CN201410030702.4A 2014-01-22 2014-01-22 基于IBinder机制实现的自动输入方法及装置 Expired - Fee Related CN103761096B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410030702.4A CN103761096B (zh) 2014-01-22 2014-01-22 基于IBinder机制实现的自动输入方法及装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410030702.4A CN103761096B (zh) 2014-01-22 2014-01-22 基于IBinder机制实现的自动输入方法及装置

Publications (2)

Publication Number Publication Date
CN103761096A true CN103761096A (zh) 2014-04-30
CN103761096B CN103761096B (zh) 2016-11-02

Family

ID=50528340

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410030702.4A Expired - Fee Related CN103761096B (zh) 2014-01-22 2014-01-22 基于IBinder机制实现的自动输入方法及装置

Country Status (1)

Country Link
CN (1) CN103761096B (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536839A (zh) * 2014-12-26 2015-04-22 北京奇虎科技有限公司 进程间进行方法调用的方法及装置
CN107329584A (zh) * 2017-06-20 2017-11-07 努比亚技术有限公司 一种文字输入处理方法、移动终端以及计算机可读存储介质
CN108073529A (zh) * 2017-08-17 2018-05-25 北京微应软件科技有限公司 移动终端的输入输出模拟方法和模拟系统

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106547562B (zh) * 2016-11-07 2020-06-09 青岛海信宽带多媒体技术有限公司 系统服务接受用户输入的方法及设备

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090289644A1 (en) * 2008-05-23 2009-11-26 Hong Fu Jin Precision Industry(Shenzhen) Co., Ltd. Apparatus and method for testing keyboard of mobile phone
CN102799511A (zh) * 2012-06-30 2012-11-28 成都西可科技有限公司 基于Android的自动化测试方法及测试系统

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090289644A1 (en) * 2008-05-23 2009-11-26 Hong Fu Jin Precision Industry(Shenzhen) Co., Ltd. Apparatus and method for testing keyboard of mobile phone
CN102799511A (zh) * 2012-06-30 2012-11-28 成都西可科技有限公司 基于Android的自动化测试方法及测试系统

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536839A (zh) * 2014-12-26 2015-04-22 北京奇虎科技有限公司 进程间进行方法调用的方法及装置
CN104536839B (zh) * 2014-12-26 2019-02-01 北京奇虎科技有限公司 进程间进行方法调用的方法及装置
CN107329584A (zh) * 2017-06-20 2017-11-07 努比亚技术有限公司 一种文字输入处理方法、移动终端以及计算机可读存储介质
CN108073529A (zh) * 2017-08-17 2018-05-25 北京微应软件科技有限公司 移动终端的输入输出模拟方法和模拟系统

Also Published As

Publication number Publication date
CN103761096B (zh) 2016-11-02

Similar Documents

Publication Publication Date Title
US10964317B2 (en) Voice wakeup method, apparatus and system, cloud server and readable medium
US9451100B2 (en) Method for transmitting notification information and electronic device thereof
US9552199B2 (en) Method and apparatus of prompting an update of an application
CN105468416A (zh) 一种应用程序清理的方法及终端
EP3499353A1 (en) Apparatus and method for displaying notification in electronic device
US20210352059A1 (en) Message Display Method, Apparatus, and Device
US20110061056A1 (en) Portable device and method for providing shortcuts in the portable device
CN103702297A (zh) 短信增强方法、装置及系统
US9921822B2 (en) End user programming for a mobile device
KR20160124765A (ko) 멀티라운드 세션 인터랙션 방법, 시스템 및 컴퓨터 기기
CN101923434B (zh) 一种应用图标的排版方法、系统移动终端
CN103761096A (zh) 基于IBinder机制实现的自动输入方法及装置
CN101876904A (zh) 一种移动终端及应用程序的运行状态输出方法和装置
CN103984626A (zh) 一种生成测试用例脚本的方法及装置
CN104461243A (zh) 移动终端上显示和管理通知的方法以及移动终端
CN104866384A (zh) 快速测试及检测移动装置的方法及系统
CN105334939A (zh) 终端功耗控制方法及装置
CN110096413A (zh) 一种磁盘定位方法、系统及电子设备和存储介质
CN102902580A (zh) 一种程序回调方法及装置
CN107885683A (zh) 一种终端及终端的电流测试方法
CN107832874A (zh) 一种天气提醒方法、装置、设备及计算机可读存储介质
CN105204849A (zh) 压力测试系统及其实现方法
CN103067464B (zh) 智能终端远程控制计算机的方法和系统
CN105260266A (zh) 一种快照卷写方法及依赖快照系统
CN110443062B (zh) 多租户数据库的操作方法、装置和计算机设备

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CP01 Change in the name or title of a patent holder

Address after: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Patentee after: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

Address before: Changan town in Guangdong province Dongguan 523860 usha Beach Road No. 18

Patentee before: GUANGDONG OPPO MOBILE TELECOMMUNICATIONS Corp.,Ltd.

CP01 Change in the name or title of a patent holder
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20161102

CF01 Termination of patent right due to non-payment of annual fee