CN109558728B - 一种Android应用内输入关键字拦截的方法 - Google Patents

一种Android应用内输入关键字拦截的方法 Download PDF

Info

Publication number
CN109558728B
CN109558728B CN201811310875.6A CN201811310875A CN109558728B CN 109558728 B CN109558728 B CN 109558728B CN 201811310875 A CN201811310875 A CN 201811310875A CN 109558728 B CN109558728 B CN 109558728B
Authority
CN
China
Prior art keywords
input
keywords
application
content
interception
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.)
Active
Application number
CN201811310875.6A
Other languages
English (en)
Other versions
CN109558728A (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.)
Beijing Zhizhangyi Technology Co ltd
Original Assignee
Beijing Zhizhangyi Technology Co 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 Beijing Zhizhangyi Technology Co ltd filed Critical Beijing Zhizhangyi Technology Co ltd
Priority to CN201811310875.6A priority Critical patent/CN109558728B/zh
Publication of CN109558728A publication Critical patent/CN109558728A/zh
Application granted granted Critical
Publication of CN109558728B publication Critical patent/CN109558728B/zh
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/554Detecting local intrusion or implementing counter-measures involving event detection and direct action
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/55Detecting local intrusion or implementing counter-measures
    • G06F21/556Detecting local intrusion or implementing counter-measures involving covert channels, i.e. data leakage between processes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/02Input arrangements using manually operated switches, e.g. using keyboards or dials
    • G06F3/023Arrangements for converting discrete items of information into a coded form, e.g. arrangements for interpreting keyboard generated codes as alphanumeric codes, operand codes or instruction codes
    • G06F3/0233Character input methods

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Human Computer Interaction (AREA)
  • Input From Keyboards Or The Like (AREA)

Abstract

本发明公开了一种Android应用内输入关键字拦截的方法,包括以下步骤:步骤1:启动Android应用;步骤2:初始化输入环境;步骤3:在拦截点对应用程序获取的通道进行代理,然后提交到系统输入法管理系统;步骤4:用户在输入法应用端输入内容;步骤5:通过拦截通道来获取到用户输入的内容;步骤6:获取输入内容后,对输入的关键字进行处理;步骤7:将关键字处理后的内容提交进系统输入法管理系统,并通过控件进行显示。本发明采用上述方法,能够实现应用内关键字拦截,无需修改应用的源码,适配性强,且拦截效率高,用户体验好。

Description

