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

Commit 130441b1 authored by David Su's avatar David Su
Browse files

Create WifiAnnotations and jarjar into framework

@IntDef annotations defined in the Wifi module are
@hide and cannot be referenced from the rest of
framework. Create a separate class for Wifi
annotations that can be jarjar'ed into external
clients.

Bug: 140299412
Test: compiles
Change-Id: I5beac976b4d12fb2c01f46cb46f9c54ab54618ea
parent 754fcc20
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -223,6 +223,7 @@ filegroup {
        ":framework-telecomm-sources",
        ":framework-telephony-common-sources",
        ":framework-telephony-sources",
        ":framework-wifi-annotations",
        ":framework-wifi-non-updatable-sources",
        ":PacProcessor-aidl-sources",
        ":ProxyHandler-aidl-sources",
@@ -400,7 +401,7 @@ java_defaults {

filegroup {
    name: "framework-jarjar-rules",
    srcs: ["jarjar_rules_hidl.txt"],
    srcs: ["framework-jarjar-rules.txt"],
}

filegroup {
+2 −0
Original line number Diff line number Diff line
rule android.hidl.** android.internal.hidl.@1
rule android.net.wifi.WifiAnnotations* android.internal.wifi.WifiAnnotations@1
+5 −0
Original line number Diff line number Diff line
@@ -38,6 +38,11 @@ filegroup {
    ],
}

filegroup {
    name: "framework-wifi-annotations",
    srcs: ["java/android/net/wifi/WifiAnnotations.java"],
}

java_library {
    name: "framework-wifi",
    sdk_version: "core_platform", // TODO(b/140299412) should be core_current
+51 −0
Original line number 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 android.net.wifi;

import android.annotation.IntDef;
import android.annotation.StringDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Wifi annotations meant to be statically linked into client modules, since they cannot be
 * exposed as @SystemApi.
 *
 * e.g. {@link IntDef}, {@link StringDef}
 *
 * @hide
 */
public final class WifiAnnotations {
    private WifiAnnotations() {}

    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"SCAN_TYPE_"}, value = {
            WifiScanner.SCAN_TYPE_LOW_LATENCY,
            WifiScanner.SCAN_TYPE_LOW_POWER,
            WifiScanner.SCAN_TYPE_HIGH_ACCURACY})
    public @interface ScanType {}

    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"WIFI_BAND_"}, value = {
            WifiScanner.WIFI_BAND_UNSPECIFIED,
            WifiScanner.WIFI_BAND_24_GHZ,
            WifiScanner.WIFI_BAND_5_GHZ,
            WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY,
            WifiScanner.WIFI_BAND_6_GHZ})
    public @interface WifiBandBasic {}
}
+3 −3
Original line number Diff line number Diff line
@@ -725,7 +725,7 @@ public class WifiCondManager implements IBinder.DeathRecipient {
    /**
     * Return scan type for the parcelable {@link SingleScanSettings}
     */
    private static int getScanType(@WifiScanner.ScanType int scanType) {
    private static int getScanType(@WifiAnnotations.ScanType int scanType) {
        switch (scanType) {
            case WifiScanner.SCAN_TYPE_LOW_LATENCY:
                return IWifiScannerImpl.SCAN_TYPE_LOW_SPAN;
@@ -746,7 +746,7 @@ public class WifiCondManager implements IBinder.DeathRecipient {
     * @param hiddenNetworkSSIDs List of hidden networks to be scanned for.
     * @return Returns true on success.
     */
    public boolean scan(@NonNull String ifaceName, @WifiScanner.ScanType int scanType,
    public boolean scan(@NonNull String ifaceName, @WifiAnnotations.ScanType int scanType,
            Set<Integer> freqs, List<byte[]> hiddenNetworkSSIDs) {
        IWifiScannerImpl scannerImpl = getScannerImpl(ifaceName);
        if (scannerImpl == null) {
@@ -868,7 +868,7 @@ public class WifiCondManager implements IBinder.DeathRecipient {
     * @return frequencies vector of valid frequencies (MHz), or null for error.
     * @throws IllegalArgumentException if band is not recognized.
     */
    public int [] getChannelsForBand(@WifiScanner.WifiBandBasic int band) {
    public int [] getChannelsForBand(@WifiAnnotations.WifiBandBasic int band) {
        if (mWificond == null) {
            Log.e(TAG, "No valid wificond scanner interface handler");
            return null;
Loading