summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Plass <mplass@google.com>2018-10-25 14:28:18 -0700
committerMichael Plass <mplass@google.com>2018-11-13 17:17:26 -0800
commit919d0e28482a9a6bc8e0c31f719ab2f6b337886d (patch)
tree933283005a232add78fe63255be339f0c3969d7e
parent3e592dd784bb9ec027f8d60603358a1fa5dd98d9 (diff)
[WifiScoreCard] Add a proto for wifi score cards
Includes a simple unit test, to make sure the build setup works as intended. Bug: 112196799 Test: Builds Test: Unit test Change-Id: I86c87d5ffcf6a9e3a95d00d5d180eb284dc28d98
-rw-r--r--Android.bp1
-rw-r--r--service/Android.mk4
-rw-r--r--service/proto/Android.bp21
-rw-r--r--service/proto/src/scorecard.proto107
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiScoreCardProtoTest.java51
5 files changed, 183 insertions, 1 deletions
diff --git a/Android.bp b/Android.bp
index ca791257a..9735cc727 100644
--- a/Android.bp
+++ b/Android.bp
@@ -15,4 +15,5 @@
subdirs = [
"libwifi_system",
"libwifi_system_iface",
+ "service/proto",
]
diff --git a/service/Android.mk b/service/Android.mk
index d336b7bbd..3f67ee5cb 100644
--- a/service/Android.mk
+++ b/service/Android.mk
@@ -58,6 +58,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under, java) \
LOCAL_JAVA_LIBRARIES := \
android.hidl.manager-V1.0-java \
error_prone_annotations \
+ libprotobuf-java-lite \
jsr305 \
services
LOCAL_STATIC_JAVA_LIBRARIES := \
@@ -69,7 +70,8 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
android.hardware.wifi.hostapd-V1.1-java \
android.hardware.wifi.supplicant-V1.0-java \
android.hardware.wifi.supplicant-V1.1-java \
- android.hardware.wifi.supplicant-V1.2-java \
+ android.hardware.wifi.supplicant-V1.2-java \
+ wifi_service_proto \
ksoap2 \
libnanohttpd
diff --git a/service/proto/Android.bp b/service/proto/Android.bp
new file mode 100644
index 000000000..3686bb05e
--- /dev/null
+++ b/service/proto/Android.bp
@@ -0,0 +1,21 @@
+// Copyright (C) 2018 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.
+
+java_library {
+ name: "wifi_service_proto",
+ proto: {
+ type: "lite",
+ },
+ srcs: ["src/**/*.proto"],
+}
diff --git a/service/proto/src/scorecard.proto b/service/proto/src/scorecard.proto
new file mode 100644
index 000000000..9640207dc
--- /dev/null
+++ b/service/proto/src/scorecard.proto
@@ -0,0 +1,107 @@
+//
+// Copyright (C) 2018 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.
+//
+
+syntax = "proto2";
+
+package com_android_server_wifi;
+
+option java_package = "com.android.server.wifi";
+option java_outer_classname = "WifiScoreCardProto";
+
+message NetworkList {
+ optional int64 start_time_millis = 1; // Start of collection period
+ optional int64 end_time_millis = 2; // End of collection period
+ // A collection of network descriptions
+ repeated Network networks = 3;
+};
+
+// Describes a network, consisting of a collection of access points that share
+// the same SSID, the same security type, and (hopefully) the same L3 subnet.
+message Network {
+ optional string ssid = 1; // The SSID
+ reserved 2; // Reserved for security type
+ repeated AccessPoint access_points = 3;
+};
+
+// Describes an access point (single BSSID)
+//
+// In addition to the BSSID, a concise id is assigned to track references
+// among APs. These ids are local to the device, but unique among all APs
+// known to the device.
+message AccessPoint {
+ optional int32 id = 1; // Concise id
+ optional bytes bssid = 2; // BSSID of the access point
+ optional Technology technology = 3; // Wireless technology
+ repeated Signal event_stats = 4; // Statistics taken at specific events
+ repeated Roam roams = 5; // Roaming failures and successes
+};
+
+// Describes the IEEE 802.11 technology used by the access point
+enum Technology {
+ MODE_11A = 1; // 802.11a
+ MODE_11B = 2; // 802.11b
+ MODE_11G = 3; // 802.11g
+ MODE_11N = 4; // 802.11n
+ MODE_11AC = 5; // 802.11ac
+};
+
+// Records statistics gathered at various points in the life-cycle of
+// a connection, e.g., at disconnections of various flavors. May be
+// further split out by frequency.
+//
+message Signal {
+ optional Event event = 1; // Type of the event
+ optional int32 frequency = 2; // Frequency (MHz)
+ optional UnivariateStatistic rssi = 3; // Signal strength (dBm) of beacons
+ optional UnivariateStatistic linkspeed = 4; // Link speed (Mbits/sec)
+};
+
+// Statistics about a real value
+message UnivariateStatistic {
+ // Short-term statistics (for current collection period)
+ optional int64 count = 1; // Number of events
+ optional double sum = 2; // Sum of values
+ optional double sum_of_squares = 3; // Sum of squares of values
+ optional double min_value = 4; // Minimum value during period
+ optional double max_value = 5; // Maximum value during period
+
+ // Long-term statistics
+ // These are accumulated over a longer time span, and are aged so that
+ // more recent measurements get a higher weight.
+ optional double historical_mean = 6; // Long-term average
+ optional double historical_variance = 7; // Long-term variance
+};
+
+// Tracks roaming failures and successes
+message Roam {
+ optional int32 to_id = 1; // AP that we roamed to
+ optional int32 good = 2; // Successful roams
+ optional int32 bad = 3; // Failed roams
+};
+
+// Events where statistics may be collected
+enum Event {
+ SIGNAL_POLL = 1;
+ SCAN_BEFORE_SUCCESSFUL_CONNECTION = 2;
+ FIRST_POLL_AFTER_CONNECTION = 3;
+ IP_CONFIGURATION_SUCCESS = 4;
+ SCAN_BEFORE_FAILED_CONNECTION = 5;
+ CONNECTION_FAILURE = 6;
+ IP_REACHABILITY_LOST = 7;
+ LAST_POLL_BEFORE_ROAM = 8;
+ ROAM_SUCCESS = 9;
+ WIFI_DISABLED = 10;
+};
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiScoreCardProtoTest.java b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardProtoTest.java
new file mode 100644
index 000000000..7ef4e899a
--- /dev/null
+++ b/tests/wifitests/src/com/android/server/wifi/WifiScoreCardProtoTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2018 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.server.wifi;
+
+import static org.junit.Assert.assertEquals;
+
+import android.support.test.filters.SmallTest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Unit tests for {@link com.android.server.wifi.WifiScoreCardProto}.
+ */
+@SmallTest
+public class WifiScoreCardProtoTest {
+
+ /**
+ * Sets up for unit test
+ */
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ /**
+ * Test a builder
+ */
+ @Test
+ public void testBuilder() throws Exception {
+ WifiScoreCardProto.Network network = WifiScoreCardProto.Network.newBuilder()
+ .setSsid("FloogleGuest")
+ .build();
+ assertEquals("FloogleGuest", network.getSsid());
+ }
+}