250304:图片转化去除jar包,放入代码内
authorxiewei <892331662@qq.com>
Tue, 4 Mar 2025 02:58:41 +0000 (10:58 +0800)
committerxiewei <892331662@qq.com>
Tue, 4 Mar 2025 02:58:41 +0000 (10:58 +0800)
18 files changed:
app/src/main/java/com/zhixun/android/sdk/polymerizesdk/MainActivity.java
polysdk/build.gradle
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/ai/VoiceChatManager.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/authentication/AuthReceiverHandler.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/callback/IPicDecompressCallback.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/CompressParam.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/DecompressRet.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/ErrorNo.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/PicZipApi.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/PicZipEventCallback.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/BuildConfig.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/CrashHandler.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/FileLogger.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/NativeLib.java [new file with mode: 0644]
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/data/PolyAiKit.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/data/PolyApiKit.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/util/AudioConvertManage.java
polysdk/src/main/java/com/zhixun/android/sdk/polysdk/util/PicManager.java

index 8ba5809..058ef0d 100644 (file)
@@ -42,7 +42,7 @@ public class MainActivity extends AppCompatActivity {
             Log.d(TAG, "No ble permission");
         }
 
-        VoiceChatManager.getInstance().start();
+        VoiceChatManager.getInstance().start("pcm",16000);
         String cannel = PolymerizeAgent.getInstance().getAiAPI().getAIChannel();
         Log.i(TAG,"cannel--"+cannel);
         /*PolymerizeAgent.getInstance().getAiAPI().checkGPTKey("sk-proj-fdifVB2nPBIVcQeegE0AT3BlbkFJsgOXO5mnrmzox8pnSxMV", new IOnKeyCheckCallback() {
index a39869a..a4790d9 100644 (file)
@@ -79,7 +79,7 @@ def getTime() {
 }
 
 dependencies {
-    implementation fileTree(dir: 'libs', include: ['compresslib.jar'])
+//    implementation fileTree(dir: 'libs', include: ['compresslib.jar'])
     implementation 'androidx.appcompat:appcompat:1.6.1'
     implementation 'com.google.android.material:material:1.8.0'
     /*implementation files('libs\\Java-WebSocket-1.5.1.jar')
index 7602bd9..618b5e1 100644 (file)
@@ -27,6 +27,7 @@ import org.json.JSONObject;
 import java.net.URI;
 import java.nio.ByteBuffer;
 import java.util.HashMap;
+import java.util.Map;
 
 public class VoiceChatManager {
 
@@ -82,14 +83,33 @@ public class VoiceChatManager {
     private String dialog_id = "";
     private String dialogState = "";
     private boolean isStart = false;
+    private Map<String,String> channelMap = new HashMap<>();
     public void init() {
         SobLog.d(TAG, "-----VoiceChatManager---init--");
+        channelMap.put("aliyun","qianwen");
+        channelMap.put("huoshan","doubao");
+        channelMap.put("baidu","wenxin");
+        channelMap.put("moonshot","kimi");
+        channelMap.put("deepseek","Deepseek");
+        channelMap.put("xunfei","Xinghuo");
         connectChat();
     }
 
     /********************* chat部分 ***********************/
     private void connectChat() {
-        String url = MyConfig.URL_VOICE_CHAT+"?is_auth=0"+"&dt="+MyConfig.TOKEN+"&platform=raisound";
+        String channel = SpUtils.getInstance().getStringValue(SpUtils.KEY_CHANNEL);
+        if (channel.equals(MyConfig.CHANNLE_CHAT)) {
+            if (channelChangeCallback != null) {
+                channelChangeCallback.onChange(true, channel);
+            }
+            isReConnect = false;
+            return;
+        }
+        String param = "";
+        if(channelMap.containsKey(channel)){
+            param = "&bot_type="+channelMap.get(channel);
+        }
+        String url = MyConfig.URL_VOICE_CHAT+"?is_auth=0"+"&dt="+MyConfig.TOKEN+"&platform=raisound"+param;
         URI chatRri = URI.create(url);
         handler.removeMessages(MSG_RECONNECT);
         SobLog.d(TAG, "url--" + url);
@@ -170,6 +190,12 @@ public class VoiceChatManager {
             public void onOpen(ServerHandshake handShakeData) {
                 super.onOpen(handShakeData);
                 SobLog.d(TAG, "onOpen: voicechatClient");
+                if (isReConnect) {
+                    if (channelChangeCallback != null) {
+                        channelChangeCallback.onChange(true, channel);
+                    }
+                }
+                isReConnect = false;
                 isCancle = false;
                 handler.sendEmptyMessageDelayed(MSG_SENDPING,5000);
                 start("pcm",16000);
@@ -180,13 +206,30 @@ public class VoiceChatManager {
             public void onClose(int code, String reason, boolean remote) {
                 super.onClose(code, reason, remote);
                 SobLog.d(TAG, "onClose:voicechatClient-"+code+"-reason-"+reason);
-                if(!isCancle){
+                /*if(!isCancle){
                     isStart = false;
                     dialog_id = "";
                     handler.removeMessages(MSG_RECONNECT);
                     handler.sendEmptyMessageDelayed(MSG_RECONNECT,2000);
+                }*/
+                if (!ischeckoutChannel) {
+                    handler.removeMessages(MSG_RECONNECT);
+                    handler.sendEmptyMessageDelayed(MSG_RECONNECT, 1500);
+                    if (isReConnect) {
+                        if (channelChangeCallback != null) {
+                            channelChangeCallback.onChange(false, channel);
+                        }
+                        isReConnect = false;
+                    }
+                } else {
+                    ischeckoutChannel = false;
+                    isReConnect = true;
+                    handler.removeMessages(MSG_RECONNECT);
+                    connectChat();
+                    if ( iVoiceChatCallback!= null) {
+                        iVoiceChatCallback.OnRespond(true, "");
+                    }
                 }
-
             }
 
             @Override
@@ -334,12 +377,9 @@ public class VoiceChatManager {
             handler.removeMessages(MSG_RECONNECT);
             connectChat();
         }
-//        if (onChatMsgListener != null) {
-//            if (chatType.equals("start") || chatType.equals("middle")) {
-//                chatType = "end";
-//                onChatMsgListener.onChange(chatType, "");
-//            }
-//        }
+        if ( iVoiceChatCallback!= null) {
+            iVoiceChatCallback.OnRespond(true, "");
+        }
 
     }
 
index 72ca206..ddec1c0 100644 (file)
@@ -327,7 +327,7 @@ public class AuthReceiverHandler {
 
                                 MyConfig.TOKEN = id;
                                 MyConfig.DEVICE_ID = deviceId;
-                                ChatManager.getInstance().init();
+//                                ChatManager.getInstance().init();
                                 VoiceChatManager.getInstance().init();
                                 TranscriptionManager.getInstance().init();
 //                                TTsManager.getInstance().init();
index fbc10a6..606b6dc 100644 (file)
@@ -2,7 +2,6 @@ package com.zhixun.android.sdk.polysdk.callback;
 
 import android.graphics.Bitmap;
 
-import com.compress.api.DecompressRet;
 import com.zhixun.android.sdk.polysdk.entity.PolyDecompressRet;
 
 public interface IPicDecompressCallback {
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/CompressParam.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/CompressParam.java
new file mode 100644 (file)
index 0000000..519ae62
--- /dev/null
@@ -0,0 +1,124 @@
+package com.zhixun.android.sdk.polysdk.compress.api;
+
+public class CompressParam {
+    private int id;
+    private int width;
+    private int height;
+    private int stride;
+    private int pixelFormat;
+    private int tileWidth;
+    private int modeAlpha;
+    private int modeRgb;
+    private int cmpMode;
+    private byte[] redChannel;
+    private byte[] greenChannel;
+    private byte[] blueChannel;
+    private byte[] alphaChannel;
+
+    public CompressParam() {
+    }
+
+    public int getId() {
+        return this.id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public int getCmpMode() {
+        return this.cmpMode;
+    }
+
+    public void setCmpMode(int cmpMode) {
+        this.cmpMode = cmpMode;
+    }
+
+    public int getWidth() {
+        return this.width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getHeight() {
+        return this.height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    public int getStride() {
+        return this.stride;
+    }
+
+    public void setStride(int stride) {
+        this.stride = stride;
+    }
+
+    public int getPixelFormat() {
+        return this.pixelFormat;
+    }
+
+    public void setPixelFormat(int pixelFormat) {
+        this.pixelFormat = pixelFormat;
+    }
+
+    public int getTileWidth() {
+        return this.tileWidth;
+    }
+
+    public void setTileWidth(int tileWidth) {
+        this.tileWidth = tileWidth;
+    }
+
+    public int getModeAlpha() {
+        return this.modeAlpha;
+    }
+
+    public void setModeAlpha(int modeAlpha) {
+        this.modeAlpha = modeAlpha;
+    }
+
+    public int getModeRgb() {
+        return this.modeRgb;
+    }
+
+    public void setModeRgb(int modeRgb) {
+        this.modeRgb = modeRgb;
+    }
+
+    public byte[] getRedChannel() {
+        return this.redChannel;
+    }
+
+    public void setRedChannel(byte[] redChannel) {
+        this.redChannel = redChannel;
+    }
+
+    public byte[] getGreenChannel() {
+        return this.greenChannel;
+    }
+
+    public void setGreenChannel(byte[] greenChannel) {
+        this.greenChannel = greenChannel;
+    }
+
+    public byte[] getBlueChannel() {
+        return this.blueChannel;
+    }
+
+    public void setBlueChannel(byte[] blueChannel) {
+        this.blueChannel = blueChannel;
+    }
+
+    public byte[] getAlphaChannel() {
+        return this.alphaChannel;
+    }
+
+    public void setAlphaChannel(byte[] alphaChannel) {
+        this.alphaChannel = alphaChannel;
+    }
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/DecompressRet.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/DecompressRet.java
new file mode 100644 (file)
index 0000000..cc12049
--- /dev/null
@@ -0,0 +1,70 @@
+package com.zhixun.android.sdk.polysdk.compress.api;
+
+public class DecompressRet {
+    private int width;
+    private int height;
+    private int format;
+    private byte[] redChannel;
+    private byte[] greenChannel;
+    private byte[] blueChannel;
+    private byte[] alphaChannel;
+
+    public DecompressRet() {
+    }
+
+    public byte[] getRedChannel() {
+        return this.redChannel;
+    }
+
+    public void setRedChannel(byte[] redChannel) {
+        this.redChannel = redChannel;
+    }
+
+    public byte[] getGreenChannel() {
+        return this.greenChannel;
+    }
+
+    public void setGreenChannel(byte[] greenChannel) {
+        this.greenChannel = greenChannel;
+    }
+
+    public byte[] getBlueChannel() {
+        return this.blueChannel;
+    }
+
+    public void setBlueChannel(byte[] blueChannel) {
+        this.blueChannel = blueChannel;
+    }
+
+    public byte[] getAlphaChannel() {
+        return this.alphaChannel;
+    }
+
+    public void setAlphaChannel(byte[] alphaChannel) {
+        this.alphaChannel = alphaChannel;
+    }
+
+    public int getWidth() {
+        return this.width;
+    }
+
+    public void setWidth(int width) {
+        this.width = width;
+    }
+
+    public int getHeight() {
+        return this.height;
+    }
+
+    public void setHeight(int height) {
+        this.height = height;
+    }
+
+    public int getFormat() {
+        return this.format;
+    }
+
+    public void setFormat(int format) {
+        this.format = format;
+    }
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/ErrorNo.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/ErrorNo.java
new file mode 100644 (file)
index 0000000..1fe9652
--- /dev/null
@@ -0,0 +1,7 @@
+package com.zhixun.android.sdk.polysdk.compress.api;
+
+public interface ErrorNo {
+    int LIB_UNINITIALIZED = 4097;
+    int COMPRESS_PARAM_INVALID = 4098;
+    int DECOMPRESS_PARAM_INVALID = 4099;
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/PicZipApi.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/PicZipApi.java
new file mode 100644 (file)
index 0000000..60a827b
--- /dev/null
@@ -0,0 +1,66 @@
+package com.zhixun.android.sdk.polysdk.compress.api;
+
+
+import com.zhixun.android.sdk.polysdk.compress.nativelib.NativeLib;
+
+public class PicZipApi {
+    private static PicZipApi instance;
+    private PicZipEventCallback callback;
+    private NativeLib nativeLib;
+
+    public static PicZipApi getInstance() {
+        if (instance == null) {
+            instance = new PicZipApi();
+        }
+
+        return instance;
+    }
+
+    private PicZipApi() {
+    }
+
+    public void setCallback(PicZipEventCallback callback) {
+        this.callback = callback;
+        if (this.nativeLib != null) {
+            this.nativeLib.setCallback(callback);
+        }
+
+    }
+
+    public void init() {
+        this.nativeLib = new NativeLib();
+        System.loadLibrary("nativelib");
+    }
+
+    public void compress(CompressParam param) {
+        if (this.nativeLib == null) {
+            if (this.callback != null) {
+                this.callback.compressRets(param.getId(), 4097, param.getTileWidth(), (byte[])null);
+            }
+
+        } else if (param == null) {
+            if (this.callback != null) {
+                this.callback.compressRets(-1, 4098, -1, (byte[])null);
+            }
+
+        } else {
+            this.nativeLib.CompressInJNI(param);
+        }
+    }
+
+    public void decompress(int id, byte[] fileBuffer) {
+        if (this.nativeLib == null) {
+            if (this.callback != null) {
+                this.callback.deCompressRets(id, 4097, (DecompressRet)null);
+            }
+
+        } else if (fileBuffer == null) {
+            if (this.callback != null) {
+                this.callback.deCompressRets(id, 4099, (DecompressRet)null);
+            }
+
+        } else {
+            this.nativeLib.DecompressInJNI(id, fileBuffer);
+        }
+    }
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/PicZipEventCallback.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/api/PicZipEventCallback.java
new file mode 100644 (file)
index 0000000..18eedcb
--- /dev/null
@@ -0,0 +1,9 @@
+package com.zhixun.android.sdk.polysdk.compress.api;
+
+import com.zhixun.android.sdk.polysdk.compress.api.DecompressRet;
+
+public interface PicZipEventCallback {
+    void compressRets(int var1, int var2, int var3, byte[] var4);
+
+    void deCompressRets(int var1, int var2, DecompressRet var3);
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/BuildConfig.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/BuildConfig.java
new file mode 100644 (file)
index 0000000..777c4fd
--- /dev/null
@@ -0,0 +1,10 @@
+package com.zhixun.android.sdk.polysdk.compress.nativelib;
+
+public final class BuildConfig {
+    public static final boolean DEBUG = false;
+    public static final String LIBRARY_PACKAGE_NAME = "com.compress.nativelib";
+    public static final String BUILD_TYPE = "release";
+
+    public BuildConfig() {
+    }
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/CrashHandler.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/CrashHandler.java
new file mode 100644 (file)
index 0000000..6ff6c05
--- /dev/null
@@ -0,0 +1,92 @@
+package com.zhixun.android.sdk.polysdk.compress.nativelib;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.os.Build;
+import android.os.Environment;
+import android.os.Process;
+import android.util.Log;
+
+
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+class CrashHandler implements Thread.UncaughtExceptionHandler {
+    private static final String TAG = "CrashHandler";
+    private static final boolean DEBUG = true;
+    private static final String PATH = Environment.getExternalStorageDirectory().getPath() + "/ryg_test/log/";
+    private static final String FILE_NAME = "crash";
+    private static final String FILE_NAME_SUFFIX = ".trace";
+    private static CrashHandler sInstance = new CrashHandler();
+    private Thread.UncaughtExceptionHandler mDefaultCrashHandler;
+    private Context mContext;
+
+    private CrashHandler() {
+    }
+
+    public static CrashHandler getInstance() {
+        return sInstance;
+    }
+
+    public void init(Context context) {
+        this.mDefaultCrashHandler = Thread.getDefaultUncaughtExceptionHandler();
+        Thread.setDefaultUncaughtExceptionHandler(this);
+        this.mContext = context.getApplicationContext();
+        FileLogger.write("PATH = " + PATH);
+    }
+
+    public void uncaughtException(Thread thread, Throwable throwable) {
+        FileLogger.write("uncaughtException");
+
+        try {
+            this.dumpExceptionToSDCard(throwable);
+        } catch (IOException var4) {
+            var4.printStackTrace();
+            FileLogger.write("uncaughtException" + var4.getMessage());
+        }
+
+        throwable.printStackTrace();
+        if (this.mDefaultCrashHandler != null) {
+            this.mDefaultCrashHandler.uncaughtException(thread, throwable);
+        } else {
+            Process.killProcess(Process.myPid());
+        }
+
+    }
+
+    private void dumpExceptionToSDCard(Throwable throwable) throws IOException {
+        try {
+            PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(FileLogger.getLogFile2())));
+            this.dumpPhoneInfo(pw);
+            pw.println();
+            throwable.printStackTrace(pw);
+            pw.close();
+        } catch (Exception var3) {
+            Log.e("CrashHandler", "dump crash info failed");
+        }
+
+    }
+
+    private void dumpPhoneInfo(PrintWriter pw) throws PackageManager.NameNotFoundException {
+        PackageManager pm = this.mContext.getPackageManager();
+        PackageInfo pi = pm.getPackageInfo(this.mContext.getPackageName(), 1);
+        pw.print("App Version: ");
+        pw.print(pi.versionName);
+        pw.print('_');
+        pw.println(pi.versionCode);
+        pw.print("OS Version: ");
+        pw.print(Build.VERSION.RELEASE);
+        pw.print("_");
+        pw.println(Build.VERSION.SDK_INT);
+        pw.print("Vendor: ");
+        pw.println(Build.MANUFACTURER);
+        pw.print("Model: ");
+        pw.println(Build.MODEL);
+        pw.print("CPU ABI: ");
+        pw.println(Build.CPU_ABI);
+    }
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/FileLogger.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/FileLogger.java
new file mode 100644 (file)
index 0000000..b52880b
--- /dev/null
@@ -0,0 +1,245 @@
+package com.zhixun.android.sdk.polysdk.compress.nativelib;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.os.Environment;
+import android.text.format.Formatter;
+import android.util.Log;
+
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class FileLogger {
+    private static Context mContext;
+    private static FileLogger instance;
+    private static File logFile;
+    private static SimpleDateFormat logSDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
+    private static final int LOG_MAX_SIZE = 10485760;
+    private static String tag;
+    private static final String MY_TAG = "LogToFileUtils";
+
+    public FileLogger() {
+    }
+
+    public static void init(Context context) {
+        Log.i("LogToFileUtils", "init ...");
+        if (null != mContext && null != instance && null != logFile && logFile.exists()) {
+            Log.i("LogToFileUtils", "LogToFileUtils has been init ...");
+        } else {
+            mContext = context;
+            instance = new FileLogger();
+            logFile = getLogFile();
+            Log.i("LogToFileUtils", "LogFilePath is: " + logFile.getPath());
+            long logFileSize = getFileSize(logFile);
+            Log.d("LogToFileUtils", "Log max size is: " + Formatter.formatFileSize(context, 10485760L));
+            Log.i("LogToFileUtils", "log now size is: " + Formatter.formatFileSize(context, logFileSize));
+            CrashHandler.getInstance().init(context);
+            if (10485760L < logFileSize) {
+                resetLogFile();
+            }
+        }
+
+    }
+
+    public static void write(Object str) {
+        if (null != mContext && null != instance && null != logFile && logFile.exists()) {
+            String logStr = getFunctionInfo() + " - " + str.toString();
+            Log.i(tag, logStr);
+
+            try {
+                BufferedWriter bw = new BufferedWriter(new FileWriter(logFile, true));
+                bw.write(logStr);
+                bw.write("\r\n");
+                bw.flush();
+            } catch (Exception var3) {
+                Log.e(tag, "Write failure !!! " + var3.toString());
+            }
+
+        } else {
+            Log.e("LogToFileUtils", "Initialization failure !!!");
+        }
+    }
+
+    private static void resetLogFile() {
+        Log.i("LogToFileUtils", "Reset Log File ... ");
+        File lastLogFile = new File(logFile.getParent() + "/lastLog.txt");
+        if (lastLogFile.exists()) {
+            lastLogFile.delete();
+        }
+
+        logFile.renameTo(lastLogFile);
+
+        try {
+            logFile.createNewFile();
+        } catch (Exception var2) {
+            Log.e("LogToFileUtils", "Create log file failure !!! " + var2.toString());
+        }
+
+    }
+
+    private static long getFileSize(File file) {
+        long size = 0L;
+        if (file.exists()) {
+            try {
+                FileInputStream fis = new FileInputStream(file);
+                size = (long)fis.available();
+            } catch (Exception var4) {
+                Log.e("LogToFileUtils", var4.toString());
+            }
+        }
+
+        return size;
+    }
+
+    public static File getLogFile2() {
+        File file;
+        if (Environment.getExternalStorageState().equals("mounted")) {
+            file = new File(mContext.getExternalFilesDir("Log").getPath() + "/");
+        } else {
+            file = new File(mContext.getFilesDir().getPath() + "/Log/");
+        }
+
+        if (!file.exists()) {
+            file.mkdir();
+        }
+
+        File logFile = new File(file.getPath() + "/logs2.txt");
+        if (!logFile.exists()) {
+            try {
+                logFile.createNewFile();
+            } catch (Exception var3) {
+                Log.e("LogToFileUtils", "Create log file failure !!! " + var3.toString());
+            }
+        }
+
+        return logFile;
+    }
+
+    public static File writeBuffer(String name, byte[] content, int offset, int length) {
+        File bufferFile = getBufferFile(name);
+
+        try {
+            FileOutputStream fos = new FileOutputStream(bufferFile);
+            fos.write(content, 0, length);
+        } catch (IOException var6) {
+            var6.printStackTrace();
+        }
+
+        return bufferFile;
+    }
+
+    public static void saveBitmap(Bitmap bitmapDe) {
+        File bufferFile = getBufferFile("DecompressedFile");
+        BufferedOutputStream bos = null;
+
+        try {
+            bos = new BufferedOutputStream(new FileOutputStream(bufferFile));
+            bitmapDe.compress(Bitmap.CompressFormat.PNG, 100, bos);
+            bos.flush();
+            bos.close();
+        } catch (IOException var4) {
+            var4.printStackTrace();
+        }
+
+    }
+
+    public static File getBitmapFile(String name) {
+        File file;
+        if (Environment.getExternalStorageState().equals("mounted")) {
+            file = new File(mContext.getExternalFilesDir("Log").getPath() + "/");
+        } else {
+            file = new File(mContext.getFilesDir().getPath() + "/Log/");
+        }
+
+        if (!file.exists()) {
+            file.mkdir();
+        }
+
+        File bitmapFile = new File(file.getPath() + "/" + name + ".png");
+        if (!bitmapFile.exists()) {
+            try {
+                bitmapFile.createNewFile();
+            } catch (Exception var4) {
+                Log.e("LogToFileUtils", "Create log file failure !!! " + var4.toString());
+            }
+        }
+
+        return bitmapFile;
+    }
+
+    public static File getBufferFile(String name) {
+        File file;
+        if (Environment.getExternalStorageState().equals("mounted")) {
+            file = new File(mContext.getExternalFilesDir("Log").getPath() + "/");
+        } else {
+            file = new File(mContext.getFilesDir().getPath() + "/Log/");
+        }
+
+        if (!file.exists()) {
+            file.mkdir();
+        }
+
+        File logFile = new File(file.getPath() + "/" + name + ".bin");
+        if (!logFile.exists()) {
+            try {
+                logFile.createNewFile();
+            } catch (Exception var4) {
+                Log.e("LogToFileUtils", "Create log file failure !!! " + var4.toString());
+            }
+        }
+
+        return logFile;
+    }
+
+    public static File getLogFile() {
+        File file;
+        if (Environment.getExternalStorageState().equals("mounted")) {
+            file = new File(mContext.getExternalFilesDir("Log").getPath() + "/");
+        } else {
+            file = new File(mContext.getFilesDir().getPath() + "/Log/");
+        }
+
+        if (!file.exists()) {
+            file.mkdir();
+        }
+
+        File logFile = new File(file.getPath() + "/logs.txt");
+        if (!logFile.exists()) {
+            try {
+                logFile.createNewFile();
+            } catch (Exception var3) {
+                Log.e("LogToFileUtils", "Create log file failure !!! " + var3.toString());
+            }
+        }
+
+        return logFile;
+    }
+
+    private static String getFunctionInfo() {
+        StackTraceElement[] sts = Thread.currentThread().getStackTrace();
+        if (sts == null) {
+            return null;
+        } else {
+            StackTraceElement[] var1 = sts;
+            int var2 = sts.length;
+
+            for(int var3 = 0; var3 < var2; ++var3) {
+                StackTraceElement st = var1[var3];
+                if (!st.isNativeMethod() && !st.getClassName().equals(Thread.class.getName()) && !st.getClassName().equals(instance.getClass().getName())) {
+                    tag = st.getFileName();
+                    return "[" + logSDF.format(new Date()) + " " + st.getClassName() + " " + st.getMethodName() + " Line:" + st.getLineNumber() + "]";
+                }
+            }
+
+            return null;
+        }
+    }
+}
diff --git a/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/NativeLib.java b/polysdk/src/main/java/com/zhixun/android/sdk/polysdk/compress/nativelib/NativeLib.java
new file mode 100644 (file)
index 0000000..edfe203
--- /dev/null
@@ -0,0 +1,69 @@
+package com.zhixun.android.sdk.polysdk.compress.nativelib;
+
+import android.util.Log;
+
+
+import com.zhixun.android.sdk.polysdk.compress.api.CompressParam;
+import com.zhixun.android.sdk.polysdk.compress.api.DecompressRet;
+import com.zhixun.android.sdk.polysdk.compress.api.PicZipEventCallback;
+
+import java.util.Locale;
+
+public class NativeLib {
+    private static final String TAG = "NativeLib";
+    private PicZipEventCallback callback;
+
+    public NativeLib() {
+    }
+
+    public void setCallback(PicZipEventCallback callback) {
+        this.callback = callback;
+    }
+
+    public native boolean CompressInJNI(CompressParam var1);
+
+    public native void DecompressInJNI(int var1, byte[] var2);
+
+    public void compressRetsFromJNI(int id, int state, int tileWidth, byte[] data) {
+        if (this.callback != null) {
+            this.callback.compressRets(id, state, tileWidth, data);
+        }
+
+    }
+
+    public void decompressRetsFromJNI(int id, int state, int width, int height, int format,
+                                      byte[] red, byte[] green, byte[] blue, byte[] alpha) {
+        if (this.callback != null) {
+            DecompressRet ret = new DecompressRet();
+            ret.setWidth(width);
+            ret.setHeight(height);
+            ret.setFormat(format);
+            ret.setRedChannel(red);
+            ret.setGreenChannel(green);
+            ret.setBlueChannel(blue);
+            ret.setAlphaChannel(alpha);
+            Log.i("NativeLib", "decompressRetsFromJNI: format = " + format);
+            this.callback.deCompressRets(id, state, ret);
+        }
+
+    }
+
+    private static void printHexStr(byte[] b) {
+        StringBuilder sb = new StringBuilder("");
+
+        for(int n = 0; n < b.length; ++n) {
+            String stmp = Integer.toHexString(b[n] & 255);
+            sb.append(stmp.length() == 1 ? "0" + stmp : stmp);
+            if (n < b.length - 1) {
+                char isHX = (char) (n % 16 == 15 ? 10 : 32);
+                sb.append((char)isHX);
+                if (isHX == 10) {
+                    FileLogger.write(sb.toString().toUpperCase(Locale.getDefault()));
+                    sb = new StringBuilder("");
+                }
+            }
+        }
+
+        FileLogger.write(sb.toString().toUpperCase(Locale.getDefault()));
+    }
+}
index aa28913..b6900ff 100644 (file)
@@ -516,7 +516,7 @@ public class PolyAiKit implements IPolyAiAPI {
             iAudioConvertListener.onError(NOTLOGIN_TIP);
             return;
         }
-        AudioConvertManage.getInstance().convertAudioMsbcToPcm(inData,rate,track,iAudioConvertListener);
+        AudioConvertManage.getInstance().convertAudioFMsbcToPcm(inData,rate,track,iAudioConvertListener);
     }
 
     @Override
index 7b5bbc2..0dcc5d9 100644 (file)
@@ -7,6 +7,7 @@ import com.google.gson.Gson;
 import com.zhixun.android.sdk.polysdk.ai.ChatManager;
 import com.zhixun.android.sdk.polysdk.ai.TTsManager;
 import com.zhixun.android.sdk.polysdk.ai.TranscriptionManager;
+import com.zhixun.android.sdk.polysdk.ai.VoiceChatManager;
 import com.zhixun.android.sdk.polysdk.authentication.AuthMsgSendHandler;
 import com.zhixun.android.sdk.polysdk.authentication.AuthReceiverHandler;
 import com.zhixun.android.sdk.polysdk.callback.AuthCallback;
@@ -74,7 +75,7 @@ public class PolyApiKit implements IPolyAPI, IBtReceiverCallback {
         }
         SpUtils.getInstance().saveValue(SpUtils.KEY_CHANNEL,channel);
         SpUtils.getInstance().saveValue(SpUtils.KEY_CHANNEL_KEY,key);
-        ChatManager.getInstance().checkoutChannel(channelChangeCallback);
+        VoiceChatManager.getInstance().checkoutChannel(channelChangeCallback);
         TranscriptionManager.getInstance().connectTran(false);
 //        TTsManager.getInstance().init();
     }
@@ -84,7 +85,7 @@ public class PolyApiKit implements IPolyAPI, IBtReceiverCallback {
     @Override
     public void release() {
         AuthMsgSendHandler.getInstance().clear();
-        ChatManager.getInstance().close();
+        VoiceChatManager.getInstance().close();
         AuthReceiverHandler.getInstance().close();
         TranscriptionManager.getInstance().close(false);
 //        TTsManager.getInstance().close();
index 835e915..79a2a35 100644 (file)
@@ -80,7 +80,7 @@ public class AudioConvertManage {
 
     }
 
-    public void convertAudioMsbcToPcm(byte[] inputData, String rate,String track, IAudioConvertListener iAudioConvertListener) {
+    public void convertAudioFMsbcToPcm(byte[] inputData, String rate,String track, IAudioConvertListener iAudioConvertListener) {
         String inPath = SpUtils.getInstance().getSdkPath()+"input_temp.msbc";
         String outPath = SpUtils.getInstance().getSdkPath()+"output_temp.pcm";
         SobLog.d(TAG, "convertAudioMsbcToPcm--");
@@ -92,6 +92,8 @@ public class AudioConvertManage {
         if(outfile.exists()){
             outfile.delete();
         }
+        SobLog.d(TAG, "outPath--"+outPath);
+        SobLog.d(TAG, "inputFile--"+inputFile);
         try {
             FileOutputStream fos = new FileOutputStream(inputFile);
             fos.write(inputData);
@@ -172,6 +174,8 @@ public class AudioConvertManage {
         if(outfile.exists()){
             outfile.delete();
         }
+        SobLog.d(TAG, "outPath--"+outPath);
+        SobLog.d(TAG, "inputFile--"+inputFile);
         try {
             FileOutputStream fos = new FileOutputStream(inputFile);
             fos.write(inputData);
@@ -191,8 +195,8 @@ public class AudioConvertManage {
 
                     if(outfile.exists()){
                         byte[] outData = readFile(outfile);
-                        outfile.delete();
-                        inputFile.delete();
+//                        outfile.delete();
+//                        inputFile.delete();
 
                         int bufferSize = AudioRecord.getMinBufferSize(16000,
                                 AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
index 400b9ab..e444660 100644 (file)
@@ -6,14 +6,14 @@ import android.graphics.Color;
 import android.util.Log;
 import android.widget.Toast;
 
-import com.compress.api.CompressParam;
-import com.compress.api.DecompressRet;
-import com.compress.api.PicZipApi;
-import com.compress.api.PicZipEventCallback;
-import com.compress.nativelib.FileLogger;
 import com.google.gson.Gson;
 import com.zhixun.android.sdk.polysdk.callback.IPicCompressCallback;
 import com.zhixun.android.sdk.polysdk.callback.IPicDecompressCallback;
+import com.zhixun.android.sdk.polysdk.compress.api.CompressParam;
+import com.zhixun.android.sdk.polysdk.compress.api.DecompressRet;
+import com.zhixun.android.sdk.polysdk.compress.api.PicZipApi;
+import com.zhixun.android.sdk.polysdk.compress.api.PicZipEventCallback;
+import com.zhixun.android.sdk.polysdk.compress.nativelib.FileLogger;
 import com.zhixun.android.sdk.polysdk.entity.PolyDecompressRet;
 
 import java.io.File;