Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91d7368f authored by rambowang's avatar rambowang
Browse files

Check system process UID with a multi-user-aware way

This CL calls UserHandle.getAppId to compare system process UIDs
with Process.XXX_UID constants which are app id instead of UID in
multiple user context.

Bug: 328511085
Test: atest CtsWebkitTestCases
Flag: com.android.internal.telephony.flags.support_phone_uid_check_for_multiuser
Change-Id: Icc0f3ed6c7e6de868c88b13e3b38996c9193a8b8
parent 5460f4c5
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.AndroidRuntimeException;
import android.util.ArraySet;
@@ -339,10 +340,10 @@ public final class WebViewFactory {
            if (sProviderInstance != null) return sProviderInstance;

            sTimestamps.mWebViewLoadStart = SystemClock.uptimeMillis();
            final int uid = android.os.Process.myUid();
            if (uid == android.os.Process.ROOT_UID || uid == android.os.Process.SYSTEM_UID
                    || uid == android.os.Process.PHONE_UID || uid == android.os.Process.NFC_UID
                    || uid == android.os.Process.BLUETOOTH_UID) {
            final int appId = UserHandle.getAppId(android.os.Process.myUid());
            if (appId == android.os.Process.ROOT_UID || appId == android.os.Process.SYSTEM_UID
                    || appId == android.os.Process.PHONE_UID || appId == android.os.Process.NFC_UID
                    || appId == android.os.Process.BLUETOOTH_UID) {
                throw new UnsupportedOperationException(
                        "For security reasons, WebView is not allowed in privileged processes");
            }