release hs_debugtools_1.3 修改代码,取消除了OTA以外的其他代码,方便客户用来专门升级设备
authorSnickerSun <snickersun@163.com>
Sat, 5 Oct 2024 11:28:55 +0000 (19:28 +0800)
committerSnickerSun <snickersun@163.com>
Sat, 5 Oct 2024 11:29:05 +0000 (19:29 +0800)
16 files changed:
app/release/hs_debugtool_1.3_release_2024100519.apk [moved from app/release/Hs-sdk_1.2_release_2024100215.apk with 99% similarity]
app/release/output-metadata.json
app/src/main/AndroidManifest.xml
app/src/main/java/com/zhixun/blesdk/debug_tool/AiLogActivity.java
app/src/main/java/com/zhixun/blesdk/debug_tool/DialTestActivity.java
app/src/main/java/com/zhixun/blesdk/debug_tool/MainActivity.java
app/src/main/java/com/zhixun/blesdk/debug_tool/OtaActivity.java [new file with mode: 0644]
app/src/main/java/com/zhixun/blesdk/debug_tool/TestActivity.java
app/src/main/java/com/zhixun/blesdk/debug_tool/adapter/DeviceAdapter.java
app/src/main/java/com/zhixun/blesdk/debug_tool/utils/FuncationChosePopupWindow.java
app/src/main/res/layout/activity_ai_log.xml
app/src/main/res/layout/activity_dial_test.xml
app/src/main/res/layout/activity_main.xml
app/src/main/res/layout/activity_ota.xml [new file with mode: 0644]
app/src/main/res/layout/activity_test.xml
app/src/main/res/layout/item_device.xml

similarity index 99%
rename from app/release/Hs-sdk_1.2_release_2024100215.apk
rename to app/release/hs_debugtool_1.3_release_2024100519.apk
index 8fb5b89..3788c45 100644 (file)
Binary files a/app/release/Hs-sdk_1.2_release_2024100215.apk and b/app/release/hs_debugtool_1.3_release_2024100519.apk differ
index 0619470..3a78b81 100644 (file)
@@ -4,16 +4,16 @@
     "type": "APK",
     "kind": "Directory"
   },
-  "applicationId": "com.zhixun.blesdk.app",
+  "applicationId": "com.zhixun.blesdk.debug_tool",
   "variantName": "release",
   "elements": [
     {
       "type": "SINGLE",
       "filters": [],
       "attributes": [],
-      "versionCode": 2,
-      "versionName": "1.2",
-      "outputFile": "Hs-sdk_1.2_release_2024100215.apk"
+      "versionCode": 3,
+      "versionName": "1.3",
+      "outputFile": "hs_debugtool_1.3_release_2024100519.apk"
     }
   ],
   "elementType": "File"
index c1347ff..53ab160 100644 (file)
         <activity
             android:name="com.zhixun.blesdk.debug_tool.TestActivity"
             android:exported="false" />
+        <activity
+            android:name="com.zhixun.blesdk.debug_tool.OtaActivity"
+            android:exported="false" >
+        </activity>
         <activity
             android:name="com.zhixun.blesdk.debug_tool.MainActivity"
             android:exported="true">
index f8bcd07..5a7e432 100644 (file)
@@ -7,7 +7,6 @@ import androidx.recyclerview.widget.RecyclerView;
 import android.os.Bundle;
 import android.view.View;
 
-import com.zhixun.blesdk.debug_tool.R;
 import com.zhixun.blesdk.debug_tool.adapter.MsgAdapter;
 import com.zhixun.blesdk.hssdk.data.AiManage;
 
@@ -26,7 +25,7 @@ public class AiLogActivity extends AppCompatActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_ai_log);
-        msg_list = findViewById(R.id.msg_list);
+        msg_list = findViewById(R.id.msg_list_ota);
         LinearLayoutManager layoutManager2 = new LinearLayoutManager(this);
         msg_list.setLayoutManager(layoutManager2);
         msg = new ArrayList<>();
