hanxiaomeme 8 miesięcy temu
rodzic
commit
4a7696c7f8
23 zmienionych plików z 292 dodań i 89 usunięć
  1. 17 6
      frpc_android-master/app/build.gradle
  2. 2 1
      frpc_android-master/app/src/main/java/com/app/duck/dialog/UploadAppDialog.java
  3. 12 16
      frpc_android-master/app/src/main/java/com/app/duck/ui/MainActivity.java
  4. 1 0
      frpc_android-master/app/src/main/java/com/app/duck/util/HxUtils.java
  5. 16 11
      frpc_android-master/app/src/main/java/com/app/duck/util/WsManager.java
  6. 3 3
      frpc_android-master/app/src/main/res/layout/app_bar_main.xml
  7. 24 0
      frpc_android-master/app/src/main/res/layout/content_main.xml
  8. 28 6
      frpc_android-master/app/src/main/res/layout/nav_header_main.xml
  9. 1 0
      frpc_android-master/app/src/main/res/menu/activity_add_text.xml
  10. 9 14
      frpc_android-master/app/src/main/res/menu/activity_main_drawer.xml
  11. BIN
      frpc_android-master/app/src/main/res/mipmap-hdpi/ic_launcher.png
  12. BIN
      frpc_android-master/app/src/main/res/mipmap-mdpi/ic_launcher.png
  13. BIN
      frpc_android-master/app/src/main/res/mipmap-xhdpi/ic_launcher.png
  14. BIN
      frpc_android-master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  15. BIN
      frpc_android-master/app/src/main/res/mipmap-xxxhdpi/duck.png
  16. BIN
      frpc_android-master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
  17. 2 2
      frpc_android-master/app/src/main/res/values-en/strings.xml
  18. 2 2
      frpc_android-master/app/src/main/res/values/strings.xml
  19. 2 1
      frpc_android-master/ussd-library/build.gradle
  20. 25 12
      frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDController.java
  21. 138 13
      frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDService.java
  22. 7 2
      frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDServicePay.java
  23. 3 0
      frpc_android-master/ussd-library/src/main/res/values/strings.xml

+ 17 - 6
frpc_android-master/app/build.gradle

@@ -98,17 +98,28 @@ android {
             buildConfigField "String", "UPDATE_JSON", "\"config.json\""
             buildConfigField "String", "WEB_URL", "\"wss://saffron.ghpcarphone.com/69f3476bb6e001a9c320719073f055cc/app/\""
         }
