summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-11-19 06:55:37 -0800
committerRoshan Pius <rpius@google.com>2019-11-25 20:57:06 -0800
commit5af72d01d81f092db948432d2c1e6ddd50f8af3a (patch)
treebdb2e7ba764227d8067bd6885a45be345a7fba18
parent94c0650af0dd9b8a2a0ca665800c454af79f34a0 (diff)
Revert "Create Mainline wifi stack module"
This reverts commit fa4865828574f11464b5f0c06b27e2829b3672e6 Reason for revert: Wifi services no longer plan to be a separate APK/process for mainline. Will instead become a jar loaded from Apex. Also, a) JarJar all external libraries to a separate com.android.server.x.wifi namespace. b) Use proguard to preserve all of com.android.server.wifi and only strip out unused code from the static libraries linked. Bug: 144722612 Test: Device boots up & connects to wifi networks Change-Id: I13f4cad0147e7baa028bc7cf578b72b3636d874e
-rw-r--r--WifiStackPermissionConfig/Android.bp40
-rw-r--r--WifiStackPermissionConfig/AndroidManifest.xml41
-rw-r--r--WifiStackPermissionConfig/AndroidManifest_InProcess.xml41
-rw-r--r--service/Android.bp59
-rw-r--r--service/AndroidManifest.xml70
-rw-r--r--service/AndroidManifestBase.xml29
-rw-r--r--service/AndroidManifest_InProcess.xml43
-rw-r--r--service/CleanSpec.mk2
-rw-r--r--service/jarjar-rules-shared.txt34
-rw-r--r--service/java/com/android/server/wifi/BootCompleteReceiver.java98
-rw-r--r--service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java2
-rw-r--r--service/java/com/android/server/wifi/WakeupNotificationFactory.java2
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java2
-rw-r--r--service/java/com/android/server/wifi/WifiService.java66
-rw-r--r--service/java/com/android/server/wifi/WifiServiceBase.java62
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java9
-rw-r--r--service/java/com/android/server/wifi/WifiStackService.java269
-rw-r--r--service/java/com/android/server/wifi/WrongPasswordNotifier.java2
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareService.java71
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pService.java18
-rw-r--r--service/java/com/android/server/wifi/rtt/RttService.java48
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningService.java20
-rw-r--r--service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java22
-rw-r--r--service/java/com/android/server/wifi/util/WifiPermissionsUtil.java9
-rw-r--r--service/proguard.flags7
-rw-r--r--service/wifi.rc28
-rw-r--r--service/wifi_inprocess.rc85
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java71
30 files changed, 232 insertions, 1023 deletions
diff --git a/WifiStackPermissionConfig/Android.bp b/WifiStackPermissionConfig/Android.bp
deleted file mode 100644
index 766ce61e7..000000000
--- a/WifiStackPermissionConfig/Android.bp
+++ /dev/null
@@ -1,40 +0,0 @@
-//
-// 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.
-//
-
-java_defaults {
- name: "WifiStackPermissionConfigDefaults",
- sdk_version: "system_current",
- min_sdk_version: "29",
- privileged: true,
-}
-
-// Stub APK to define permissions for WifiStack
-android_app {
- name: "WifiStackPermissionConfig",
- defaults: ["WifiStackPermissionConfigDefaults"],
- certificate: "networkstack",
- manifest: "AndroidManifest.xml",
-}
-
-// Alternative stub APK signed with platform certificate. To use with InProcessWifiStack.
-// TODO (b/135753701): Test this path.
-android_app {
- name: "PlatformWifiStackPermissionConfig",
- defaults: ["WifiStackPermissionConfigDefaults"],
- certificate: "platform",
- overrides: ["WifiStackPermissionConfig"],
- manifest: "AndroidManifest_InProcess.xml",
-}
diff --git a/WifiStackPermissionConfig/AndroidManifest.xml b/WifiStackPermissionConfig/AndroidManifest.xml
deleted file mode 100644
index a22f4b089..000000000
--- a/WifiStackPermissionConfig/AndroidManifest.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * 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.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi.permissionconfig"
- android:sharedUserId="android.uid.networkstack"
- android:versionCode="210000000"
- android:versionName="R-initial">
- <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
- <!--
- This package only exists to define the below permissions, and enforce that they are only
- granted to apps sharing the same signature.
- Permissions defined here are intended to be used only by the WifiStack: both
- WifiStack and this stub APK are to be signed with a dedicated certificate to ensure
- that, with the below permissions being signature permissions.
-
- This APK *must* be installed, even if the WifiStack app is not installed, because otherwise,
- any application will be able to define this permission and the system will give that application
- full access to the network stack.
- -->
- <permission android:name="android.permission.MAINLINE_WIFI_STACK"
- android:protectionLevel="signature"/>
-
- <application android:name="com.android.server.wifi.WifiStackPermissionConfig"
- android:hasCode="false" />
-</manifest>
diff --git a/WifiStackPermissionConfig/AndroidManifest_InProcess.xml b/WifiStackPermissionConfig/AndroidManifest_InProcess.xml
deleted file mode 100644
index 59fd53b17..000000000
--- a/WifiStackPermissionConfig/AndroidManifest_InProcess.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * 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.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi.inprocess.permissionconfig"
- android:sharedUserId="android.uid.system"
- android:versionCode="210000000"
- android:versionName="R-initial">
- <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
- <!--
- This package only exists to define the below permissions, and enforce that they are only
- granted to apps sharing the same signature.
- Permissions defined here are intended to be used only by the WifiStack: both
- WifiStack and this stub APK are to be signed with a dedicated certificate to ensure
- that, with the below permissions being signature permissions.
-
- This APK *must* be installed, even if the WifiStack app is not installed, because otherwise,
- any application will be able to define this permission and the system will give that application
- full access to the network stack.
- -->
- <permission android:name="android.permission.MAINLINE_WIFI_STACK"
- android:protectionLevel="signature"/>
-
- <application android:name="com.android.server.wifi.WifiStackPermissionConfig"
- android:hasCode="false" />
-</manifest>
diff --git a/service/Android.bp b/service/Android.bp
index 5baf164bc..e27e2ed23 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -71,6 +71,11 @@ cc_library_shared {
},
}
+filegroup {
+ name: "wifi-jarjar-rules",
+ srcs: [ "jarjar-rules-shared.txt"]
+}
+
// Build the wifi-service static library
// ============================================================
android_library {
@@ -89,7 +94,10 @@ android_library {
"services",
],
- manifest: "AndroidManifestBase.xml",
+ jarjar_rules: ":wifi-jarjar-rules",
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
static_libs: [
"android.hardware.wifi-V1.0-java",
@@ -114,64 +122,17 @@ android_library {
"libprotobuf-java-lite",
"libnanohttpd",
"services.net",
- "services.wifi",
+ "services.core",
"libwificond_aidl-java",
"wifi_proto_scorecard",
"wifi_proto_metrics",
],
-}
-
-filegroup {
- name: "wifi-jarjar-rules",
- srcs: [ "jarjar-rules-shared.txt"]
-}
-
-java_defaults {
- name: "WifiStackAppCommon",
- defaults: ["WifiStackCommon"],
- static_libs: [
- "wifi-service",
- ],
- jni_libs: [
- "libwifi-jni",
- ],
- // Resources already included in wifi-service
- resource_dirs: [],
- jarjar_rules: ":wifi-jarjar-rules",
- optimize: {
- proguard_flags_files: ["proguard.flags"],
- },
required: [
"libwifi-jni",
"services",
"cacerts_wfa",
],
-}
-// Updatable stack packaged as an application
-android_app {
- name: "WifiStack",
- defaults: ["WifiStackAppCommon"],
- certificate: "networkstack",
- manifest: "AndroidManifest.xml",
- use_embedded_native_libs: true,
- // The permission configuration *must* be included to ensure security of the device
- required: ["WifiStackPermissionConfig"],
init_rc: ["wifi.rc"],
}
-
-// Non-updatable wifi stack running in the system server process for devices not using the module
-// TODO (b/135753701): Test this path.
-android_app {
- name: "InProcessWifiStack",
- defaults: ["WifiStackAppCommon"],
- certificate: "platform",
- manifest: "AndroidManifest_InProcess.xml",
- // InProcessWifiStack is a replacement for WifiStack
- overrides: ["WifiStack"],
- // The permission configuration *must* be included to ensure security of the device
- required: ["PlatformWifiStackPermissionConfig"],
- init_rc: ["wifi_inprocess.rc"],
-}
-
diff --git a/service/AndroidManifest.xml b/service/AndroidManifest.xml
index 68e4d1ee5..787cd7539 100644
--- a/service/AndroidManifest.xml
+++ b/service/AndroidManifest.xml
@@ -18,70 +18,12 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.wifi"
- coreApp="true"
- android:sharedUserId="android.uid.networkstack"
- android:versionCode="220000000"
- android:versionName="30 system image">
-
- <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
-
- <!-- Permissions must be defined here, and not in the base manifest, as the wifi stack
- running in the system server process does not need any permission, and having privileged
- permissions added would cause crashes on startup unless they are also added to the
- privileged permissions whitelist for that package. -->
- <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
- <uses-permission android:name="android.permission.BROADCAST_STICKY" />
- <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
- <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
- <uses-permission android:name="android.permission.DEVICE_POWER" />
- <uses-permission android:name="android.permission.DUMP" />
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
- <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />
- <uses-permission android:name="android.permission.LOCATION_HARDWARE" />
- <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
- <uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" />
- <uses-permission android:name="android.permission.MANAGE_USERS" />
- <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
- <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" />
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
- <uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- <uses-permission android:name="android.permission.REORDER_TASKS" />
- <uses-permission android:name="android.permission.REQUEST_NETWORK_SCORES" />
- <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
- <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
- <uses-permission android:name="android.permission.UPDATE_APP_OPS_STATS" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.WRITE_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
- <!-- Signature permission defined for wifi module-->
- <uses-permission android:name="android.permission.MAINLINE_WIFI_STACK" />
-
+ android:versionCode="11"
+ android:versionName="Q-initial">
<application
- android:persistent="true"
- android:process="com.android.networkstack.process">
- <service
- android:name="com.android.server.wifi.WifiStackService">
- <intent-filter>
- <action android:name="android.net.wifi.IWifiStackConnector"/>
- </intent-filter>
- </service>
- <receiver android:name="com.android.server.wifi.BootCompleteReceiver">
- <intent-filter>
- <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
+ android:label="@string/wifiAppLabel"
+ android:defaultToDeviceProtectedStorage="true"
+ android:directBootAware="true"
+ android:usesCleartextTraffic="true">
</application>
</manifest>
diff --git a/service/AndroidManifestBase.xml b/service/AndroidManifestBase.xml
deleted file mode 100644
index 787cd7539..000000000
--- a/service/AndroidManifestBase.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * 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.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi"
- android:versionCode="11"
- android:versionName="Q-initial">
- <application
- android:label="@string/wifiAppLabel"
- android:defaultToDeviceProtectedStorage="true"
- android:directBootAware="true"
- android:usesCleartextTraffic="true">
- </application>
-</manifest>
diff --git a/service/AndroidManifest_InProcess.xml b/service/AndroidManifest_InProcess.xml
deleted file mode 100644
index 605c1ee29..000000000
--- a/service/AndroidManifest_InProcess.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * 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.
- */
--->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.wifi.inprocess"
- coreApp="true"
- android:sharedUserId="android.uid.system"
- android:versionCode="220000000"
- android:versionName="30 system image">
-
- <uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
-
- <application
- android:persistent="true"
- android:process="system">
- <service
- android:name="com.android.server.wifi.WifiStackService">
- <intent-filter>
- <action android:name="android.net.wifi.IWifiStackConnector.InProcess"/>
- </intent-filter>
- </service>
- <receiver android:name="com.android.server.wifi.BootCompleteReceiver">
- <intent-filter>
- <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- </application>
-</manifest>
diff --git a/service/CleanSpec.mk b/service/CleanSpec.mk
index 2450b6727..da0481f51 100644
--- a/service/CleanSpec.mk
+++ b/service/CleanSpec.mk
@@ -48,6 +48,8 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/wifi.rc)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/WifiStack)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/wifi_inprocess.rc)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/InProcessWifiStack)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/service/jarjar-rules-shared.txt b/service/jarjar-rules-shared.txt
index 8fa2b1a1e..4595cf321 100644
--- a/service/jarjar-rules-shared.txt
+++ b/service/jarjar-rules-shared.txt
@@ -1,25 +1,25 @@
# We don't jar-jar the entire package because, we still use some classes (like
# AsyncChannel in com.android.internal.util) from these packages which are not
# inside our jar (currently in framework.jar, but will be in wifisdk.jar in the future).
-rule com.android.internal.util.FastXmlSerializer* com.android.server.wifi.util.FastXmlSerializer@1
-rule com.android.internal.util.HexDump* com.android.server.wifi.util.HexDump@1
-rule com.android.internal.util.IState* com.android.server.wifi.util.IState@1
-rule com.android.internal.util.MessageUtils* com.android.server.wifi.util.MessageUtils@1
-rule com.android.internal.util.Preconditions* com.android.server.wifi.util.Preconditions@1
-rule com.android.internal.util.State* com.android.server.wifi.util.State@1
-rule com.android.internal.util.StateMachine* com.android.server.wifi.util.StateMachine@1
-rule com.android.internal.util.WakeupMessage* com.android.server.wifi.util.WakeupMessage@1
-rule com.android.internal.util.XmlUtils* com.android.server.wifi.util.XmlUtils@1
+rule com.android.internal.util.FastXmlSerializer* com.android.server.x.wifi.util.FastXmlSerializer@1
+rule com.android.internal.util.HexDump* com.android.server.x.wifi.util.HexDump@1
+rule com.android.internal.util.IState* com.android.server.x.wifi.util.IState@1
+rule com.android.internal.util.MessageUtils* com.android.server.x.wifi.util.MessageUtils@1
+rule com.android.internal.util.Preconditions* com.android.server.x.wifi.util.Preconditions@1
+rule com.android.internal.util.State* com.android.server.x.wifi.util.State@1
+rule com.android.internal.util.StateMachine* com.android.server.x.wifi.util.StateMachine@1
+rule com.android.internal.util.WakeupMessage* com.android.server.x.wifi.util.WakeupMessage@1
+rule com.android.internal.util.XmlUtils* com.android.server.x.wifi.util.XmlUtils@1
-rule android.util.KeyValueListParser* com.android.server.wifi.util.KeyValueListParser@1
-rule android.util.LocalLog* com.android.server.wifi.util.LocalLog@1
-rule android.util.Rational* com.android.server.wifi.util.Rational@1
-rule android.util.proto.ProtoStream* com.android.server.wifi.util.proto.ProtoStream@1
-rule android.util.proto.ProtoOutputStream* com.android.server.wifi.util.proto.ProtoOutputStream@1
+rule android.util.KeyValueListParser* com.android.server.x.wifi.util.KeyValueListParser@1
+rule android.util.LocalLog* com.android.server.x.wifi.util.LocalLog@1
+rule android.util.Rational* com.android.server.x.wifi.util.Rational@1
+rule android.util.proto.ProtoStream* com.android.server.x.wifi.util.proto.ProtoStream@1
+rule android.util.proto.ProtoOutputStream* com.android.server.x.wifi.util.proto.ProtoOutputStream@1
-rule android.os.HandlerExecutor* com.android.server.wifi.os.HandlerExecutor@1
+rule android.os.HandlerExecutor* com.android.server.x.wifi.os.HandlerExecutor@1
# Use our statically linked bouncy castle library
-rule org.bouncycastle.** com.android.server.wifi.bouncycastle.@1
+rule org.bouncycastle.** com.android.server.x.wifi.bouncycastle.@1
# Use our statically linked protobuf library
-rule com.google.protobuf.** com.android.server.wifi.protobuf.@1
+rule com.google.protobuf.** com.android.server.x.wifi.protobuf.@1
diff --git a/service/java/com/android/server/wifi/BootCompleteReceiver.java b/service/java/com/android/server/wifi/BootCompleteReceiver.java
deleted file mode 100644
index 86f263a2d..000000000
--- a/service/java/com/android/server/wifi/BootCompleteReceiver.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.server.wifi;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.util.Log;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.concurrent.GuardedBy;
-
-/**
- * Receives boot complete broadcast (registered in AndroidManifest.xml).
- *
- * Ensures that if WifiStack is initialized after boot complete, we can check whether boot was
- * already completed, since if we start listening for the boot complete broadcast now it will be too
- * late and we will never get the broadcast.
- *
- * This BroadcastReceiver can be registered multiple times in different places, and it will ensure
- * that all registered callbacks are triggered exactly once.
- */
-public class BootCompleteReceiver extends BroadcastReceiver {
- private static final String TAG = "WifiBootCompleteReceiver";
-
- private static final Object sLock = new Object();
- @GuardedBy("sLock")
- private static boolean sIsBootCompleted = false;
- @GuardedBy("sLock")
- private static final List<Runnable> sCallbacks = new ArrayList<>(1);
-
- public BootCompleteReceiver() {
- Log.d(TAG, "Constructed BootCompleteReceiver");
- }
-
- /**
- * Registers a callback that will be triggered when boot is completed. Note that if boot has
- * already been completed when the callback is registered, the callback will be triggered
- * immediately.
- *
- * No guarantees are made about which thread the callback is triggered on. Please do not
- * perform expensive operations in the callback, instead post to other threads.
- */
- public static void registerCallback(Runnable callback) {
- boolean runImmediately = false;
-
- synchronized (sLock) {
- if (sIsBootCompleted) {
- runImmediately = true;
- } else {
- sCallbacks.add(callback);
- }
- }
-
- // run callback outside of synchronized block
- if (runImmediately) {
- Log.d(TAG, "Triggering callback immediately since boot is already complete.");
- callback.run();
- } else {
- Log.d(TAG, "Enqueuing callback since boot is not yet complete.");
- }
- }
-
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d(TAG, "Received boot complete broadcast");
-
- List<Runnable> callbacks = new ArrayList<>(1);
-
- synchronized (sLock) {
- sIsBootCompleted = true;
- callbacks.addAll(sCallbacks);
- sCallbacks.clear();
- }
-
- // run callbacks outside of synchronized block
- for (Runnable r : callbacks) {
- Log.d(TAG, "Triggered callback");
- r.run();
- }
- }
-}
diff --git a/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java b/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
index 3350739bb..02065dac5 100644
--- a/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
+++ b/service/java/com/android/server/wifi/ConnectToNetworkNotificationBuilder.java
@@ -159,7 +159,7 @@ public class ConnectToNetworkNotificationBuilder {
private Notification.Builder createNotificationBuilder(
CharSequence title, CharSequence content, String extraData) {
return mFrameworkFacade.makeNotificationBuilder(mContext,
- WifiStackService.NOTIFICATION_NETWORK_AVAILABLE)
+ WifiService.NOTIFICATION_NETWORK_AVAILABLE)
.setSmallIcon(android.R.drawable.stat_notify_wifi_in_range)
.setTicker(title)
.setContentTitle(title)
diff --git a/service/java/com/android/server/wifi/WakeupNotificationFactory.java b/service/java/com/android/server/wifi/WakeupNotificationFactory.java
index 60b32c042..a16a4e591 100644
--- a/service/java/com/android/server/wifi/WakeupNotificationFactory.java
+++ b/service/java/com/android/server/wifi/WakeupNotificationFactory.java
@@ -66,7 +66,7 @@ public class WakeupNotificationFactory {
.build();
return mFrameworkFacade.makeNotificationBuilder(mContext,
- WifiStackService.NOTIFICATION_NETWORK_STATUS)
+ WifiService.NOTIFICATION_NETWORK_STATUS)
.setSmallIcon(R.drawable.ic_wifi_settings)
.setTicker(title)
.setContentTitle(title)
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 04b8468fb..ce030c918 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -901,7 +901,7 @@ public class WifiNetworkSuggestionsManager {
CharSequence appName = getAppName(packageName, uid);
Notification notification = new Notification.Builder(
- mContext, WifiStackService.NOTIFICATION_NETWORK_STATUS)
+ mContext, WifiService.NOTIFICATION_NETWORK_STATUS)
.setSmallIcon(android.R.drawable.stat_notify_wifi_in_range)
.setTicker(mResources.getString(R.string.wifi_suggestion_title))
.setContentTitle(mResources.getString(R.string.wifi_suggestion_title))
diff --git a/service/java/com/android/server/wifi/WifiService.java b/service/java/com/android/server/wifi/WifiService.java
index aaf9b1989..9eb118278 100644
--- a/service/java/com/android/server/wifi/WifiService.java
+++ b/service/java/com/android/server/wifi/WifiService.java
@@ -16,31 +16,50 @@
package com.android.server.wifi;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
import android.content.Context;
-import android.os.Binder;
import android.util.Log;
+import com.android.server.SystemService;
import com.android.server.wifi.util.WifiAsyncChannel;
+import java.util.ArrayList;
+import java.util.List;
+
/**
- * Manages the wifi service instance.
+ * Service implementing Wi-Fi functionality. Delegates actual interface
+ * implementation to WifiServiceImpl.
*/
-public final class WifiService implements WifiServiceBase {
+public final class WifiService extends SystemService {
private static final String TAG = "WifiService";
+ // Notification channels used by the wifi service.
+ public static final String NOTIFICATION_NETWORK_STATUS = "NETWORK_STATUS";
+ public static final String NOTIFICATION_NETWORK_ALERTS = "NETWORK_ALERTS";
+ public static final String NOTIFICATION_NETWORK_AVAILABLE = "NETWORK_AVAILABLE";
+
final WifiServiceImpl mImpl;
public WifiService(Context context) {
- mImpl = new WifiServiceImpl(context, WifiInjector.getInstance(), new WifiAsyncChannel(TAG));
+ super(context);
+ mImpl = new WifiServiceImpl(context, new WifiInjector(context), new WifiAsyncChannel(TAG));
}
@Override
public void onStart() {
- Log.i(TAG, "Starting " + Context.WIFI_SERVICE);
- mImpl.checkAndStartWifi();
+ Log.i(TAG, "Registering " + Context.WIFI_SERVICE);
+ publishBinderService(Context.WIFI_SERVICE, mImpl);
+ }
- // Trigger all the necessary boot completed actions, since we are starting late now.
- mImpl.handleBootCompleted();
+ @Override
+ public void onBootPhase(int phase) {
+ if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
+ createNotificationChannels(getContext());
+ mImpl.checkAndStartWifi();
+ } else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
+ mImpl.handleBootCompleted();
+ }
}
@Override
@@ -58,8 +77,33 @@ public final class WifiService implements WifiServiceBase {
mImpl.handleUserStop(userId);
}
- @Override
- public Binder retrieveImpl() {
- return mImpl;
+ // Create notification channels used by wifi.
+ private static void createNotificationChannels(Context ctx) {
+ final NotificationManager nm = ctx.getSystemService(NotificationManager.class);
+ List<NotificationChannel> channelsList = new ArrayList<>();
+ final NotificationChannel networkStatusChannel = new NotificationChannel(
+ NOTIFICATION_NETWORK_STATUS,
+ ctx.getResources().getString(
+ android.R.string.notification_channel_network_status),
+ NotificationManager.IMPORTANCE_LOW);
+ channelsList.add(networkStatusChannel);
+
+ final NotificationChannel networkAlertsChannel = new NotificationChannel(
+ NOTIFICATION_NETWORK_ALERTS,
+ ctx.getResources().getString(
+ android.R.string.notification_channel_network_alerts),
+ NotificationManager.IMPORTANCE_HIGH);
+ networkAlertsChannel.setBlockableSystem(true);
+ channelsList.add(networkAlertsChannel);
+
+ final NotificationChannel networkAvailable = new NotificationChannel(
+ NOTIFICATION_NETWORK_AVAILABLE,
+ ctx.getResources().getString(
+ android.R.string.notification_channel_network_available),
+ NotificationManager.IMPORTANCE_LOW);
+ networkAvailable.setBlockableSystem(true);
+ channelsList.add(networkAvailable);
+
+ nm.createNotificationChannels(channelsList);
}
}
diff --git a/service/java/com/android/server/wifi/WifiServiceBase.java b/service/java/com/android/server/wifi/WifiServiceBase.java
deleted file mode 100644
index 8cf8add6d..000000000
--- a/service/java/com/android/server/wifi/WifiServiceBase.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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 android.os.Binder;
-
-/**
- * Base class for all the wifi services. This is used to manage the lifetime of the services.
- * Each service should override the methods corresponding to the lifetime events they care about.
- *
- * Note: Services can listen to these system broadcasts on their own, but they're explicitly listed
- * here to better manage inter-service dependencies. (For ex: wifi aware service needs wifi service
- * to initialize the HAL first).
- */
-public interface WifiServiceBase {
- /**
- * Invoked when the APK service is bound. Should bed used to publish
- * it's binder service & perform necessary initialization. This should happen very close to
- * bootup phase {@link SystemService#PHASE_BOOT_COMPLETED} in system_server.
- */
- void onStart();
-
- /**
- * Invoked when the user switches.
- *
- * @param userId Id for the new user.
- */
- default void onSwitchUser(int userId) {}
-
- /**
- * Invoked when the user unlocks.
- *
- * @param userId Id for the user.
- */
- default void onUnlockUser(int userId) {}
-
- /**
- * Invoked when the user stops.
- *
- * @param userId Id for the user.
- */
- default void onStopUser(int userId) {}
-
- /**
- * Retrieve the underlying binder service implementation.
- */
- Binder retrieveImpl();
-}
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index c8a445fa3..5ed82a8ec 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -72,7 +72,6 @@ import android.net.wifi.WifiManager.SuggestionConnectionStatusListener;
import android.net.wifi.WifiNetworkSuggestion;
import android.net.wifi.WifiScanner;
import android.net.wifi.WifiSsid;
-import android.net.wifi.WifiStackClient;
import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
@@ -510,11 +509,6 @@ public class WifiServiceImpl extends BaseWifiService {
== PackageManager.PERMISSION_GRANTED;
}
- private boolean checkMainlineWifiStackPermission(int pid, int uid) {
- return mContext.checkPermission(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK, pid, uid)
- == PackageManager.PERMISSION_GRANTED;
- }
-
private boolean checkNetworkManagedProvisioningPermission(int pid, int uid) {
return mContext.checkPermission(android.Manifest.permission.NETWORK_MANAGED_PROVISIONING,
pid, uid) == PackageManager.PERMISSION_GRANTED;
@@ -528,8 +522,7 @@ public class WifiServiceImpl extends BaseWifiService {
return checkNetworkSettingsPermission(pid, uid)
|| checkNetworkSetupWizardPermission(pid, uid)
|| checkNetworkStackPermission(pid, uid)
- || checkNetworkManagedProvisioningPermission(pid, uid)
- || checkMainlineWifiStackPermission(pid, uid);
+ || checkNetworkManagedProvisioningPermission(pid, uid);
}
/**
diff --git a/service/java/com/android/server/wifi/WifiStackService.java b/service/java/com/android/server/wifi/WifiStackService.java
deleted file mode 100644
index b673620d9..000000000
--- a/service/java/com/android/server/wifi/WifiStackService.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * 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.server.wifi;
-
-import android.annotation.NonNull;
-import android.app.ActivityManager;
-import android.app.NotificationChannel;
-import android.app.NotificationManager;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.net.wifi.IWifiStackConnector;
-import android.net.wifi.WifiApiServiceInfo;
-import android.os.Binder;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Looper;
-import android.os.UserHandle;
-import android.os.storage.StorageManager;
-import android.util.Log;
-
-import com.android.internal.annotations.GuardedBy;
-import com.android.server.wifi.aware.WifiAwareService;
-import com.android.server.wifi.p2p.WifiP2pService;
-import com.android.server.wifi.rtt.RttService;
-import com.android.server.wifi.scanner.WifiScanningService;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Android service used to start the wifi stack when bound to via an intent.
- */
-public class WifiStackService extends Service {
- private static final String TAG = WifiStackService.class.getSimpleName();
-
- // Notification channels used by the wifi stack.
- public static final String NOTIFICATION_NETWORK_STATUS = "NETWORK_STATUS";
- public static final String NOTIFICATION_NETWORK_ALERTS = "NETWORK_ALERTS";
- public static final String NOTIFICATION_NETWORK_AVAILABLE = "NETWORK_AVAILABLE";
-
- // Ordered list of wifi services. The ordering determines the order in which the events
- // are delivered to the services.
- @GuardedBy("mApiServices")
- private final LinkedHashMap<String, WifiServiceBase> mApiServices = new LinkedHashMap<>();
- private static WifiStackConnector sConnector;
-
- private class WifiStackConnector extends IWifiStackConnector.Stub {
- private final Context mContext;
-
- WifiStackConnector(Context context) {
- mContext = context;
- }
-
- @Override
- public List<WifiApiServiceInfo> getWifiApiServiceInfos() {
- // Ensure this is being invoked from system_server only.
- mContext.enforceCallingOrSelfPermission(
- android.Manifest.permission.NETWORK_STACK, "WifiStackService");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (mApiServices) {
- return mApiServices.entrySet().stream()
- .map(entry -> {
- WifiApiServiceInfo service = new WifiApiServiceInfo();
- service.name = entry.getKey();
- service.binder = entry.getValue().retrieveImpl();
- return service;
- })
- .collect(Collectors.toList());
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- private class WifiBroadcastReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.i(TAG, "Received " + intent + " broadcast");
- final String action = intent.getAction();
- if (action == null) {
- Log.w(TAG, "Received null action for broadcast.");
- return;
- }
- int userId;
- switch (action) {
- case Intent.ACTION_USER_SWITCHED:
- userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
- synchronized (mApiServices) {
- for (WifiServiceBase service : mApiServices.values()) {
- service.onSwitchUser(userId);
- }
- }
- break;
- case Intent.ACTION_USER_STOPPED:
- userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
- synchronized (mApiServices) {
- for (WifiServiceBase service : mApiServices.values()) {
- service.onStopUser(userId);
- }
- }
- break;
- case Intent.ACTION_USER_UNLOCKED:
- userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
- synchronized (mApiServices) {
- for (WifiServiceBase service : mApiServices.values()) {
- service.onUnlockUser(userId);
- }
- }
- break;
- default:
- Log.e(TAG, "Received unexpected action for broadcast.");
- break;
- }
- }
- }
-
- // Create notification channels used by wifi.
- private void createNotificationChannels() {
- final NotificationManager nm = getSystemService(NotificationManager.class);
- List<NotificationChannel> channelsList = new ArrayList<>();
- final NotificationChannel networkStatusChannel = new NotificationChannel(
- NOTIFICATION_NETWORK_STATUS,
- getString(android.R.string.notification_channel_network_status),
- NotificationManager.IMPORTANCE_LOW);
- channelsList.add(networkStatusChannel);
-
- final NotificationChannel networkAlertsChannel = new NotificationChannel(
- NOTIFICATION_NETWORK_ALERTS,
- getString(android.R.string.notification_channel_network_alerts),
- NotificationManager.IMPORTANCE_HIGH);
- networkAlertsChannel.setBlockableSystem(true);
- channelsList.add(networkAlertsChannel);
-
- final NotificationChannel networkAvailable = new NotificationChannel(
- NOTIFICATION_NETWORK_AVAILABLE,
- getString(android.R.string.notification_channel_network_available),
- NotificationManager.IMPORTANCE_LOW);
- networkAvailable.setBlockableSystem(true);
- channelsList.add(networkAvailable);
-
- nm.createNotificationChannels(channelsList);
- }
-
-
- private synchronized boolean initializeServices(Context context) {
- if (UserHandle.myUserId() != 0) {
- Log.w(TAG, "Wifi stack can only be bound from primary user");
- return false;
- }
- // Don't start wifi services if we're in crypt bounce state.
- if (StorageManager.inCryptKeeperBounce()) {
- Log.d(TAG, "Device still encrypted. Need to restart SystemServer."
- + " Do not start wifi.");
- return false;
- }
-
- // BootCompleteReceiver is registered in AndroidManifest.xml and here. The receiver
- // registered here is triggered earlier, while the receiver registered in the manifest
- // is more reliable since it is registered earlier, so we are guaranteed to get the
- // broadcast (if we register too late the broadcast may have already triggered and we
- // would have missed it). Register in both places and BootCompleteReceiver will ensure that
- // callbacks are called exactly once.
- Log.d(TAG, "Registering BootCompleteReceiver to listen for ACTION_LOCKED_BOOT_COMPLETED");
- context.registerReceiver(new BootCompleteReceiver(),
- new IntentFilter(Intent.ACTION_LOCKED_BOOT_COMPLETED));
-
- synchronized (mApiServices) {
- // Top level wifi feature flag.
- if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
- Log.w(TAG, "Wifi not supported on the device");
- return false;
- }
-
- // initialize static instance of WifiInjector
- new WifiInjector(this);
- // Ordering of wifi services.
- // wifiscanner service
- mApiServices.put(Context.WIFI_SCANNING_SERVICE, new WifiScanningService(this));
- // wifi service
- mApiServices.put(Context.WIFI_SERVICE, new WifiService(this));
- // wifi-p2p service
- if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_DIRECT)) {
- mApiServices.put(Context.WIFI_P2P_SERVICE, new WifiP2pService(this));
- }
- // wifi-aware service
- if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE)) {
- mApiServices.put(Context.WIFI_AWARE_SERVICE, new WifiAwareService(this));
- }
- // wifirtt service
- if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_RTT)) {
- mApiServices.put(Context.WIFI_RTT_RANGING_SERVICE, new RttService(this));
- }
- }
-
- Handler handler = new Handler(Looper.myLooper());
- // register callback to start Wifi services after boot completes
- BootCompleteReceiver.registerCallback(() -> handler.post(() -> {
- int currentUser = ActivityManager.getCurrentUser();
- synchronized (mApiServices) {
- for (WifiServiceBase service : mApiServices.values()) {
- service.onStart();
- // The current active user might have switched before the wifi services started
- // up. So, send a onSwitchUser callback just after onStart callback is invoked.
- if (currentUser != UserHandle.USER_SYSTEM) {
- service.onSwitchUser(currentUser);
- }
- }
- }
- }));
-
- // Register broadcast receiver for system events.
- IntentFilter intentFilter = new IntentFilter();
- intentFilter.addAction(Intent.ACTION_USER_SWITCHED);
- intentFilter.addAction(Intent.ACTION_USER_STOPPED);
- intentFilter.addAction(Intent.ACTION_USER_UNLOCKED);
- registerReceiver(new WifiBroadcastReceiver(), intentFilter);
-
- // Create notification channels.
- createNotificationChannels();
-
- return true;
- }
-
- /**
- * Create a binder connector for the system server to communicate with the network stack.
- *
- * <p>On platforms where the network stack runs in the system server process, this method may
- * be called directly instead of obtaining the connector by binding to the service.
- */
- private synchronized IBinder makeConnectorAndInitializeServices(Context context) {
- if (sConnector == null) {
- if (!initializeServices(context)) {
- Log.w(TAG, "Failed to initialize services");
- return null;
- }
- sConnector = new WifiStackConnector(context);
- }
- return sConnector;
- }
-
- @NonNull
- @Override
- public IBinder onBind(Intent intent) {
- Log.i(TAG, "WifiStack Service onBind");
- return makeConnectorAndInitializeServices(this);
- }
-}
diff --git a/service/java/com/android/server/wifi/WrongPasswordNotifier.java b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
index 253af5e4f..2ad7b2cba 100644
--- a/service/java/com/android/server/wifi/WrongPasswordNotifier.java
+++ b/service/java/com/android/server/wifi/WrongPasswordNotifier.java
@@ -81,7 +81,7 @@ public class WrongPasswordNotifier {
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
intent.putExtra("wifi_start_connect_ssid", NativeUtil.removeEnclosingQuotes(ssid));
Notification.Builder builder = mFrameworkFacade.makeNotificationBuilder(mContext,
- WifiStackService.NOTIFICATION_NETWORK_ALERTS)
+ WifiService.NOTIFICATION_NETWORK_ALERTS)
.setAutoCancel(true)
.setTimeoutAfter(CANCEL_TIMEOUT_MILLISECONDS)
// TODO(zqiu): consider creating a new icon.
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareService.java b/service/java/com/android/server/wifi/aware/WifiAwareService.java
index e4b1e443c..f38c37316 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareService.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareService.java
@@ -17,63 +17,64 @@
package com.android.server.wifi.aware;
import android.content.Context;
-import android.os.Binder;
import android.os.HandlerThread;
import android.util.Log;
+import com.android.server.SystemService;
import com.android.server.wifi.HalDeviceManager;
import com.android.server.wifi.WifiInjector;
-import com.android.server.wifi.WifiServiceBase;
/**
* Service implementing Wi-Fi Aware functionality. Delegates actual interface
* implementation to WifiAwareServiceImpl.
*/
-public final class WifiAwareService implements WifiServiceBase {
+public final class WifiAwareService extends SystemService {
private static final String TAG = "WifiAwareService";
final WifiAwareServiceImpl mImpl;
public WifiAwareService(Context context) {
+ super(context);
mImpl = new WifiAwareServiceImpl(context);
}
@Override
public void onStart() {
- Log.i(TAG, "Starting " + Context.WIFI_AWARE_SERVICE);
- WifiInjector wifiInjector = WifiInjector.getInstance();
- if (wifiInjector == null) {
- Log.e(TAG, "NULL injector!");
- return;
- }
-
- HalDeviceManager halDeviceManager = wifiInjector.getHalDeviceManager();
+ Log.i(TAG, "Registering " + Context.WIFI_AWARE_SERVICE);
+ publishBinderService(Context.WIFI_AWARE_SERVICE, mImpl);
+ }
- WifiAwareStateManager wifiAwareStateManager = new WifiAwareStateManager();
- WifiAwareNativeCallback wifiAwareNativeCallback = new WifiAwareNativeCallback(
- wifiAwareStateManager);
- WifiAwareNativeManager wifiAwareNativeManager = new WifiAwareNativeManager(
- wifiAwareStateManager, halDeviceManager, wifiAwareNativeCallback);
- WifiAwareNativeApi wifiAwareNativeApi = new WifiAwareNativeApi(wifiAwareNativeManager);
- wifiAwareStateManager.setNative(wifiAwareNativeManager, wifiAwareNativeApi);
- WifiAwareShellCommand wifiAwareShellCommand = new WifiAwareShellCommand();
- wifiAwareShellCommand.register("native_api", wifiAwareNativeApi);
- wifiAwareShellCommand.register("native_cb", wifiAwareNativeCallback);
- wifiAwareShellCommand.register("state_mgr", wifiAwareStateManager);
+ @Override
+ public void onBootPhase(int phase) {
+ if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
+ WifiInjector wifiInjector = WifiInjector.getInstance();
+ if (wifiInjector == null) {
+ Log.e(TAG, "onBootPhase(PHASE_SYSTEM_SERVICES_READY): NULL injector!");
+ return;
+ }
- HandlerThread awareHandlerThread = wifiInjector.getWifiAwareHandlerThread();
- mImpl.start(awareHandlerThread, wifiAwareStateManager, wifiAwareShellCommand,
- wifiInjector.getWifiMetrics().getWifiAwareMetrics(),
- wifiInjector.getWifiPermissionsUtil(),
- wifiInjector.getWifiPermissionsWrapper(), wifiInjector.getFrameworkFacade(),
- wifiAwareNativeManager, wifiAwareNativeApi, wifiAwareNativeCallback);
+ HalDeviceManager halDeviceManager = wifiInjector.getHalDeviceManager();
- // TODO: This 2 step initialization is no longer necessary because of service ordering in
- // WifiStackService.
- mImpl.startLate();
- }
+ WifiAwareStateManager wifiAwareStateManager = new WifiAwareStateManager();
+ WifiAwareNativeCallback wifiAwareNativeCallback = new WifiAwareNativeCallback(
+ wifiAwareStateManager);
+ WifiAwareNativeManager wifiAwareNativeManager = new WifiAwareNativeManager(
+ wifiAwareStateManager, halDeviceManager, wifiAwareNativeCallback);
+ WifiAwareNativeApi wifiAwareNativeApi = new WifiAwareNativeApi(wifiAwareNativeManager);
+ wifiAwareStateManager.setNative(wifiAwareNativeManager, wifiAwareNativeApi);
+ WifiAwareShellCommand wifiAwareShellCommand = new WifiAwareShellCommand();
+ wifiAwareShellCommand.register("native_api", wifiAwareNativeApi);
+ wifiAwareShellCommand.register("native_cb", wifiAwareNativeCallback);
+ wifiAwareShellCommand.register("state_mgr", wifiAwareStateManager);
- @Override
- public Binder retrieveImpl() {
- return mImpl;
+ HandlerThread awareHandlerThread = wifiInjector.getWifiAwareHandlerThread();
+ mImpl.start(awareHandlerThread, wifiAwareStateManager, wifiAwareShellCommand,
+ wifiInjector.getWifiMetrics().getWifiAwareMetrics(),
+ wifiInjector.getWifiPermissionsUtil(),
+ wifiInjector.getWifiPermissionsWrapper(), wifiInjector.getFrameworkFacade(),
+ wifiAwareNativeManager, wifiAwareNativeApi, wifiAwareNativeCallback);
+ } else if (phase == SystemService.PHASE_BOOT_COMPLETED) {
+ mImpl.startLate();
+ }
}
}
+
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pService.java b/service/java/com/android/server/wifi/p2p/WifiP2pService.java
index 97da28b3e..6137c3cd9 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pService.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pService.java
@@ -17,34 +17,36 @@
package com.android.server.wifi.p2p;
import android.content.Context;
-import android.os.Binder;
import android.util.Log;
+import com.android.server.SystemService;
import com.android.server.wifi.WifiInjector;
-import com.android.server.wifi.WifiServiceBase;
/**
* Wifi P2p Service class, instantiates P2p service
- * Overrides onStart() and onBootCompleted() methods in
+ * Overrides onStart() and onBootPhase() methods in
* the super class.
*/
-public final class WifiP2pService implements WifiServiceBase {
+public final class WifiP2pService extends SystemService {
private static final String TAG = "WifiP2pService";
final WifiP2pServiceImpl mImpl;
public WifiP2pService(Context context) {
+ super(context);
mImpl = new WifiP2pServiceImpl(context, WifiInjector.getInstance());
}
@Override
public void onStart() {
- Log.i(TAG, "Starting " + Context.WIFI_P2P_SERVICE);
- mImpl.connectivityServiceReady();
+ Log.i(TAG, "Registering " + Context.WIFI_P2P_SERVICE);
+ publishBinderService(Context.WIFI_P2P_SERVICE, mImpl);
}
@Override
- public Binder retrieveImpl() {
- return mImpl;
+ public void onBootPhase(int phase) {
+ if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
+ mImpl.connectivityServiceReady();
+ }
}
}
diff --git a/service/java/com/android/server/wifi/rtt/RttService.java b/service/java/com/android/server/wifi/rtt/RttService.java
index e4ce9235f..74370516e 100644
--- a/service/java/com/android/server/wifi/rtt/RttService.java
+++ b/service/java/com/android/server/wifi/rtt/RttService.java
@@ -18,53 +18,57 @@ package com.android.server.wifi.rtt;
import android.content.Context;
import android.net.wifi.aware.IWifiAwareManager;
-import android.os.Binder;
import android.os.HandlerThread;
import android.os.ServiceManager;
import android.util.Log;
+import com.android.server.SystemService;
import com.android.server.wifi.HalDeviceManager;
import com.android.server.wifi.WifiInjector;
-import com.android.server.wifi.WifiServiceBase;
import com.android.server.wifi.util.WifiPermissionsUtil;
/**
* TBD.
*/
-public class RttService implements WifiServiceBase {
+public class RttService extends SystemService {
private static final String TAG = "RttService";
private Context mContext;
private RttServiceImpl mImpl;
public RttService(Context context) {
+ super(context);
mContext = context;
mImpl = new RttServiceImpl(context);
}
@Override
public void onStart() {
- Log.i(TAG, "Starting " + Context.WIFI_RTT_RANGING_SERVICE);
- WifiInjector wifiInjector = WifiInjector.getInstance();
- if (wifiInjector == null) {
- Log.e(TAG, "onBootPhase(PHASE_SYSTEM_SERVICES_READY): NULL injector!");
- return;
- }
+ Log.i(TAG, "Registering " + Context.WIFI_RTT_RANGING_SERVICE);
+ publishBinderService(Context.WIFI_RTT_RANGING_SERVICE, mImpl);
+ }
- HalDeviceManager halDeviceManager = wifiInjector.getHalDeviceManager();
- HandlerThread handlerThread = wifiInjector.getRttHandlerThread();
- WifiPermissionsUtil wifiPermissionsUtil = wifiInjector.getWifiPermissionsUtil();
- RttMetrics rttMetrics = wifiInjector.getWifiMetrics().getRttMetrics();
+ @Override
+ public void onBootPhase(int phase) {
+ if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
+ Log.i(TAG, "Starting " + Context.WIFI_RTT_RANGING_SERVICE);
- IWifiAwareManager awareBinder = (IWifiAwareManager) ServiceManager.getService(
- Context.WIFI_AWARE_SERVICE);
+ WifiInjector wifiInjector = WifiInjector.getInstance();
+ if (wifiInjector == null) {
+ Log.e(TAG, "onBootPhase(PHASE_SYSTEM_SERVICES_READY): NULL injector!");
+ return;
+ }
- RttNative rttNative = new RttNative(mImpl, halDeviceManager);
- mImpl.start(handlerThread.getLooper(), wifiInjector.getClock(), awareBinder, rttNative,
- rttMetrics, wifiPermissionsUtil, wifiInjector.getFrameworkFacade());
- }
+ HalDeviceManager halDeviceManager = wifiInjector.getHalDeviceManager();
+ HandlerThread handlerThread = wifiInjector.getRttHandlerThread();
+ WifiPermissionsUtil wifiPermissionsUtil = wifiInjector.getWifiPermissionsUtil();
+ RttMetrics rttMetrics = wifiInjector.getWifiMetrics().getRttMetrics();
- @Override
- public Binder retrieveImpl() {
- return mImpl;
+ IWifiAwareManager awareBinder = (IWifiAwareManager) ServiceManager.getService(
+ Context.WIFI_AWARE_SERVICE);
+
+ RttNative rttNative = new RttNative(mImpl, halDeviceManager);
+ mImpl.start(handlerThread.getLooper(), wifiInjector.getClock(), awareBinder, rttNative,
+ rttMetrics, wifiPermissionsUtil, wifiInjector.getFrameworkFacade());
+ }
}
}
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningService.java b/service/java/com/android/server/wifi/scanner/WifiScanningService.java
index 3f2ebb04a..8c0de0e8c 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningService.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningService.java
@@ -18,23 +18,24 @@ package com.android.server.wifi.scanner;
import android.content.Context;
import android.os.BatteryStatsManager;
-import android.os.Binder;
import android.os.HandlerThread;
import android.util.Log;
+import com.android.server.SystemService;
import com.android.server.wifi.WifiInjector;
-import com.android.server.wifi.WifiServiceBase;
/**
- * Manages the wifi scanner service instance.
+ * Service implementing Wi-Fi scanning functionality. Delegates actual interface
+ * implementation to WifiScanningServiceImpl.
*/
-public class WifiScanningService implements WifiServiceBase {
+public class WifiScanningService extends SystemService {
static final String TAG = "WifiScanningService";
private final WifiScanningServiceImpl mImpl;
private final HandlerThread mHandlerThread;
public WifiScanningService(Context context) {
+ super(context);
Log.i(TAG, "Creating " + Context.WIFI_SCANNING_SERVICE);
mHandlerThread = new HandlerThread("WifiScanningService");
mHandlerThread.start();
@@ -46,12 +47,15 @@ public class WifiScanningService implements WifiServiceBase {
@Override
public void onStart() {
- Log.i(TAG, "Starting " + Context.WIFI_SCANNING_SERVICE);
- mImpl.startService();
+ Log.i(TAG, "Publishing " + Context.WIFI_SCANNING_SERVICE);
+ publishBinderService(Context.WIFI_SCANNING_SERVICE, mImpl);
}
@Override
- public Binder retrieveImpl() {
- return mImpl;
+ public void onBootPhase(int phase) {
+ if (phase == SystemService.PHASE_SYSTEM_SERVICES_READY) {
+ Log.i(TAG, "Starting " + Context.WIFI_SCANNING_SERVICE);
+ mImpl.startService();
+ }
}
}
diff --git a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
index 7a99f0946..27efc91fd 100644
--- a/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
+++ b/service/java/com/android/server/wifi/scanner/WifiScanningServiceImpl.java
@@ -16,8 +16,10 @@
package com.android.server.wifi.scanner;
+import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
+import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AlarmManager;
@@ -30,7 +32,6 @@ import android.net.wifi.WifiScanner.PnoSettings;
import android.net.wifi.WifiScanner.ScanData;
import android.net.wifi.WifiScanner.ScanSettings;
import android.net.wifi.WifiScanner.WifiBand;
-import android.net.wifi.WifiStackClient;
import android.os.BadParcelableException;
import android.os.BatteryStatsManager;
import android.os.Binder;
@@ -128,16 +129,11 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
return b;
}
- private void enforceWifiStackPermission(int uid) {
+ private void enforceNetworkStack(int uid) {
mContext.enforcePermission(
- WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK,
+ Manifest.permission.NETWORK_STACK,
UNKNOWN_PID, uid,
- "MainlineWifiStack");
- }
-
- private boolean checkWifiStackPermission(int uid) {
- return mContext.checkPermission(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK,
- UNKNOWN_PID, uid) == PERMISSION_GRANTED;
+ "NetworkStack");
}
// Helper method to check if the incoming message is for a privileged request.
@@ -214,8 +210,8 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
boolean isPrivilegedRequest, boolean shouldIgnoreLocationSettings,
boolean shouldHideFromApps) {
try {
- // Wifi stack issued requests.
- enforceWifiStackPermission(uid);
+ /** Wifi stack issued requests.*/
+ enforceNetworkStack(uid);
} catch (SecurityException e) {
// System-app issued requests
if (isPrivilegedRequest) {
@@ -1033,7 +1029,9 @@ public class WifiScanningServiceImpl extends IWifiScanner.Stub {
Log.e(TAG, "Invalid scan type " + settings.type);
return false;
}
- if (!checkWifiStackPermission(ci.getUid())) {
+ if (mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, UNKNOWN_PID, ci.getUid())
+ == PERMISSION_DENIED) {
if (!ArrayUtils.isEmpty(settings.hiddenNetworks)) {
Log.e(TAG, "Failing single scan because app " + ci.getUid()
+ " does not have permission to set hidden networks");
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
index 5e651d415..d733c93d5 100644
--- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
+++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java
@@ -408,8 +408,13 @@ public class WifiPermissionsUtil {
*/
public boolean isLocationModeEnabled() {
if (!retrieveLocationManagerIfNecessary()) return false;
- return mLocationManager.isLocationEnabledForUser(UserHandle.of(
- mWifiPermissionsWrapper.getCurrentUser()));
+ try {
+ return mLocationManager.isLocationEnabledForUser(UserHandle.of(
+ mWifiPermissionsWrapper.getCurrentUser()));
+ } catch (Exception e) {
+ Log.e(TAG, "Failure to get location mode", e);
+ return false;
+ }
}
/**
diff --git a/service/proguard.flags b/service/proguard.flags
index 84d9556f8..d2d7866ad 100644
--- a/service/proguard.flags
+++ b/service/proguard.flags
@@ -1,2 +1,5 @@
-# Prevent proguard from stripping out any proto fields.
--keep class com.android.server.wifi.proto.** { *; }
+# Prevent proguard from stripping out any wifi-service.
+# TODO: This could be optimized in the future to only keep the critical
+# entry points and then let proguard strip out any unused code within
+# the service.
+-keep class com.android.server.wifi.** { *; }
diff --git a/service/wifi.rc b/service/wifi.rc
index 5362ee69f..927067bda 100644
--- a/service/wifi.rc
+++ b/service/wifi.rc
@@ -14,26 +14,6 @@
# limitations under the License.
#
-# These are needed for migration of data from "system" user to "network_stack" user
-# since wifi is no longer running in "system_server".
-on post-fs-data
- chown network_stack network_stack /data/misc/wifi
- chown network_stack network_stack /data/misc/wifi/WifiConfigStore.xml
- chown network_stack network_stack /data/misc/wifi/WifiConfigStoreSoftAp.xml
- chown network_stack network_stack /data/misc/wifi/softap.conf
-
-on property:sys.user.0.ce_available=true
- mkdir /data/misc_ce/0/wifi 0770 network_stack network_stack
- # For devices upgrading, we need to change permission.
- chown network_stack network_stack /data/misc_ce/0/wifi
- chown network_stack network_stack /data/misc_ce/0/wifi/WifiConfigStore.xml
- chown network_stack network_stack /data/misc_ce/0/wifi/WifiConfigStoreNetworkSuggestions.xml
-
- # Load the new sepolicy file context labels (these files were relabeled in R).
- restorecon /data/misc_ce/0/wifi
- restorecon /data/misc_ce/0/wifi/WifiConfigStore.xml
- restorecon /data/misc_ce/0/wifi/WifiConfigStoreNetworkSuggestions.xml
-
# Below are for kernel tracing related stuff.
on fs
setprop sys.wifitracing.started 0
@@ -70,11 +50,11 @@ on property:sys.boot_completed=1 && property:sys.wifitracing.started=0
write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_rx/enable 1
write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_receive_skb/enable 1
- # Set DAC to allow network_stack to enable/disable, and read wifi trace
+ # Set DAC to allow system to enable/disable, and read wifi trace
# events.
- chown network_stack network_stack /sys/kernel/debug/tracing/instances/wifi/tracing_on
- chown network_stack network_stack /sys/kernel/debug/tracing/instances/wifi/free_buffer
- chown network_stack network_stack /sys/kernel/debug/tracing/instances/wifi/trace
+ chown system /sys/kernel/debug/tracing/instances/wifi/tracing_on
+ chown system /sys/kernel/debug/tracing/instances/wifi/free_buffer
+ chown system /sys/kernel/debug/tracing/instances/wifi/trace
chmod 200 /sys/kernel/debug/tracing/instances/wifi/tracing_on
chmod 400 /sys/kernel/debug/tracing/instances/wifi/free_buffer
chmod 600 /sys/kernel/debug/tracing/instances/wifi/trace
diff --git a/service/wifi_inprocess.rc b/service/wifi_inprocess.rc
deleted file mode 100644
index 43e4866b5..000000000
--- a/service/wifi_inprocess.rc
+++ /dev/null
@@ -1,85 +0,0 @@
-#
-# Copyright (C) 2016 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.
-#
-
-# These are needed for migration of data from "network_stack" user to "system" user
-# if wifi is no longer running in "system_server".
-on post-fs-data
- chown system system /data/misc/wifi
- chown system system /data/misc/wifi/WifiConfigStore.xml
- chown system system /data/misc/wifi/WifiConfigStoreSoftAp.xml
- chown system system /data/misc/wifi/softap.conf
-
-on property:sys.user.0.ce_available=true
- mkdir /data/misc_ce/0/wifi 0770 system system
- # For devices upgrading, we need to change permission.
- chown system system /data/misc_ce/0/wifi
- chown system system /data/misc_ce/0/wifi/WifiConfigStore.xml
- chown system system /data/misc_ce/0/wifi/WifiConfigStoreNetworkSuggestions.xml
-
- # Load the new sepolicy file context labels (these files were relabeled in R).
- restorecon /data/misc_ce/0/wifi
- restorecon /data/misc_ce/0/wifi/WifiConfigStore.xml
- restorecon /data/misc_ce/0/wifi/WifiConfigStoreNetworkSuggestions.xml
-
-# Below are for kernel tracing related stuff.
-on fs
- setprop sys.wifitracing.started 0
-
-on property:sys.boot_completed=1 && property:sys.wifitracing.started=0
- # Create trace buffer, and set basic configuration.
- mkdir /sys/kernel/debug/tracing/instances/wifi 711
- restorecon_recursive /sys/kernel/debug/tracing/instances/wifi
- write /sys/kernel/debug/tracing/instances/wifi/tracing_on 0
- write /sys/kernel/debug/tracing/instances/wifi/buffer_size_kb 1
- write /sys/kernel/debug/tracing/instances/wifi/trace_options disable_on_free
-
- # Enable cfg80211 events for connection and key management events.
- # - Events are not actually logged until WifiService writes "1" to
- # /sys/kernel/debug/tracing/instances/wifi/tracing_on.
- # - WifiService is responsible for turning tracing off and on.
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/cfg80211_gtk_rekey_notify/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_add_key/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_assoc/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_auth/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_connect/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_default_key/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_default_mgmt_key/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/cfg80211/rdev_set_rekey_data/enable 1
-
- # Enable datapath events for Wifi.
- # - Events are not actually logged until WifiService writes "1" to
- # /sys/kernel/debug/tracing/instances/wifi/tracing_on.
- # - WifiService will ensure that tracing is turned back off,
- # when a connection attempt ends (whether in success or failure)
- write /sys/kernel/debug/tracing/instances/wifi/events/net/filter name==${wifi.interface:-wlan0}
- write /sys/kernel/debug/tracing/instances/wifi/events/net/net_dev_queue/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/net/net_dev_xmit/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_rx/enable 1
- write /sys/kernel/debug/tracing/instances/wifi/events/net/netif_receive_skb/enable 1
-
- # Set DAC to allow system to enable/disable, and read wifi trace
- # events.
- chown system /sys/kernel/debug/tracing/instances/wifi/tracing_on
- chown system /sys/kernel/debug/tracing/instances/wifi/free_buffer
- chown system /sys/kernel/debug/tracing/instances/wifi/trace
- chmod 200 /sys/kernel/debug/tracing/instances/wifi/tracing_on
- chmod 400 /sys/kernel/debug/tracing/instances/wifi/free_buffer
- chmod 600 /sys/kernel/debug/tracing/instances/wifi/trace
- setprop sys.wifitracing.started 1
-
-on property:sys.boot_completed=1 && property:wifi.interface=* && property:sys.wifitracing.started=1
- # Override default value.
- write /sys/kernel/debug/tracing/instances/wifi/events/net/filter name==${wifi.interface}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
index e527ed05e..4bf695d77 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java
@@ -114,7 +114,6 @@ import android.net.wifi.WifiManager.SoftApCallback;
import android.net.wifi.WifiNetworkScoreCache;
import android.net.wifi.WifiNetworkSuggestion;
import android.net.wifi.WifiSsid;
-import android.net.wifi.WifiStackClient;
import android.net.wifi.hotspot2.IProvisioningCallback;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
@@ -361,8 +360,6 @@ public class WifiServiceImplTest extends WifiBaseTest {
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
when(mContext.checkPermission(eq(android.Manifest.permission.NETWORK_MANAGED_PROVISIONING),
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_DENIED);
when(mScanRequestProxy.startScan(anyInt(), anyString())).thenReturn(true);
when(mLohsCallback.asBinder()).thenReturn(mock(IBinder.class));
diff --git a/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
index ae184bec7..3b4bdfd31 100644
--- a/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WrongPasswordNotifierTest.java
@@ -71,7 +71,7 @@ public class WrongPasswordNotifierTest extends WifiBaseTest {
@Test
public void onWrongPasswordError() throws Exception {
when(mFrameworkFacade.makeNotificationBuilder(any(),
- eq(WifiStackService.NOTIFICATION_NETWORK_ALERTS))).thenReturn(mNotificationBuilder);
+ eq(WifiService.NOTIFICATION_NETWORK_ALERTS))).thenReturn(mNotificationBuilder);
mWrongPassNotifier.onWrongPasswordError(TEST_SSID);
verify(mNotificationManager).notify(eq(WrongPasswordNotifier.NOTIFICATION_ID), any());
ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
diff --git a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
index 666028a98..d1cb3ba86 100644
--- a/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/scanner/WifiScanningServiceTest.java
@@ -52,6 +52,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
+import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.test.MockAnswerUtil.AnswerWithArguments;
@@ -60,7 +61,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiScanner;
-import android.net.wifi.WifiStackClient;
import android.os.BatteryStatsManager;
import android.os.Binder;
import android.os.Bundle;
@@ -189,7 +189,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
when(mWifiNative.getClientInterfaceNames())
.thenReturn(new ArraySet<>(Arrays.asList(TEST_IFACE_NAME_0)));
when(mWifiInjector.getWifiNative()).thenReturn(mWifiNative);
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
+ when(mContext.checkPermission(eq(Manifest.permission.NETWORK_STACK),
anyInt(), eq(Binder.getCallingUid())))
.thenReturn(PERMISSION_GRANTED);
mWifiScanningServiceImpl = new WifiScanningServiceImpl(mContext, mLooper.getLooper(),
@@ -759,8 +759,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
requestSettings.type = WifiScanner.TYPE_HIGH_ACCURACY;
WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
+ when(mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid()))
.thenReturn(PERMISSION_DENIED);
startServiceAndLoadDriver();
@@ -811,8 +811,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
};
WorkSource workSource = new WorkSource(Binder.getCallingUid()); // don't explicitly set
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
+ when(mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid()))
.thenReturn(PERMISSION_DENIED);
startServiceAndLoadDriver();
@@ -898,8 +898,8 @@ public class WifiScanningServiceTest extends WifiBaseTest {
@Test
public void sendSingleScanRequestWithNoPrivilegedParamsSetFromNonPrivilegedApp()
throws Exception {
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
+ when(mContext.checkPermission(
+ Manifest.permission.NETWORK_STACK, -1, Binder.getCallingUid()))
.thenReturn(PERMISSION_DENIED);
WifiScanner.ScanSettings requestSettings = createRequest(channelsToSpec(2400, 5150, 5175),
0, 0, 20, WifiScanner.REPORT_EVENT_AFTER_EACH_SCAN);
@@ -2623,7 +2623,7 @@ public class WifiScanningServiceTest extends WifiBaseTest {
}
/**
- * Verifies that only clients with PERMISSION_MAINLINE_WIFI_STACK permission can issues restricted messages
+ * Verifies that only clients with NETWORK_STACK permission can issues restricted messages
* (from API's).
*/
@Test
@@ -2633,10 +2633,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
controlChannel.sendMessage(Message.obtain(null, WifiScanner.CMD_ENABLE));
mLooper.dispatchAll();
@@ -2674,19 +2673,13 @@ public class WifiScanningServiceTest extends WifiBaseTest {
}
/**
- * Verifies that clients without PERMISSION_MAINLINE_WIFI_STACK permission cannot issue any messages when they
+ * Verifies that clients without NETWORK_STACK permission cannot issue any messages when they
* don't have the necessary location permissions & location is enabled.
*/
@Test
public void rejectAllMessagesFromNonPrivilegedAppsWithoutLocationPermission() throws Exception {
// Start service & initialize it.
startServiceAndLoadDriver();
- doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
// Location permission or mode check fail.
doThrow(new SecurityException()).when(mWifiPermissionsUtil)
@@ -2696,10 +2689,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
+ // Client doesn't have NETWORK_STACK permission.
+ doThrow(new SecurityException()).when(mContext).enforcePermission(
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
controlChannel.sendMessage(Message.obtain(null, WifiScanner.CMD_START_SINGLE_SCAN));
mLooper.dispatchAll();
@@ -2741,13 +2733,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
@@ -2809,13 +2797,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client doesn't have PERMISSION_MAINLINE_WIFI_STACK permission.
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
- when(mContext.checkPermission(eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK),
- anyInt(), eq(Binder.getCallingUid())))
- .thenReturn(PERMISSION_DENIED);
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
@@ -2879,10 +2863,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
Handler handler = mock(Handler.class);
BidirectionalAsyncChannel controlChannel = connectChannel(handler);
- // Client does have WIFI_STACK permission.
+ // Client does have NETWORK_STACK permission.
doNothing().when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
Bundle bundle = new Bundle();
bundle.putString(WifiScanner.REQUEST_PACKAGE_NAME_KEY, TEST_PACKAGE_NAME);
@@ -3510,10 +3493,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
public void getAvailableChannels_noPermission_throwsException() throws Exception {
startServiceAndLoadDriver();
- // no MAINLINE_WIFI_STACK permission
+ // Client doesn't have NETWORK_STACK permission.
doThrow(new SecurityException()).when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
// Location permission or mode check fail.
doThrow(new SecurityException())
@@ -3532,10 +3514,9 @@ public class WifiScanningServiceTest extends WifiBaseTest {
public void getAvailableChannels_hasPermission_returnsSuccessfully() throws Exception {
startServiceAndLoadDriver();
- // has MAINLINE_WIFI_STACK permission
- doNothing().when(mContext).enforcePermission(
- eq(WifiStackClient.PERMISSION_MAINLINE_WIFI_STACK), anyInt(),
- eq(Binder.getCallingUid()), any());
+ // Client doesn't have NETWORK_STACK permission.
+ doThrow(new SecurityException()).when(mContext).enforcePermission(
+ eq(Manifest.permission.NETWORK_STACK), anyInt(), eq(Binder.getCallingUid()), any());
// has access scan results permission
doNothing().when(mWifiPermissionsUtil).enforceCanAccessScanResultsForWifiScanner(