//网络类型
public MutableLiveData<String> networkTypeValue = new MutableLiveData<>();
//未佩戴状态
- public MutableLiveData<Boolean> wearState = new MutableLiveData<>();
+ public MutableLiveData<Boolean> wearStateValue = new MutableLiveData<>();
+ //剪断状态
+ public MutableLiveData<Boolean> cutStateValue = new MutableLiveData<>();
private Handler handler;
private TelephonyManager mTelephony;
}
//获取佩戴状态
getWearState();
+ getCutState();
getConnectionState();
handler.postDelayed(this, 3000);
}
}
private void getWearState() {
- boolean isAntiOff = SystemUtils.getSystemPropertiesBoolean("persist.sys.ic_antioff",
- false);
- if (isAntiOff) {
+ String isAntiOff = SystemUtils.getSystemPropertiesString("persist.sys.ic_antioff", "");
+ ICLogger.d("isAntiOff ==> " + isAntiOff);
+ if ("true".equals(isAntiOff)) {
//未佩戴
- wearState.postValue(Boolean.FALSE);
+ wearStateValue.postValue(Boolean.FALSE);
+ } else {
+ wearStateValue.postValue(Boolean.TRUE);
+ }
+ }
+
+ private void getCutState() {
+ String isAntiOff = SystemUtils.getSystemPropertiesString("persist.sys.ic_cutoff", "");
+ ICLogger.d("isAntiOff ==> " + isAntiOff);
+ if ("true".equals(isAntiOff)) {
+ //剪断了
+ cutStateValue.postValue(Boolean.TRUE);
} else {
- wearState.postValue(Boolean.TRUE);
+ cutStateValue.postValue(Boolean.FALSE);
}
}
}
- public static String getSystemPropertiesString(String prop, String defaultvlaue){
- String ret=defaultvlaue;
+ public static String getSystemPropertiesString(String prop, String defaultValue){
+ String ret=defaultValue;
String temp=getSystemProperties(prop);
if (!temp.trim().isEmpty()){
ret = temp;
}
return ret;
}
- public static boolean getSystemPropertiesBoolean(String prop, boolean defaultvlaue){
+ public static boolean getSystemPropertiesBoolean(String prop, boolean defaultValue){
- boolean ret=defaultvlaue;
+ boolean ret=defaultValue;
String temp=getSystemProperties(prop);
if (!temp.trim().isEmpty()){
if( temp.trim().equals("true")) {
//是否有未接电话
phoneView.setVisibility(hasMiss == Boolean.TRUE ? VISIBLE : GONE);
});
- statusBarPresenter.wearState.observe(lifecycleOwner, hasWear -> {
+ statusBarPresenter.wearStateValue.observe(lifecycleOwner, hasWear -> {
//是否有穿戴
+ wearView.setVisibility(hasWear == Boolean.TRUE ? GONE : VISIBLE);
+ });
+ statusBarPresenter.cutStateValue.observe(lifecycleOwner, hasWear -> {
+ //是否剪断,如果没有剪断,则会显示图标,如果剪断了,那么就没有图标了
wearView.setVisibility(hasWear == Boolean.TRUE ? VISIBLE : GONE);
});
statusBarPresenter.msgUnReadState.observe(lifecycleOwner, hasRead -> {