搜狗输入法联想版增强

BetterZUIKey-SogouOEMExt

简体中文

Android Xposed Java License

联想 OEM 版搜狗输入法(29496052 / 1.0.android_pad_lenovo_2024.20260130165252)的增强模块

君ノ声ガ 聞コエルヨ。

你的声音,我能听到呀。

声明:本仓库主要部分均为 AIGC,可能有缺陷,欢迎审查和 PR。

应用图标基于搜狗输入法自带图标二次创作;流萤像素画来源未知,如有侵权请联系删除


Le judgement du pécheur / 罪行宣判

其一:闭门塞户

联想平板预装的搜狗输入法联想 OEM 版里明明有拼音 / 英语 / 五笔三种语言,但它只声明了一个 subtype,因此框架完全不知道它们。于是,系统与 BetterZUIKey 中那套「切换到下一个输入法语言」不会起任何作用。能且只能通过 Shift 切换输入法语言。

其二:粗枝大叶

在汉字输入模式下,输入法只维护了一些的中-英标点映射,但对于列表外的标点,粗暴地全部使用全角输出,包括 {}[]等,导致部分要求半角输入的区域必须切换到英文模式。

这个问题已经经过反馈,但没有实质性进展。

另外,很多功能看起来像是半成品:

  1. 中文输入时会提供单词建议,却不允许大写字母进入拼音栏触发建议 ¹
  2. 软键盘允许括号自动完成,物理键盘却没有此功能
  3. PC 端全半角、智能编号等功能均未提供

¹ 当输入“Dance”时,“D” 直接上屏而 “ance”进入拼音栏


唯一的缺点就是没有广告了

本模块通过注入搜狗 IME 进程,用搜狗自己的身份补入 subtype,并接管其语言切换链路;修正英文输入、补全自动完成功能;增加全半角切换……以此将其优化成一个相对可用的输入法。

版本:1.2.0versionCode 3

功能特性

  • 自定义语言切换:勾选要把哪些语言暴露给框架(做成 subtype),切换序列交给 BetterZUIKey
  • 严格模式:屏蔽搜狗原生切换键,语言切换完全由框架管理
  • 标点管线:分离中英标点和全角半角状态位,允许独立切换
  • 中文态大写字母:中文态下 Shift+字母也整词进拼音栏,上屏时按记录还原大小写
  • 引号 / 括号自动关闭:两个独立开关共用一份可编辑的匹配列表(默认提供 18 对)
    • 软键盘:修改搜狗原生配对,改用自定义列表
    • 物理键盘:打字即自动补闭字符,Ctrl+Shift+9 可临时切换开关
    • 有选区时包裹选区而不是替换它;光标后侧已有闭字符时只移光标,这和部分 IDE 行为相似
  • 完整的 …… 和 ——:破折号/省略号直接打出两个
  • 配置热生效 —— 通过广播更新配置,另外每 5 秒懒检查配置变化,更新配置无需重启输入法
  • 与 BetterZUIKey 联动 —— 若安装了 BetterZUIKey 会给出配置建议

工作原理

模块在搜狗 IME 进程里做五件事:注入 subtype / 推进 marker / 改写提交内容 / 配对与引号 / 光标兜底

模块 App(MainActivity)
    ↕ ContentProvider IPC(ConfigProvider · 每 2 秒轮询 + 签名比对)+ ConfigPoke 广播即时戳一下
