"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"
<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">
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;
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<>();
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;
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);
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));
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";
}
-
+ 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
}
-
}
\ No newline at end of file
--- /dev/null
+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
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;
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);
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
+import android.widget.CheckBox;
import android.widget.TextView;
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();
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;
}
class ViewHolder {
TextView tv_device_name;
-
+ TextView tv_device_version;
+ TextView tv_device_bat;
}
}
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);
<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"
<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"
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
--- /dev/null
+<?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
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"
<?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