From: TrillGates Date: Tue, 16 Mar 2021 03:25:51 +0000 (+0800) Subject: fixed l02 voice chat issues. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=87121242f8659b131844950a19f2348f1f88d545;p=protocol_srv.git fixed l02 voice chat issues. --- diff --git a/app/src/main/java/com/enqualcomm/support/CoreService.java b/app/src/main/java/com/enqualcomm/support/CoreService.java index c101e0ea..f72b0c22 100644 --- a/app/src/main/java/com/enqualcomm/support/CoreService.java +++ b/app/src/main/java/com/enqualcomm/support/CoreService.java @@ -12,6 +12,8 @@ import android.media.AudioManager; import android.os.Handler; import android.os.HandlerThread; import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; import android.os.PowerManager; import android.os.SystemClock; import android.support.annotation.Nullable; @@ -113,6 +115,8 @@ public class CoreService extends Service { public static final int interval = 60000; + final Messenger mMessenger = new Messenger(new RequestHandler(this)); + public static boolean needLocateInAfterHeartBeat = false; private static int is_allowed_in_sleep_mode = 1; @@ -155,6 +159,23 @@ public class CoreService extends Service { } }; + private static class RequestHandler extends Handler { + private final WeakReference mReference; + + RequestHandler(CoreService param1CoreService) { + this.mReference = new WeakReference(param1CoreService); + } + + public void handleMessage(Message param1Message) { + CoreService coreService = (CoreService) this.mReference.get(); + if (coreService == null) { + return; + } + coreService.invokeHandlerServiceChain.processUserRequest(param1Message, + coreService.connection, coreService.runtime); + } + } + private BroadcastReceiver TimeChangeBroadcastReceiver = new BroadcastReceiver() { public void onReceive(Context param1Context, Intent param1Intent) { StringBuilder stringBuilder2 = new StringBuilder(); @@ -1647,7 +1668,7 @@ public class CoreService extends Service { } return mFZDService; } - return null; + return this.mMessenger.getBinder(); } public void disconnect_server() { diff --git a/app/src/main/java/com/enqualcomm/support/service/SendChatMessage.java b/app/src/main/java/com/enqualcomm/support/service/SendChatMessage.java index 436070ab..f92e3089 100644 --- a/app/src/main/java/com/enqualcomm/support/service/SendChatMessage.java +++ b/app/src/main/java/com/enqualcomm/support/service/SendChatMessage.java @@ -7,13 +7,11 @@ import android.os.Bundle; import android.os.Message; import android.os.Messenger; -import com.enqualcomm.support.CoreService; import com.enqualcomm.support.bean.Runtime; import com.enqualcomm.support.bean.VoiceContent; import com.enqualcomm.support.service.base.AbstractInvokeHandlerService; import com.enqualcomm.support.utils.Connection; import com.enqualcomm.support.utils.ICLogger; -import com.enqualcomm.support.utils.NettyConnection; import com.enqualcomm.support.utils.SimSignalUtil; import com.enqualcomm.support.utils.TimeUtil; import com.enqualcomm.support.utils.Util; @@ -21,27 +19,27 @@ import com.enqualcomm.support.utils.Util; import static com.enqualcomm.support.bean.Content.CONTACT_CATEGORY_GROUP; public class SendChatMessage extends AbstractInvokeHandlerService { - private static final int LOCATION_TYPE = 7; - - private int mNetworkType; - - private SimSignalUtil mSignalUtil; - - static { - - } - - private void callback(Messenger paramMessenger, int paramInt) { - if (paramMessenger != null) - try { - paramMessenger.send(Message.obtain(null, paramInt)); - return; - } catch (Exception e) { - e.printStackTrace(); - } - } - - private void deleteImage(String paramString, Context paramContext) { + private static final int LOCATION_TYPE = 7; + + private int mNetworkType; + + private SimSignalUtil mSignalUtil; + + static { + + } + + private void callback(Messenger paramMessenger, int paramInt) { + if (paramMessenger != null) + try { + paramMessenger.send(Message.obtain(null, paramInt)); + return; + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void deleteImage(String paramString, Context paramContext) { // Uri uri1; // ContentResolver contentResolver = paramContext.getContentResolver(); // Uri uri2 = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; @@ -60,29 +58,34 @@ public class SendChatMessage extends AbstractInvokeHandlerService { // return; // } // ICLogger.i("删除失败"); - } - - public void onAlarmClock(Connection paramConnection, Runtime paramRuntime) {} - - public void onAttach(Connection paramConnection, Runtime paramRuntime) { this.mSignalUtil = SimSignalUtil.getInstance((paramRuntime.getContextProxy()).context); } - - public void onDetach(Connection paramConnection, Runtime paramRuntime) {} - - public boolean onUserRequest(Intent paramIntent, Connection paramConnection, final Runtime runtime) { - String str = paramIntent.getAction(); - if ("com.enqualcomm.support.ACTION_REMOTE_CAMERA".equals(str)) { - this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); - str = paramIntent.getStringExtra("filepath"); - String str1 = paramIntent.getStringExtra("number"); - if (str != null) { - if (str1 == null) - return true; - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("filepath == "); - stringBuilder.append(str); - stringBuilder.append("number == "); - stringBuilder.append(str1); - ICLogger.i(stringBuilder.toString()); + } + + public void onAlarmClock(Connection paramConnection, Runtime paramRuntime) { + } + + public void onAttach(Connection paramConnection, Runtime paramRuntime) { + this.mSignalUtil = SimSignalUtil.getInstance((paramRuntime.getContextProxy()).context); + } + + public void onDetach(Connection paramConnection, Runtime paramRuntime) { + } + + public boolean onUserRequest(Intent paramIntent, Connection paramConnection, final Runtime runtime) { + String action = paramIntent.getAction(); + ICLogger.d("str == > action ===> " + action); + if ("com.enqualcomm.support.ACTION_REMOTE_CAMERA".equals(action)) { + this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); + action = paramIntent.getStringExtra("filepath"); + String str1 = paramIntent.getStringExtra("number"); + if (action != null) { + if (str1 == null) + return true; + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append("filepath == "); + stringBuilder.append(action); + stringBuilder.append("number == "); + stringBuilder.append(str1); + ICLogger.i(stringBuilder.toString()); // final PictureContent pictureContent = PictureContent.placeHolderOut(1, str1, str); // final Uri uri = runtime.getDbHelper().insertOrUpdate(pictureContent, 0L); // Observable.create(new SendFileMessage(API.H30(paramRuntime, str1, "2", new File(str)), paramRuntime)).subscribeOn(Schedulers.io()).subscribe(new Subscriber() { @@ -105,58 +108,56 @@ public class SendChatMessage extends AbstractInvokeHandlerService { // runtime.getDbHelper().updateMessage(pictureContent, uri); // } // }); - } else { - return true; - } - } else if (!"SYNC".equals(str) && "com.enqualcomm.imessage.ACTION_ADDTEST_CONTACTS".equals(str)) { - ICLogger.i("添加测试人员名单"); - } - return false; - } - - public boolean onUserRequest(Message paramMessage, Connection paramConnection, final Runtime runtime) { - - ICLogger.i("=============received Message What="+paramMessage.what); - int i = 1; - switch (paramMessage.what) { - default: + } else { + return true; + } + } else if (!"SYNC".equals(action) && "com.enqualcomm.imessage.ACTION_ADDTEST_CONTACTS".equals(action)) { + ICLogger.i("添加测试人员名单"); + } return false; - case 1001: - this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); - this.mNetworkType = this.mSignalUtil.getNetworkType(); - Bundle bundle = paramMessage.getData(); - String filepath = bundle.getString("filepath"); - String number = bundle.getString("number"); - int category = bundle.getInt("category", -1); - ICLogger.i(" msg.what 101 category="+category+", filepath="+filepath+",number="+number); - - - if (filepath == null || number == null || category == -1) - return true; - - //创建voiceConent并添加到数据 - final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, number, filepath,1,3); - final Uri uri2 = runtime.getDbHelper().insertOrUpdate(voiceContent, bundle.getLong("id")); - - //回复UI消息,表示已经接收到 - Messenger messenger = paramMessage.replyTo; - callback(messenger, 200); - voiceContent.status = 3; - voiceContent.serverTime = TimeUtil.getSystemTime3(); -// voiceContent.content = Util.cutFile(voiceContent.content, runtime.getCacheDir()); - voiceContent.preview = String.valueOf(Util.getDuration(voiceContent.content)); - runtime.getDbHelper().updateMessage(voiceContent, uri2); + } + public boolean onUserRequest(Message paramMessage, Connection paramConnection, final Runtime runtime) { + ICLogger.i("=============received Message What=" + paramMessage.what); + switch (paramMessage.what) { + default: + return false; + case 1001: + this.mSignalUtil = SimSignalUtil.getInstance((runtime.getContextProxy()).context); + this.mNetworkType = this.mSignalUtil.getNetworkType(); + Bundle bundle = paramMessage.getData(); + String filepath = bundle.getString("filepath"); + String number = bundle.getString("number"); + int category = bundle.getInt("category", -1); + ICLogger.i(" msg.what 101 category=" + category + ", filepath=" + filepath + ",number=" + number); - // 把voiceContent拆解成1024的分包 - Util.parseToVoicePacketSent(voiceContent); - //trigger 分包发送 - paramConnection.DeliverCMDMessageToSystem("SentVoicePacket", ""); - case 1000: - break; - } + if (filepath == null || number == null || category == -1) + return true; + + //创建voiceConent并添加到数据 + final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, number, filepath, 1, 3); + final Uri uri2 = runtime.getDbHelper().insertOrUpdate(voiceContent, bundle.getLong("id")); + + //回复UI消息,表示已经接收到 + Messenger messenger = paramMessage.replyTo; + callback(messenger, 200); + voiceContent.status = 3; + voiceContent.serverTime = TimeUtil.getSystemTime3(); +// voiceContent.content = Util.cutFile(voiceContent.content, runtime.getCacheDir()); + voiceContent.preview = String.valueOf(Util.getDuration(voiceContent.content)); + runtime.getDbHelper().updateMessage(voiceContent, uri2); + + + // 把voiceContent拆解成1024的分包 + Util.parseToVoicePacketSent(voiceContent); + //trigger 分包发送 + paramConnection.DeliverCMDMessageToSystem("SentVoicePacket", ""); + + case 1000: + break; + } // Bundle bundle1 = paramMessage.getData(); // i = bundle1.getInt("category"); // Observable.create(new GetVoice(String.valueOf(i), bundle1.getString("number"), bundle1.getString("filepath"), String.valueOf(i), paramRuntime)).subscribeOn(Schedulers.io()).subscribe(new Subscriber() { @@ -174,7 +175,7 @@ public class SendChatMessage extends AbstractInvokeHandlerService { // runtime.getDbHelper().updateMessage(param1VoiceContent, this.uri); // } // }); - return true; - } + return true; + } }