【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

相关推荐
来来走走29 分钟前
Flutter开发 webview_flutter的基本使用
android·flutter
Jerry说前后端1 小时前
Android 组件封装实践:从解耦到架构演进
android·前端·架构
louisgeek2 小时前
Android OkHttp Interceptor
android
大王派来巡山的小旋风2 小时前
Kotlin基本用法三
android·kotlin
Jerry说前后端3 小时前
Android 移动端 UI 设计:前端常用设计原则总结
android·前端·ui
bytebeats3 小时前
Jetpack Compose 1.9: 核心新特性简介
android·android jetpack
Icey_World3 小时前
Mysql笔记-错误条件\处理程序
android
大王派来巡山的小旋风4 小时前
Kotlin基本用法之集合(一)
android·程序员·kotlin
用户2018792831674 小时前
智能广播系统(RemoteCallbackList)的诞生
android
用户2018792831675 小时前
Binder 同应用内(本地)通信是否存在 1MB 大小限制?
android