index 01c06c0..17f5c8d 100644 (file)
@@ -17,7 +17,6 @@ import android.widget.Button;
 import android.widget.EditText;
 import android.widget.Toast;
 
-import com.zhixun.blesdk.debug_tool.R;
 import com.zhixun.blesdk.debug_tool.adapter.MsgAdapter;
 import com.zhixun.blesdk.debug_tool.utils.FileHelper;
 import com.zhixun.blesdk.hssdk.HsAgentSdk;
@@ -43,7 +42,7 @@ public class DialTestActivity extends AppCompatActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_dial_test);
-        msg_list = findViewById(R.id.msg_list);
+        msg_list = findViewById(R.id.msg_list_ota);
         LinearLayoutManager layoutManager2 = new LinearLayoutManager(this);
         msg_list.setLayoutManager(layoutManager2);
         btn_dial_chose = findViewById(R.id.btn_dial_chose);
index be296e3..7ab4a27 100644 (file)
@@ -104,9 +104,25 @@ public class MainActivity extends AppCompatActivity {
         deviceAdapter = new DeviceAdapter(bluetoothDevices, this);
         deviceListview.setAdapter(deviceAdapter);
         mainHandler.sendEmptyMessageDelayed(MSG_REQUEST_PERMISSION, 500);
+        deviceListview.setItemsCanFocus(true);
+        deviceListview.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+            @Override
+            public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
+                Log.i(TAG, "onItemSelected-- position = " + position +", id = " +id);
+
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> adapterView) {
+                Log.i(TAG, "onNothingSelected ");
+
+            }
+        });
         deviceListview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+                Log.i(TAG, "onItemClick-- position = " + position +", id = " +id);
+
                 HsAgentSdk.getInstance().getAPI().disconnect();
                 HsAgentSdk.getInstance().getAPI().connect(bluetoothDevices.get(position));
 
@@ -132,9 +148,12 @@ public class MainActivity extends AppCompatActivity {
                 mainHandler.sendMessage(message);
             }
         });
-
+        HsAgentSdk.getInstance().setFileCannel(1);//0走之前的通道流程,1走新的流程
         checkOtaChannel_btn.setText("切换ota通道(目前:"+(HsAgentSdk.getInstance().getFileCannel()==0?"2AE0":"2AE6")+")");
     }
