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

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

Snap for 6084815 from ee87b653 to rvc-release

Change-Id: Ie0c3feab7e8fb3dc0e60785acbb8068a208cb5ea
parents 7f98d449 ee87b653
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -86,7 +86,7 @@ java_defaults {
    libs: ["unsupportedappusage"],
    libs: ["unsupportedappusage"],
    static_libs: [
    static_libs: [
        "androidx.annotation_annotation",
        "androidx.annotation_annotation",
        "netd_aidl_interface-V2-java",
        "netd_aidl_interface-unstable-java",
        "netlink-client",
        "netlink-client",
        "networkstack-client",
        "networkstack-client",
        "datastallprotosnano",
        "datastallprotosnano",
+1 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@
         permissions added would cause crashes on startup unless they are also added to the
         permissions added would cause crashes on startup unless they are also added to the
         privileged permissions whitelist for that package. -->
         privileged permissions whitelist for that package. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+55 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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 com.android.networkstack.apishim.api29;

import android.net.Network;

import androidx.annotation.NonNull;

import com.android.networkstack.apishim.NetworkShim;
import com.android.networkstack.apishim.UnsupportedApiLevelException;
/**
 * Implementation of NetworkShim for API 29.
 */
public class NetworkShimImpl implements NetworkShim {
    @NonNull
    protected final Network mNetwork;

    protected NetworkShimImpl(@NonNull Network network) {
        mNetwork = network;
    }

    /**
     * Get a new instance of {@link NetworkShim}.
     *
     * Use com.android.networkstack.apishim.NetworkShimImpl#newInstance()
     * (non-API29 version) instead, to use the correct shims depending on build SDK.
     */
    public static NetworkShim newInstance(@NonNull Network network) {
        return new NetworkShimImpl(network);
    }

    /**
     * Get the netId of the network.
     * @throws UnsupportedApiLevelException if API is not available in this API level.
     */
    @Override
    public int getNetId() throws UnsupportedApiLevelException {
        // Not supported for API 29.
        throw new UnsupportedApiLevelException("Not supported in API 29.");
    }
}
+49 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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 com.android.networkstack.apishim;

import android.net.Network;
import android.os.Build;

import androidx.annotation.NonNull;

/**
 * Implementation of {@link NetworkShim} for API 30.
 */
public class NetworkShimImpl extends com.android.networkstack.apishim.api29.NetworkShimImpl {
    protected NetworkShimImpl(@NonNull Network network) {
        super(network);
    }

    /**
     * Get a new instance of {@link NetworkShim}.
     */
    public static NetworkShim newInstance(@NonNull Network network) {
        if (!ShimUtils.isReleaseOrDevelopmentApiAbove(Build.VERSION_CODES.Q)) {
            return com.android.networkstack.apishim.api29.NetworkShimImpl.newInstance(network);
        }
        return new NetworkShimImpl(network);
    }

    /**
     * Get the netId of the network.
     */
    @Override
    public int getNetId() {
        return mNetwork.netId;
    }
}
+34 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2019 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 com.android.networkstack.apishim;

/**
 * Interface used to access API methods in {@link android.net.Network}, with appropriate fallbacks
 * if the methods are not yet part of the released API.
 *
 * <p>This interface makes it easier for callers to use NetworkShimImpl, as it's more obvious what
 * methods must be implemented on each API level, and it abstracts from callers the need to
 * reference classes that have different implementations (which also does not work well with IDEs).
 */
public interface NetworkShim {
    /**
     * @see android.net.Network.netId.
     *
     * @throws UnsupportedApiLevelException if API is not available in the API level.
     */
    int getNetId() throws UnsupportedApiLevelException;
}
Loading