【android7.1 默认开启Data saver,同时只打开部分apk】

android7.1 默认开启Data saver,同时只打开部分apk

郑重声明:本人原创博文,都是实战,均经过实际项目验证出货的
转载请标明出处:攻城狮2015

Platform: Rockchip

OS:Android 7.1.2

Kernel: 3.10

问题描述

项目是带有4G模块,然后客户需要最省流量模式,同时只运行指定apk跑流量,其他的apk不允许在后台偷偷跑流量

解决方法

xml 复制代码
废话不多说,直接上补丁
xml 复制代码
b/frameworks/base/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -2211,7 +2211,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
         mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
         synchronized (mUidRulesFirstLock) {
			-            return mRestrictBackground;
			+            return true;//mRestrictBackground;
         }
    }
xml 复制代码
+++ b/frameworks/base/data/etc/platform.xml
@@ -175,6 +175,7 @@
     <!-- These are the standard packages that are white-listed to always have internet
          access while in data mode, even if they aren't in the foreground. -->
     <allow-in-data-usage-save package="com.android.providers.downloads" />
+       <allow-in-data-usage-save package="net.idara.xxxx" />
 
     <!-- These are the packages that are white-listed to be able to run as system user -->
     <system-user-whitelisted-app package="com.android.settings" />
xml 复制代码
+++ b/vendor/partner_gms/etc/sysconfig/google.xml
@@ -21,8 +21,8 @@
 
     <!-- GmsCore must always have network access for GCM and other things. -->
     <allow-in-power-save package="com.google.android.gms" />
-    <allow-in-data-usage-save package="com.google.android.gms" />
-
+    <!--<allow-in-data-usage-save package="com.google.android.gms" />-->
+       <allow-in-data-usage-save package="net.idara.xxxx" />
     <!-- Play Store likewise must have network access to support other applications. -->
     <allow-in-power-save-except-idle package="com.android.vending" />

郑重声明:本人原创博文,都是实战,均经过实际项目验证出货的
转载请标明出处:攻城狮2015
有需要加VX

相关推荐
天空之城--11 小时前
Android逆向安全合规接单指南
android·安全
消失的旧时光-194313 小时前
Android 系统层扫盲 09:AMS、ATMS、WMS、PMS 到底分别管什么?
android·wms·pms·ams·aosp·atms
Godikov13 小时前
Android 系统级设备应用踩坑实录:sharedUserId 签名、SDK 授权失败 -4、开机自启与 U 盘 OTA 升级
android
IT毕设实战小研16 小时前
基于大数据的国内主要农作物产量趋势分析与可视化
android·java·大数据·django·课程设计
企业数字化笔记18 小时前
固定资产历史数据怎么导入系统?Excel模板、字段映射和数据校验
android·java·数据库·后端
龙之叶18 小时前
Android出海系列-GMS认证介绍
android
潮族大Z18 小时前
Android性能优化:启动、内存、卡顿的一站式排查手册
android
事圆则缓20 小时前
从suspend字节码到 Retrofit 协程桥:挂起函数识别与恢复
android·retrofit
杉氧21 小时前
RN 性能调优指南:重渲染(Re-renders)控制与长列表(FlatList)优化
android·前端·react native
Coffeeee21 小时前
claude-video 一个让你的Agent拥有看视频能力的Skill
android·人工智能·aigc