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

Commit 27fef17b authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [13532551, 13532552, 13534990, 13533561, 13533870,...

Merge cherrypicks of [13532551, 13532552, 13534990, 13533561, 13533870, 13533871, 13534991, 13533562, 13532553, 13533872, 13534992, 13532554, 13535065, 13535085, 13535105, 13535125, 13535126, 13535106, 13535107, 13535086] into rvc-qpr2-release

Change-Id: I5cca44426f73508e4e2645643de28bebf0cb4f42
parents 47e0424b 77a098a3
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -7623,8 +7623,8 @@ public class AppOpsManager {
                } else if (collectionMode == COLLECT_SYNC
                        // Only collect app-ops when the proxy is trusted
                        && (mContext.checkPermission(Manifest.permission.UPDATE_APP_OPS_STATS, -1,
                        myUid) == PackageManager.PERMISSION_GRANTED
                        || isTrustedVoiceServiceProxy(mContext, mContext.getOpPackageName(), op))) {
                        myUid) == PackageManager.PERMISSION_GRANTED || isTrustedVoiceServiceProxy(
                        mContext, mContext.getOpPackageName(), op, mContext.getUserId()))) {
                    collectNotedOpSync(op, proxiedAttributionTag);
                }
            }
@@ -7642,7 +7642,7 @@ public class AppOpsManager {
     * @hide
     */
    public static boolean isTrustedVoiceServiceProxy(Context context, String packageName,
            int code) {
            int code, int userId) {
        // This is a workaround for R QPR, new API change is not allowed. We only allow the current
        // voice recognizer is also the voice interactor to noteproxy op.
        if (code != OP_RECORD_AUDIO) {
@@ -7654,7 +7654,7 @@ public class AppOpsManager {
        final String voiceRecognitionServicePackageName =
                getComponentPackageNameFromString(voiceRecognitionComponent);
        return (Objects.equals(packageName, voiceRecognitionServicePackageName))
                && isPackagePreInstalled(context, packageName);
                && isPackagePreInstalled(context, packageName, userId);
    }

    private static String getComponentPackageNameFromString(String from) {
@@ -7662,10 +7662,10 @@ public class AppOpsManager {
        return componentName != null ? componentName.getPackageName() : "";
    }

    private static boolean isPackagePreInstalled(Context context, String packageName) {
    private static boolean isPackagePreInstalled(Context context, String packageName, int userId) {
        try {
            final PackageManager pm = context.getPackageManager();
            final ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
            final ApplicationInfo info = pm.getApplicationInfoAsUser(packageName, 0, userId);
            return ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
        } catch (PackageManager.NameNotFoundException e) {
            return false;
+20 −13
Original line number Diff line number Diff line
@@ -6318,6 +6318,25 @@ public class ConnectivityService extends IConnectivityManager.Stub
        return newNc;
    }

    private void updateNetworkInfoForRoamingAndSuspended(NetworkAgentInfo nai,
            NetworkCapabilities prevNc, NetworkCapabilities newNc) {
        final boolean prevSuspended = !prevNc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED);
        final boolean suspended = !newNc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED);
        final boolean prevRoaming = !prevNc.hasCapability(NET_CAPABILITY_NOT_ROAMING);
        final boolean roaming = !newNc.hasCapability(NET_CAPABILITY_NOT_ROAMING);
        if (prevSuspended != suspended) {
            // TODO (b/73132094) : remove this call once the few users of onSuspended and
            // onResumed have been removed.
            notifyNetworkCallbacks(nai, suspended ? ConnectivityManager.CALLBACK_SUSPENDED
                    : ConnectivityManager.CALLBACK_RESUMED);
        }
        if (prevSuspended != suspended || prevRoaming != roaming) {
            // updateNetworkInfo will mix in the suspended info from the capabilities and
            // take appropriate action for the network having possibly changed state.
            updateNetworkInfo(nai, nai.networkInfo);
        }
    }

    /**
     * Update the NetworkCapabilities for {@code nai} to {@code nc}. Specifically:
     *
@@ -6349,25 +6368,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
            // on this network. We might have been called by rematchNetworkAndRequests when a
            // network changed foreground state.
            processListenRequests(nai);
            final boolean prevSuspended = !prevNc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED);
            final boolean suspended = !newNc.hasCapability(NET_CAPABILITY_NOT_SUSPENDED);
            final boolean prevRoaming = !prevNc.hasCapability(NET_CAPABILITY_NOT_ROAMING);
            final boolean roaming = !newNc.hasCapability(NET_CAPABILITY_NOT_ROAMING);
            if (prevSuspended != suspended || prevRoaming != roaming) {
                // TODO (b/73132094) : remove this call once the few users of onSuspended and
                // onResumed have been removed.
                notifyNetworkCallbacks(nai, suspended ? ConnectivityManager.CALLBACK_SUSPENDED
                        : ConnectivityManager.CALLBACK_RESUMED);
                // updateNetworkInfo will mix in the suspended info from the capabilities and
                // take appropriate action for the network having possibly changed state.
                updateNetworkInfo(nai, nai.networkInfo);
            }
        } else {
            // If the requestable capabilities have changed or the score changed, we can't have been
            // called by rematchNetworkAndRequests, so it's safe to start a rematch.
            rematchAllNetworksAndRequests();
            notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_CAP_CHANGED);
        }
        updateNetworkInfoForRoamingAndSuspended(nai, prevNc, newNc);

        // TODO : static analysis indicates that prevNc can't be null here (getAndSetNetworkCaps
        // never returns null), so mark the relevant members and functions in nai as @NonNull and
+2 −2
Original line number Diff line number Diff line
@@ -3014,8 +3014,8 @@ public class AppOpsService extends IAppOpsService.Stub {

        // This is a workaround for R QPR, new API change is not allowed. We only allow the current
        // voice recognizer is also the voice interactor to noteproxy op.
        final boolean isTrustVoiceServiceProxy =
                AppOpsManager.isTrustedVoiceServiceProxy(mContext, proxyPackageName, code);
        final boolean isTrustVoiceServiceProxy = AppOpsManager.isTrustedVoiceServiceProxy(mContext,
                proxyPackageName, code, UserHandle.getUserId(proxyUid));
        final boolean isSelfBlame = Binder.getCallingUid() == proxiedUid;
        final boolean isProxyTrusted = mContext.checkPermission(
                Manifest.permission.UPDATE_APP_OPS_STATS, -1, proxyUid)
+2 −1
Original line number Diff line number Diff line
@@ -202,7 +202,8 @@ public class Vpn {
    @VisibleForTesting protected String mPackage;
    private int mOwnerUID;
    private boolean mIsPackageTargetingAtLeastQ;
    private String mInterface;
    @VisibleForTesting
    protected String mInterface;
    private Connection mConnection;

    /** Tracks the runners for all VPN types managed by the platform (eg. LegacyVpn, PlatformVpn) */
+3 −2
Original line number Diff line number Diff line
@@ -195,7 +195,8 @@ class ConnectivityServiceIntegrationTest {
                "https://secure.test.android.com",
                responseCode = 204, contentLength = 42, redirectUrl = null))

        val na = NetworkAgentWrapper(TRANSPORT_CELLULAR, LinkProperties(), context)
        val na = NetworkAgentWrapper(TRANSPORT_CELLULAR, LinkProperties(), null /* ncTemplate */,
                context)
        networkStackClient.verifyNetworkMonitorCreated(na.network, TEST_TIMEOUT_MS)

        na.addCapability(NET_CAPABILITY_INTERNET)
Loading