一种Android应用内输入关键字拦截的方法
技术领域
本发明属于关键字拦截领域,具体涉及一种Android应用内输入关键字拦截的方法。
背景技术
目前,android智能手机已经十分普及了,对于一些行业对关键信息比较看重的领域,或者对用户输入信息进行大数据审计分析的领域,信息的输入显得特别重要。怎样才能在不改变输入法源码的状态下,安全、快速实现关键字拦截,成为了眼下的一个研究课题。目前,现有的一些现成方案或多或少都存在一定的缺陷:
1)OnKeyListener,实现EditText的OnKeyListener并不能拦截EditText的输入,OnKeyListener只能够监听到一些按物理键事件,例如菜单键、返回键、音量键等,而输入法作为一个单独的进程,EditText与输入法的通讯显然是OnKeyListener所无能为力的;
2)TextWatcher,相信很多人做这个功能的第一反应都是使用TextWatcher,因为TextWatcher可以监听到EditText输入前后内容的变化,但那也只是监听到而已它并没有办法真正拦截到输入,而只是在某一字符输入发生后,对EditText做一个事后的处理。典型的例子如下,假设我监听到了”s“的输入,但实际上我是不允许”s“输入的,那么我在TextWatcher中监听到”s“输入了以后,重新设置EditText的内容。但这样做的恶果就是重设EditText的内容后,又会回调TextWatcher的那几个方法,造成死循环。当然您可以设置一个标志位来停止这个循环,但麻烦不止于此。因为你是先让字符输入,然后再手动把它删除,那么这其中涉及到的光标位置调整,漏洞百出。
发明内容
为了克服现有技术的不足,本发明提出一种Android应用内输入关键字拦截的方法,解决现有的拦截方法没法真正实现输入拦截,而要实现输入拦截需要进行各种修改,不仅会导致各种漏洞,而且适配性较差、用户体验不好的问题。
本发明为实现上述目的,采用以下技术方案实现:
一种Android应用内输入关键字拦截的方法,包括以下步骤:
步骤1:启动Android应用;
步骤2:初始化输入环境;
步骤3:在拦截点对应用程序获取的通道进行代理,然后提交到系统输入法
管理系统;
步骤4:用户在输入法应用端输入内容;
步骤5:通过拦截通道来获取到用户输入的内容;
步骤6:获取输入内容后,对输入的关键字进行处理;
步骤7:将关键字处理后的内容提交进系统输入法管理系统,并通过控件进行显示。
进一步地,作为优选技术方案,所述步骤3中,hook机制下,代理输入法与Android应用的交互通道interface InputConnection的接口。
进一步地,作为优选技术方案,所述步骤5中,通过android API拦截InputMethodManager的调用,接着通过InputMethodManager服务获取mServedInputConnectionWrapper的connection,再通过反射IInputConnectionWrapper类获取mInputConnection的变量,实现获取用户的输入。
进一步地,作为优选技术方案,所述步骤6中,对关键字的处理包括替换、过滤、记录及上报。
进一步地,作为优选技术方案,所述步骤6中,通过本地实现一个类implementsInputConnection接口重写,以替换应用的InputConnection对象而进行关键字的拦截替换。
本发明与现有技术相比,具有以下优点及有益效果:
(1)本发明通过android API拦截InputMethodManager的调用,接着通过InputMethodManager服务获取mServedInputConnectionWrapper的connection,再通过反射IInputConnectionWrapper类获取mInputConnection的变量,并通过本地实现一个类implements InputConnection接口重写,以替换应用的InputConnection对象而进行关键字的拦截替换,从而实现了真正意义上的关键字拦截,且不需要修改应用的源码,适配性强。
(2)本发明对于企业管理者来说,对应企业管理者来说,可以在员工处于无感知的状态下,监控员工的输入内容,且对一些敏感词汇进行替换、记录或者上报等操作,可以对员工的输入行为、使用词汇及输入习惯进行分析,起到辅助了解员工的目的。
(3)本发明可以准确记录整个手机或者平板电脑上的应用的用户输入信息,并对用户输入信息进行过滤、统计、分析,并可进一步分析用户行为,另外,对高频词汇的收集及研究也有非常重要的意义。
附图说明
图1为本发明的方法流程图;
图2为本发明的应用内拦截某个输入的过程示意图。
具体实施方式
下面结合实施例对本发明作进一步地详细说明,但本发明的实施方式不限于此。
实施例:
如图1、图2所示,本实施例所述的一种Android应用内输入关键字拦截的方法,包括以下步骤:
步骤1:启动Android应用;
步骤2:初始化输入环境;
步骤3:在拦截点对应用程序获取的通道进行代理,然后提交到系统输入法
管理系统;
步骤4:用户在输入法应用端输入内容;
步骤5:通过拦截通道来获取到用户输入的内容;
步骤6:获取输入内容后,对输入的关键字进行处理,比如替换、过滤、记录及上报等;
步骤7:将关键字处理后的内容提交进系统输入法管理系统,并通过控件进行显示。
在本实施例中,对于android系统而言,应用、输入法、系统三者相互依赖,相辅相成地工作,在大量的开发中我们发现InputConnection.java是连接用户应用的桥梁,该接口还有commitText这个重要的方法,事实证明只要代理InputConnectionWrapper相关的InputConnection,而这个类的实现方法中有多个极为可靠的方法,比如提交文本和按键事件,继承于InputConnectionWrapper,实现自己的InputConnection并且再替换返回。在自定义的InputConnectionWrapper类中,可实现输入法输入和按键时间的相关方法的拦截。在某些方法中,如果执行父类的某些方法后返回true,那么表示不拦截;如果返回false,则表示拦截;至此拦截输入控件view与输入法的通讯已经成功实现。
本实施例中,由于interface InputConnection是输入法与Android应用的交互通道,通过动态代理该交互通道的接口并重写该接口,即可实现输入法提交的相关文本的关键字的拦截,并将拦截处理后的文本再次提交到文本域。因此,只需要选择合适的hook点,即可达到拦截的目的。
本实施例通过android API拦截InputMethodManager的调用,当应用启动时,调用某些方法时通过接着通过InputMethodManager服务而获取mServedInputConnectionWrapper的connection,再通过反射IInputConnectionWrapper类获取mInputConnection的变量,本地实现一个类implements InputConnection接口重写其方法方法,达到替换应用的InputConnection对象,进而获取用户的输入去进行关键字的拦截替换。
本实施例的InputManager由UI控件(View,TextView,EditText等)调用,用来操作输入法,比如,打开、关闭、切换输入法等。
本实施例中,InputMethodManagerService.java是整个系统的总控制中心,它通过管理三个模块来实现系统的输入法框架,分别是WindowManagerService、InputMethodService以及InputManager,WindowManagerService负责显示输入法,接收用户事件;InputMethodService负责输入法内部逻辑,键盘布局,选词等,并最终把选出的字符显示出来,具体地,最终把选出的字符通过commitText提交出来;InputManager由UI控件(View、TextView、EditText等)调用,用来操作输入法,比如打开、关闭、切换输入法等。
本发明通过采用上述方法,对应企业管理者来说,可以在员工处于无感知的状态下,监控员工的输入内容,且对一些敏感词汇进行替换、记录或者上报等操作。
上述方法还能够针对一些特殊情况进行规避,比如军队人员等特殊机构不允许人员向网络发送敏感词汇或者关键信息,运用本发明,可很好地解决这一问题。
对于企业管理者来说,可以监控某个应用的输入信息,对员工的输入内容进行管控、监控,避免企业机密的泄露,当然,管理者还可以对员工的输入行为、使用词汇及输入习惯进行分析,起到辅助了解员工的目的。
更进一步地,上述方法还可以准确记录整个手机或者平板电脑上的应用的用户输入信息,并对用户输入信息进行过滤、统计、分析,并可进一步分析用户行为,另外,对高频词汇的收集及研究也有非常重要的意义。
以上所述,仅是本发明的较佳实施例,并非对本发明做任何形式上的限制,凡是依据本发明的技术实质对以上实施例所作的任何简单修改、等同变化,均落入本发明的保护范围之内。