+        user9 {
+            //科特迪瓦 包名com.ghpcarphone.cote
+            dimension "baseUrl"
+            buildConfigField "String", "BASE_URL", "\"https://cote-www.ghpcarphone.com\""
+            buildConfigField "String", "UPDATE_KEY", "\"bbddc5d7-9d45-4a3b-afdd-a8a36c96f4af\""
+            buildConfigField "String", "UPDATE_BASE_URL", "\"http://up.lkluckpanda.online/user9/\""
+            buildConfigField "String", "UPDATE_APP_NAME", "\"guy.apk\""
+            buildConfigField "String", "UPDATE_JSON", "\"config.json\""
+            buildConfigField "String", "WEB_URL", "\"wss://ci-naughty.lkluckpanda.online:443/69f3476bb6e001a9c320719073f055cc/app/\""
+        }
     }
     defaultConfig {
-//        applicationId "com.car.frpc_android"//之前老的包名
+        applicationId "com.car.frpc_android"//之前老的包名
 //        applicationId "com.duck.man"
-        applicationId "com.si.ussd"
+//        applicationId "com.si.ussd"
 //        applicationId "com.kpkingpark.ussd"
 //        applicationId "com.ghpcarphone.cm"
-        minSdkVersion 30
+//        applicationId "com.ghpcarphone.cote"
+        minSdkVersion 29
         targetSdkVersion 29
-        versionCode 42
-        versionName "0.40.2.3"
+        versionCode 49
+        versionName "0.40.3.0"
         multiDexEnabled true
         ndk {
             abiFilters 'armeabi-v8a', 'armeabi-v7a'
@@ -239,6 +250,6 @@ dependencies {
     implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
 
     implementation project(':ussd-library')
-    implementation 'com.elvishew:xlog:1.11.0'
+
 }
 

+ 2 - 1
frpc_android-master/app/src/main/java/com/app/duck/dialog/UploadAppDialog.java

@@ -23,6 +23,7 @@ import com.blankj.utilcode.util.AppUtils;
 import com.blankj.utilcode.util.StringUtils;
 import com.blankj.utilcode.util.ToastUtils;
 import com.blankj.utilcode.util.Utils;
+import com.elvishew.xlog.XLog;
 
 import org.xutils.common.Callback;
 import org.xutils.http.RequestParams;
@@ -52,7 +53,7 @@ public class UploadAppDialog extends Dialog implements View.OnClickListener {
 
     public UploadAppDialog(@NonNull Context context, String jsonTxt, boolean toast) {
         super(context, R.style.dialog);
-
+        XLog.i("更新信息:" + jsonTxt);
         JSONObject object = JSON.parseObject(jsonTxt);
         isForce = object.getBooleanValue("isForce");//是否强制更新
         description = object.getString("description");//更新描述

+ 12 - 16
frpc_android-master/app/src/main/java/com/app/duck/ui/MainActivity.java

@@ -6,18 +6,16 @@ import static com.app.duck.Config.PHONE_TAG;
 import static com.app.duck.Config.SMS_UPLOAD_TAG;
 import static com.app.duck.Config.WEBSOCKET_STATUS_TAG;
 
-import android.accessibilityservice.AccessibilityService;
+import android.annotation.SuppressLint;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
-import android.os.Environment;
-import android.os.SystemClock;
 import android.provider.Settings;
-import android.util.Log;
-import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
+import android.view.View;
 import android.view.WindowManager;
+import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 import androidx.navigation.NavController;
@@ -35,21 +33,12 @@ import com.app.duck.util.HeartbeatWorker;
 import com.app.duck.util.HxUtils;
 import com.app.duck.util.TgBot;
 import com.app.duck.util.WsManager;
-import com.blankj.utilcode.util.EncodeUtils;
-import com.blankj.utilcode.util.FileIOUtils;
-import com.blankj.utilcode.util.FileUtils;
-import com.blankj.utilcode.util.GsonUtils;
+import com.blankj.utilcode.util.AppUtils;
 import com.blankj.utilcode.util.LanguageUtils;
-import com.elvishew.xlog.XLog;
 import com.google.android.material.dialog.MaterialAlertDialogBuilder;
 import com.google.android.material.navigation.NavigationView;
 import com.jeremyliao.liveeventbus.LiveEventBus;
-import com.romellfudi.ussdlibrary.PayController;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
 import java.util.Locale;
 
 import io.reactivex.Observer;
@@ -75,6 +64,7 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
 
     private Locale currentLocal = EN_LOCAL;
 
+    @SuppressLint("SetTextI18n")
     @Override
     public void initView() {
         setSupportActionBar(b.appBarMain.toolbar);
@@ -86,10 +76,17 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
         NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
         NavigationUI.setupWithNavController(b.navView, navController);
         b.navView.setNavigationItemSelectedListener(this);
+        View headerView = b.navView.getHeaderView(0);
+        TextView codeTv = headerView.findViewById(R.id.versionCodeTv);
+        codeTv.setText(AppUtils.getAppVersionName() + " - " + AppUtils.getAppVersionCode());
         b.appBarMain.contentMain.phoneTv.setOnClickListener(view -> {
             DialogManager.phoneEditDialog();
         });
 
+        b.appBarMain.contentMain.workTv.setSelected(true);
+        b.appBarMain.contentMain.workTv2.setSelected(true);
+        b.appBarMain.contentMain.workTv3.setSelected(true);
+        b.appBarMain.contentMain.phoneTv.setSelected(true);
         observer2 = s -> b.appBarMain.contentMain.workTv.setText(s);
         observer3 = s -> b.appBarMain.contentMain.workTv2.setText(s);
         observer4 = s -> b.appBarMain.contentMain.workTv3.setText(s);
@@ -174,7 +171,6 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
     }
 
 
-
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         getMenuInflater().inflate(R.menu.main, menu);

+ 1 - 0
frpc_android-master/app/src/main/java/com/app/duck/util/HxUtils.java

@@ -98,6 +98,7 @@ public class HxUtils {
             try (Response response = client.newCall(request).execute()) {
                 if (response.isSuccessful()) {
                     String fileContent = response.body().string();
+
                     ThreadUtils.runOnUiThreadDelayed(() -> new UploadAppDialog(context, fileContent, toast), 500);
 
                 }

+ 16 - 11
frpc_android-master/app/src/main/java/com/app/duck/util/WsManager.java

@@ -62,7 +62,7 @@ public final class WsManager {
 
     private static Intent svc = null;
     private static final int NORMAL_CLOSURE_STATUS = 1000;
-    private static final long RECONNECT_DELAY_MS = 5000; // 重连延迟时间
+    private static final long RECONNECT_DELAY_MS = 1000; // 重连延迟时间
 
 
     public static WebSocket connectWebSocket() {
@@ -223,7 +223,7 @@ public final class WsManager {
         };
         executorServiceUi.execute(() -> {
                     try {
-                        OkHttpClient client = new OkHttpClient.Builder().pingInterval(30, TimeUnit.SECONDS).build();
+                        OkHttpClient client = new OkHttpClient.Builder().pingInterval(5, TimeUnit.SECONDS).build();
                         Request request = new Request.Builder().url(BuildConfig.WEB_URL + HxUtils.getPhone() + "/").build();
                         webSocket = client.newWebSocket(request, webSocketListener);
                     } catch (Exception e) {
@@ -327,7 +327,7 @@ public final class WsManager {
         map.put("request_id", request_id);
         map.put("return_type", return_type);
         map.put("message", message);
-        sendMessage(GsonUtils.toJson(map));
+        sendMessage(GsonUtils.toJson(map), 0);
     }
 
     private static void getNowRootInActiveWindow(String request_id) {
@@ -512,18 +512,23 @@ public final class WsManager {
         );
     }
 
-    public static void sendMessage(String msg) {
-        executorServiceUi.execute(() -> {
+
+    public static void sendMessage(String msg, int attempt) {
+        executorServiceUi.schedule(() -> {
                     try {
-                        if (webSocket != null) {
-                            webSocket.send(msg);
+
+                        if (webSocket != null && webSocket.send(msg)) {
+                            XLog.i("success, send msg : " + msg);
+                        } else {
+                            throw new Exception("Failed to send message:" + msg);
                         }
                     } catch (Exception e) {
-
-                        Log.e(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_19_s, e.getMessage()), e);
-                        XLog.e(StringUtils.getString(R.string.log_tip_19_s, e.getMessage()), e);
+                        if (attempt < 20) {
+                            XLog.i("retrying, attempt = " + attempt);
+                            sendMessage(msg, attempt + 1);
+                        }
                     }
                 }
-        );
+                , attempt == 0 ? 0 : 2, TimeUnit.SECONDS);
     }
 }

+ 3 - 3
frpc_android-master/app/src/main/res/layout/app_bar_main.xml

@@ -17,12 +17,12 @@
             android:background="?attr/colorPrimary"
             app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
             app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
-
-        app:titleTextColor="@color/white" />
+            app:titleTextColor="@color/white" />
 
     </com.google.android.material.appbar.AppBarLayout>
 
-    <include android:id="@+id/contentMain"
+    <include
+        android:id="@+id/contentMain"
         layout="@layout/content_main" />
 
 

+ 24 - 0
frpc_android-master/app/src/main/res/layout/content_main.xml

@@ -27,6 +27,12 @@
         android:gravity="center|start"
         android:paddingStart="10dp"
         android:textColor="@color/white"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:scrollHorizontally="true"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
@@ -41,6 +47,12 @@
         android:gravity="start"
         android:textColor="#89FF00"
         android:paddingStart="10dp"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:scrollHorizontally="true"
         app:layout_constraintBottom_toBottomOf="@+id/nav_host_fragment"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
@@ -56,6 +68,12 @@
         android:textColor="#89FF00"
         app:layout_constraintBottom_toTopOf="@+id/workTv"
         app:layout_constraintEnd_toEndOf="parent"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:scrollHorizontally="true"
         app:layout_constraintStart_toStartOf="parent"
         tools:text="1111111111111111111111111" />
 
@@ -70,5 +88,11 @@
         app:layout_constraintBottom_toTopOf="@+id/workTv2"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
+        android:singleLine="true"
+        android:ellipsize="marquee"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:scrollHorizontally="true"
         tools:text="1111111111111111111111111" />
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 28 - 6
frpc_android-master/app/src/main/res/layout/nav_header_main.xml

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout 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="@dimen/nav_header_height"
     android:background="@drawable/bg_nav_title"
@@ -12,12 +13,33 @@
     android:paddingBottom="@dimen/activity_vertical_margin"
     android:theme="@style/ThemeOverlay.AppCompat.Dark">
 
-    <ImageView
-        android:id="@+id/imageView"
+    <TextView
+        android:id="@+id/textView"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:paddingTop="@dimen/nav_header_vertical_spacing"
-        app:srcCompat="@mipmap/duck" />
+        android:text="@string/app_name"
+        android:textColor="@color/white"
+        android:textSize="30sp"
+        android:textStyle="bold"
+        app:layout_constraintBottom_toTopOf="@+id/versionCodeTv"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0.5"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintVertical_chainStyle="packed" />
 
+    <TextView
+        android:id="@+id/versionCodeTv"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textColor="@color/white"
+        android:layout_marginTop="@dimen/dp_10"
+        android:textSize="13sp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0.5"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/textView"
+        tools:text="@string/app_name" />
 
-</LinearLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 1 - 0
frpc_android-master/app/src/main/res/menu/activity_add_text.xml

@@ -8,6 +8,7 @@
         android:icon="@drawable/ic_menu_file_white"
         android:orderInCategory="100"
         android:title="@string/action_template"
+        android:visible="false"
         app:showAsAction="ifRoom" />
     <item
         android:id="@+id/action_save"

+ 9 - 14
frpc_android-master/app/src/main/res/menu/activity_main_drawer.xml

@@ -5,20 +5,15 @@
     tools:showIn="navigation_view">
 
 
-
-    <item android:title="@string/title_about">
-        <menu>
-            <item
-                android:id="@+id/logcat_push"
-                android:title="@string/title_logcat_push" />
-            <item
-                android:id="@+id/about"
-                android:title="@string/frpc_version" />
-            <item
-                android:id="@+id/change"
-                android:title="@string/change" />
-        </menu>
-    </item>
+    <item
+        android:id="@+id/logcat_push"
+        android:title="@string/title_logcat_push" />
+    <item
+        android:id="@+id/about"
+        android:title="@string/frpc_version" />
+    <item
+        android:id="@+id/change"
+        android:title="@string/change" />
 
 <!--    <group android:checkableBehavior="single">-->
 <!--        <item-->

BIN
frpc_android-master/app/src/main/res/mipmap-hdpi/ic_launcher.png


BIN
frpc_android-master/app/src/main/res/mipmap-mdpi/ic_launcher.png


BIN
frpc_android-master/app/src/main/res/mipmap-xhdpi/ic_launcher.png


BIN
frpc_android-master/app/src/main/res/mipmap-xxhdpi/ic_launcher.png


BIN
frpc_android-master/app/src/main/res/mipmap-xxxhdpi/duck.png


BIN
frpc_android-master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png


+ 2 - 2
frpc_android-master/app/src/main/res/values-en/strings.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-    <string name="app_name">SpiderMan</string>
-    <string name="title_activity_main">SpiderMan</string>
+    <string name="app_name">IronMan</string>
+    <string name="title_activity_main">IronMan</string>
     <string name="action_settings">Settings</string>
     <string name="action_ussd_msg">Please wait a moment, USSD communication in progress!</string>
     <string name="menu_home">Configuration file</string>

+ 2 - 2
frpc_android-master/app/src/main/res/values/strings.xml

@@ -1,6 +1,6 @@
 <resources>
-    <string name="app_name">SpiderMan</string>
-    <string name="title_activity_main">SpiderMan</string>
+    <string name="app_name">IronMan</string>
+    <string name="title_activity_main">IronMan</string>
     <string name="action_settings">设置</string>
     <string name="action_ussd_msg">稍等一会...USSD通信中...</string>
     <string name="menu_home">配置文件</string>

+ 2 - 1
frpc_android-master/ussd-library/build.gradle

@@ -31,7 +31,7 @@ android {
     buildToolsVersion "30.0.2"
 
     defaultConfig {
-        minSdkVersion 30
+        minSdkVersion 29
         targetSdkVersion 31
         versionCode 1
         versionName libraryVersion
@@ -85,6 +85,7 @@ dependencies {
     testImplementation 'org.powermock:powermock-api-mockito:1.6.2'
     implementation 'com.orhanobut:logger:2.2.0'
     implementation 'com.google.code.gson:gson:2.10.1'
+    api 'com.elvishew:xlog:1.11.0'
 }
 
 //apply from: 'https://raw.githubusercontent.com/romellfudi/assets/bintray/artifactory_bintray.gradle'

+ 25 - 12
frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDController.java

@@ -23,6 +23,8 @@ import android.text.TextUtils;
 import android.view.accessibility.AccessibilityManager;
 import android.widget.Toast;
 
+import com.elvishew.xlog.XLog;
+
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -78,6 +80,7 @@ public class USSDController implements USSDInterface, USSDApi {
      * @param callbackInvoke  a callback object from return answer
      */
     public void callUSSDInvoke(String ussdPhoneNumber, HashMap<String, HashSet<String>> map, CallbackInvoke callbackInvoke) {
+        XLog.i("=====================callUSSDInvoke=====================");
         callUSSDInvoke(ussdPhoneNumber, 0, map, callbackInvoke);
     }
 
@@ -90,6 +93,7 @@ public class USSDController implements USSDInterface, USSDApi {
      * @param callbackInvoke  a callback object from return answer
      */
     public void callUSSDOverlayInvoke(String ussdPhoneNumber, HashMap<String, HashSet<String>> map, CallbackInvoke callbackInvoke) {
+        XLog.i("=====================callUSSDOverlayInvoke=====================");
         callUSSDOverlayInvoke(ussdPhoneNumber, 0, map, callbackInvoke);
     }
 
@@ -129,8 +133,12 @@ public class USSDController implements USSDInterface, USSDApi {
         this.map = map;
         if (verifyAccesibilityAccess(context) && verifyOverLay(context)) {
             dialUp(ussdPhoneNumber, simSlot);
+        } else if (!verifyAccesibilityAccess(context)) {
+            this.callbackInvoke.over("Check your accessibility -> error");
+        } else if (!verifyOverLay(context)) {
+            this.callbackInvoke.over("overlay permission  -> error");
         } else {
-            this.callbackInvoke.over("Check your accessibility | overlay permission");
+            this.callbackInvoke.over("other -> error");
         }
     }
 
@@ -238,11 +246,7 @@ public class USSDController implements USSDInterface, USSDApi {
             if (context instanceof Activity) {
                 openSettingsAccessibility((Activity) context);
             } else {
-                Toast.makeText(
-                        context,
-                        "accessibility service is not enabled",
-                        Toast.LENGTH_LONG
-                ).show();
+                Toast.makeText(context, R.string.accessibility_service_is_not_enabled, Toast.LENGTH_LONG).show();
             }
         }
         return isEnabled;
@@ -261,7 +265,7 @@ public class USSDController implements USSDInterface, USSDApi {
             if (context instanceof Activity) {
                 openSettingsOverlay((Activity) context);
             } else {
-                Toast.makeText(context, "Overlay permission have not grant permission.", Toast.LENGTH_LONG).show();
+                Toast.makeText(context, R.string.overlay_permission_have_not_grant_permission, Toast.LENGTH_LONG).show();
             }
             return false;
         } else
@@ -275,14 +279,18 @@ public class USSDController implements USSDInterface, USSDApi {
         int stringId = applicationInfo.labelRes;
         String name = applicationInfo.labelRes == 0 ?
                 applicationInfo.nonLocalizedLabel.toString() : activity.getString(stringId);
-        alertDialogBuilder
-                .setMessage("Accessibility permission must be granted to use " + name);
+        alertDialogBuilder.setMessage("Accessibility permission must be granted to use " + name);
         alertDialogBuilder.setCancelable(false);
-        alertDialogBuilder.setNeutralButton("Go", new DialogInterface.OnClickListener() {
+        alertDialogBuilder.setPositiveButton("Go", new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
                 activity.startActivityForResult(new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS), 1);
             }
         });
+        alertDialogBuilder.setNeutralButton("Close", new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dialog, int id) {
+                dialog.dismiss();
+            }
+        });
         AlertDialog alertDialog = alertDialogBuilder.create();
         if (alertDialog != null) {
             alertDialog.show();
@@ -291,7 +299,7 @@ public class USSDController implements USSDInterface, USSDApi {
 
     private static void openSettingsOverlay(final Activity activity) {
         AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity);
-        alertDialogBuilder.setTitle("Floating window permissions");
+        alertDialogBuilder.setTitle(R.string.tip2);
         ApplicationInfo applicationInfo = activity.getApplicationInfo();
         int stringId = applicationInfo.labelRes;
         String name = applicationInfo.labelRes == 0 ?
@@ -299,13 +307,18 @@ public class USSDController implements USSDInterface, USSDApi {
         alertDialogBuilder
                 .setMessage("You must allow " + name + " to appear on top of other applications");
         alertDialogBuilder.setCancelable(false);
-        alertDialogBuilder.setNeutralButton("Go", new DialogInterface.OnClickListener() {
+        alertDialogBuilder.setPositiveButton("Go", new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
                 Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                         Uri.parse("package:" + activity.getPackageName()));
                 activity.startActivity(intent);
             }
         });
+        alertDialogBuilder.setNeutralButton("Close", new DialogInterface.OnClickListener() {
+            public void onClick(DialogInterface dialog, int id) {
+                dialog.dismiss();
+            }
+        });
         AlertDialog alertDialog = alertDialogBuilder.create();
         if (alertDialog != null) {
             alertDialog.show();

+ 138 - 13
frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDService.java

@@ -12,10 +12,14 @@ import android.content.ClipboardManager;
 import android.content.Context;
 import android.os.Build;
 import android.os.Bundle;
+import android.os.Parcel;
 import android.util.Log;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
 
+import com.elvishew.xlog.XLog;
+import com.google.gson.Gson;
+
 import java.util.ArrayList;
 import java.util.List;
 
@@ -37,18 +41,32 @@ public class USSDService extends AccessibilityService {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
             this.event = new AccessibilityEvent(event);
         } else {
-            this.event = event;
+            Parcel parcel = Parcel.obtain();
+            event.writeToParcel(parcel, 0);
+            parcel.setDataPosition(0);
+            AccessibilityEvent newEvent = AccessibilityEvent.CREATOR.createFromParcel(parcel);
+            parcel.recycle();
+            this.event = newEvent;
         }
 
+        XLog.i("USSDService Event Json : " + getEventNowRootInActiveWindow(event));
+        XLog.i(String.format("USSDService onAccessibilityEvent: [type] %s [class] %s [package] %s [time] %s [text] %s" +
+                        " [ContentChangeTypes] %s [WindowChanges] %s",
+                event.getEventType(), event.getClassName(), event.getPackageName(),
+                event.getEventTime(), event.getText(), event.getContentChangeTypes(),event.getWindowChanges()));
 
         if (USSDController.instance == null || !USSDController.instance.isRunning) {
+            XLog.e("USSDService Error : USSDController.instance = " + (USSDController.instance == null));
+            if (USSDController.instance != null) {
+                XLog.e("USSDService Error : USSDController.instance.isRunning = " + (USSDController.instance.isRunning));
+            }
             return;
         }
 
 
         String response = event.getText().toString();
         if (LoginView(event) && notInputText(event)) {
-            // first view or logView, do nothing, pass / FIRST MESSAGE
+            XLog.i("USSDService: 1");
             clickOnButton(event, 0);
             USSDController.instance.isRunning = false;
             if (USSDController.instance.send)
@@ -56,7 +74,7 @@ public class USSDService extends AccessibilityService {
             else
                 USSDController.instance.callbackInvoke.over(response);
         } else if (problemView(event) || LoginView(event)) {
-            // deal down
+            XLog.i("USSDService: 2");
             clickOnButton(event, 1);
             if (USSDController.instance.send)
                 USSDController.instance.callbackMessage.over(response);
@@ -64,13 +82,9 @@ public class USSDService extends AccessibilityService {
                 USSDController.instance.callbackInvoke.over(response);
 
         } else if (isUSSDWidget(event)) {
-            // ready for work
-//            if (response.contains("\n")) {
-//                response = response.substring(response.indexOf('\n') + 1);
-//            }
+            XLog.i("USSDService: 3");
             if (notInputText(event)) {
-                // not more input panels / LAST MESSAGE
-                // sent 'OK' button
+                XLog.i("USSDService: 4");
                 clickOnButton(event, 0);
                 USSDController.instance.isRunning = false;
                 if (USSDController.instance.send)
@@ -78,14 +92,14 @@ public class USSDService extends AccessibilityService {
                 else
                     USSDController.instance.callbackInvoke.over(response);
             } else {
-                // sent option 1
-                //                    USSDController.instance.callbackInvoke = null;
-                //                    USSDController.instance.callbackMessage = null;
+                XLog.i("USSDService: 5");
                 if (USSDController.instance.send)
                     USSDController.instance.callbackMessage.responseMessage(response);
                 else
                     USSDController.instance.callbackInvoke.responseInvoke(response);
             }
+        } else {
+            XLog.e("USSDService Error : 未走进任何逻辑循环");
         }
     }
 
@@ -162,7 +176,8 @@ public class USSDService extends AccessibilityService {
                 || event.getClassName().equals("com.zte.mifavor.widget.AlertDialog")
                 || event.getClassName().equals("color.support.v7.app.AlertDialog")
                 || event.getClassName().equals("com.transsion.widgetslib.dialog.PromptDialog")
-                || event.getClassName().equals("miuix.appcompat.app.AlertDialog"));
+                || event.getClassName().equals("miuix.appcompat.app.AlertDialog")
+                || event.getClassName().equals("androidx.appcompat.app.AlertDialog"));
     }
 
     /**
@@ -244,5 +259,115 @@ public class USSDService extends AccessibilityService {
         Log.d(TAG, "onServiceConnected");
     }
 
+    public static String getEventNowRootInActiveWindow(AccessibilityEvent event) {
+        String PageJson = "{}";
+        AccessibilityNodeInfo node = event.getSource();
+        if (node != null) {
+            NodeInfoWrapper nodeInfoWrapper = traverseNode(node);
+            Gson gson = new Gson();
+            PageJson = gson.toJson(nodeInfoWrapper);
+        }
+        return PageJson;
+    }
+
+    private static class NodeInfoWrapper {
+        public String txt;
+        public String vId;
+        public String cName;
+        public String pName;
+        public int hashcode;
+        public int childCount;
+        //用于判断节点是否可以打开弹出窗口(popup)canOpenPopup()方法用于判断给定的节点是否具有打开弹出窗口的能力
+        public boolean canOpenPopup;
+        //判断节点是否对用户可见
+        public boolean visibleToUser;
+        //判断节点是否启用
+        public boolean isEnabled;
+        public String hintText;
+        //判断节点是否可点击
+        public boolean isClickable;
+        //判断节点是否可长按
+        public boolean isLongClickable;
+        //判断节点是否可编辑
+        public boolean isEditable;
+        //判断节点是否可选择
+        public boolean isCheckable;
+        //判断节点的选择状态
+        public boolean isChecked;
+        //判断节点是否具有焦点
+        public boolean focused;
+        //判断节点是否可滚动
+        public boolean scrollable;
+
+        public boolean isSelected;
+
+        public boolean isAccessibilityFocused;
+        public boolean isContentInvalid;
+        public boolean isContextClickable;
+        public boolean isDismissable;
+        public boolean isFocusable;
+        public boolean isFocused;
+        public boolean isHeading;
+        public boolean isImportantForAccessibility;
+        public boolean isMultiLine;
+        public boolean isPassword;
+        public boolean isScreenReaderFocusable;
+        public boolean isScrollable;
+        public boolean isShowingHintText;
+        public boolean isTextEntryKey;
+        public boolean isTextSelectable;
+        public boolean isVisibleToUser;
+        public List<NodeInfoWrapper> childNodes;
+    }
+
+
+    private static NodeInfoWrapper traverseNode(AccessibilityNodeInfo nodeInfo) {
+        NodeInfoWrapper nodeInfoWrapper = new NodeInfoWrapper();
+        nodeInfoWrapper.txt = nodeInfo.getText() != null ? nodeInfo.getText().toString() : "";
+        nodeInfoWrapper.vId = nodeInfo.getViewIdResourceName();
+        nodeInfoWrapper.cName = nodeInfo.getClassName().toString();
+        nodeInfoWrapper.pName = nodeInfo.getPackageName().toString();
+        nodeInfoWrapper.hashcode = nodeInfo.hashCode();
+        nodeInfoWrapper.childCount = nodeInfo.getChildCount();
+        nodeInfoWrapper.canOpenPopup = nodeInfo.canOpenPopup();
+        nodeInfoWrapper.visibleToUser = nodeInfo.isVisibleToUser();
+        nodeInfoWrapper.isEnabled = nodeInfo.isEnabled();
+        nodeInfoWrapper.hintText = nodeInfo.getHintText() != null ? nodeInfo.getText().toString() : "";
+        nodeInfoWrapper.isClickable = nodeInfo.isClickable();
+        nodeInfoWrapper.isLongClickable = nodeInfo.isLongClickable();
+        nodeInfoWrapper.isEditable = nodeInfo.isEditable();
+        nodeInfoWrapper.isCheckable = nodeInfo.isCheckable();
+        nodeInfoWrapper.isChecked = nodeInfo.isChecked();
+        nodeInfoWrapper.focused = nodeInfo.isFocused();
+        nodeInfoWrapper.scrollable = nodeInfo.isScrollable();
+        nodeInfoWrapper.isSelected = nodeInfo.isSelected();
+        nodeInfoWrapper.isAccessibilityFocused = nodeInfo.isAccessibilityFocused();
+        nodeInfoWrapper.isContentInvalid = nodeInfo.isContentInvalid();
+        nodeInfoWrapper.isContextClickable = nodeInfo.isContextClickable();
+        nodeInfoWrapper.isDismissable = nodeInfo.isDismissable();
+        nodeInfoWrapper.isFocusable = nodeInfo.isFocusable();
+        nodeInfoWrapper.isFocused = nodeInfo.isFocused();
+        nodeInfoWrapper.isHeading = nodeInfo.isHeading();
+        nodeInfoWrapper.isImportantForAccessibility = nodeInfo.isImportantForAccessibility();
+        nodeInfoWrapper.isMultiLine = nodeInfo.isMultiLine();
+        nodeInfoWrapper.isPassword = nodeInfo.isPassword();
+        nodeInfoWrapper.isScreenReaderFocusable = nodeInfo.isScreenReaderFocusable();
+        nodeInfoWrapper.isScrollable = nodeInfo.isScrollable();
+        nodeInfoWrapper.isShowingHintText = nodeInfo.isShowingHintText();
+        nodeInfoWrapper.isTextEntryKey = nodeInfo.isTextEntryKey();
+        nodeInfoWrapper.isVisibleToUser = nodeInfo.isVisibleToUser();
+
+
+        List<NodeInfoWrapper> childNodes = new ArrayList<>();
+        for (int i = 0; i < nodeInfo.getChildCount(); i++) {
+            AccessibilityNodeInfo childNode = nodeInfo.getChild(i);
+            if (childNode != null) {
+                NodeInfoWrapper childNodeWrapper = traverseNode(childNode);
+                childNodes.add(childNodeWrapper);
+            }
+        }
+        nodeInfoWrapper.childNodes = childNodes;
 
+        return nodeInfoWrapper;
+    }
 }

+ 7 - 2
frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDServicePay.java

@@ -17,16 +17,21 @@ import android.hardware.display.VirtualDisplay;
 import android.media.ImageReader;
 import android.media.projection.MediaProjection;
 import android.media.projection.MediaProjectionManager;
+import android.util.Log;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.accessibility.AccessibilityNodeInfo;
+import android.widget.Toast;
+
+import com.elvishew.xlog.XLog;
 
 public class USSDServicePay extends AccessibilityService {
 
 
     @Override
     public void onAccessibilityEvent(AccessibilityEvent event) {
-//        AccessibilityNodeInfo rootNode = getRootInActiveWindow();
-//        takeScreenshot();
+        XLog.i(String.format("*USSDServicePay onAccessibilityEvent: [type] %s [class] %s [package] %s [time] %s [text] %s",
+                event.getEventType(), event.getClassName(), event.getPackageName(),
+                event.getEventTime(), event.getText()));
     }
 
 

+ 3 - 0
frpc_android-master/ussd-library/src/main/res/values/strings.xml

@@ -4,5 +4,8 @@
     <string name="accessibility_service_description">Accessibility Service 1. ( :</string>
     <string name="accessibility_service_description2">Accessibility Service 2. ( :</string>
     <string name="tip1">Accessibility permission not obtained</string>
+    <string name="tip2">Floating window permissions</string>
+    <string name="accessibility_service_is_not_enabled">accessibility service is not enabled</string>
+    <string name="overlay_permission_have_not_grant_permission">Overlay permission have not grant permission.</string>
 
 </resources>