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

Commit 6c16aead authored by James Mattis's avatar James Mattis Committed by Automerger Merge Worker
Browse files

Merge changes from topics "pans", "pans-permission" am: 601d16a3 am: d11f866e

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1561317

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I8afdee99c0b0813d3e3a61df053f9cdef966949c
parents 5ea7cd28 d11f866e
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ package android {
    field public static final String CONTROL_DISPLAY_SATURATION = "android.permission.CONTROL_DISPLAY_SATURATION";
    field public static final String CONTROL_INCALL_EXPERIENCE = "android.permission.CONTROL_INCALL_EXPERIENCE";
    field public static final String CONTROL_KEYGUARD_SECURE_NOTIFICATIONS = "android.permission.CONTROL_KEYGUARD_SECURE_NOTIFICATIONS";
    field public static final String CONTROL_OEM_PAID_NETWORK_PREFERENCE = "android.permission.CONTROL_OEM_PAID_NETWORK_PREFERENCE";
    field public static final String CONTROL_VPN = "android.permission.CONTROL_VPN";
    field public static final String CREATE_USERS = "android.permission.CREATE_USERS";
    field public static final String CRYPT_KEEPER = "android.permission.CRYPT_KEEPER";
@@ -6045,6 +6046,7 @@ package android.net {
    method @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void registerTetheringEventCallback(@NonNull java.util.concurrent.Executor, @NonNull android.net.ConnectivityManager.OnTetheringEventCallback);
    method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void requestNetwork(@NonNull android.net.NetworkRequest, int, int, @NonNull android.os.Handler, @NonNull android.net.ConnectivityManager.NetworkCallback);
    method @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_AIRPLANE_MODE, android.Manifest.permission.NETWORK_SETTINGS, android.Manifest.permission.NETWORK_SETUP_WIZARD, android.Manifest.permission.NETWORK_STACK}) public void setAirplaneMode(boolean);
    method @RequiresPermission(android.Manifest.permission.CONTROL_OEM_PAID_NETWORK_PREFERENCE) public void setOemNetworkPreference(@NonNull android.net.OemNetworkPreferences, @Nullable java.util.concurrent.Executor, @Nullable android.net.ConnectivityManager.OnSetOemNetworkPreferenceListener);
    method @RequiresPermission(anyOf={android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK, android.Manifest.permission.NETWORK_STACK}) public boolean shouldAvoidBadWifi();
    method @RequiresPermission(android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK) public void startCaptivePortalApp(@NonNull android.net.Network, @NonNull android.os.Bundle);
    method @Deprecated @RequiresPermission(android.Manifest.permission.TETHER_PRIVILEGED) public void startTethering(int, boolean, android.net.ConnectivityManager.OnStartTetheringCallback);