Claims (2)

1.一种Android应用内输入关键字拦截的方法,其特征在于,包括以下步骤:
步骤1:启动Android应用;
步骤2:初始化输入环境;
步骤3:hook机制下,代理输入法与Android应用的交互通道interfaceInputConnection的接口,在拦截点对应用程序获取的通道进行代理,然后提交到系统输入法管理系统;
步骤4:用户在输入法应用端输入内容;
步骤5:通过android API拦截InputMethodManager的调用,接着通过InputMethodManager服务获取mServedInputConnectionWrapper的connection,再通过反射IInputConnectionWrapper类获取mInputConnection的变量,实现获取用户的输入的内容;
步骤6:获取输入内容后,对输入的关键字进行处理,通过本地实现一个类implementsInputConnection接口重写,以替换应用的InputConnection对象而进行关键字的拦截替换;
步骤7:将关键字处理后的内容提交进系统输入法管理系统,并通过控件进行显示。
2.根据权利要求1所述的一种Android应用内输入关键字拦截的方法,其特征在于,所述步骤6中,对关键字的处理包括替换、过滤、记录及上报。
CN201811310875.6A 2018-11-06 2018-11-06 一种Android应用内输入关键字拦截的方法 Active CN109558728B (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811310875.6A CN109558728B (zh) 2018-11-06 2018-11-06 一种Android应用内输入关键字拦截的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811310875.6A CN109558728B (zh) 2018-11-06 2018-11-06 一种Android应用内输入关键字拦截的方法

Publications (2)

Publication Number Publication Date
CN109558728A CN109558728A (zh) 2019-04-02
CN109558728B true CN109558728B (zh) 2021-09-10

Family

ID=65865684

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811310875.6A Active CN109558728B (zh) 2018-11-06 2018-11-06 一种Android应用内输入关键字拦截的方法

Country Status (1)

Country Link
CN (1) CN109558728B (zh)

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073542B (zh) * 2010-12-22 2013-04-03 浙大网新科技股份有限公司 Linux应用在Android手机上运行时整合中文输入法的方法
CN107273022A (zh) * 2012-05-17 2017-10-20 联发科技(新加坡)私人有限公司 自动纠错方法及装置和移动终端
CN104111977B (zh) * 2014-06-24 2018-04-06 小米科技有限责任公司 信息匹配方法、装置及终端
CN104320693A (zh) * 2014-11-11 2015-01-28 浪潮软件集团有限公司 一种Android系统的智能电视上实现输入法外发光的方法
CN105898740A (zh) * 2016-06-12 2016-08-24 Tcl集团股份有限公司 一种基于移动设备通讯的信息加密解密方法及系统

Also Published As

Publication number Publication date
CN109558728A (zh) 2019-04-02

Similar Documents

Publication Publication Date Title
US11004039B2 (en) Cable reader labeling
US5497484A (en) File menu support for encapsulated applications
EP2835745A2 (en) Reader snippets
US20080301559A1 (en) User Interface That Uses a Task Respository
US9953100B2 (en) Automated runtime command replacement in a client-server session using recorded user events
US20050119853A1 (en) Method and apparatus for making and using test verbs
EP3968185A1 (en) Method and apparatus for pushing information, device and storage medium
CN106775647A (zh) 一种移动终端的控制方法、控制装置及移动终端
US10025689B2 (en) Enhanced policy editor with completion support and on demand validation
CN111651296A (zh) 数据删除操作的拦截备份方法、装置、设备及存储介质
CN106775677A (zh) 一种多屏显示方法及其实现方法和系统
US8015262B2 (en) Stateless core service transaction patterns
Serrano et al. Multimodal interaction on mobile phones: development and evaluation using ACICARE
CN106850838A (zh) 移动终端云应用的控制方法及系统
CN109558728B (zh) 一种Android应用内输入关键字拦截的方法
US20110258169A1 (en) Customization of Information Using a Desktop Module
US20110258578A1 (en) Interfacing Between Applications Utilizing a Desktop Module
US20140337728A1 (en) Operating oracle forms using a web service
US8645314B2 (en) Apparatus, system, and method for communicating interactive forms and reports in messaging applications
CN109542246B (zh) 一种Android输入法应用输入关键字拦截的方法
CN111611476B (zh) 专题页面的显示方法和装置
US8566724B2 (en) Online customization of information using a site management module
US11689574B2 (en) Optimizing security and event information
CN115297019B (zh) 物联网应用平台的管理方法、物联网系统、设备及介质
CN110851346B (zh) 查询语句边界问题的检测方法、装置、设备及存储介质

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant