Skip to content

Commit e2a2269

Browse files
committed
🐛网页上的发送消息接口错误修改
1 parent 51073c0 commit e2a2269

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

android_debug_lib/src/main/assets/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h4>版本号:${appVersionCode}</h4>
2424
data.append('param', apdu);
2525
$.ajax({
2626
type:'post',
27-
url:'/',
27+
url:'/message',
2828
cache: false,
2929
processData: false,
3030
contentType: false,
@@ -50,7 +50,7 @@ <h4>版本号:${appVersionCode}</h4>
5050
data.append('param', text);
5151
$.ajax({
5252
type:'post',
53-
url:'/',
53+
url:'/message',
5454
cache: false,
5555
processData: false,
5656
contentType: false,
@@ -76,7 +76,7 @@ <h4>版本号:${appVersionCode}</h4>
7676
data.append('param', command);
7777
$.ajax({
7878
type:'post',
79-
url:'/',
79+
url:'/message',
8080
cache: false,
8181
processData: false,
8282
contentType: false,
@@ -102,7 +102,7 @@ <h4>版本号:${appVersionCode}</h4>
102102
data.append('param', text);
103103
$.ajax({
104104
type:'post',
105-
url:'/',
105+
url:'/message',
106106
cache: false,
107107
processData: false,
108108
contentType: false,

android_debug_lib/src/main/java/com/itlgl/android/debuglib/DebugServer.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,7 @@ private Response responsePostMessage(IHTTPSession session) throws Exception {
190190
return responseTextError("uri=" + strUri + ",param is null!");
191191
}
192192

193-
//获取剪贴板管理器:
194-
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
195-
// 创建普通字符型ClipData
196-
ClipData mClipData = ClipData.newPlainText(param, param);
197-
// 将ClipData内容放到系统剪贴板里。
198-
cm.setPrimaryClip(mClipData);
193+
AppUtils.copyToClipboardThread(context, param);
199194

200195
return responseText("copy '" + param + "' to mobile clipboard");
201196
} else if("sendMessage".equalsIgnoreCase(method)) {

android_debug_lib/src/main/java/com/itlgl/android/debuglib/utils/AppUtils.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package com.itlgl.android.debuglib.utils;
22

3+
import android.content.ClipData;
4+
import android.content.ClipboardManager;
35
import android.content.Context;
46
import android.content.pm.ApplicationInfo;
57
import android.content.pm.PackageInfo;
68
import android.content.pm.PackageManager;
79
import android.graphics.Bitmap;
810
import android.graphics.drawable.BitmapDrawable;
911
import android.graphics.drawable.Drawable;
12+
import android.os.Handler;
13+
import android.os.Looper;
1014

1115
public class AppUtils {
1216

@@ -105,4 +109,19 @@ public static synchronized Bitmap getBitmap(Context context) {
105109
return bm;
106110
}
107111

112+
public static Handler MAIN_HANDLER = new Handler(Looper.getMainLooper());
113+
114+
public static void copyToClipboardThread(final Context context, final String text) {
115+
MAIN_HANDLER.post(new Runnable() {
116+
@Override
117+
public void run() {
118+
//获取剪贴板管理器:
119+
ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
120+
// 创建普通字符型ClipData
121+
ClipData mClipData = ClipData.newPlainText(text, text);
122+
// 将ClipData内容放到系统剪贴板里。
123+
cm.setPrimaryClip(mClipData);
124+
}
125+
});
126+
}
108127
}

0 commit comments

Comments
 (0)