From c2d0d4b234be1cb78f4e5c4a3d098d7d557c71e1 Mon Sep 17 00:00:00 2001 From: fanhuitong <981964879@qq.com> Date: Fri, 8 Jul 2022 20:29:14 +0800 Subject: [PATCH] =?UTF-8?q?version:2.6=20beta=20fix:=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E6=8E=A8=E9=80=81=20add:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/uiui/sn/tpush/MessageReceiver.java | 62 +++++++++++++++++-- .../main/java/com/uiui/sn/utils/JGYUtils.java | 2 +- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/uiui/sn/tpush/MessageReceiver.java b/app/src/main/java/com/uiui/sn/tpush/MessageReceiver.java index 269563f..0590547 100644 --- a/app/src/main/java/com/uiui/sn/tpush/MessageReceiver.java +++ b/app/src/main/java/com/uiui/sn/tpush/MessageReceiver.java @@ -10,6 +10,8 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.res.Resources; import android.media.AudioManager; +import android.net.ConnectivityManager; +import android.net.wifi.WifiManager; import android.os.Environment; import android.os.Handler; import android.provider.Settings; @@ -55,6 +57,7 @@ import com.uiui.sn.utils.Utils; import java.io.File; import java.io.FileNotFoundException; +import java.lang.reflect.Method; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; @@ -739,12 +742,13 @@ public class MessageReceiver extends XGPushBaseReceiver { break; case HOT_SPOT: ToastUtil.debugShow("收到推送消息: 热点开关"); + setHotPoint(context, extras); break; case ACTION_DEFAULT_DESKTOP: - + setDefaultDesktop(context,extras); break; case ACTION_DEFAULT_BRPWSER: - + setDefaultBrowser(context,extras); break; case ACTION_DEFAULT_INPUT_METHOD: setDefaultInputMethod(context, extras); @@ -759,7 +763,6 @@ public class MessageReceiver extends XGPushBaseReceiver { Settings.System.putInt(context.getContentResolver(), "setting_admin_app", setting_admin_app); } - private void setZenMode(Context context, String extras) { JsonObject jsonObject = GsonUtils.getJsonObject(extras); int setting_disturbance = jsonObject.get("setting_disturbance").getAsInt(); @@ -1430,9 +1433,60 @@ public class MessageReceiver extends XGPushBaseReceiver { String app_url = jsonObject.get("app_url").getAsString(); } + + /** + * @param context + * @param jsonString 设置热点开关 + */ + private void setHotPoint(Context context, String jsonString) { + JsonObject jsonObject = GsonUtils.getJsonObject(jsonString); + int setting_hotspot = changeNum(jsonObject.get("hot_point").getAsInt());//热点 + try { + if (setting_hotspot == 1) { + Intent intent = new Intent(); + intent.setAction("aole_hotspot_close"); + intent.setPackage("com.android.settings"); + context.sendStickyBroadcast(intent); + stopTethering(context); + + } + boolean aole_hotspot_forbid_on = Settings.System.putInt(context.getContentResolver(), CommonConfig.AOLE_ACTION_HOTSPOT_FORBID_ON, setting_hotspot); + Log.e("setHotPoint", "aole_hotspot_forbid_on: " + setting_hotspot); + Log.e("setHotPoint", "aole_hotspot_forbid_on: " + aole_hotspot_forbid_on); + } catch (Exception e) { + Log.e(TAG, "setHotPoint: " + e.getMessage()); + } + } + + /** + * android8.0以上关闭手机热点 + */ + private static void stopTethering(Context context) { + ConnectivityManager connectivityManager = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)); + try { + Method stopTethering = connectivityManager.getClass().getDeclaredMethod("stopTethering", int.class); + stopTethering.invoke(connectivityManager, 0); + } catch (Exception e) { + Log.e(TAG, "关闭热点失败"); + e.printStackTrace(); + } + } + + private void setDefaultDesktop(Context context, String extras){ + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String packeges = jsonObject.get("desktop_app").getAsString(); + JGYUtils.getInstance().setDefaultInputMethod(packeges); + } + + private void setDefaultBrowser(Context context, String extras){ + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String packeges = jsonObject.get("browser_app").getAsString(); + JGYUtils.getInstance().setDefaultInputMethod(packeges); + } + private void setDefaultInputMethod(Context context, String extras) { JsonObject jsonObject = GsonUtils.getJsonObject(extras); - String packeges = jsonObject.get("package").getAsString(); + String packeges = jsonObject.get("typewriting_app").getAsString(); JGYUtils.getInstance().setDefaultInputMethod(packeges); } } diff --git a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java index ce49ad0..41d5fea 100644 --- a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java +++ b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java @@ -958,7 +958,7 @@ public class JGYUtils { } public void getLauncherClassName(String pkg) { - + } public String getInputMethodId(String pkg) {