@@ -6066,6 +6068,10 @@ package android.net {
    field @Deprecated public static final int TYPE_WIFI_P2P = 13; // 0xd
  }
  public static interface ConnectivityManager.OnSetOemNetworkPreferenceListener {
    method public void onComplete();
  }
  @Deprecated public abstract static class ConnectivityManager.OnStartTetheringCallback {
    ctor @Deprecated public ConnectivityManager.OnStartTetheringCallback();
    method @Deprecated public void onTetheringFailed();
@@ -6423,6 +6429,26 @@ package android.net {
    ctor public NetworkStats.Entry(@Nullable String, int, int, int, int, int, int, long, long, long, long, long);
  }
  public final class OemNetworkPreferences implements android.os.Parcelable {
    method public int describeContents();
    method @NonNull public java.util.Map<java.lang.String,java.lang.Integer> getNetworkPreferences();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.net.OemNetworkPreferences> CREATOR;
    field public static final int OEM_NETWORK_PREFERENCE_OEM_PAID = 1; // 0x1
    field public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK = 2; // 0x2
    field public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY = 3; // 0x3
    field public static final int OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY = 4; // 0x4
    field public static final int OEM_NETWORK_PREFERENCE_UNINITIALIZED = 0; // 0x0
  }
  public static final class OemNetworkPreferences.Builder {
    ctor public OemNetworkPreferences.Builder();
    ctor public OemNetworkPreferences.Builder(@NonNull android.net.OemNetworkPreferences);
    method @NonNull public android.net.OemNetworkPreferences.Builder addNetworkPreference(@NonNull String, int);
    method @NonNull public android.net.OemNetworkPreferences build();
    method @NonNull public android.net.OemNetworkPreferences.Builder clearNetworkPreference(@NonNull String);
  }
  public abstract class QosCallback {
    ctor public QosCallback();
    method public void onError(@NonNull android.net.QosCallbackException);
+23 −0
Original line number Diff line number Diff line
/**
 *
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net;

/** @hide */
oneway interface IOnSetOemNetworkPreferenceListener {
    void onComplete();
}
+13 −11
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.net;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Parcelable;

@@ -29,11 +30,12 @@ import java.util.Map;
import java.util.Objects;

/** @hide */
@SystemApi
public final class OemNetworkPreferences implements Parcelable {
    /**
     * Use default behavior requesting networks. Equivalent to not setting any preference at all.
     * Default in case this value is not set. Using it will result in an error.
     */
    public static final int OEM_NETWORK_PREFERENCE_DEFAULT = 0;
    public static final int OEM_NETWORK_PREFERENCE_UNINITIALIZED = 0;

    /**
     * If an unmetered network is available, use it.
@@ -45,17 +47,17 @@ public final class OemNetworkPreferences implements Parcelable {
    /**
     * If an unmetered network is available, use it.
     * Otherwise, if a network with the OEM_PAID capability is available, use it.
     * Otherwise, the app doesn't get a network.
     * Otherwise, the app doesn't get a default network.
     */
    public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK = 2;

    /**
     * Prefer only NET_CAPABILITY_OEM_PAID networks.
     * Use only NET_CAPABILITY_OEM_PAID networks.
     */
    public static final int OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY = 3;

    /**
     * Prefer only NET_CAPABILITY_OEM_PRIVATE networks.
     * Use only NET_CAPABILITY_OEM_PRIVATE networks.
     */
    public static final int OEM_NETWORK_PREFERENCE_OEM_PRIVATE_ONLY = 4;

@@ -95,8 +97,6 @@ public final class OemNetworkPreferences implements Parcelable {
    /**
     * Builder used to create {@link OemNetworkPreferences} objects.  Specify the preferred Network
     * to package name mappings.
     *
     * @hide
     */
    public static final class Builder {
        private final Bundle mNetworkMappings;
@@ -135,7 +135,7 @@ public final class OemNetworkPreferences implements Parcelable {
         * @return The builder to facilitate chaining.
         */
        @NonNull
        public Builder removeNetworkPreference(@NonNull final String packageName) {
        public Builder clearNetworkPreference(@NonNull final String packageName) {
            Objects.requireNonNull(packageName);
            mNetworkMappings.remove(packageName);
            return this;
@@ -160,7 +160,7 @@ public final class OemNetworkPreferences implements Parcelable {

    /** @hide */
    @IntDef(prefix = "OEM_NETWORK_PREFERENCE_", value = {
            OEM_NETWORK_PREFERENCE_DEFAULT,
            OEM_NETWORK_PREFERENCE_UNINITIALIZED,
            OEM_NETWORK_PREFERENCE_OEM_PAID,
            OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK,
            OEM_NETWORK_PREFERENCE_OEM_PAID_ONLY,
@@ -174,12 +174,14 @@ public final class OemNetworkPreferences implements Parcelable {
     *
     * @param value int value of OemNetworkPreference
     * @return string version of OemNetworkPreference
     *
     * @hide
     */
    @NonNull
    public static String oemNetworkPreferenceToString(@OemNetworkPreference int value) {
        switch (value) {
            case OEM_NETWORK_PREFERENCE_DEFAULT:
                return "OEM_NETWORK_PREFERENCE_DEFAULT";
            case OEM_NETWORK_PREFERENCE_UNINITIALIZED:
                return "OEM_NETWORK_PREFERENCE_UNINITIALIZED";
            case OEM_NETWORK_PREFERENCE_OEM_PAID:
                return "OEM_NETWORK_PREFERENCE_OEM_PAID";
            case OEM_NETWORK_PREFERENCE_OEM_PAID_NO_FALLBACK:
+6 −0
Original line number Diff line number Diff line
@@ -1797,6 +1797,12 @@
    <permission android:name="android.permission.WIFI_ACCESS_COEX_UNSAFE_CHANNELS"
                android:protectionLevel="signature|privileged" />

    <!-- @SystemApi @hide Allows an application to manage an automotive device's application network
         preference as it relates to OEM_PAID and OEM_PRIVATE capable networks.
         <p>Not for use by third-party or privileged applications. -->
    <permission android:name="android.permission.CONTROL_OEM_PAID_NETWORK_PREFERENCE"
        android:protectionLevel="signature" />

    <!-- ======================================= -->
    <!-- Permissions for short range, peripheral networks -->
    <!-- ======================================= -->
+56 −9
Original line number Diff line number Diff line
@@ -4886,15 +4886,6 @@ public class ConnectivityManager {
        }
    }

    private void setOemNetworkPreference(@NonNull final OemNetworkPreferences preference) {
        try {
            mService.setOemNetworkPreference(preference);
        } catch (RemoteException e) {
            Log.e(TAG, "setOemNetworkPreference() failed for preference: " + preference.toString());
            throw e.rethrowFromSystemServer();
        }
    }

    @NonNull
    private final List<QosCallbackConnection> mQosCallbackConnections = new ArrayList<>();

@@ -5096,4 +5087,60 @@ public class ConnectivityManager {
        sendRequestForNetwork(nc, networkCallback, 0, BACKGROUND_REQUEST,
                TYPE_NONE, handler == null ? getDefaultHandler() : new CallbackHandler(handler));
    }

    /**
     * Listener for {@link #setOemNetworkPreference(OemNetworkPreferences, Executor,
     * OnSetOemNetworkPreferenceListener)}.
     * @hide
     */
    @SystemApi
    public interface OnSetOemNetworkPreferenceListener {
        /**
         * Called when setOemNetworkPreference() successfully completes.
         */
        void onComplete();
    }

    /**
     * Used by automotive devices to set the network preferences used to direct traffic at an
     * application level as per the given OemNetworkPreferences. An example use-case would be an
     * automotive OEM wanting to provide connectivity for applications critical to the usage of a
     * vehicle via a particular network.
     *
     * Calling this will overwrite the existing preference.
     *
     * @param preference {@link OemNetworkPreferences} The application network preference to be set.
     * @param executor the executor on which listener will be invoked.
     * @param listener {@link OnSetOemNetworkPreferenceListener} optional listener used to
     *                  communicate completion of setOemNetworkPreference(). This will only be
     *                  called once upon successful completion of setOemNetworkPreference().
     * @throws IllegalArgumentException if {@code preference} contains invalid preference values.
     * @throws SecurityException if missing the appropriate permissions.
     * @throws UnsupportedOperationException if called on a non-automotive device.
     * @hide
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.CONTROL_OEM_PAID_NETWORK_PREFERENCE)
    public void setOemNetworkPreference(@NonNull final OemNetworkPreferences preference,
            @Nullable @CallbackExecutor final Executor executor,
            @Nullable final OnSetOemNetworkPreferenceListener listener) {
        Objects.requireNonNull(preference, "OemNetworkPreferences must be non-null");
        if (null != listener) {
            Objects.requireNonNull(executor, "Executor must be non-null");
        }
        final IOnSetOemNetworkPreferenceListener listenerInternal = listener == null ? null :
                new IOnSetOemNetworkPreferenceListener.Stub() {
                    @Override
                    public void onComplete() {
                        executor.execute(listener::onComplete);
                    }
        };

        try {
            mService.setOemNetworkPreference(preference, listenerInternal);
        } catch (RemoteException e) {
            Log.e(TAG, "setOemNetworkPreference() failed for preference: " + preference.toString());
            throw e.rethrowFromSystemServer();
        }
    }
}
Loading