diff options
author | Roshan Pius <rpius@google.com> | 2019-06-14 14:37:14 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2019-08-12 07:22:56 -0700 |
commit | 6f5338dd8f90400fe67a97ed13f2479c6bd7237e (patch) | |
tree | d423a386d474afe7793ba3696c13ef750f0a4644 /services/wifi | |
parent | 7e6f5f5e080f2d2ae3ef0397c21bd666f5ce4d31 (diff) |
Mainline wifi stack module
a) Moved wifi service to a separate APK
b) Use the IWifiStackConnector to load the wifi stack from
SystemServer (similar to network stack).
c) Create a new WifiStackClient interface for system server to interact
with the wifi stack (under new services/wifi folder). Note: This not planned
to be updated via wifi-sdk Apex.
d) Add priv-app permissions for the new wifi stack APK.
Bug: 113174748
Test: Device boots up & connects to wifi networks, hotspot toggle, etc.
Test: Will send for regression tests
Change-Id: I54b3a11ed30668bad5a387370484b2bb0eabca5f
Merged-In: I54b3a11ed30668bad5a387370484b2bb0eabca5f
Diffstat (limited to 'services/wifi')
-rw-r--r-- | services/wifi/Android.bp | 11 | ||||
-rw-r--r-- | services/wifi/java/android/net/wifi/IWifiStackConnector.aidl | 20 | ||||
-rw-r--r-- | services/wifi/java/android/net/wifi/WifiStackClient.java | 81 |
3 files changed, 112 insertions, 0 deletions
diff --git a/services/wifi/Android.bp b/services/wifi/Android.bp new file mode 100644 index 000000000000..3c916a6d00cd --- /dev/null +++ b/services/wifi/Android.bp @@ -0,0 +1,11 @@ +// Interfaces between the core system and the wifi mainline module. +java_library_static { + name: "services.wifi", + srcs: [ + "java/**/*.java", + "java/**/*.aidl", + ], + libs: [ + "services.net", + ], +} diff --git a/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl b/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl new file mode 100644 index 000000000000..ad052b9b7928 --- /dev/null +++ b/services/wifi/java/android/net/wifi/IWifiStackConnector.aidl @@ -0,0 +1,20 @@ +/** + * 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 perNmissions and + * limitations under the License. + */ +package android.net.wifi; + +/** @hide */ +oneway interface IWifiStackConnector { +} diff --git a/services/wifi/java/android/net/wifi/WifiStackClient.java b/services/wifi/java/android/net/wifi/WifiStackClient.java new file mode 100644 index 000000000000..067d98ba086c --- /dev/null +++ b/services/wifi/java/android/net/wifi/WifiStackClient.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.net.wifi; + +import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_HIGH; +import static android.os.IServiceManager.DUMP_FLAG_PRIORITY_NORMAL; + +import android.annotation.NonNull; +import android.content.Context; +import android.net.ConnectivityModuleConnector; +import android.os.IBinder; +import android.os.ServiceManager; +import android.util.Log; + +/** + * Service used to communicate with the wifi stack, which could be running in a separate + * module. + * @hide + */ +public class WifiStackClient { + public static final String PERMISSION_MAINLINE_WIFI_STACK = + "android.permission.MAINLINE_WIFI_STACK"; + + private static final String TAG = WifiStackClient.class.getSimpleName(); + private static WifiStackClient sInstance; + + private WifiStackClient() { } + + /** + * Get the WifiStackClient singleton instance. + */ + public static synchronized WifiStackClient getInstance() { + if (sInstance == null) { + sInstance = new WifiStackClient(); + } + return sInstance; + } + + private class WifiStackConnection implements + ConnectivityModuleConnector.ModuleServiceCallback { + @Override + public void onModuleServiceConnected(IBinder service) { + Log.i(TAG, "Wifi stack connected"); + registerWifiStackService(service); + } + } + + private void registerWifiStackService(@NonNull IBinder service) { + ServiceManager.addService(Context.WIFI_STACK_SERVICE, service, + false /* allowIsolated */, + DUMP_FLAG_PRIORITY_HIGH | DUMP_FLAG_PRIORITY_NORMAL); + Log.i(TAG, "Wifi stack service registered"); + } + + /** + * Start the wifi stack. Should be called only once on device startup. + * + * <p>This method will start the wifi stack either in the wifi stack + * process, or inside the system server on devices that do not support the wifi stack + * module. + */ + public void start() { + Log.i(TAG, "Starting wifi stack"); + ConnectivityModuleConnector.getInstance().startModuleService( + IWifiStackConnector.class.getName(), PERMISSION_MAINLINE_WIFI_STACK, + new WifiStackConnection()); + } +} |