搜狗 IME 进程(BridgeHook)
    ├── SubtypeInjector   用搜狗自己的 uid 补 subtype(绕开 setAdditionalInputMethodSubtypes 的闸门)
    ├── SogouTranslator   marker 推进 / 语言切换命令 / 快捷键与热键 / 配置热重载
    ├── PunctPipeline     在 commitText 上做「语义层 → 形式层」的标点改写
    └── AutoPairHook      配对三件套:闸门 UU.a · 自定义表 Yja.a · 引号标志位 KG.d
                          · 软键盘:闸门放行,由搜狗按自定义表提交开+闭
                          · 物理键盘:闸门拦住搜狗,改由模块注入闭字符并把光标移进中间
                          · 有选区:不让原提交走,改由模块提交「开 + 选区 + 闭」
                          · 闭合符已在光标后:只把光标移过去(按过闭字符 / 用户点过别处即恢复)
  • 自定义表若留空则继续走搜狗原有的配对规则
  • 中文引号由 KG.d 决定,每按一次就翻转 KG.e/KG.f。模块一次上屏两个字符,就得多替它翻一格,否则下一次按键只吐出一个
  • 配对之后的光标由搜狗的 Qja.setSelection 定:它那次是排队执行的、而且比模块返回还晚,所以只能改写它那次请求的参数,不能自己再设一遍
  • subtype 顺序 = 框架 enabled subtype 列表顺序
  • 若由于版本更新导致内部符号变化则退回合成 Shift / 走默认表,避免造成崩溃
  • dex 级逆向、踩坑与实测数据全部整理在 PRINCIPLE.md

模块安装

  1. 前置条件:已安装 LSPosed + 联想 OEM 版搜狗输入法

    包名 com.sohu.inputmethod.sogou.oem
    版本 versionCode 29496052 / versionName 1.0.android_pad_lenovo_2024.20260130165252
    来源 联想平板 TB710FU(Android 16)预装,位于 /system/preinstall/SogouInput

    模块按这个版本的搜狗内部符号实现(实测 + 逆向均基于它)。其他版本可能符号不同,届时功能可能会降级(而不会崩溃),但请以本表版本为准。

  2. Releases 下载 APK 并安装

  3. LSPosed Manager 里启用模块即可 —— 作用域由模块静态声明无需也无法手动勾选

  4. 打开模块 App,勾好要暴露给框架的语言

  5. 杀死输入法进程

  6. 多次进入/退出编辑以触发键盘弹出

若要使用“只响应系统框架语言切换消息”功能,需要 BZK v1.7.0 以上。 1.6.x 亦可联动部分功能,但无法使用轮转顺序自定义功能,系统框架只能切换最近使用的 2 门语言。

开发构建

git clone git@github.com:CommandPrompt-Wang/BetterZUIKey-SogouOEMExt.git
cd BetterZUIKey-SogouOEMExt
./gradlew :app:assembleDebug
# APK: app/build/outputs/apk/debug/BetterZUIKey-SogouOEMExt-v<versionName>.apk

需要 JDK 17 + Android SDK 37(compileSdk 37 / minSdk 27 / targetSdk 36),以及 libxposedxposedminversion=93)。

  • 请自备 app-sign.keystorekeystore.properties

使用方法

主页只决定「暴露哪些语言」:勾哪个,哪个语言才会被做成 subtype 交给框架;顺序不在这里(那是 BetterZUIKey 的事)。

下面每项一张卡片,开关与热键:

功能 解释 默认值
智能中文标点 更合理的中文标点符号,使用半角的 +-*#[] 等符号
智能编号 中文模式下,任意数字后面的 改用半角,以形成 1. 2) 这类编号
大写字母进拼音栏 中文态下 Shift+字母也整词进拼音,上屏时按记录还原大小写
切换快捷键:Ctrl+Shift+9
引号/括号自动补全 软键盘打 → 自动补 并把光标移进中间;配对规则来自「编辑匹配列表」
物理键盘自动补全 物理键盘打 → 模块注入 并移光标;Ctrl+Shift+9 可临时开关
选区自动补全 选中文本时用配对标点包住(abc(abc)),而不是替换掉选区
跳过已存在的闭合符号 光标后侧已有闭合符时只移光标、不再多出一个;手动移动光标后恢复正常闭合
完整的 ……—— 输入 / 时输出两个(关闭则恢复搜狗原生单出)
全角模式 标点与数字全部输出全角( ),关闭则半角
切换快捷键:Shift+Space
中英文标点 中文态下也输出 ASCII 标点(英文标点模式)
切换快捷键:Ctrl+.
只响应系统框架语言切换消息 严格模式:屏蔽搜狗原生切换键,只接受框架信号
条目「编辑匹配列表」 自定义「前-后」配对串,长度必须是偶数;留空 = 用输入法默认匹配规则 18 对建议值
条目「原样输出斜杠」 搜狗把 /\ 都输出成 ;可以选一个原样保留

