|
|
@@ -45,6 +45,10 @@ import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import org.las2mile.okio.message.BaseMsg;
|
|
|
import org.las2mile.okio.message.resp.HartBeatMsgResp;
|
|
|
+import org.las2mile.okio.message.resp.LogFileEndMsgResp;
|
|
|
+import org.las2mile.okio.message.resp.LogFileMsgResp;
|
|
|
+import android.widget.TextView;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
|
|
|
public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, SensorEventListener {
|
|
|
@@ -83,6 +87,9 @@ public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, S
|
|
|
static final int ADB_CONNECT_FAIL_HIDE = 5;
|
|
|
static final int SERVER_ENV_PREPARED = 6;
|
|
|
static final int GOT_REMOTE_VERSION = 7;
|
|
|
+ static final int GOT_REMOTE_LOG_PROCEDURE = 8;
|
|
|
+ static final int GOT_REMOTE_LOG_PROCEDURE_END = 9;
|
|
|
+
|
|
|
Handler mainHandler = new Handler(new Handler.Callback() {
|
|
|
@Override
|
|
|
public boolean handleMessage(Message message) {
|
|
|
@@ -108,11 +115,31 @@ public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, S
|
|
|
hideProgress();
|
|
|
HartBeatMsgResp hartBeatMsgResp = (HartBeatMsgResp)message.obj;
|
|
|
Toast.makeText(context, hartBeatMsgResp.remoteInfo, Toast.LENGTH_SHORT).show();
|
|
|
+ TextView tv_remote_device_info = findViewById(R.id.tv_remote_device_info);
|
|
|
+ String remoteVer = String.format(getResources().getString(R.string.str_remote_dev_info),hartBeatMsgResp.remoteInfo);
|
|
|
+ tv_remote_device_info.setText(remoteVer);
|
|
|
+ } else if(what == GOT_REMOTE_LOG_PROCEDURE){
|
|
|
+ String str_save_log_to_local = (String)message.obj;
|
|
|
+ TextView tv_save_log_to_local = findViewById(R.id.tv_save_log_to_local);
|
|
|
+ tv_save_log_to_local.setText(str_save_log_to_local);
|
|
|
+ } else if (what == GOT_REMOTE_LOG_PROCEDURE_END){
|
|
|
+ Boolean ok = (Boolean)message.obj;
|
|
|
+ String str_remote_log_dlst = String.format(getResources().getString(R.string.str_remote_log_dlst),ok ? "成功":"失败");
|
|
|
+ TextView tv_remote_log_dlst = findViewById(R.id.tv_remote_log_dlst);
|
|
|
+ tv_remote_log_dlst.setText(str_remote_log_dlst);
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ private void initDownloadBtn(){
|
|
|
+ final Button btn_dl_status = findViewById(R.id.btn_dl_status);
|
|
|
+ btn_dl_status.setOnClickListener(v -> {
|
|
|
+ Log.e("scrcpy","Asset initDownloadBtn");
|
|
|
+ scrcpy.downloadLog();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
|
|
@Override
|
|
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
|
|
@@ -177,10 +204,27 @@ public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, S
|
|
|
|
|
|
@Override
|
|
|
public void onOkIoMsg(BaseMsg baseMsg){
|
|
|
- Message msg = new Message();
|
|
|
- msg.what = GOT_REMOTE_VERSION;
|
|
|
- msg.obj = baseMsg;
|
|
|
- mainHandler.sendMessage(msg);
|
|
|
+ if(baseMsg instanceof LogFileMsgResp){
|
|
|
+ LogFileMsgResp logFileMsgResp = (LogFileMsgResp)baseMsg;
|
|
|
+ String percentStr = Math.round((logFileMsgResp.pktNo+1)*1.0f/logFileMsgResp.pktNums * 100)+"%";
|
|
|
+ String str_save_log_to_local = String.format(getResources().getString(R.string.str_save_log_to_local),"sdcd/df",percentStr);
|
|
|
+ Message msg = new Message();
|
|
|
+ msg.what = GOT_REMOTE_LOG_PROCEDURE;
|
|
|
+ msg.obj = str_save_log_to_local;
|
|
|
+ mainHandler.sendMessage(msg);
|
|
|
+ } else if(baseMsg instanceof HartBeatMsgResp){
|
|
|
+ Message msg = new Message();
|
|
|
+ msg.what = GOT_REMOTE_VERSION;
|
|
|
+ msg.obj = baseMsg;
|
|
|
+ mainHandler.sendMessage(msg);
|
|
|
+ } else if(baseMsg instanceof LogFileEndMsgResp){
|
|
|
+ LogFileEndMsgResp logFileEndMsgResp = (LogFileEndMsgResp)baseMsg;
|
|
|
+ Message msg = new Message();
|
|
|
+ msg.what = GOT_REMOTE_LOG_PROCEDURE_END;
|
|
|
+ msg.obj = logFileEndMsgResp.allDownloaded;
|
|
|
+ mainHandler.sendMessage(msg);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void showProgress(){
|
|
|
@@ -200,7 +244,9 @@ public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, S
|
|
|
}
|
|
|
|
|
|
private void hideProgress(){
|
|
|
- mainProgressDialog.dismiss();
|
|
|
+ if(mainProgressDialog.isShowing()){
|
|
|
+ mainProgressDialog.dismiss();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@SuppressLint("SourceLockedOrientationActivity")
|
|
|
@@ -394,6 +440,7 @@ public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, S
|
|
|
}
|
|
|
linearLayout = findViewById(R.id.container1);
|
|
|
start_Scrcpy_service();
|
|
|
+ initDownloadBtn();//loadNewRotation 屏幕旋转需要重新初始化
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -442,6 +489,7 @@ public class MainActivity extends Activity implements Scrcpy.ServiceCallbacks, S
|
|
|
@SuppressLint("SourceLockedOrientationActivity")
|
|
|
@Override
|
|
|
public void loadNewRotation() {
|
|
|
+ Log.e("Scrcpy: ","loadNewRotation "+first_time);
|
|
|
if (first_time){
|
|
|
int[] rem_res = scrcpy.get_remote_device_resolution();
|
|
|
remote_device_height = rem_res[1];
|