version:2.6 beta

fix:对接推送
add:
This commit is contained in:
2022-07-08 20:29:14 +08:00
parent 2b0872c013
commit c2d0d4b234
2 changed files with 59 additions and 5 deletions

View File

@@ -10,6 +10,8 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.res.Resources; import android.content.res.Resources;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.Environment; import android.os.Environment;
import android.os.Handler; import android.os.Handler;
import android.provider.Settings; import android.provider.Settings;
@@ -55,6 +57,7 @@ import com.uiui.sn.utils.Utils;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -739,12 +742,13 @@ public class MessageReceiver extends XGPushBaseReceiver {
break; break;
case HOT_SPOT: case HOT_SPOT:
ToastUtil.debugShow("收到推送消息: 热点开关"); ToastUtil.debugShow("收到推送消息: 热点开关");
setHotPoint(context, extras);
break; break;
case ACTION_DEFAULT_DESKTOP: case ACTION_DEFAULT_DESKTOP:
setDefaultDesktop(context,extras);
break; break;
case ACTION_DEFAULT_BRPWSER: case ACTION_DEFAULT_BRPWSER:
setDefaultBrowser(context,extras);
break; break;
case ACTION_DEFAULT_INPUT_METHOD: case ACTION_DEFAULT_INPUT_METHOD:
setDefaultInputMethod(context, extras); setDefaultInputMethod(context, extras);
@@ -759,7 +763,6 @@ public class MessageReceiver extends XGPushBaseReceiver {
Settings.System.putInt(context.getContentResolver(), "setting_admin_app", setting_admin_app); Settings.System.putInt(context.getContentResolver(), "setting_admin_app", setting_admin_app);
} }
private void setZenMode(Context context, String extras) { private void setZenMode(Context context, String extras) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras); JsonObject jsonObject = GsonUtils.getJsonObject(extras);
int setting_disturbance = jsonObject.get("setting_disturbance").getAsInt(); 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(); 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) { private void setDefaultInputMethod(Context context, String extras) {
JsonObject jsonObject = GsonUtils.getJsonObject(extras); JsonObject jsonObject = GsonUtils.getJsonObject(extras);
String packeges = jsonObject.get("package").getAsString(); String packeges = jsonObject.get("typewriting_app").getAsString();
JGYUtils.getInstance().setDefaultInputMethod(packeges); JGYUtils.getInstance().setDefaultInputMethod(packeges);
} }
} }