【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

相关推荐
沐怡旸8 小时前
【底层机制】LeakCanary深度解析:从对象监控到内存泄漏分析的完整技术体系
android·面试
又菜又爱coding8 小时前
Android + Flutter打包出来的APK体积太大
android·flutter
LiuYaoheng8 小时前
【Android】Drawable 基础
android·java
Jerry10 小时前
构建 Compose 界面
android
Y多了个想法10 小时前
Linux驱动开发与Android驱动开发
android·linux·驱动开发
2501_9160074713 小时前
从零开始学习iOS App开发:Xcode、Swift和发布到App Store完整教程
android·学习·ios·小程序·uni-app·iphone·xcode
姝然_952713 小时前
ConstraintLayout属性详解
android
2501_9160088914 小时前
前端工具全景实战指南,从开发到调试的效率闭环
android·前端·小程序·https·uni-app·iphone·webview
浅影歌年15 小时前
Android和h5页面相互传参
android
用户693717500138415 小时前
搞懂 Kotlin 软关键字与硬关键字:灵活命名与语法陷阱全解析
android