1919
2020package com .sevtinge .hyperceiler .module .hook .various .clipboard ;
2121
22- import static com .sevtinge .hyperceiler .utils .log .XposedLogUtils .logD ;
23- import static com .sevtinge .hyperceiler .utils .log .XposedLogUtils .logE ;
24- import static com .sevtinge .hyperceiler .utils .log .XposedLogUtils .logI ;
25- import static com .sevtinge .hyperceiler .utils .log .XposedLogUtils .logW ;
26-
2722import android .content .ClipData ;
2823import android .content .Context ;
2924import android .net .Uri ;
3833import com .hchen .hooktool .tool .ParamTool ;
3934import com .sevtinge .hyperceiler .utils .ContentModel ;
4035import com .sevtinge .hyperceiler .utils .FileHelper ;
36+ import com .sevtinge .hyperceiler .utils .log .XposedLogUtils ;
37+
38+ import org .json .JSONArray ;
4139
4240import java .util .ArrayList ;
4341import java .util .stream .Collectors ;
4442
43+ import de .robv .android .xposed .XC_MethodHook ;
44+ import de .robv .android .xposed .XposedHelpers ;
45+
4546/**
4647 * 解除常用语剪贴板时间限制,条数限制和字数限制。
4748 * from <a href="https://github.com/HChenX/ClipboardList">ClipboardList</a>
@@ -60,11 +61,11 @@ public class NewClipboardList extends BaseHC implements LoadInputMethodDex.OnInp
6061 public void load (ClassLoader classLoader ) {
6162 mGson = new GsonBuilder ().setPrettyPrinting ().create ();
6263 mDataPath = lpparam .appInfo .dataDir + "/files/clipboard_data.dat" ;
63- logI (TAG , "class loader: " + classLoader );
64+ XposedLogUtils . logI (TAG , "class loader: " + classLoader );
6465
6566 FileHelper .TAG = TAG ;
6667 if (!FileHelper .exists (mDataPath )) {
67- logE (TAG , "file create failed!" );
68+ XposedLogUtils . logE (TAG , "file create failed!" );
6869 return ;
6970 }
7071
@@ -193,6 +194,23 @@ public void before() {
193194 }
194195 })
195196 );
197+ XposedHelpers .findAndHookMethod ("com.miui.inputmethod.MiuiClipboardManager" , classLoader , "buildClipboardModelDataType" , "com.miui.inputmethod.ClipboardContentModel" , new XC_MethodHook () {
198+ @ Override
199+ protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
200+ final boolean [] isSkip = {false };
201+ XposedHelpers .findAndHookConstructor (JSONArray .class , String .class , new XC_MethodHook () {
202+ @ Override
203+ protected void beforeHookedMethod (MethodHookParam param ) throws Throwable {
204+ String json = (String ) param .args [0 ];
205+ if (TextUtils .isEmpty (json ) || json == null ) {
206+ isSkip [0 ] = true ;
207+ XposedLogUtils .logW (TAG , lpparam .packageName , "Got null string, skip run. String = " + param .args [0 ]);
208+ }
209+ }
210+ });
211+ if (isSkip [0 ]) param .setResult (null );
212+ }
213+ });
196214
197215 }
198216
@@ -222,7 +240,7 @@ private void addClipboard(String add, int type, Context context) {
222240 }
223241 ArrayList <ContentModel > readData = toContentModelList (FileHelper .read (mDataPath ));
224242 if (readData .isEmpty ()) {
225- logW (TAG , "can't read any data!" );
243+ XposedLogUtils . logW (TAG , "can't read any data!" );
226244 } else {
227245 if (readData .stream ().anyMatch (contentModel -> contentModel .content .equals (add ))) {
228246 readData .removeIf (contentModel -> contentModel .content .equals (add ));
0 commit comments