[Sony Cross-Device Development Themes and Apps] Aqq123:
Xperia Chinese Keyboard modified to work on any device

Supports pinyin, zhuyin, stroke order, handwriting and Cangjie, as well as English input

Version: 25.1.A.0.45 Patch #6 Updated 2022-11-18

View attachment 5741893

View attachment 5741895

View attachment 5741897

View attachment 5741899​

Download

From Mega.nz (file too large to attach here):

Patch 6 for LOS 19.1 / Android 12

Patch 5 for LOS 18.1 / Android 11

Spoiler content hidden.

Installation

Best installed with: adb install -g <filename>

Otherwise, have to manually grant the permission: Settings → Apps & notifications → See all apps → Xperia Chinese keyboard → Advanced → Display over other apps: Allowed (will crash if you won't)

Enable the input method in Settings → Languages & input and switch to it using the keyboard icon on the navigation bar, which appears when you start editing text

Some Details

Based on firmware H9493_Customized TW_52.1.A.3.137-R4C for Sony Xperia XZ3 (Akatsuki)

Includes libraries to make it work as a user (not system) app:

libbase.so, libc++.so, and libnativehelper.so from LineageOS 18.1

libsqlite.so from SQLite's official precompiled Android binaries

Changed values loaded into $LayoutParams;->type:I from 0x000007dc = 0x000007d9 (TYPE_KEYGUARD_DIALOG) | 0x00000002 (TYPE_APPLICATION) | 0x00000001 (TYPE_BASE_APPLICATION), only allowed for system apps, to 0x000007f6 (TYPE_APPLICATION_OVERLAY) and updated the manifest accordingly to request the permission android.permission.SYSTEM_ALERT_WINDOW (which must be granted manually)

Patch 3: Remove dependency on Sony Vibration Effect library (com.sonymobile.vibrationeffect.api_1) from the manifest

Patch 3: Replace all references to Sony Vibration Effect library: invoke-static {p1}, Lcom/sonymobile/vibrationeffect/VibrationEffect;->get(I)Landroid/os/VibrationEffect;which were causing the app to crash, with standard Android calls:

const/4 p0, -0x1 (DEFAULT_AMPLITUDE)

const-wide/16 v2, 0xc (Duration: 12 ms)

invoke-static {v2, v3, p0}, Landroid/os/VibrationEffect;->createOneShot(JI)Landroid/os/VibrationEffect;

— for keypresses

const v0, 0x2 (EFFECT_TICK)

invoke-static {v0}, Landroid/os/VibrationEffect;->createPredefined(I)Landroid/os/VibrationEffect;

— for other events

Patch 4 - Test: Remove the invocation of a virtual method invoke-virtual {p0}, Lcom/sonyericsson/textinput/chinese/uxp/view/hw/HWFullView;->getVisibility()I that causes a crash under some circumstances in InputMethodServiceGlue. However the side effect of this change is that other UI elements cannot be interacted with while the keyboard is open. How to fix this completely needs further investigation. Since the crash seems rare, I recommend sticking with Patch 3 for now.

Patch 5: A different workaround for the above mentioned issue. If iget-object p0, p0, Lcom/sonyericsson/textinput/chinese/glue/InputMethodServiceGlue;->mHwFullView:Lcom/sonyericsson/textinput/chinese/uxp/view/hw/HWFullView; returns 0 (i.e. effectively NULL but there's no explicit check for that in Smali), then skip the call and return from the method. Otherwise, proceed. After a week of testing, this seems to work well: no rare crashes, and the UI is accessible too with the keyboard open.

Tested to work on two different LineageOS 18.1 devices. Should work elsewhere too. If it doesn't, it's probably because of the three libraries (libbase.so, libc++.so, and libnativehelper.so): check adb logcat and replace them with the versions from your system.

Patch 6: Fix compatibility with LOS 19.1/Android 12 where a call to jniGetFDFromFileDescriptor() from libnativehelper.so fails by design due to API changes (see: Google Issue Tracker), and the version of the library included with the app can no longer be used due to name conflict with the system library with the same name. The workaround: rename the bundled libnativehelper.so (same as Patch 5/Android 11/LOS 18.1, so unchanged) to libforeignenemy.so and change references to it in libcootek_pte_oem.so, libcootek_pte_oem_western.so and libcurve_oem.so accordingly. Also update libbase.so and libc++.so to current versions from LOS 19.1 (Android 12).

Related

Xperia keyboard for most languages port by @greenys'

Xperia Chinese keyboard version 10.1.A.0.1 (Android 4.4+, 2012-2013) by @danist727