From d8fed88f2d87e90670251a7dd8d535a7d0000f12 Mon Sep 17 00:00:00 2001 From: Aaron Huang Date: Thu, 29 Jul 2021 14:39:27 +0800 Subject: [PATCH] Use bindServiceAsUser to bind PacService and ProxyService PacService and ProxyService should be running on system user. Use bindServiceAsUser with UserHandle.SYSTEM to start the services. Bug: 192114565 Test: CtsNetTestCases:PacProxyManagerTest on target aosp_cf_x86_auto Change-Id: I88d1bfa1e482a072674f0b96dda027aa1f92d93f --- .../android/server/connectivity/PacProxyService.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/PacProxyService.java b/services/core/java/com/android/server/connectivity/PacProxyService.java index 00703390a1184..7d0b0ab2f11e8 100644 --- a/services/core/java/com/android/server/connectivity/PacProxyService.java +++ b/services/core/java/com/android/server/connectivity/PacProxyService.java @@ -34,7 +34,6 @@ import android.net.ProxyInfo; import android.net.TrafficStats; import android.net.Uri; import android.os.Handler; -import android.os.HandlerExecutor; import android.os.HandlerThread; import android.os.IBinder; import android.os.RemoteCallbackList; @@ -42,6 +41,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemClock; import android.os.SystemProperties; +import android.os.UserHandle; import android.provider.Settings; import android.util.Log; @@ -357,8 +357,9 @@ public class PacProxyService extends IPacProxyManager.Stub { } } }; - mContext.bindService(intent, mConnection, - Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE); + mContext.bindServiceAsUser(intent, mConnection, + Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE, + UserHandle.SYSTEM); intent = new Intent(); intent.setClassName(PROXY_PACKAGE, PROXY_SERVICE); @@ -398,9 +399,9 @@ public class PacProxyService extends IPacProxyManager.Stub { } } }; - mContext.bindService(intent, + mContext.bindServiceAsUser(intent, mProxyConnection, Context.BIND_AUTO_CREATE | Context.BIND_NOT_FOREGROUND | Context.BIND_NOT_VISIBLE, - new HandlerExecutor(mNetThreadHandler), mProxyConnection); + mNetThreadHandler, UserHandle.SYSTEM); } private void unbind() {