【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

相关推荐
三少爷的鞋3 小时前
Java 线程自上而下,Kotlin 协程自下而上
android
好的佩奇5 小时前
Dart 之增强枚举
android·flutter·dart
梦影_5 小时前
MySQL进阶教程(五)—— SQL调优(下)
android·大数据·数据库·后端·sql·mysql·database
好的佩奇8 小时前
蓝牙之无线电与通信距离
android·flutter·蓝牙
vilya8 小时前
我把一套完整的 Python Agent 运行时塞进手机 APK:依赖闭包、Rust 轮子和三个真机坑
android
呆呆敲代码的小Y10 小时前
【实战精选面试题】C# 面试题详细解答,按难易程度排序
android·java·游戏·c#·游戏开发·unity面试题·c#面试题
思想觉悟12 小时前
SEAndroid实战
android·linux·c++
思想觉悟12 小时前
Aosp开发磨刀石之ADB速查
android·c++
应用市场14 小时前
用本机跑的开源音乐模型,给安卓小游戏做 20 秒无缝循环背景音乐
android·python·游戏开发·soundpool·音频处理
企业数字化笔记14 小时前
表单发布前怎么验收?版本引用、字段兼容和历史数据回归
android·数据挖掘·回归