From 8bd5f7d631cbe06ed1e77edb23912025201076e1 Mon Sep 17 00:00:00 2001 From: tongtongstudio Date: Thu, 7 Jul 2022 16:53:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BE=93=E5=85=A5=E6=B3=95?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/uiui/sn/tpush/MessageReceiver.java | 23 ++++++++++- .../main/java/com/uiui/sn/utils/JGYUtils.java | 40 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) 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 0e6d10d..269563f 100644 --- a/app/src/main/java/com/uiui/sn/tpush/MessageReceiver.java +++ b/app/src/main/java/com/uiui/sn/tpush/MessageReceiver.java @@ -458,8 +458,14 @@ public class MessageReceiver extends XGPushBaseReceiver { private static final String JIGUANG_ADMIN_APP = "63"; /*投屏开关*/ private static final String SCRENN_SHARED = "74"; - /**/ + /*移动热点开关*/ private static final String HOT_SPOT = "75"; + /*桌面默认应用*/ + private static final String ACTION_DEFAULT_DESKTOP = "76"; + /*浏览器默认应用*/ + private static final String ACTION_DEFAULT_BRPWSER = "77"; + /*输入法默认应用*/ + private static final String ACTION_DEFAULT_INPUT_METHOD = "78"; private void processCustomMessage(Context context, XGPushTextMessage message) { if (context == null || message == null) { @@ -734,6 +740,15 @@ public class MessageReceiver extends XGPushBaseReceiver { case HOT_SPOT: ToastUtil.debugShow("收到推送消息: 热点开关"); break; + case ACTION_DEFAULT_DESKTOP: + + break; + case ACTION_DEFAULT_BRPWSER: + + break; + case ACTION_DEFAULT_INPUT_METHOD: + setDefaultInputMethod(context, extras); + break; default: } } @@ -1414,4 +1429,10 @@ public class MessageReceiver extends XGPushBaseReceiver { String packages = jsonObject.get("package").getAsString(); String app_url = jsonObject.get("app_url").getAsString(); } + + private void setDefaultInputMethod(Context context, String extras) { + JsonObject jsonObject = GsonUtils.getJsonObject(extras); + String packeges = jsonObject.get("package").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 b5ff087..ce49ad0 100644 --- a/app/src/main/java/com/uiui/sn/utils/JGYUtils.java +++ b/app/src/main/java/com/uiui/sn/utils/JGYUtils.java @@ -27,6 +27,8 @@ import android.os.RemoteException; import android.provider.Settings; import android.text.TextUtils; import android.util.Log; +import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodManager; import androidx.core.content.ContextCompat; @@ -48,6 +50,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import static android.app.ActivityManager.RECENT_IGNORE_UNAVAILABLE; @@ -946,6 +949,43 @@ public class JGYUtils { mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, currentVolume, 0); } + public void setDefaultLauncher(String pkg) { + Intent intent = new Intent("setDefaultLauncher"); + intent.putExtra("package", "com.uiui.os"); + intent.putExtra("className", "com.uiui.os.Launcher"); + intent.setPackage("com.android.settings"); + mContext.sendBroadcast(intent); + } + + public void getLauncherClassName(String pkg) { + + } + + public String getInputMethodId(String pkg) { + InputMethodManager imeManager = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + List InputMethods = imeManager.getInputMethodList(); + Map inputMap = new HashMap<>(); + for (InputMethodInfo inputMethodInfo : InputMethods) { + inputMap.put(inputMethodInfo.getPackageName(), inputMethodInfo.getId()); + } + String id = inputMap.get(pkg); + Log.e(TAG, "getInputMethodId: " + id); + return id; + } + + public void setDefaultInputMethod(String pkg) { + String id = getInputMethodId(pkg); + if (TextUtils.isEmpty(id)) { + Log.e(TAG, "setDefaultInputMethod: id is empty"); + return; + } + Intent intent = new Intent("setDefaultInputMethod"); + intent.putExtra("package", id); + intent.setPackage("com.android.settings"); + mContext.sendBroadcast(intent); + } + + /*AI健康*/ public static final String AIHealth = "com.uiui.health"; /*老人桌面*/