|
@@ -482,43 +482,46 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
}
|
|
|
|
|
|
Constants.EVENT_DATA_REFRESH -> { //更新通讯录,更新通话白名单列表
|
|
|
- Thread(Runnable {
|
|
|
- var jsonStr = ""
|
|
|
- val contactVos = ApiManager.API_WatchManageDevice.getWatchContactList(Constants.deviceId).map {
|
|
|
- jsonStr = it.getJsonString()
|
|
|
- val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
- val contactList: List<WatchContactVO> = gson.fromJson(jsonStr, object : TypeToken<List<WatchContactVO>>() {}.type)
|
|
|
- return@map contactList
|
|
|
- }.blockingSingle()
|
|
|
-
|
|
|
- if (contactVos != null && contactVos.size > 0) {
|
|
|
- Log.e(TAG, "222 start update contacts...")
|
|
|
- /*for (contactVO in contactVos) {
|
|
|
- if (!Strings.isNullOrEmpty(contactVO.name) && !Strings.isNullOrEmpty(contactVO.phoneNumber)) {
|
|
|
- ContactHelper.setContact(BaseApplication.appContext, contactVO.name, contactVO.phoneNumber)
|
|
|
- }
|
|
|
- }*/
|
|
|
+ Thread{
|
|
|
+ try {
|
|
|
+ var jsonStr = ""
|
|
|
+ val contactVos = ApiManager.API_WatchManageDevice.getWatchContactList(Constants.deviceId).map {
|
|
|
+ jsonStr = it.getJsonString()
|
|
|
+ val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
+ val contactList: List<WatchContactVO> = gson.fromJson(jsonStr, object : TypeToken<List<WatchContactVO>>() {}.type)
|
|
|
+ return@map contactList
|
|
|
+ }.blockingSingle()
|
|
|
+
|
|
|
+ if (contactVos != null && contactVos.size > 0) {
|
|
|
+ Log.e(TAG, "222 start update contacts...")
|
|
|
+ /*for (contactVO in contactVos) {
|
|
|
+ if (!Strings.isNullOrEmpty(contactVO.name) && !Strings.isNullOrEmpty(contactVO.phoneNumber)) {
|
|
|
+ ContactHelper.setContact(BaseApplication.appContext, contactVO.name, contactVO.phoneNumber)
|
|
|
+ }
|
|
|
+ }*/
|
|
|
|
|
|
- ContactHelper.setContact2(BaseApplication.appContext, contactVos)
|
|
|
- Log.e(TAG, "222 update contacts end...")
|
|
|
- }
|
|
|
+ ContactHelper.setContact2(BaseApplication.appContext, contactVos)
|
|
|
+ Log.e(TAG, "222 update contacts end...")
|
|
|
+ }
|
|
|
|
|
|
- //更新白名单列表
|
|
|
- val whiteList = ApiManager.API_WatchManageDevice.getPhoneWhiteList(Constants.deviceId).map {
|
|
|
- jsonStr = it.getJsonString()
|
|
|
- val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
- val whiteList: List<String> = gson.fromJson(jsonStr, object : TypeToken<List<String>>() {}.type)
|
|
|
- return@map whiteList
|
|
|
- }.blockingSingle()
|
|
|
+ //更新白名单列表
|
|
|
+ val whiteList = ApiManager.API_WatchManageDevice.getPhoneWhiteList(Constants.deviceId).map {
|
|
|
+ jsonStr = it.getJsonString()
|
|
|
+ val gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
+ val whiteList: List<String> = gson.fromJson(jsonStr, object : TypeToken<List<String>>() {}.type)
|
|
|
+ return@map whiteList
|
|
|
+ }.blockingSingle()
|
|
|
|
|
|
|
|
|
- if (whiteList != null && whiteList.size > 0) {
|
|
|
- Constants.phoneWhiteList.clear()
|
|
|
- Constants.phoneWhiteList.addAll(whiteList)
|
|
|
+ if (whiteList != null && whiteList.size > 0) {
|
|
|
+ Constants.phoneWhiteList.clear()
|
|
|
+ Constants.phoneWhiteList.addAll(whiteList)
|
|
|
+ }
|
|
|
+ } catch (ex: Exception) {
|
|
|
+ ex.printStackTrace()
|
|
|
}
|
|
|
|
|
|
- }).start()
|
|
|
-
|
|
|
+ }.start()
|
|
|
|
|
|
}
|
|
|
|
|
@@ -958,6 +961,11 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
}
|
|
|
//通话中或者某些特定界面不响应耳机按键留言,未绑定用户时也不响应按键
|
|
|
else if (!DeviceChannel.calling && Constants.allowVoiceMsg && !TextUtils.isEmpty(Constants.userName)) {
|
|
|
+ //小米Android 11手机需要亮屏后才能录音
|
|
|
+ if ("Redmi".equals(Build.BRAND)) {
|
|
|
+ Util.wakeUpAndUnlock()
|
|
|
+ }
|
|
|
+
|
|
|
if (Constants.channelId == -1) {
|
|
|
showMessage(R.string.str_im_no_channel)
|
|
|
} else {
|