Remi NGUYEN VAN | cdb45f8 | 2021-05-13 12:53:15 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.util.Log; |
| 21 | |
| 22 | /** |
| 23 | * Connectivity service initializer for core networking. This is called by system server to create |
| 24 | * a new instance of ConnectivityService. |
| 25 | */ |
| 26 | public final class ConnectivityServiceInitializer extends SystemService { |
| 27 | private static final String TAG = ConnectivityServiceInitializer.class.getSimpleName(); |
| 28 | private final ConnectivityService mConnectivity; |
| 29 | |
| 30 | public ConnectivityServiceInitializer(Context context) { |
| 31 | super(context); |
| 32 | // Load JNI libraries used by ConnectivityService and its dependencies |
| 33 | System.loadLibrary("service-connectivity"); |
| 34 | // TODO: Define formal APIs to get the needed services. |
| 35 | mConnectivity = new ConnectivityService(context); |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public void onStart() { |
| 40 | Log.i(TAG, "Registering " + Context.CONNECTIVITY_SERVICE); |
| 41 | publishBinderService(Context.CONNECTIVITY_SERVICE, mConnectivity, |
| 42 | /* allowIsolated= */ false); |
| 43 | } |
| 44 | } |