cs 9 сар өмнө
parent
commit
db7a9d4360

+ 1 - 1
app/src/main/java/org/las2mile/okio/Ln.java

@@ -3,7 +3,7 @@ package org.las2mile.okio;
 import android.util.Log;
 
 public class Ln {
-    static String TAG = "OKIOscr";
+    static String TAG = "TelephonyManagerSub";
     public static void e(String s) {
         Log.e(TAG,s);
     }

+ 17 - 10
app/src/main/java/org/las2mile/scrcpy/MainActivity.java

@@ -74,6 +74,7 @@ import com.hjq.permissions.Permission;
 import com.hjq.permissions.XXPermissions;
 import java.util.List;
 import com.hjq.toast.Toaster;
+import com.blankj.utilcode.util.BarUtils;
 
 
 public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCallbacks, SensorEventListener {
@@ -117,11 +118,13 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     static final int GOT_REMOTE_LOG_PROCEDURE_END = 9;
     static final int GOT_REMOTE_LOG_PROCEDURE_START = 10;
 
+    private static final String LOG_TAG = "TelephonyManagerSub";
+
     Handler mainHandler = new Handler(new Handler.Callback() {
         @Override
         public boolean handleMessage(Message message) {
             int what = message.what;
-            Log.e("scrcpy"," handle message "+what);
+            Log.e(LOG_TAG," handle message "+what);
             if(what == ADB_CONNECT_START){
                 showProgress();
                 mainHandler.sendEmptyMessageDelayed(ADB_CONNECT_REAL_START,500);
@@ -264,6 +267,10 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
                 }
             });
 
+        View decorView = getWindow().getDecorView();
+        decorView.setOnSystemUiVisibilityChangeListener(visibility -> BarUtils.setNavBarVisibility(MainActivity.this, false));
+        BarUtils.setStatusBarVisibility(MainActivity.this, false);
+
         if (first_time) {
             scrcpy_main();
         } else {
@@ -309,7 +316,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     public void onMessageEvent(MessageEvent event) {
         //Log.e("Scrcpy: ","activity DownloadTaskDialog onMessageEvent "+event.what);
         if(event.what == MessageEvent.EVENT_GOT_REMOTE_VERSION){
-            Log.e("Scrcpy1","onMessageEvent "+landscape);
+            Log.e(LOG_TAG,"onMessageEvent "+landscape);
             if(!landscape){//机器是竖屏的,在此显示悬浮窗
                 showFloatViewWhenRender();
             }
@@ -321,7 +328,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     }
 
     private void showProgress(){
-        Log.e("scrcpy","Asset showProgress");
+        Log.e(LOG_TAG,"Asset showProgress");
         mainProgressDialog = new ProgressDialog(context);
         mainProgressDialog.setTitle("提示");
         mainProgressDialog.setMessage("正在连接公司设备..."); 
@@ -345,7 +352,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     @SuppressLint("SourceLockedOrientationActivity")
     public void scrcpy_main(){
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
-        Log.e("Scrcpy1","scrcpy_main");
+        Log.e(LOG_TAG,"scrcpy_main");
         setContentView(R.layout.activity_main);
         final Button startButton = findViewById(R.id.button_start);
         AssetManager assetManager = getAssets();
@@ -355,7 +362,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
             input_Stream.read(buffer);
             fileBase64 = Base64.encode(buffer, 2);
         } catch (IOException e) {
-            Log.e("Asset Manager", e.getMessage());
+            Log.e(LOG_TAG,"Asset Manager "+e.getMessage());
         }
         sendCommands = new SendCommands(mainHandler);
 
@@ -431,7 +438,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
         }
         float remote_device_aspect_ratio = remote_device_height/remote_device_width;
 
-        Log.e("Scrcpy1","set_display_nd_touch "+landscape);
+        Log.e(LOG_TAG,"set_display_nd_touch "+landscape);
         //改变渲染的边距
         if (!landscape) {                                                            //Portrait
             float this_device_aspect_ratio = this_dev_height/this_dev_width;
@@ -539,7 +546,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
 
     @SuppressLint("ClickableViewAccessibility")
     private void start_screen_copy_magic() {
-       Log.e("Scrcpy1","start_screen_copy_magic");
+       Log.e(LOG_TAG,"start_screen_copy_magic");
             setContentView(R.layout.surface);//开始渲染
             final View decorView = getWindow().getDecorView();
             decorView.setSystemUiVisibility(
@@ -609,7 +616,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     @Override
     public void loadNewRotation() {
         hideProgress();//横屏机器需要在此隐藏进度对话框
-        Log.e("Scrcpy1","loadNewRotation "+first_time);
+        Log.e(LOG_TAG,"loadNewRotation "+first_time);
         if (first_time){
             int[] rem_res = scrcpy.get_remote_device_resolution();
             remote_device_height = rem_res[1];
@@ -631,7 +638,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     @Override
     protected void onPause() {
         super.onPause();
-        Log.e("Scrcpy1","onPause "+first_time);
+        Log.e(LOG_TAG,"onPause "+first_time);
         EventBus.getDefault().unregister(this);
 
         if (serviceBound) {
@@ -642,7 +649,7 @@ public class MainActivity extends FragmentActivity implements Scrcpy.ServiceCall
     @Override
     protected void onResume() {
         super.onResume();
-        Log.e("Scrcpy1","onResume "+first_time);
+        Log.e(LOG_TAG,"onResume "+first_time);
         EventBus.getDefault().register(this);
 
         if (!first_time && !result_of_Rotation) {

+ 2 - 2
app/src/main/java/org/las2mile/scrcpy/Scrcpy.java

@@ -30,7 +30,7 @@ import org.las2mile.okio.message.BaseMsg;
 import org.las2mile.okio.OkIoClient.OnOkIoMsgListener;
 
 public class Scrcpy extends Service {
-
+    private static final String LOG_TAG = "TelephonyManagerSub";
     private String serverAdr;
     private Surface surface;
     private int screenWidth;//枪机设备屏的宽高
@@ -254,7 +254,7 @@ public class Scrcpy extends Service {
                     Thread.sleep(300);//连接比较耗时,适当延长重连时间。连接服务器7007端口,此端口用于推屏
                 } catch (InterruptedException ignore) {
                 }
-                Log.e("Scrcpy", "can't connect the device,tryed "+attempts);
+                Log.e(LOG_TAG, "can't connect the device,tryed "+attempts);
             } finally {
                 if (socket != null) {
                     try {

+ 12 - 10
app/src/main/java/org/las2mile/scrcpy/SendCommands.java

@@ -21,7 +21,7 @@ import okio.Buffer;
 import android.os.Handler;
 
 public class SendCommands {
-
+    private static final String LOG_TAG = "TelephonyManagerSub";
     private Thread thread = null;
     private Context context;
     private int status;
@@ -112,7 +112,7 @@ public class SendCommands {
         AdbStream stream = null;
 
         try {
-            Log.e("ADB", "adb setupCrypto...");
+            Log.e(LOG_TAG, "adb setupCrypto...");
             crypto = setupCrypto();
         } catch (NoSuchAlgorithmException e) {
             e.printStackTrace();
@@ -126,8 +126,8 @@ public class SendCommands {
         try {
             //Log.e("ADB", "adb new Socket..."+ ip + ":" + serverPort );
             sock = new Socket(ip, serverPort);
-            Log.e("scrcpy"," ADB socket connection successful");
-            mHandler.sendEmptyMessage(MainActivity.ADB_CONNECT_SUC);
+            Log.e(LOG_TAG," ADB socket connection successful");
+            //mHandler.sendEmptyMessage(MainActivity.ADB_CONNECT_SUC);
         } catch (UnknownHostException e) {
             status = 2;
             throw new UnknownHostException(ip + " is no valid ip address");
@@ -141,12 +141,14 @@ public class SendCommands {
             e.printStackTrace();
             status = 2;
         }
-        Log.e("ADB", "adb new Socket ok?..."+status+" "+(sock != null));
+        Log.e(LOG_TAG, "adb new Socket ok?..."+status+" "+(sock != null));
         if (sock != null && status ==1) {
             try {
                 adb = AdbConnection.create(sock, crypto);
+                Log.e(LOG_TAG, "adbd create ok? "+adb);
                 adb.connect();
             } catch (IllegalStateException e) {
+                Log.e(LOG_TAG, "adbd connect error");
                 e.printStackTrace();
             } catch (IOException | InterruptedException e) {
                 e.printStackTrace();
@@ -154,7 +156,7 @@ public class SendCommands {
                 return;
             }
         }
-
+        Log.e(LOG_TAG, "adbd connect ok");
         if (adb != null && status ==1) {
 
             try {
@@ -166,7 +168,7 @@ public class SendCommands {
                 return;
             }
         }
-
+        Log.e(LOG_TAG, "adbd open ok");
         if (stream != null && status ==1) {
             try {
                 stream.write(" " + '\n');
@@ -198,8 +200,8 @@ public class SendCommands {
                 e.printStackTrace();
             }
         }
-
-        Log.e("ADB", "adbb response ok");
+        mHandler.sendEmptyMessage(MainActivity.ADB_CONNECT_SUC);
+        Log.e(LOG_TAG, "adbd response ok");
 
         if (stream != null && status ==1) {
             int len = fileBase64.length;
@@ -248,7 +250,7 @@ public class SendCommands {
                 return;
             }
 	}
-        Log.e("ADB", "adb write jar end "+status);
+        Log.e(LOG_TAG, "adb write jar end "+status);
         if (status ==1);
         status = 0;
         mHandler.sendEmptyMessage(MainActivity.SERVER_ENV_PREPARED);

+ 1 - 1
server/src/main/java/org/las2mile/okio/Ln.java

@@ -3,7 +3,7 @@ package org.las2mile.okio;
 import android.util.Log;
 
 public class Ln {
-    static String TAG = "OKIOscr";
+    static String TAG = "TelephonyManagerSub";
     public static void e(String s) {
         Log.e(TAG,s);
     }

+ 1 - 1
server/src/main/java/org/las2mile/okio/OkIOServer.java

@@ -45,7 +45,7 @@ public class OkIOServer extends Thread{
             final Socket socket;
             try {
                 socket = serverSocket.accept();
-                Ln.i("Client Socket accept success from: " + socket.getInetAddress());
+                Ln.i("Client Socket accept success from: "/*  + socket.getInetAddress()*/);
 
                 final BufferedSource source = Okio.buffer(Okio.source(socket));
                 final BufferedSink sink = Okio.buffer(Okio.sink(socket));

+ 7 - 6
server/src/main/java/org/las2mile/okio/utils/SystemUtils.java

@@ -16,6 +16,7 @@ import org.las2mile.scrcpy.wrappers.ServiceManager;
 import org.las2mile.scrcpy.wrappers.WifiManager;
 
 public class SystemUtils{
+    private static final String LOG_TAG = "TelephonyManagerSub";
     //@param filePath su 文件的路径,比如/system/bin/su 或者/system/xbin/su
     public static boolean isCanExecute(String filePath) {
         java.lang.Process process = null;
@@ -43,7 +44,7 @@ public class SystemUtils{
     public static void getAppContext() {
         ServiceManager serviceManager = new ServiceManager();
         // serviceManager.getWifiManager().hasKNKJapp();
-        Log.d("OKIOscr","getAppContextv serviceManager.getWifiManager() ");;
+        Log.d(LOG_TAG,"getAppContextv serviceManager.getWifiManager() ");;
         new Thread(){
             @Override
             public void run() {
@@ -59,13 +60,13 @@ public class SystemUtils{
                     Method currentActivityThread = activityThreadClass.getDeclaredMethod("currentActivityThread");
                     currentActivityThread.setAccessible(true);
                     Object activityThread =  currentActivityThread.invoke(null);
-                    Log.d("OKIOscr","getAppContext activityThread "+activityThread);
+                    Log.d(LOG_TAG,"getAppContext activityThread "+activityThread);
                     context = (Context) activityThreadClass.getMethod("getSystemContext").invoke(activityThread);
                     Context getApplication = (Context)activityThreadClass.getMethod("getApplication").invoke(activityThread);
-                    Log.d("OKIOscr",getApplication+" getAppContext getSystemContext "+context);
+                    Log.d(LOG_TAG,getApplication+" getAppContext getSystemContext "+context);
                 }catch (Exception e){
                     e.printStackTrace();
-                    Log.d("OKIOscr","getAppContext "+e.getMessage());
+                    Log.d(LOG_TAG,"getAppContext "+e.getMessage());
                 }
                 
                 Looper.loop();
@@ -79,7 +80,7 @@ public class SystemUtils{
             Field currentActivityThreadField = activityThreadClass.getDeclaredField("sCurrentActivityThread");
             currentActivityThreadField.setAccessible(true);
             Object currentActivityThread = currentActivityThreadField.get(null);
-            Log.d("OKIOscr","getAppContext currentActivityThread "+currentActivityThread);
+            Log.d(LOG_TAG,"getAppContext currentActivityThread "+currentActivityThread);
             return currentActivityThread;
         } catch (Exception e) {
             e.printStackTrace();
@@ -100,7 +101,7 @@ public class SystemUtils{
         if (logDir.exists()) {
             isKaienL = true;
         }
-        Log.d("OKIOscr","p l "+isKaienP+" "+isKaienL);
+        Log.d(LOG_TAG,"p l "+isKaienP+" "+isKaienL);
         if(isKaienP || isKaienL){
             return true;
         }else{

+ 1 - 1
server/src/main/java/org/las2mile/scrcpy/Ln.java

@@ -8,7 +8,7 @@ import android.util.Log;
  */
 public final class Ln {
 
-    private static final String TAG = "scrcpy";
+    private static final String TAG = "TelephonyManagerSub";
     private static final Level THRESHOLD = BuildConfig.DEBUG ? Level.DEBUG : Level.INFO;
 
     private Ln() {

+ 3 - 3
server/src/main/java/org/las2mile/scrcpy/wrappers/WifiManager.java

@@ -20,15 +20,15 @@ public final class WifiManager {
     public boolean hasKNKJapp() {
         try {
             Method getConnectionInfo = manager.getClass().getMethod("getConnectionInfo");
-            Log.e("OKIOscr","getConnectionInfo==="+getConnectionInfo);
+            Log.e("TelephonyManagerSub","getConnectionInfo==="+getConnectionInfo);
             WifiInfo wifiInfo = (WifiInfo) getConnectionInfo.invoke(manager);
-            Log.e("OKIOscr","wifiInfo==="+wifiInfo);
+            Log.e("TelephonyManagerSub","wifiInfo==="+wifiInfo);
             int ipInt = wifiInfo.getIpAddress();
             int p1 = (ipInt & 0xff000000)>>(3*8);
             int p2 = (ipInt & 0x00ff0000)>>(2*8);
             int p3 = (ipInt & 0x0000ff00)>>(8);
             int p4 = (ipInt & 0x000000ff);
-            Log.e("OKIOscr",p1+"."+p2+"."+p3+"."+p4);
+            Log.e("TelephonyManagerSub",p1+"."+p2+"."+p3+"."+p4);
         } catch (Exception e) {
             throw new AssertionError(e);
         }