feat(network): 新增应用管控接口与广播兼容适配
- 新增 getIconControl 接口,按禁用/显示清单管理桌面图标 - 应用管控数据与在线禁用数据分开存储 - 新增 ReceiverCompat 统一处理 Android13+ 广播注册导出标志 - 异常捕获交回系统默认处理,移除主线程异常吞没逻辑 - 定位数据存储由 SPUtils 迁移至 MMKV - 修复百度定位 SDK 构造异常及隐私合规声明
This commit is contained in:
@@ -51,7 +51,7 @@ import com.aoleyun.sn.utils.CmdUtil;
|
||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||
import com.aoleyun.sn.utils.JgyUtils;
|
||||
import com.aoleyun.sn.utils.MySQLData;
|
||||
import com.aoleyun.sn.utils.SPUtils;
|
||||
import com.aoleyun.sn.utils.ReceiverCompat;
|
||||
import com.aoleyun.sn.utils.ServiceAliveUtils;
|
||||
import com.aoleyun.sn.utils.SysSettingUtils;
|
||||
import com.aoleyun.sn.utils.TimeUtils;
|
||||
@@ -336,7 +336,7 @@ public class PushManager {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getAppLimit();
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
NetInterfaceManager.getInstance().getIconControl();
|
||||
NetInterfaceManager.getInstance().getDefaultDesktop();
|
||||
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
|
||||
}
|
||||
@@ -378,7 +378,7 @@ public class PushManager {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getAppLimit();
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
NetInterfaceManager.getInstance().getIconControl();
|
||||
NetInterfaceManager.getInstance().getDefaultDesktop();
|
||||
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
|
||||
}
|
||||
@@ -421,7 +421,7 @@ public class PushManager {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
//后台发送时数据库未改变,有时候可能获取到的数据时上一次的
|
||||
Log.e(TAG, "run: HIDE_DESKTOP_ICON ");
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
NetInterfaceManager.getInstance().getIconControl();
|
||||
}, 2000);
|
||||
break;
|
||||
case DISABLE_APP_SLIDE:
|
||||
@@ -457,28 +457,28 @@ public class PushManager {
|
||||
case BDLocation.TypeOffLineLocation:// 离线定位结果
|
||||
Log.e(TAG, "onLocationChanged: " + "定位成功");
|
||||
Log.e(TAG, "onLocationChanged: " + location.getAddrStr() + location.getLocationDescribe());
|
||||
SPUtils.put(mContext, "MapAddress", location.getAddrStr() + location.getLocationDescribe());
|
||||
SPUtils.put(mContext, "longitude", location.getLongitude());
|
||||
SPUtils.put(mContext, "latitude", location.getLatitude());
|
||||
SPUtils.put(mContext, "MapError", "-");
|
||||
mMMKV.encode("MapAddress", location.getAddrStr() + location.getLocationDescribe());
|
||||
mMMKV.encode("longitude", String.valueOf(location.getLongitude()));
|
||||
mMMKV.encode("latitude", String.valueOf(location.getLatitude()));
|
||||
mMMKV.encode("MapError", "-");
|
||||
break;
|
||||
case BDLocation.TypeServerError:
|
||||
Log.e(TAG, "onReceiveLocation: " + "服务端网络定位失败");
|
||||
SPUtils.put(mContext, "MapError", "服务端网络定位失败,可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com,会有人追查原因");
|
||||
mMMKV.encode("MapError", "服务端网络定位失败,可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com,会有人追查原因");
|
||||
break;
|
||||
case BDLocation.TypeNetWorkException:
|
||||
Log.e(TAG, "onReceiveLocation: " + "网络不同导致定位失败,请检查网络是否通畅");
|
||||
SPUtils.put(mContext, "MapError", "网络不同导致定位失败,请检查网络是否通畅");
|
||||
mMMKV.encode("MapError", "网络不同导致定位失败,请检查网络是否通畅");
|
||||
break;
|
||||
case BDLocation.TypeCriteriaException:
|
||||
Log.e(TAG, "onReceiveLocation: " + "无法获取有效定位依据导致定位失败");
|
||||
SPUtils.put(mContext, "MapError", "无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
|
||||
mMMKV.encode("MapError", "无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "MapAddress: " + SPUtils.get(mContext, "MapAddress", "-"));
|
||||
Log.e(TAG, "MapError: " + SPUtils.get(mContext, "MapError", "-"));
|
||||
Log.e(TAG, "MapAddress: " + mMMKV.decodeString("MapAddress", "-"));
|
||||
Log.e(TAG, "MapError: " + mMMKV.decodeString("MapError", "-"));
|
||||
locationClient.stop();
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ public class PushManager {
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "onLocationChanged: " + "定位失败");
|
||||
SPUtils.put(mContext, "MapError", sb);
|
||||
mMMKV.encode("MapError", sb.toString());
|
||||
Log.e(TAG, "onLocDiagnosticMessage: " + sb);
|
||||
}
|
||||
});
|
||||
@@ -783,7 +783,7 @@ public class PushManager {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NetInterfaceManager.getInstance().getDesktopIcon();
|
||||
NetInterfaceManager.getInstance().getIconControl();
|
||||
NetInterfaceManager.getInstance().getDefaultDesktop();
|
||||
NetInterfaceManager.getInstance().getAppAutoStartUpdateAndNet();
|
||||
}
|
||||
@@ -890,7 +890,8 @@ public class PushManager {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
return ((BatteryManager) mContext.getSystemService(Context.BATTERY_SERVICE)).getIntProperty(4);
|
||||
}
|
||||
Intent intent = (new ContextWrapper(mContext)).registerReceiver(null, new IntentFilter("android.intent.action.BATTERY_CHANGED"));
|
||||
Intent intent = ReceiverCompat.registerReceiver(new ContextWrapper(mContext), null,
|
||||
new IntentFilter("android.intent.action.BATTERY_CHANGED"), ReceiverCompat.RECEIVER_NOT_EXPORTED);
|
||||
return intent.getIntExtra("level", -1) * 100 / intent.getIntExtra("scale", -1);
|
||||
}
|
||||
|
||||
@@ -1390,13 +1391,13 @@ public class PushManager {
|
||||
String ebagCode = jsonObject.get("ebagCode").getAsString();
|
||||
if (TextUtils.isEmpty(ebagCode)) {
|
||||
Log.e(TAG, "setEbagCode: " + "ebagCode is empty");
|
||||
SPUtils.put(mContext, "ebagCode", "");
|
||||
mMMKV.encode("ebagCode", "");
|
||||
if (JgyUtils.getInstance().checkAppPlatform() != JgyUtils.YXPD1Platform) {
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ACTIVATIONBEAN_CODE_KEY, "");
|
||||
Settings.Global.putInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 0);
|
||||
}
|
||||
} else {
|
||||
SPUtils.put(mContext, "ebagCode", ebagCode);
|
||||
mMMKV.encode("ebagCode", ebagCode);
|
||||
if (JgyUtils.getInstance().checkAppPlatform() != JgyUtils.YXPD1Platform) {
|
||||
Settings.System.putString(mContext.getContentResolver(), CommonConfig.ACTIVATIONBEAN_CODE_KEY, ebagCode);
|
||||
Settings.Global.putInt(mContext.getContentResolver(), CommonConfig.UIUI_ACTIVATION_KEY, 1);
|
||||
@@ -1483,13 +1484,13 @@ public class PushManager {
|
||||
if (is_log_type == 0) {
|
||||
NetInterfaceManager.getInstance().uploadLogFile();
|
||||
} else {
|
||||
SPUtils.put(mContext, CommonConfig.UPLOAD_LOG_TYPE, 1);
|
||||
mMMKV.encode(CommonConfig.UPLOAD_LOG_TYPE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void getBatteryInfo(Context context) {
|
||||
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||
Intent receiver = context.registerReceiver(null, filter);
|
||||
Intent receiver = ReceiverCompat.registerReceiver(context, null, filter, ReceiverCompat.RECEIVER_NOT_EXPORTED);
|
||||
String jsonString = BatteryUtils.getBatteryJson(context, receiver).toString();
|
||||
Gson gson = new Gson();
|
||||
Type type = new TypeToken<BatteryInfo>() {
|
||||
|
||||
Reference in New Issue
Block a user