|
@@ -1,20 +1,12 @@
|
|
|
package com.wdkl.ncs.android.component.home.activity
|
|
|
|
|
|
import android.Manifest
|
|
|
-import android.content.BroadcastReceiver
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.content.IntentFilter
|
|
|
-import android.content.pm.PackageManager
|
|
|
import android.graphics.Color
|
|
|
-import android.media.session.MediaSession
|
|
|
-import android.net.wifi.WifiManager
|
|
|
import android.os.Bundle
|
|
|
import android.os.CountDownTimer
|
|
|
-import android.provider.Settings
|
|
|
-import android.support.v4.app.ActivityCompat
|
|
|
-import android.support.v4.content.ContextCompat
|
|
|
-import android.support.v4.media.session.MediaSessionCompat
|
|
|
import android.telephony.PhoneStateListener
|
|
|
import android.telephony.SignalStrength
|
|
|
import android.telephony.TelephonyManager
|
|
@@ -59,7 +51,6 @@ import com.wdkl.ncs.android.middleware.utils.MessageEvent
|
|
|
import com.wdkl.ncs.keepbackground.utils.SpManager
|
|
|
import com.wdkl.ncs.keepbackground.work.DaemonEnv
|
|
|
import io.reactivex.Observable
|
|
|
-import kotlinx.android.synthetic.main.watch_activity_call_records.*
|
|
|
import kotlinx.android.synthetic.main.watch_activity_home2.*
|
|
|
import kotlinx.android.synthetic.main.watch_activity_register.*
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
@@ -118,14 +109,34 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
|
teleManager = (applicationContext.getSystemService(Context.TELEPHONY_SERVICE)) as TelephonyManager
|
|
|
netType = NetHelper.getInstance().getNetworkState(applicationContext)
|
|
|
Log.i(TAG, "网络类型:" + netType)
|
|
|
- if (netType == NetHelper.NETWORK_2G || netType == NetHelper.NETWORK_3G || netType == NetHelper.NETWORK_4G) {
|
|
|
+ /*
|
|
|
+-50 to -79 dBm, then it's generally considered great signal (4 to 5 bars).
|
|
|
+-80 to -89 dBm, then it's generally considered good signal (3 to 4 bars).
|
|
|
+-90 to -99 dBm, then it's generally considered average signal (2 to 3 bars).
|
|
|
+-100 to -109 dBm, then it's generally considered poor signal (1 to 2 bars).
|
|
|
+-110 to -120 dBm, then it's generally considered very poor signal (0 to 1 bar)
|
|
|
+ */
|
|
|
+ if (netType == NetHelper.NETWORK_4G) {
|
|
|
if (teleManager != null) {
|
|
|
teleManager.listen(object : PhoneStateListener() {
|
|
|
override fun onSignalStrengthsChanged(signalStrength: SignalStrength) {
|
|
|
+ val signalinfo = signalStrength.toString()
|
|
|
+ val parts = signalinfo.split(" ".toRegex()).toTypedArray()
|
|
|
+ val ltedbm = parts[9].toInt()
|
|
|
+ if (ltedbm>=-79){
|
|
|
+ tv_signal_strength.text = "网络极好"
|
|
|
+ } else if (ltedbm>=-89 && ltedbm<=-80){
|
|
|
+ tv_signal_strength.text = "网络好"
|
|
|
+ } else if (ltedbm>=-99 && ltedbm<=-90){
|
|
|
+ tv_signal_strength.text = "网络正常"
|
|
|
+ } else if (ltedbm>=-109 && ltedbm<=-100){
|
|
|
+ tv_signal_strength.text = "网络较差"
|
|
|
+ } else if (ltedbm>=-120 && ltedbm<=-110){
|
|
|
+ tv_signal_strength.text = "网络极差"
|
|
|
+ }
|
|
|
+ Log.i(TAG, "网络:LTE 信号强度:$ltedbm======Detail:$signalinfo")
|
|
|
+
|
|
|
super.onSignalStrengthsChanged(signalStrength)
|
|
|
- val asu = signalStrength.gsmSignalStrength
|
|
|
- val lastSignal = -113 + 2 * asu;
|
|
|
- tv_signal_strength.text = "" + lastSignal
|
|
|
}
|
|
|
}, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
|
|
|
}
|
|
@@ -141,6 +152,7 @@ class WatchHome2Activity : BaseActivity<WatchHomeActivityPresenter, WatchActivit
|
|
|
startActivity(intent)
|
|
|
}
|
|
|
DaemonEnv.startServiceSafelyWithData(this, WdKeepAliveService::class.java)
|
|
|
+ presenter.getDeviceVO(Constants.imei)
|
|
|
} else {
|
|
|
requestPermissions()
|
|
|
|