From: snickersun Date: Sun, 19 Jan 2020 08:03:02 +0000 (+0800) Subject: 在SimSignalUtil.java中添加了 airpaln的设置函数,但是逻辑未定,暂时未开启。 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=634cda3517f733dbf2996282a6aad24b799bad8c;p=icsupport.git 在SimSignalUtil.java中添加了 airpaln的设置函数,但是逻辑未定,暂时未开启。 --- diff --git a/app/src/main/java/com/ic/protocol/LocationClient.java b/app/src/main/java/com/ic/protocol/LocationClient.java index 2c1b2119..e9fb3d4b 100644 --- a/app/src/main/java/com/ic/protocol/LocationClient.java +++ b/app/src/main/java/com/ic/protocol/LocationClient.java @@ -140,50 +140,49 @@ public class LocationClient { private static int getMinSignalStrength(int paramInt) { - byte b = -105; + int b = -105; switch (paramInt) { - default: - return -105; - case 2: + case SimSignalUtil.IS_4G: b = -100; break; - case 0: - case 1: + case SimSignalUtil.IS_2G: + case SimSignalUtil.IS_3G: + default: break; } return b; } private void handler2GTo4G() { - int i = this.mSignalUtil.getNetworkType(); - int j = runtime.getSignalStrength(); - long l = SystemClock.elapsedRealtime(); + int networktype = this.mSignalUtil.getNetworkType(); + int singal = runtime.getSignalStrength(); + long currenttime = SystemClock.elapsedRealtime(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("networkType="); - stringBuilder.append(i); + stringBuilder.append(networktype); stringBuilder.append("signalStrength="); - stringBuilder.append(j); + stringBuilder.append(singal); stringBuilder.append("haveChanegTo4G="); stringBuilder.append(this.haveChanegTo4G); Logger.i(stringBuilder.toString()); - switch (i) { + switch (networktype) { default: return; - case 2: - if (j < -93) { + case SimSignalUtil.IS_4G: + if (singal < -93) { this.mSignalUtil.changeNetWorkType("2G"); - this.haveChanegTo4GTime = l; + this.haveChanegTo4GTime = currenttime; return; } return; - case 0: - case 1: + case SimSignalUtil.IS_2G: + case SimSignalUtil.IS_3G: break; } - if (this.haveChanegTo4G || l - this.haveChanegTo4GTime > 43200000L) { + if (this.haveChanegTo4G || currenttime - this.haveChanegTo4GTime > 43200000L) { this.mSignalUtil.changeNetWorkType("4G"); this.haveChanegTo4G = false; - this.haveChanegTo4GTime = l; + this.haveChanegTo4GTime = currenttime; } } //计算运动并发送数据 @@ -234,7 +233,7 @@ public class LocationClient { private void performAlarm(PowerManager.WakeLock paramWakeLock) { if (!runtime.isAirMode) { CellInfoUtil.triggerUpdateCellinfo(); - sendBatteryNotification(); + sendBatteryNotification(); // startLocationProcess(); } } @@ -433,33 +432,36 @@ public void updateCellInfo() { // public void EqcAlgorithmInterfaceMethod6(int paramInt) { // 飞行模式 1 开启 0 关闭 public void setAirMode(int paramInt) { - boolean bool1 = this.mSignalUtil.IsAirModeOn(); - boolean bool2 = this.mSignalUtil.isScreenON(); + boolean isAirModeOn = this.mSignalUtil.IsAirModeOn(); + boolean isScreenOn = this.mSignalUtil.isScreenON(); switch (paramInt) { - default: - return; + case 1: - if (!bool1 && !bool2) { + if (!isAirModeOn && !isScreenOn) { this.mSignalUtil.setAirMode("OpenAirplane"); runtime.isAirMode = true; notifiSetAirModeMethod(); - return; + } - if (bool1) { + if (isAirModeOn) { // EqcAlgorithmNative.native_EqcAlgorithmMethod8(1); - return; - } - return; + + } + break; case 0: - break; - } - if (bool1) { - this.mSignalUtil.setAirMode("CloseAirplane"); - runtime.isAirMode = false; - notifiSetAirModeMethod(); - return; + + if (isAirModeOn) { + this.mSignalUtil.setAirMode("CloseAirplane"); + runtime.isAirMode = false; + notifiSetAirModeMethod(); + return; + } + break; + + default: + break; } -// EqcAlgorithmNative.native_EqcAlgorithmMethod8(0); + } public PowerManager.WakeLock getLocationWakeLock() { diff --git a/app/src/main/java/com/ic/protocol/utils/SimSignalUtil.java b/app/src/main/java/com/ic/protocol/utils/SimSignalUtil.java index bba8afb9..55b5225d 100644 --- a/app/src/main/java/com/ic/protocol/utils/SimSignalUtil.java +++ b/app/src/main/java/com/ic/protocol/utils/SimSignalUtil.java @@ -1,5 +1,6 @@ package com.ic.protocol.utils; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.hardware.display.DisplayManager; @@ -11,6 +12,14 @@ import android.view.Display; import com.ic.protocol.bean.Runtime; import static android.content.Context.POWER_SERVICE; +import static android.telephony.TelephonyManager.NETWORK_TYPE_CDMA; +import static android.telephony.TelephonyManager.NETWORK_TYPE_EDGE; +import static android.telephony.TelephonyManager.NETWORK_TYPE_EVDO_0; +import static android.telephony.TelephonyManager.NETWORK_TYPE_EVDO_A; +import static android.telephony.TelephonyManager.NETWORK_TYPE_GPRS; +import static android.telephony.TelephonyManager.NETWORK_TYPE_HSDPA; +import static android.telephony.TelephonyManager.NETWORK_TYPE_LTE; +import static android.telephony.TelephonyManager.NETWORK_TYPE_UMTS; public class SimSignalUtil { public static final int IS_2G = 0; @@ -64,10 +73,36 @@ public class SimSignalUtil { public int getNetworkType() { init(); - return (this.mNetworkType != 3) ? ((this.mNetworkType == 8) ? 1 : ((this.mNetworkType != 1) ? ((this.mNetworkType == 2) ? 0 : ((this.mNetworkType == 4) ? 0 : ((this.mNetworkType != 5) ? ((this.mNetworkType == 6) ? 1 : ((this.mNetworkType == 13) ? 2 : -1)) : 1))) : 0)) : 1; + int networktype=IS_UNKNOWN; + switch (this.mNetworkType){ + + case NETWORK_TYPE_GPRS: //1 + case NETWORK_TYPE_EDGE: //2 + case NETWORK_TYPE_CDMA://4 + networktype=IS_2G; + break; + case NETWORK_TYPE_UMTS://3 + case NETWORK_TYPE_HSDPA://8 + case NETWORK_TYPE_EVDO_0: //5 + case NETWORK_TYPE_EVDO_A: //6 + networktype=IS_3G; + break; + + case NETWORK_TYPE_LTE: + networktype=IS_4G; + break; + + default: + networktype=IS_UNKNOWN; + break; + } + + return networktype; } - public void init() { this.mNetworkType = ((TelephonyManager)this.context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType(); } + public void init() { + this.mNetworkType = ((TelephonyManager)this.context.getSystemService(Context.TELEPHONY_SERVICE)).getNetworkType(); + } public boolean isScreenON() { // If you use less than API20: @@ -100,10 +135,32 @@ public class SimSignalUtil { ( runtime.getContextProxy()).context.sendBroadcast(intent); Logger.i("send_at_to_update_lbs "); } - public void setAirMode(String paramString) {} - public void setIccCard(boolean on_off){ + public void setAirMode(String paramString) { + + final ContentResolver cr = context.getContentResolver(); + + if ("OpenAirplane".equals(paramString)) + { + if (Settings.System.getString(cr, Settings.System.AIRPLANE_MODE_ON).equals("0")) { + //获取当前飞行模式状态,返回的是String值0,或1.0为关闭飞行,1为开启飞行 + //如果关闭飞行,则打开飞行 + Settings.System.putString(cr, Settings.System.AIRPLANE_MODE_ON, "1"); + Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); + context.sendBroadcast(intent); + } + }else if ("CloseAirplane".equals(paramString)) { + if (Settings.System.getString(cr, Settings.System.AIRPLANE_MODE_ON).equals("1")) { + //获取当前飞行模式状态,返回的是String值0,或1.0为关闭飞行,1为开启飞行 + //如果关闭飞行,则打开飞行 + Settings.System.putString(cr, Settings.System.AIRPLANE_MODE_ON, "0"); + Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED); + context.sendBroadcast(intent); + } + } + } + }