Split updatable/non-updatable Wifi APIs into separate directories

This creates a clearer boundary between what is updatable
(part of the Wifi module) and what is not updatable (outside
the module).

Bug: 176105484
Test: compiles
Change-Id: Ia95e300da9286d79ee57c285c3bfa88ecc98e326
This commit is contained in:
David Su
2020-12-03 14:28:24 -08:00
parent 02e160056b
commit e7cc3ae663
26 changed files with 182 additions and 21 deletions

View File

@@ -31,9 +31,6 @@ filegroup {
"java/**/*.java",
"java/**/*.aidl",
],
exclude_srcs: [
":framework-wifi-non-updatable-sources"
],
path: "java",
visibility: ["//visibility:private"],
}
@@ -47,20 +44,6 @@ filegroup {
],
}
filegroup {
name: "framework-wifi-non-updatable-sources",
srcs: [
// TODO(b/146011398) package android.net.wifi is now split amongst 2 jars: framework.jar and
// framework-wifi.jar. This is not a good idea, should move WifiNetworkScoreCache
// to a separate package.
"java/android/net/wifi/SoftApConfToXmlMigrationUtil.java",
"java/android/net/wifi/WifiNetworkScoreCache.java",
"java/android/net/wifi/WifiMigration.java",
"java/android/net/wifi/nl80211/*.java",
":libwificond_ipc_aidl",
],
}
filegroup {
name: "framework-wifi-annotations",
srcs: ["java/android/net/wifi/WifiAnnotations.java"],
@@ -69,6 +52,7 @@ filegroup {
// list of tests that are allowed to access @hide APIs from framework-wifi
test_access_hidden_api_whitelist = [
"//frameworks/base/wifi/tests",
"//frameworks/base/wifi/non-updatable/tests",
"//frameworks/opt/net/wifi/tests/wifitests:__subpackages__",
"//external/robolectric-shadows:__subpackages__",

View File

@@ -0,0 +1,35 @@
// Copyright (C) 2020 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.
// This directory contains framework Wifi APIs that are not part of the Wifi module (i.e. not
// updatable), and are generally only called by the Wifi module.
// necessary since we only want the `path` property to only refer to these files
filegroup {
name: "framework-wifi-non-updatable-sources-internal",
srcs: ["src/**/*.java"],
path: "src",
visibility: ["//visibility:private"],
}
filegroup {
name: "framework-wifi-non-updatable-sources",
srcs: [
// TODO(b/146011398) package android.net.wifi is now split amongst 2 jars: framework.jar and
// framework-wifi.jar. This is not a good idea, should move WifiNetworkScoreCache
// to a separate package.
":framework-wifi-non-updatable-sources-internal",
":libwificond_ipc_aidl",
],
}

View File

@@ -89,7 +89,7 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub {
@Override public final void updateScores(List<ScoredNetwork> networks) {
if (networks == null || networks.isEmpty()) {
return;
return;
}
if (DBG) {
Log.d(TAG, "updateScores list size=" + networks.size());
@@ -97,7 +97,7 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub {
boolean changed = false;
synchronized(mLock) {
synchronized (mLock) {
for (ScoredNetwork network : networks) {
String networkKey = buildNetworkKey(network);
if (networkKey == null) {
@@ -189,7 +189,7 @@ public class WifiNetworkScoreCache extends INetworkScoreCache.Stub {
String key = buildNetworkKey(result);
if (key == null) return null;
synchronized(mLock) {
synchronized (mLock) {
ScoredNetwork network = mCache.get(key);
return network;
}

View File

@@ -0,0 +1,44 @@
// Copyright (C) 2020 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.
android_test {
name: "FrameworksWifiNonUpdatableApiTests",
defaults: ["framework-wifi-test-defaults"],
srcs: ["src/**/*.java"],
jacoco: {
include_filter: ["android.net.wifi.*"],
// TODO(b/147521214) need to exclude test classes
exclude_filter: [],
},
static_libs: [
"androidx.test.rules",
"frameworks-base-testutils",
"guava",
"mockito-target-minus-junit4",
"truth-prebuilt",
],
libs: [
"android.test.runner",
"android.test.base",
],
test_suites: [
"general-tests",
],
}

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2020 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
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.net.wifi.test">
<application>
<uses-library android:name="android.test.runner"/>
<activity android:label="WifiTestDummyLabel"
android:name="WifiTestDummyName"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="android.net.wifi.test"
android:label="Frameworks Wifi Non-updatable API Tests">
</instrumentation>
</manifest>

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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.
-->
<configuration description="Runs Frameworks Wifi Non-updatable API Tests.">
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
<option name="test-file-name" value="FrameworksWifiNonUpdatableApiTests.apk" />
</target_preparer>
<option name="test-suite-tag" value="apct" />
<option name="test-tag" value="FrameworksWifiNonUpdatableApiTests" />
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.net.wifi.test" />
<option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
<option name="hidden-api-checks" value="false"/>
</test>
</configuration>

View File

@@ -0,0 +1,32 @@
# Wifi Non-Updatable Framework Unit Tests
This package contains unit tests for the non-updatable part (i.e. outside the Wifi module) of the
Android Wifi framework APIs based on the
[Android Testing Support Library](http://developer.android.com/tools/testing-support-library/index.html).
The test cases are built using the [JUnit](http://junit.org/) and [Mockito](http://mockito.org/)
libraries.
## Running Tests
The easiest way to run tests is simply run
```
atest android.net.wifi
```
To pick up changes in framework/base, you will need to:
1. rebuild the framework library 'make -j32'
2. sync over the updated library to the device 'adb sync'
3. restart framework on the device 'adb shell stop' then 'adb shell start'
To enable syncing data to the device for first time after clean reflash:
1. adb disable-verity
2. adb reboot
3. adb remount
## Adding Tests
Tests can be added by adding classes to the src directory. JUnit4 style test cases can
be written by simply annotating test methods with `org.junit.Test`.
## Debugging Tests
If you are trying to debug why tests are not doing what you expected, you can add android log
statements and use logcat to view them. The beginning and end of every tests is automatically logged
with the tag `TestRunner`.

View File

@@ -11,7 +11,7 @@
* 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
* limitations under the License.
*/
package android.net.wifi;