private void setupSignalStrength() {
final TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
final ImageView signalIcon = ((ImageView) statusBar.findViewById(R.id.signal_icon));
phoneListener = new PhoneStateListener() {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (manager.getNetworkOperator().equals("")) {
signalIcon.setVisibility(View.GONE);
} else {
signalIcon.setVisibility(View.VISIBLE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// See https://github.com/AlstonLin/TheLearningLock/issues/54
Integer imageRes = signalStrengthToIcon.get(signalStrength.getLevel());
if (imageRes != null) signalIcon.setImageResource(imageRes);
else signalIcon.setImageResource(signalStrengthToIcon.get(4));
} else {
// Just show the full icon
signalIcon.setImageResource(signalStrengthToIcon.get(4));
}
}
}
};
manager.listen(phoneListener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
java类android.telephony.SignalStrength的实例源码
StatusBar.java 文件源码
项目:TheLearningLock
阅读 22
收藏 0
点赞 0
评论 0
CellTracker.java 文件源码
项目:AIMSICDL
阅读 19
收藏 0
点赞 0
评论 0
/**
* Description: TODO: add more info
*
* Issues:
*
* [ ] Getting and comparing signal strengths between different RATs can be very
* tricky, since they all return different ranges of values. AOS doesn't
* specify very clearly what exactly is returned, even though people have
* a good idea, by trial and error.
*
* See note in : SignalStrengthTracker.java
*
* Notes:
*
*
*
*/
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// Update Signal Strength
if (signalStrength.isGsm()) {
int dbm;
if (signalStrength.getGsmSignalStrength() <= 2 ||
signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
// Unknown signal strength, get it another way
String[] bits = signalStrength.toString().split(" ");
dbm = Integer.parseInt(bits[9]);
} else {
dbm = signalStrength.getGsmSignalStrength();
}
mDevice.setSignalDbm(dbm);
} else {
int evdoDbm = signalStrength.getEvdoDbm();
int cdmaDbm = signalStrength.getCdmaDbm();
// Use lowest signal to be conservative
mDevice.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
}
// Send it to signal tracker
signalStrengthTracker.registerSignalStrength(mDevice.mCell.getCID(), mDevice.getSignalDBm());
//signalStrengthTracker.isMysterious(mDevice.mCell.getCID(), mDevice.getSignalDBm());
}
TelephonyModule.java 文件源码
项目:react-native-telephony
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void phoneSignalStrengthsUpdated(SignalStrength signalStrength) {
WritableMap map = Arguments.createMap();
map.putInt("cdmaDbm", signalStrength.getCdmaDbm());
map.putInt("cdmaEcio()", signalStrength.getCdmaEcio());
map.putInt("evdoDbm", signalStrength.getEvdoDbm());
map.putInt("evdoEcio", signalStrength.getEvdoEcio());
map.putInt("evdoSnr", signalStrength.getEvdoSnr());
map.putInt("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
map.putInt("gsmSignalStrength", signalStrength.getGsmSignalStrength());
map.putBoolean("gsm", signalStrength.isGsm());
WritableMap result = Arguments.createMap();
result.putString("type", "LISTEN_SIGNAL_STRENGTHS");
result.putMap("data", map);
sendEvent(PHONE_STATE_LISTENER, result);
}
SignalStrengthPresenter.java 文件源码
项目:microbit
阅读 20
收藏 0
点赞 0
评论 0
private void updateSignalStrength(SignalStrength signalStrength) {
final int level;
Log.i(TAG, "updateSignalStrength: ");
if(!isCdma(signalStrength)) {
int asu = signalStrength.getGsmSignalStrength();
// ASU ranges from 0 to 31 - TS 27.007 Sec 8.5
// asu = 0 (-113dB or less) is very weak
// signal, its better to show 0 bars to the user in such cases.
// asu = 99 is a special case, where the signal strength is unknown.
if(asu <= 2 || asu == 99) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_NO_BAR;
else if(asu >= 12) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_FOUR_BAR;
else if(asu >= 8) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_THREE_BAR;
else if(asu >= 5) level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_TWO_BAR;
else level = EventSubCodes.SAMSUNG_SIGNAL_STRENGTH_EVT_ONE_BAR;
} else {
level = getCdmaLevel(signalStrength);
}
if(level != sCurrentSignalStrength) {
sCurrentSignalStrength = level;
MBApp application = MBApp.getApp();
Intent intent = new Intent(application, IPCService.class);
intent.putExtra(IPCConstants.INTENT_TYPE, EventCategories.IPC_BLE_NOTIFICATION_CHARACTERISTIC_CHANGED);
intent.putExtra(IPCConstants.INTENT_CHARACTERISTIC_MESSAGE, Utils.makeMicroBitValue
(EventCategories.SAMSUNG_SIGNAL_STRENGTH_ID, level));
application.startService(intent);
}
}
SignalStrengthPresenter.java 文件源码
项目:microbit
阅读 19
收藏 0
点赞 0
评论 0
private int getCdmaLevel(SignalStrength signalStrength) {
final int cdmaDbm = signalStrength.getCdmaDbm();
final int cdmaEcio = signalStrength.getCdmaEcio();
final int levelDbm;
if(cdmaDbm >= -75) levelDbm = 4;
else if(cdmaDbm >= -85) levelDbm = 3;
else if(cdmaDbm >= -95) levelDbm = 2;
else if(cdmaDbm >= -100) levelDbm = 1;
else levelDbm = 0;
final int levelEcio;
// Ec/Io are in dB*10
if(cdmaEcio >= -90) levelEcio = 4;
else if(cdmaEcio >= -110) levelEcio = 3;
else if(cdmaEcio >= -130) levelEcio = 2;
else if(cdmaEcio >= -150) levelEcio = 1;
else levelEcio = 0;
return (levelDbm < levelEcio) ? levelDbm : levelEcio;
}
CellTracker.java 文件源码
项目:Android-IMSI-Catcher-Detector
阅读 22
收藏 0
点赞 0
评论 0
/**
* Description: TODO: add more info
*
* Issues:
*
* [ ] Getting and comparing signal strengths between different RATs can be very
* tricky, since they all return different ranges of values. AOS doesn't
* specify very clearly what exactly is returned, even though people have
* a good idea, by trial and error.
*
* See note in : SignalStrengthTracker.java
*/
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// Update Signal Strength
if (signalStrength.isGsm()) {
int dbm;
if (signalStrength.getGsmSignalStrength() <= 2 ||
signalStrength.getGsmSignalStrength() == NeighboringCellInfo.UNKNOWN_RSSI) {
// Unknown signal strength, get it another way
String[] bits = signalStrength.toString().split(" ");
dbm = Integer.parseInt(bits[9]);
} else {
dbm = signalStrength.getGsmSignalStrength();
}
device.setSignalDbm(dbm);
} else {
int evdoDbm = signalStrength.getEvdoDbm();
int cdmaDbm = signalStrength.getCdmaDbm();
// Use lowest signal to be conservative
device.setSignalDbm((cdmaDbm < evdoDbm) ? cdmaDbm : evdoDbm);
}
// Send it to signal tracker
signalStrengthTracker.registerSignalStrength(device.cell.getCellId(), device.getSignalDBm());
//signalStrengthTracker.isMysterious(device.cell.getCid(), device.getSignalDBm());
}
SignalStrengths.java 文件源码
项目:SignalStrengths
阅读 16
收藏 0
点赞 0
评论 0
public static double getFirstValid(SignalStrength signalStrength) {
for (SignalMethod method : methods) {
if (method.isExcluded()) continue;
double level;
try {
level = method.getLevel(signalStrength);
} catch (Exception e) {
continue;
}
if (SignalUtils.isValidLevel(level) && level > 0)
return level;
}
return 0;
}
DeviceInfoActivty.java 文件源码
项目:PracticeDemo
阅读 41
收藏 0
点赞 0
评论 0
/**
* signalStrength.isGsm() 是否GSM信号 2G or 3G
* signalStrength.getCdmaDbm(); 联通3G 信号强度
* signalStrength.getCdmaEcio(); 联通3G 载干比
* signalStrength.getEvdoDbm(); 电信3G 信号强度
* signalStrength.getEvdoEcio(); 电信3G 载干比
* signalStrength.getEvdoSnr(); 电信3G 信噪比
* signalStrength.getGsmSignalStrength(); 2G 信号强度
* signalStrength.getGsmBitErrorRate(); 2G 误码率
* 载干比 ,它是指空中模拟电波中的信号与噪声的比值
*/
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
Log.d(TAG, "onSignalStrengthsChanged() called with " + "signalStrength :"+signalStrength+";\n gsmSignalStrength = [" + signalStrength.getGsmSignalStrength() + "]");
// if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
// mTvSignalInfo.setText("GSM Strength" + signalStrength.getGsmSignalStrength());
// } else if (mTelephonyManager.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA) {
// mTvSignalInfo.setText("CDMA Strength" + signalStrength.getCdmaDbm() + " dBm");
// } else {
// mTvSignalInfo.setText("Unknown PhoneType: " + mTelephonyManager.getPhoneType());
// }
mTvSignalInfo.setText("IsGsm : " + signalStrength.isGsm() +
"\nCDMA Dbm : " + signalStrength.getCdmaDbm() + " Dbm" +
"\nCDMA Ecio : " + signalStrength.getCdmaEcio() + " dB*10" +
"\nEvdo Dbm : " + signalStrength.getEvdoDbm() + " Dbm" +
"\nEvdo Ecio : " + signalStrength.getEvdoEcio() + " dB*10" +
"\nGsm SignalStrength : " + signalStrength.getGsmSignalStrength() +
"\nGsm BitErrorRate : " + signalStrength.getGsmBitErrorRate());
}
SignalStrengthSensor.java 文件源码
项目:swan-sense-studio
阅读 19
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
long now = System.currentTimeMillis();
if (signalStrength.isGsm()) {
Log.d(TAG,
"GSM Signal Strength: "
+ signalStrength.getGsmSignalStrength() + ", "
+ signalStrength.getGsmBitErrorRate());
} else {
Log.d(TAG,
"CDMA Signal Strength: " + signalStrength.getCdmaDbm()
+ ", " + signalStrength.getCdmaEcio());
}
putValueTrimSize(IS_GSM_FIELD, null, now, signalStrength.isGsm());
putValueTrimSize(GSM_SIGNAL_STRENGTH_FIELD, null, now, signalStrength.getGsmSignalStrength());
putValueTrimSize(GSM_BIT_ERROR_RATE_FIELD, null, now, signalStrength.getGsmBitErrorRate());
putValueTrimSize(CDMA_DBM_FIELD, null, now, signalStrength.getCdmaDbm());
putValueTrimSize(CDMA_ECIO_FIELD, null, now, signalStrength.getCdmaEcio());
putValueTrimSize(EVDO_DBM_FIELD, null, now, signalStrength.getEvdoDbm());
putValueTrimSize(EVDO_ECIO_FIELD, null, now, signalStrength.getEvdoEcio());
putValueTrimSize(EVDO_SNR_FIELD, null, now, signalStrength.getEvdoSnr());
}
SignalStrengthSensor.java 文件源码
项目:swan_sense_integration
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
long now = System.currentTimeMillis();
if (signalStrength.isGsm()) {
Log.d(TAG,
"GSM Signal Strength: "
+ signalStrength.getGsmSignalStrength() + ", "
+ signalStrength.getGsmBitErrorRate());
} else {
Log.d(TAG,
"CDMA Signal Strength: " + signalStrength.getCdmaDbm()
+ ", " + signalStrength.getCdmaEcio());
}
putValueTrimSize(IS_GSM_FIELD, null, now, signalStrength.isGsm());
putValueTrimSize(GSM_SIGNAL_STRENGTH_FIELD, null, now, signalStrength.getGsmSignalStrength());
putValueTrimSize(GSM_BIT_ERROR_RATE_FIELD, null, now, signalStrength.getGsmBitErrorRate());
putValueTrimSize(CDMA_DBM_FIELD, null, now, signalStrength.getCdmaDbm());
putValueTrimSize(CDMA_ECIO_FIELD, null, now, signalStrength.getCdmaEcio());
putValueTrimSize(EVDO_DBM_FIELD, null, now, signalStrength.getEvdoDbm());
putValueTrimSize(EVDO_ECIO_FIELD, null, now, signalStrength.getEvdoEcio());
putValueTrimSize(EVDO_SNR_FIELD, null, now, signalStrength.getEvdoSnr());
}
FirstActivity.java 文件源码
项目:Testes
阅读 40
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
Log.i(TAG, "onSignalStrengthsChanged" + signalStrength);
// if(Build.VERSION.SDK_INT>=18){
// if(signalStrength instanceof SignalStrength){
// Log.i("LOG_TAG", "onSignalStrengthsChanged: getcdaRscp" + signalStrength.getDbm());
// int ttt = signalStrength.getDbm();
// text1.setText(String.valueOf(ttt));
// }
// else{
Log.i(TAG, "onSignalStrengthsChanged: getcda dbm: " + signalStrength.getCdmaDbm());
int ttt = signalStrength.getCdmaDbm();
text1.setText(String.valueOf(ttt));
// }
// }
}
CellTowersDataCollector.java 文件源码
项目:skandroid-core
阅读 20
收藏 0
点赞 0
评论 0
synchronized static void sOnSignalStrengthsChanged(SignalStrength signalStrength) {
mData.setTime(System.currentTimeMillis());
mData.setSignal(signalStrength);
if (OtherUtils.isThisDeviceAnEmulator() == true) {
// The signal will usuaully be null on the Emulator...
} else {
// On a real device... there should generally be a signal...
SKPorting.sAssert(CellTowersDataCollector.class, mData.getSignal() != null);
}
try {
mData.setCellLocation(mTelManager.getCellLocation());
} catch (SecurityException e) {
// Seen - rarely - on some Android devices.
// Neither user 99999 nor current process has android.permission.ACCESS_COARSE_LOCATION.
SKPorting.sAssert(CellTowersDataCollector.class, false);
}
}
JSONHelper.java 文件源码
项目:localcloud_fe
阅读 19
收藏 0
点赞 0
评论 0
/**
* Originates from a change in signal strength
* @param signalStrength SignalStrength
* @return JSON
*/
public static String signalStrengthJSON(SignalStrength signalStrength){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
try {
json.put("provider", SIGNAL_STRENGTH); // Yep provider and type are same values
json.put("type", SIGNAL_STRENGTH);
json.put("timestamp", calendar.getTimeInMillis());
json.put("cdmaDbm", signalStrength.getCdmaDbm());
json.put("cdmaEcio", signalStrength.getCdmaEcio());
json.put("evdoDbm", signalStrength.getEvdoDbm());
json.put("evdoEcio", signalStrength.getEvdoEcio());
json.put("evdoSnr", signalStrength.getEvdoSnr());
json.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
json.put("gsmSignalStrength", signalStrength.getGsmSignalStrength());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
json.put("level", signalStrength.getLevel());
}
json.put("isGSM", signalStrength.isGsm());
}
catch(JSONException exc) {
logJSONException(exc);
}
return json.toString();
}
JSONHelper.java 文件源码
项目:localcloud_fe
阅读 25
收藏 0
点赞 0
评论 0
/**
* Originates from a change in signal strength
* @param signalStrength SignalStrength
* @return JSON
*/
public static String signalStrengthJSON(SignalStrength signalStrength){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
try {
json.put("provider", SIGNAL_STRENGTH); // Yep provider and type are same values
json.put("type", SIGNAL_STRENGTH);
json.put("timestamp", calendar.getTimeInMillis());
json.put("cdmaDbm", signalStrength.getCdmaDbm());
json.put("cdmaEcio", signalStrength.getCdmaEcio());
json.put("evdoDbm", signalStrength.getEvdoDbm());
json.put("evdoEcio", signalStrength.getEvdoEcio());
json.put("evdoSnr", signalStrength.getEvdoSnr());
json.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
json.put("gsmSignalStrength", signalStrength.getGsmSignalStrength());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
json.put("level", signalStrength.getLevel());
}
json.put("isGSM", signalStrength.isGsm());
}
catch(JSONException exc) {
logJSONException(exc);
}
return json.toString();
}
JSONHelper.java 文件源码
项目:localcloud_fe
阅读 22
收藏 0
点赞 0
评论 0
/**
* Originates from a change in signal strength
* @param signalStrength SignalStrength
* @return JSON
*/
public static String signalStrengthJSON(SignalStrength signalStrength){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
try {
json.put("provider", SIGNAL_STRENGTH); // Yep provider and type are same values
json.put("type", SIGNAL_STRENGTH);
json.put("timestamp", calendar.getTimeInMillis());
json.put("cdmaDbm", signalStrength.getCdmaDbm());
json.put("cdmaEcio", signalStrength.getCdmaEcio());
json.put("evdoDbm", signalStrength.getEvdoDbm());
json.put("evdoEcio", signalStrength.getEvdoEcio());
json.put("evdoSnr", signalStrength.getEvdoSnr());
json.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
json.put("gsmSignalStrength", signalStrength.getGsmSignalStrength());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
json.put("level", signalStrength.getLevel());
}
json.put("isGSM", signalStrength.isGsm());
}
catch(JSONException exc) {
logJSONException(exc);
}
return json.toString();
}
SignalStrengthPresenter.java 文件源码
项目:microbit
阅读 24
收藏 0
点赞 0
评论 0
private boolean isCdma(SignalStrength signalStrength) {
return (signalStrength != null) && !signalStrength.isGsm();
}
t.java 文件源码
项目:boohee_v5.6
阅读 20
收藏 0
点赞 0
评论 0
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (this.a.dX == null) {
return;
}
if (this.a.dX.new == 'g') {
this.a.dX.int = signalStrength.getGsmSignalStrength();
} else if (this.a.dX.new == 'c') {
this.a.dX.int = signalStrength.getCdmaDbm();
}
}
JSONHelper.java 文件源码
项目:cordova-plugin-advanced-geolocation
阅读 29
收藏 0
点赞 0
评论 0
/**
* Originates from a change in signal strength
* @param signalStrength SignalStrength
* @return JSON
*/
public static String signalStrengthJSON(SignalStrength signalStrength){
final Calendar calendar = Calendar.getInstance();
final JSONObject json = new JSONObject();
try {
json.put("provider", SIGNAL_STRENGTH); // Yep provider and type are same values
json.put("type", SIGNAL_STRENGTH);
json.put("timestamp", calendar.getTimeInMillis());
json.put("cdmaDbm", signalStrength.getCdmaDbm());
json.put("cdmaEcio", signalStrength.getCdmaEcio());
json.put("evdoDbm", signalStrength.getEvdoDbm());
json.put("evdoEcio", signalStrength.getEvdoEcio());
json.put("evdoSnr", signalStrength.getEvdoSnr());
json.put("gsmBitErrorRate", signalStrength.getGsmBitErrorRate());
json.put("gsmSignalStrength", signalStrength.getGsmSignalStrength());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
json.put("level", signalStrength.getLevel());
}
json.put("isGSM", signalStrength.isGsm());
}
catch(JSONException exc) {
logJSONException(exc);
}
return json.toString();
}
DualNetworkIconData.java 文件源码
项目:Status
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
if (isRegistered) {
int level = signalStrength.getGsmSignalStrength();
if (level > 4) level /= 7.75;
else if (level < 1) {
int strength = signalStrength.getCdmaDbm();
if (strength < -100) level = 0;
else if (strength < -95) level = 1;
else if (strength < -85) level = 2;
else if (strength < -75) level = 3;
else if (strength != 0) level = 4;
else {
strength = signalStrength.getEvdoDbm();
if (strength == 0 || strength < -100) level = 0;
else if (strength < -95) level = 1;
else if (strength < -85) level = 2;
else if (strength < -75) level = 3;
else level = 4;
}
}
onDrawableUpdate(level);
}
}
NetworkIconData.java 文件源码
项目:Status
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
NetworkIconData icon = null;
if (reference != null) icon = reference.get();
if (icon != null && icon.isRegistered)
icon.onDrawableUpdate((int) Math.round(SignalStrengths.getFirstValid(signalStrength)));
}
SignalStrengthSubject.java 文件源码
项目:truth-android
阅读 21
收藏 0
点赞 0
评论 0
public static SubjectFactory<SignalStrengthSubject, SignalStrength> type() {
return new SubjectFactory<SignalStrengthSubject, SignalStrength>() {
@Override
public SignalStrengthSubject getSubject(FailureStrategy fs, SignalStrength that) {
return new SignalStrengthSubject(fs, that);
}
};
}
LegacyMeasurementProcessingEvent.java 文件源码
项目:TowerCollector
阅读 24
收藏 0
点赞 0
评论 0
public LegacyMeasurementProcessingEvent(Location lastLocation, long lastLocationObtainedTime,
CellLocation lastCellLocation, SignalStrength lastSignalStrength, NetworkGroup lastNetworkType,
String lastOperatorCode, String lastOperatorName, List<NeighboringCellInfo> neighboringCells,
int minDistance) {
this.lastLocation = lastLocation;
this.lastLocationObtainedTime = lastLocationObtainedTime;
this.lastCellLocation = lastCellLocation;
this.lastSignalStrength = lastSignalStrength;
this.lastNetworkType = lastNetworkType;
this.neighboringCells = neighboringCells;
this.lastOperatorCode = lastOperatorCode;
this.lastOperatorName = lastOperatorName;
this.minDistance = minDistance;
}
SignalStrengths.java 文件源码
项目:SignalStrengths
阅读 19
收藏 0
点赞 0
评论 0
public static double get(String methodName, SignalStrength signalStrength) {
for (SignalMethod method : methods) {
if (methodName.equals(method.getName()))
try {
return method.getLevel(signalStrength);
} catch (Exception e) {
e.printStackTrace();
break;
}
}
return 0;
}
SignalListener.java 文件源码
项目:dash-api
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
int percent = 0;
if(signalStrength != null && signalStrength.getGsmSignalStrength() != UNKNOWN_CODE) {
percent = calculateSignalStrengthInPercent(signalStrength.getGsmSignalStrength());
} else {
Log.e(TAG, "Unable to get phone signal strength!");
}
onPercentKnown(percent);
}
RadioInfo.java 文件源码
项目:CellularSignal
阅读 21
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
//Log.e(Tag, signalStrength.toString());
get_Reflection_Method(signalStrength);
try {
Method getLteRsrp = signalStrength.getClass().getDeclaredMethod("getLteRsrp");
getLteRsrp.setAccessible(true);
lte_RSRP = (int) getLteRsrp.invoke(signalStrength);
Method getLteRsrq = signalStrength.getClass().getDeclaredMethod("getLteRsrq");
getLteRsrq.setAccessible(true);
lte_RSRQ = (int) getLteRsrq.invoke(signalStrength);
Method getLteRssnr = signalStrength.getClass().getDeclaredMethod("getLteRssnr");
getLteRssnr.setAccessible(true);
lte_SINR = (int) getLteRssnr.invoke(signalStrength);
cdma_RxPwr = signalStrength.getCdmaDbm();
cdma_EcIo = signalStrength.getCdmaEcio();
gsm_RSSI = signalStrength.getGsmSignalStrength();
getWcdmaSignalStrength();
((MainActivity)mcontext).mSectionsPagerAdapter.notifyDataSetChanged();
} catch (Exception e) {
e.printStackTrace();
}
getCellIdentity();
}
MainActivity.java 文件源码
项目:mobility-logger
阅读 17
收藏 0
点赞 0
评论 0
private void updateSignalStrengths(SignalStrength signalStrength){
/** Current cell */
TextView cellSignalStrength_Asu_dBm = (TextView)findViewById(R.id.cellsignalstrength_Asu_dBm);
TextView cellBitErrorRate = (TextView)findViewById(R.id.cellbiterrorrate);
if (signalStrength!=null){
int asu = signalStrength.getGsmSignalStrength();
cellSignalStrength_Asu_dBm.setText(String.valueOf(asu)+"/"+String.valueOf(-113+(2*asu)));
cellBitErrorRate.setText(String.valueOf(signalStrength.getGsmBitErrorRate()));
} else {
cellSignalStrength_Asu_dBm.setText("NA/NA");
cellBitErrorRate.setText("NA");
}
}
SignalListener.java 文件源码
项目:batteryhub
阅读 16
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// TODO Auto-generated method stub
super.onSignalStrengthsChanged(signalStrength);
gsmSignal = signalStrength.getGsmSignalStrength();
cdmaDbm = signalStrength.getCdmaDbm();
evdoDbm = signalStrength.getEvdoDbm();
}
MobileNetActivity.java 文件源码
项目:iTester
阅读 20
收藏 0
点赞 0
评论 0
private void initUI()
{
tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
tv_mobile = (TextView)findViewById(R.id.textView_mobile);
tv_mobile.setTextColor(Color.RED);
tv_mobile.setTextSize(30);
findViewById(R.id.button_pass).setOnClickListener(this);
findViewById(R.id.button_fail).setOnClickListener(this);
findViewById(R.id.button_pass).setEnabled(false);
updateViews(tm);
//����SIM��״̬��������Ϣ��ʱ�����ܷ����仯�������Ҫע��PhoneStateListener
//��ʵʱ���½�����ʾ����Ϣ��������������¼���LISTEN_SERVICE_STATE��LISTEN_DATA_CONNECTION_STATE
//���Ƿֱ��Ӧ�ص�����onServiceStateChanged��onDataConnectionStateChanged
tm.listen(new PhoneStateListener() {
@Override
public void onDataConnectionStateChanged(int state, int networkType) {
//��������״̬�ı���ܵ����������͵ĸı�
updateViews(tm);
}
@Override
public void onServiceStateChanged(ServiceState serviceState) {
updateViews(tm);
}
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
// TODO Auto-generated method stub
Stren=String.valueOf(-113+2*signalStrength.getGsmSignalStrength())+" dBm "+String.valueOf(signalStrength.getGsmSignalStrength())+" asu";
updateViews(tm);
super.onSignalStrengthsChanged(signalStrength);
}
}, PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_DATA_CONNECTION_STATE|PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
CellBackendHelper.java 文件源码
项目:android_external_UnifiedNlpApi
阅读 19
收藏 0
点赞 0
评论 0
/**
* Call this in {@link org.microg.nlp.api.LocationBackendService#onOpen()}.
*/
@Override
public synchronized void onOpen() {
super.onOpen();
if (phoneStateListener == null) {
Handler mainHandler = new Handler(context.getMainLooper());
mainHandler.post(new Runnable() {
@Override
public void run() {
phoneStateListener = new PhoneStateListener() {
@Override
public void onCellInfoChanged(List<CellInfo> cellInfo) {
if (cellInfo != null && !cellInfo.isEmpty()) {
onCellsChanged(cellInfo);
} else if (supportsCellInfoChanged) {
supportsCellInfoChanged = false;
onSignalStrengthsChanged(null);
}
}
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (!supportsCellInfoChanged) {
fallbackScan();
}
}
};
registerPhoneStateListener();
}
});
} else {
registerPhoneStateListener();
}
}
DeviceNetworkStatus.java 文件源码
项目:product-emm
阅读 22
收藏 0
点赞 0
评论 0
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
super.onSignalStrengthsChanged(signalStrength);
if (signalStrength.isGsm()) {
if (signalStrength.getGsmSignalStrength() != 99) {
// this is the equation used to convert a valid gsm signal to dbm.
setCellSignalStrength(signalStrength.getGsmSignalStrength() * 2 - 113);
} else {
setCellSignalStrength(signalStrength.getGsmSignalStrength());
}
} else {
setCellSignalStrength(signalStrength.getCdmaDbm());
}
}