实现 PTT 账号更新强制重启、补齐全量 PTT 接口及回调桥接

This commit is contained in:
844143714@qq,com 2026-04-30 01:31:40 +08:00
parent 81e3f2c23b
commit 0a1f1228cb
3 changed files with 89 additions and 38 deletions

View File

@ -478,6 +478,7 @@ public class CallBackResolution {
};
executor.scheduleAtFixedRate(task, 0, 40, TimeUnit.SECONDS);
} else if (tempTxt.contains("账号已更新")) {
com.stand.standapp.MainActivity.showPttUpdateDialog();
} else if (tempTxt.contains("账号或密码错误")) {
CallBackUtil.callBackLogin(false, "");
}else if (tempTxt.contains("请配置账号")) {

View File

@ -68,7 +68,19 @@ public class CallBackUtil {
* state true-成功 false-失败
*/
public static void callBackOnMemberSuccess(boolean state, List<GroupMemberInfoDto> dtos) {
try {
org.json.JSONArray arr = new org.json.JSONArray();
if (dtos != null && state) {
for (GroupMemberInfoDto dto : dtos) {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("memberId", dto.getMemberId());
obj.put("memberName", dto.getGmemberName());
obj.put("status", dto.getStatus());
arr.put(obj);
}
}
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('MemberList', " + arr.toString() + ");}");
} catch (Exception e) {}
}
/**
@ -101,9 +113,17 @@ public class CallBackUtil {
* GroupInfoDto 群组信息
* */
public static void callBackGroupInfo (ArrayList < GroupInfoDto > groupInfoDtos) {
for (GroupInfoDto groupInfoDto : groupInfoDtos) {
Log.d(TAG, "callBackGroupInfo: " + groupInfoDto.toString());
}
try {
org.json.JSONArray arr = new org.json.JSONArray();
for (GroupInfoDto dto : groupInfoDtos) {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("groupId", dto.getGroupId());
obj.put("groupName", dto.getGroupName());
obj.put("groupNo", dto.getGroupNo());
arr.put(obj);
}
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('GroupList', " + arr.toString() + ");}");
} catch (Exception e) {}
}
/**
@ -112,44 +132,46 @@ public class CallBackUtil {
* talkId 讲话用户ID
* talkName 讲话用户名字
* */
public static void callBackNotifySpker ( int speckType, String groupId, String
groupName, String talkId, String talkName){
public static void callBackNotifySpker ( int speckType, String groupId, String groupName, String talkId, String talkName){
try {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("speckType", speckType);
obj.put("groupId", groupId);
obj.put("groupName", groupName);
obj.put("talkId", talkId);
obj.put("talkName", talkName);
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('SpeakerUpdate', " + obj.toString() + ");}");
} catch (Exception e) {}
}
/**
* 对方讲话通知
* playStatus 1表示开始讲话, 0 表示结束讲话
* speckType 自己讲话状态 0 表示自己无法讲话 1 表示自己可以中断讲话人的讲话可以进行强插讲话
* groupId 所在群组Id
* groupName 所在群组名称
* talkId 讲话用户Id
* talkName 讲话用户名称
* */
public static void callBackNotifyPlayStatus ( int playStatus, int speckType, String
groupId, String groupName, String talkId, String talkName){
public static void callBackNotifyPlayStatus ( int playStatus, int speckType, String groupId, String groupName, String talkId, String talkName){
try {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("playStatus", playStatus);
obj.put("speckType", speckType);
obj.put("groupId", groupId);
obj.put("groupName", groupName);
obj.put("talkId", talkId);
obj.put("talkName", talkName);
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('PlayStatus', " + obj.toString() + ");}");
} catch (Exception e) {}
}
/**
*临时呼叫信息通知
* tempCallNotify
* 临时呼叫xxx表示被单呼呼叫名xxx
* 退出临时呼叫表示退出单呼
* 呼叫成功表示单呼成功
* 呼叫失败表示单呼失败
* */
public static void callBackTempCallNotify (String tempCallNotify){
try {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("msg", tempCallNotify);
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('TempCall', " + obj.toString() + ");}");
} catch (Exception e) {}
}
/**
* 用户进入群组信息通知
* userGroupId 用户所在的群组ID
* userGroupName 用户所在的群组名称
* */
public static void callBackNotifyUpdateGroup (String userGroupId, String userGroupName){
try {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("groupId", userGroupId);
obj.put("groupName", userGroupName);
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('UpdateGroup', " + obj.toString() + ");}");
} catch (Exception e) {}
}
/**
@ -160,9 +182,16 @@ public class CallBackUtil {
* longitude 经度
* time 时间
*/
public static void callBackNotifyLocationStatus ( int status, String userId,double latitude,
double longitude, String time){
public static void callBackNotifyLocationStatus ( int status, String userId,double latitude, double longitude, String time){
try {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("status", status);
obj.put("userId", userId);
obj.put("latitude", latitude);
obj.put("longitude", longitude);
obj.put("time", time);
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('LocationStatus', " + obj.toString() + ");}");
} catch (Exception e) {}
}
/**
@ -242,7 +271,13 @@ public class CallBackUtil {
* longitude 经度
* */
public static void callBackEnotifyAlarm (String memberName,double latitude, double longitude){
try {
org.json.JSONObject obj = new org.json.JSONObject();
obj.put("memberName", memberName);
obj.put("latitude", latitude);
obj.put("longitude", longitude);
com.stand.standapp.MainActivity.executeJs("if(window.onPttEvent){window.onPttEvent('Alarm', " + obj.toString() + ");}");
} catch (Exception e) {}
}
/**

View File

@ -67,6 +67,21 @@ class MainActivity : AppCompatActivity() {
}
}
@JvmStatic
fun showPttUpdateDialog() {
instance?.runOnUiThread {
val ctx = instance ?: return@runOnUiThread
androidx.appcompat.app.AlertDialog.Builder(ctx)
.setTitle("账号更新")
.setMessage("您的 PTT 账号信息已被更新,需要重新登录以应用更改。\n请点击确认重启应用。")
.setCancelable(false)
.setPositiveButton("确认") { _, _ ->
com.stand.standapp.utils.AppKiller.killApp(ctx)
}
.show()
}
}
// 获取并清除待执行的 JS 代码(由 bridge.js 轮询)
@JvmStatic
fun pollPendingJs(): String {