三个状态位(全角 / 中英标点 / 物理补全)才有快捷键;其余都是纯开关,改完即时生效。

日志:

adb shell logcat -s BZK-SogouOEMExt

config -> wubi,pinyin,en|2 | applied rotation=[wubi, pinyin] (was [pinyin, wubi])
sync marker: real=en cur=null -> want=pinyin
marker repositioned to pinyin in 1 step(s)
punct: { -> { [half] [cn]
provider: dump self-check = ok (pairMap=18 pairs)

⚠️ 免责声明

这是一个 LSPosed 模块,直接 hook 输入法的输入链路与提交链路。使用前请:

  • 先读内置的「原理 / 说明」,理解每个开关的含义再动手
  • 不当配置可能导致切不到某个语言、标点/配对行为异常
  • 只针对 com.sohu.inputmethod.sogou.oem联想 OEM 版 29496052 / 1.0.android_pad_lenovo_2024.20260130165252,对公版搜狗、其他厂商 OEM 版、以及其他版本号一律无效

开发者不承担因使用本模块造成的输入异常、数据丢失或设备故障的任何责任。

项目结构

app/src/main/java/moe/lovefirefly/bzk/sogouoemext/
├── BridgeHook.java          # Xposed 入口 + 开发期开关(DEV_*)
├── SogouTranslator.java     # 核心:subtype 注入时机 / marker 推进 / 快捷键与热键 / 配置轮询
├── SubtypeInjector.java     # 用搜狗身份补 subtype(绕开 uid 闸门)
├── PunctPipeline.java       # 标点管线:语义层(中/英/数字/斜杠)→ 形式层(全/半角)
├── AutoPairHook.java        # 引号括号:UU.a 闸门 · Yja.a 自定义表 · KG.d 引号标志位
│                            #   软键盘放行搜狗配对;物理键盘拦住搜狗、改由模块注入闭字符
│                            #   有选区则包裹;闭字符已在光标后则只移光标(含 Qja.setSelection 改写)
├── LangConfig.java          # 配置:dump / parseDump / signature,配对串解析成 Map
├── LangSpec.java            # 语言规格常量(语言清单、默认暴露集合、默认值)
├── ConfigProvider.java      # ContentProvider:App → 模块 的配置通道(含 UID 白名单)
├── ConfigPoke.java          # 配置即时生效:App 发一条不带数据的广播,模块立刻重读
├── MainActivity.java        # 首页:语言暴露勾选 + 所有开关(launcher)
├── InfoActivity.java        # 「原理 / 说明」页
├── InfoText.java            # 说明文案
├── Sogou*Probe.java         # 开发期探针:命令注册表 / 状态字段 / 按键路径 / 标点提交点 / subtype 写回
└── SogouStateWatch.java     # 开发期探针:每 500ms 采样 LUa.F(),只在变化时打日志

📄 许可证

GPL-3.0 © 2025–2026 CommandPrompt-Wang

Releases

9/19/2026, 6:52:48 PM

搜狗输入法联想版增强 v1.2.1

摘要

本次更新为界面整理:设置项全部卡片化,语言暴露改为独立子页面,子页面统一顶栏与返回箭头。

完整变更: CommandPrompt-Wang/BetterZUIKey-SogouOEMExt@3-1.2.0...4-1.2.1

界面

  • 设置项全部卡片化:严格模式、斜杠下拉等原先的裸行也套上卡片,整页版式统一。
  • 「选择在输入法框架中显示的语言」独立成子页面:勾选列表从首页搬进子页,首页只留一行入口
    (带说明)。存储格式不变,改完立即生效。
  • 子页面统一顶栏:改用标准 Toolbar + 系统返回箭头,与其它子页面同一套外观,系统返回键同样可用。
  • 修掉入口行的页边距:原先比其它条目更宽,现在与整页对齐。

Assets

1

9/17/2026, 11:13:49 AM

搜狗输入法联想版增强 v1.1.0

Please scroll down for English / 英语请向下滚动

摘要

首个公开版本。本模块通过 LSPosed 注入联想 OEM 版搜狗输入法进程,用输入法自己的身份补出 中文(zh-CN) / English(en-US) 两个 subtype,把「只能用 Shift 切语言」的搜狗改造成由系统输入法框架驱动;并在此之上加入标点管线、引号/括号配对、中文态大写字母等增强。

完整变更: 本仓库首个版本,见 https://github.com/CommandPrompt-Wang/BetterZUIKey-SogouOEMExt/commits/main

新功能

  • 框架 subtype 驱动语言切换:在搜狗自己的 uid 下补入 subtype(绕开 IMMS 的 isSameApp 闸门),模块再把 subtype 变化翻译成搜狗内部的语言切换命令;幂等执行——先读搜狗真实语言,与目标一致就不动作,所以连按一一对应,不会「按一次切两次」。

  • 自定义语言顺序:首页拖动卡片排列切换顺序,分隔线上下分别决定哪些语言接入 / 不接入框架轮换(不接入的语言只能从搜狗键盘自己切)。

  • 严格模式(「只响应系统框架语言切换消息」,默认关):屏蔽搜狗原生切换键(物理 Ctrl+Shift、屏幕中/英键),语言只由框架 subtype 驱动。需要 BetterZUIKey v1.6.1 以上,否则输入法收不到任何消息。

  • 标点管线:把「语义层(中/英/数字/斜杠)」与「形式层(全/半角)」拆开,二者可独立切换。

    功能 说明 快捷键 默认
    智能中文标点 更合理的中文标点,+-*#[] 等使用半角
    全角模式 标点与数字全部输出全角( Shift+Space
    中英文标点 中文态下也输出 ASCII 标点 Ctrl+.
    智能编号 数字后的 改半角,形成 1. 2)
    原样输出斜杠 搜狗把 /\ 都输出成 ,可选一个原样保留
  • 中文态大写字母进拼音栏(默认开):中文态下 Shift+字母也整词进拼音,上屏时按记录的 Shift 意图还原大小写(DanceFeiChangHao)。切换快捷键 Ctrl+Shift+9

  • 引号 / 括号自动补全(默认关):软键盘打 → 自动补 并把光标移进中间。

  • 物理键盘自动补全(默认关):物理键盘打 → 模块注入 并移光标;Ctrl+Shift+9 可临时开关。

  • 编辑匹配列表:自定义「前-后」配对串,长度必须为偶数;默认 18 对建议值,支持分组换行;留空则回退搜狗原有匹配规则。

  • 配置热生效:每 2 秒按签名懒检查配置,改完设置重弹键盘即可生效,无需重启输入法进程

  • 与 BetterZUIKey 联动:检测到 BZK 时给出配置建议并解锁严格模式,未安装则置灰并提示安装。

  • 界面:Material 3 风格首页 + 内置「原理 / 说明」页;接入自适应图标;快捷键状态改用贴底横幅提示(搜狗进程的 Toast 会被系统按应用通知设置拦掉)。

已知限制

  • 五笔只在物理键盘(带工具栏)下可用,软键盘只有中/英。
  • 修改 subtype 集合时,若被移除的正是当前 subtype,框架可能重建一次输入法窗口。

其他

  • 仅针对联想 OEM 版搜狗(com.sohu.inputmethod.sogou.oem),对其他搜狗版本无效。
  • 逆向、踩坑与实测数据整理在仓库 PRINCIPLE.md。欢迎研究学习。

⚠ 安装与升级注意

  • 安装后在 LSPosed 中启用模块即可 —— 作用域由模块静态声明(staticScope=truecom.sohu.inputmethod.sogou.oem),无需也无法手动勾选;随后至少打开一次模块 App(否则 App 处于 stopped 状态,模块读不到配置),再杀死输入法进程并重新弹出键盘。
  • 需要 Android 8.1+ / LSPosed;严格模式需配合 BetterZUIKey v1.6.1 以上。
  • 本模块直接 hook 输入法的输入链路与提交链路。不当配置可能导致切不到某个语言、标点或配对行为异常,首次使用请先阅读内置「原理 / 说明」。

Sogou Input Method Lenovo OEM Enhancement v1.1.0

Highlights

First public release. This module injects into the Lenovo OEM build of Sogou IME via LSPosed and, under the IME's own identity, exposes Chinese (zh-CN) / English (en-US) subtypes — turning a keyboard whose language could only be switched with Shift into one driven by the system input method framework, plus punctuation, bracket pairing and uppercase-in-pinyin enhancements.

Full changelog: first release of this repository, see https://github.com/CommandPrompt-Wang/BetterZUIKey-SogouOEMExt/commits/main

New Features

  • Framework-subtype-driven language switching: subtypes are injected under Sogou's own uid (bypassing the IMMS isSameApp gate), and the module translates subtype changes into Sogou's internal language-switch commands. Execution is idempotent — it reads Sogou's real language first and does nothing if it already matches, so one press maps to exactly one switch.

  • Custom language order: drag cards on the home screen to order switching; the divider decides which languages are exposed to / hidden from the framework rotation (hidden ones can only be switched from Sogou's own keyboard).

  • Strict mode ("Only respond to framework language-switch messages", off by default): blocks Sogou's native switch keys (physical Ctrl+Shift, on-screen zh/en key); language is driven solely by framework subtypes. Requires BetterZUIKey v1.6.1 or later, otherwise the IME receives no messages at all.

  • Punctuation pipeline: separates the semantic layer (Chinese/English/digit/slash) from the form layer (full/half width), each switchable independently.

    Feature Description Shortcut Default
    Smart Chinese punctuation More sensible Chinese punctuation; +-*#[] etc. output half-width On
    Full-width mode All punctuation and digits output full-width ( ) Shift+Space On
    Chinese/English punctuation Output ASCII punctuation even in Chinese mode Ctrl+. On
    Smart numbering after digits become half-width, forming 1. 2) On
    Raw slash output Sogou turns both / and \ into ; keep one of them raw Off
  • Uppercase letters into the pinyin bar in Chinese mode (on by default): Shift+letter also enters the pinyin bar as a whole word, and the recorded Shift intent is replayed on commit (Dance, FeiChangHao). Toggle with Ctrl+Shift+9.

  • Quote / bracket auto-pairing (off by default): type on the soft keyboard → is inserted and the cursor moves inside.

  • Physical keyboard auto-pairing (off by default): type on a physical keyboard → the module injects and moves the cursor; Ctrl+Shift+9 toggles it temporarily.

  • Editable match list: custom "open-close" pairs, length must be even; 18 suggested pairs by default with grouping line breaks; empty falls back to Sogou's original rules.

  • Hot config reload: config signature is lazily checked every 2 seconds; reopen the keyboard after changing settings — no need to restart the IME process.

  • BetterZUIKey integration: when BZK is detected, configuration suggestions appear and strict mode is unlocked; otherwise the switch is greyed out with an install hint.

  • UI: Material 3 home screen plus a built-in "How it works" page; adaptive icon; shortcut status is shown as a bottom banner (Sogou-process toasts are suppressed by the system notification settings).

Known Limitations

  • Wubi is only available on a physical keyboard (with the toolbar); the soft keyboard only offers Chinese/English.
  • When the subtype set changes, the framework may rebuild the IME window once if the removed subtype was the current one.

Other

  • Targets the Lenovo OEM build of Sogou only (com.sohu.inputmethod.sogou.oem); ineffective on other Sogou builds.
  • Reverse-engineering notes, pitfalls and measurements are collected in PRINCIPLE.md. Contributions and study are welcome.

⚠ Install & Upgrade Notes

  • After installing, just enable the module in LSPosed — the scope is statically declared by the module (staticScope=true, com.sohu.inputmethod.sogou.oem) and neither needs nor allows manual selection. Then open the module app at least once (otherwise the app stays in the stopped state and the module cannot read the config), then kill the IME process and re-open the keyboard.
  • Requires Android 8.1+ / LSPosed; strict mode also needs BetterZUIKey v1.6.1 or later.
  • This module directly hooks the IME's input and commit paths. A bad configuration may cause a language to become unreachable or punctuation/pairing to misbehave — read the built-in "How it works" page first.

Assets

1