+    public void ota(View view) {
+        startActivity(new Intent(this, OtaActivity.class));
+    }
 
     public void test(View view) {
 //        String str = "7b22706e223a224672616e6be79a846950686f6e65222c227470223a312c226d6163223a205b5d7d";
@@ -147,7 +166,9 @@ public class MainActivity extends AppCompatActivity {
 
     }
 
-
+    public void deviceStopScan(View view){
+        HsAgentSdk.getInstance().getAPI().stopScan();
+    }
     public void deviceScan(View view) {
         //FC:9B:36:E1:74:1E   FC:9B:55:29:33:EA
         //02010A 020A00 0FFF 4A48 08 EA3329559BFC 0504 010110 0E09 4B554D4920553620333345410000000000000000000000000000000000000000000000000000
@@ -266,5 +287,4 @@ public class MainActivity extends AppCompatActivity {
 
     }
 
-
 }
\ No newline at end of file
diff --git a/app/src/main/java/com/zhixun/blesdk/debug_tool/OtaActivity.java b/app/src/main/java/com/zhixun/blesdk/debug_tool/OtaActivity.java
new file mode 100644 (file)
index 0000000..7631f11
--- /dev/null
@@ -0,0 +1,153 @@
+package com.zhixun.blesdk.debug_tool;
+
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
+
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.zhixun.blesdk.debug_tool.adapter.MsgAdapter;
+import com.zhixun.blesdk.debug_tool.utils.FileHelper;
+import com.zhixun.blesdk.debug_tool.utils.FuncationChosePopupWindow;
+import com.zhixun.blesdk.hssdk.HsAgentSdk;
+import com.zhixun.blesdk.hssdk.callback.ISendFileListener;
+import com.zhixun.blesdk.hssdk.entity.OTAInfo;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+
+public class OtaActivity extends AppCompatActivity {
+
+    private String TAG = "TAG_OtaActivity";
+    private RecyclerView msg_list;
+    private MsgAdapter msgAdapter;
+    private ArrayList<String> msg;
+    private Button btn_ota_chose;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_ota);
+        msg_list = findViewById(R.id.msg_list_ota);
+        LinearLayoutManager layoutManager2 = new LinearLayoutManager(this);
+        msg_list.setLayoutManager(layoutManager2);
+        btn_ota_chose = findViewById(R.id.btn_chose_ota);
+        msg = new ArrayList<>();
+        msgAdapter = new MsgAdapter(this,msg);
+        msg_list.setAdapter(msgAdapter);
+        btn_ota_chose.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                pickFile();
+            }
+        });
+    }
+    private int REQUEST_CODE_FILE_PICKER = 1001;
+    // 启动文件选择器
+    private void pickFile() {
+        // 创建一个 Intent 用于打开文件选择器
+        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+        intent.setType("*/*");  // 设置文件类型为任意类型
+//        intent.setType("file/*"); // 设置文件类型,fwpkg
+//        intent.addCategory(Intent.CATEGORY_OPENABLE);
+
+        try {
+            // 启动 Activity 以选择文件
+            startActivityForResult(intent, REQUEST_CODE_FILE_PICKER);
+        } catch (ActivityNotFoundException e) {
+            // 未找到可以处理该 Intent 的 Activity
+            Toast.makeText(this, "无法打开文件选择器", Toast.LENGTH_SHORT).show();
+        }
+    }
+
+    protected void print_msg_to_end_of_view(String msg)
+    {
+        msgAdapter.addData(msg);
+        msg_list.scrollToPosition(msgAdapter.getCount()-1);
+    }
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        // 检查请求码和结果码是否匹配,以及是否有返回的数据
+        if (requestCode == REQUEST_CODE_FILE_PICKER && resultCode == RESULT_OK && data != null) {
+            // 获取选择的文件的 URI
+            Uri uri = data.getData();
+
+            String path = FileHelper.getFileAbsolutePath(this,uri);
+
+            print_msg_to_end_of_view("chosePath-"+path);
+
+            if(!path.endsWith(".fwpkg")){
+                print_msg_to_end_of_view("-文件类型错误-");
+                return;
+            }
+            Log.i(TAG,"chosePath--"+path);
+            startOta(path);
+
+            // 根据需要处理 URI,例如读取文件内容等
+            // 例如,可以使用 ContentResolver 来获取输入流
+            try (InputStream inputStream = getContentResolver().openInputStream(uri)) {
+                // 使用 inputStream 处理文件
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+
+    int oldpro = -1;
+    public void startOta(String filePath){
+        OTAInfo otaInfo = new OTAInfo();
+        File file = new File(filePath);
+        int length = (int) file.length();
+        Log.d("startOTA","length---"+length);//140304  139461
+        otaInfo.setSize(length);
+        otaInfo.setType(1);
+        otaInfo.setMajor(1);
+        otaInfo.setMid(2);
+        otaInfo.setMinor(1);
+        oldpro = -1;
+        HsAgentSdk.getInstance().getAPI().startOTA(filePath,
+                otaInfo, new ISendFileListener() {
+                    @Override
+                    public void onProgressChange(int progress) {
+                        if(oldpro!=progress){
+                            oldpro = progress;
+
+                            OtaActivity.this.runOnUiThread(new Runnable() {
+                                @Override
+                                public void run() {
+                                    print_msg_to_end_of_view("文件发送进度: "+progress);
+                                }
+                            });
+                        }
+                    }
+
+                    @Override
+                    public void onStateChange(int state, String msg) {
+                        OtaActivity.this.runOnUiThread(new Runnable() {
+                            @Override
+                            public void run() {
+                                print_msg_to_end_of_view("文件发送状态: "+msg);
+                            }
+                        });
+                    }
+                });
+    }
+
+    public void back(View view){
+        finish();
+    }
+}
\ No newline at end of file
index dc2ad52..f29faf7 100644 (file)
@@ -14,7 +14,6 @@ import android.view.View;
 import android.widget.Button;
 import android.widget.Toast;
 
-import com.zhixun.blesdk.debug_tool.R;
 import com.zhixun.blesdk.debug_tool.adapter.MsgAdapter;
 import com.zhixun.blesdk.debug_tool.utils.FileHelper;
 import com.zhixun.blesdk.debug_tool.utils.FuncationChosePopupWindow;
@@ -40,7 +39,7 @@ public class TestActivity extends AppCompatActivity {
         LinearLayoutManager layoutManager2 = new LinearLayoutManager(this);
         msg_list.setLayoutManager(layoutManager2);
         btn_funcation_chose = findViewById(R.id.btn_funcation_chose);
-        btn_ota_chose = findViewById(R.id.btn_ota_chose);
+        btn_ota_chose = findViewById(R.id.btn_ota_choose);
         btn_dial_chose = findViewById(R.id.btn_dial_chose);
         msg = new ArrayList<>();
         msgAdapter = new MsgAdapter(this,msg);
index 0b68880..09b1506 100644 (file)
@@ -6,6 +6,7 @@ import android.content.pm.PackageManager;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.BaseAdapter;
+import android.widget.CheckBox;
 import android.widget.TextView;
 
 
@@ -51,7 +52,8 @@ public class DeviceAdapter extends BaseAdapter {
             view = View.inflate(mContext, R.layout.item_device, null);
             holder = new ViewHolder();
             holder.tv_device_name = (TextView) view.findViewById(R.id.tv_device_name);
-
+            holder.tv_device_version = (TextView) view.findViewById(R.id.tv_device_version);
+            holder.tv_device_bat = (TextView) view.findViewById(R.id.tv_device_bat);
             view.setTag(holder);
         } else {
             holder = (ViewHolder) view.getTag();
@@ -59,6 +61,8 @@ public class DeviceAdapter extends BaseAdapter {
 
         HsWearDevice device = list.get(i);
         holder.tv_device_name.setText(device.getName());
+        holder.tv_device_version.setText(device.getVersion());
+        holder.tv_device_bat.setText(String.valueOf(device.getBatty()));
 
         return view;
     }
@@ -70,7 +74,8 @@ public class DeviceAdapter extends BaseAdapter {
 
     class ViewHolder {
         TextView tv_device_name;
-
+        TextView tv_device_version;
+        TextView tv_device_bat;
     }
 }
 
index 6139bf3..1550e12 100644 (file)
@@ -639,8 +639,8 @@ public class FuncationChosePopupWindow extends PopupWindow {
 
                         break;
                     case 57:
-                        String path1 = "/sdcard/Android/data/com.zhixun.blesdk.app/files/hs_sdk/KUMIVIEW.bin";
-                        String path2 = "/sdcard/Android/data/com.zhixun.blesdk.app/files/hs_sdk/MAIN_FACE_IMAGE.bin";
+                        String path1 = "/sdcard/Android/data/com.zhixun.blesdk.debug_tool/files/hs_sdk/KUMIVIEW.bin";
+                        String path2 = "/sdcard/Android/data/com.zhixun.blesdk.debug_tool/files/hs_sdk/MAIN_FACE_IMAGE.bin";
                         ArrayList<String> files = new ArrayList();
                         files.add(path1);
                         files.add(path2);
index d35282b..09213c1 100644 (file)
@@ -16,7 +16,7 @@
 
 
     <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/msg_list"
+        android:id="@+id/msg_list_ota"
         android:layout_width="match_parent"
         android:layout_height="0dp"
         android:layout_weight="1"
index 660e7f1..b3a1190 100644 (file)
@@ -16,7 +16,7 @@
 
 
     <androidx.recyclerview.widget.RecyclerView
-        android:id="@+id/msg_list"
+        android:id="@+id/msg_list_ota"
         android:layout_width="match_parent"
         android:layout_height="0dp"
         android:layout_weight="1"
index 7bad264..7250a5e 100644 (file)
@@ -6,6 +6,7 @@
     android:layout_height="match_parent"
     tools:context="com.zhixun.blesdk.debug_tool.MainActivity"
     android:orientation="vertical"
+    android:descendantFocusability="blocksDescendants"
     android:background="#F6F6F6">
 
 
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:orientation="horizontal">
+
         <Button
+            android:id="@+id/button_scan"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
             android:onClick="deviceScan"
+            android:text="设备扫描" />
+
+        <Button
+            android:id="@+id/button_stop_scan"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="设备扫描"/>
+            android:onClick="deviceStopScan"
+            android:text="停止扫描" />
 
         <TextView
             android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:textSize="14sp"
         android:text="设备列表:"/>
+
     <ListView
         android:id="@+id/device_list"
         android:layout_width="match_parent"
-        android:layout_height="180dp"
-        android:divider="@null"
+        android:layout_height="351dp"
+        android:background="@color/white"
         android:dividerHeight="10dp"
-        android:background="@color/white"/>
-
+        android:focusable="true" />
 
     <Button
-        android:onClick="sendTestData"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginTop="10dp"
-        android:visibility="gone"
-        android:text="发送测试数据"/>
+        android:onClick="test"
+        android:text="test"
+        android:visibility="gone" />
 
     <Button
-        android:onClick="test"
+        android:id="@+id/button_ota"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_marginTop="10dp"
-        android:text="test"/>
+        android:onClick="ota"
+        android:text="OTA" />
 
     <Button
         android:onClick="reconnect"
         android:layout_marginTop="10dp"
         android:text="切换ota通道"/>
 
-    <Button
-
-        android:onClick="goPngConver"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="10dp"
-        android:text="图片转换"/>
-
-    <Button
-        android:onClick="goAIlog"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="10dp"
-        android:text="查看AI log"/>
-
-    <Button
-        android:onClick="rotation"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="10dp"
-        android:visibility="gone"
-        android:text="旋转"/>
-
-
-    <LinearLayout
-        android:id="@+id/parent"
-        android:visibility="gone"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content">
-
-        <TextView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="10dp"
-            android:textSize="50sp"
-            android:text="test"/>
-
-    </LinearLayout>
 
 </LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_ota.xml b/app/src/main/res/layout/activity_ota.xml
new file mode 100644 (file)
index 0000000..af2d4bf
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="com.zhixun.blesdk.debug_tool.OtaActivity"
+    android:orientation="vertical"
+    android:id="@+id/parent">
+
+    <Button
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:onClick="back"
+        android:text="back" />
+
+
+    <androidx.recyclerview.widget.RecyclerView
+        android:id="@+id/msg_list_ota"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1"
+        android:dividerHeight="10dp"
+        android:divider="@null"/>
+
+
+    <Button
+        android:id="@+id/btn_chose_ota"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="10dp"
+        android:text="OTA文件选择"/>
+
+</LinearLayout>
\ No newline at end of file
index 2ff7853..7c6a042 100644 (file)
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="10dp"
-        android:text="功能选择"/>
+        android:text="功能选择" />
 
     <Button
-        android:id="@+id/btn_ota_chose"
+        android:id="@+id/btn_ota_choose"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginTop="10dp"
index e1f3691..df2c8a2 100644 (file)
@@ -1,16 +1,41 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="40dp"
     android:minHeight="40dp"
     android:gravity="center">
 
-    <TextView
-        android:id="@+id/tv_device_name"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:textSize="15sp"
-        android:textColor="@color/black"
-        />
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:orientation="horizontal">
+
+        <TextView
+            android:id="@+id/tv_device_name"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:textAlignment="center"
+            android:textColor="@color/black"
+            android:textSize="15sp"
+            tools:text="WATCH Soar 0103" />
+
+        <TextView
+            android:id="@+id/tv_device_version"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="V1.1.25"
+            android:textAlignment="center" />
+
+        <TextView
+            android:id="@+id/tv_device_bat"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:text="0%" />
+    </LinearLayout>
+
 </LinearLayout>
\ No newline at end of file