Loading Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -373,6 +373,7 @@ java_library { "core/java/com/android/internal/appwidget/IAppWidgetHost.aidl", "core/java/com/android/internal/appwidget/IAppWidgetHost.aidl", "core/java/com/android/internal/backup/IBackupTransport.aidl", "core/java/com/android/internal/backup/IBackupTransport.aidl", "core/java/com/android/internal/backup/IObbBackupService.aidl", "core/java/com/android/internal/backup/IObbBackupService.aidl", "core/java/com/android/internal/car/ICarServiceHelper.aidl", "core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl", "core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl", "core/java/com/android/internal/net/INetworkWatchlistManager.aidl", "core/java/com/android/internal/net/INetworkWatchlistManager.aidl", "core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl", "core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl", Loading core/java/com/android/internal/car/ICarServiceHelper.aidl 0 → 100644 +24 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 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.internal.car; /** * Helper API for car service. Only for itneraction between system server and car service. * @hide */ interface ICarServiceHelper { } services/core/java/com/android/server/car/CarServiceHelperService.java 0 → 100644 +91 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 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.car; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Binder; import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.UserHandle; import android.util.Slog; import com.android.internal.car.ICarServiceHelper; import com.android.server.SystemService; /** * System service side companion service for CarService. * Starts car service and provide necessary API for CarService. Only for car product. */ public class CarServiceHelperService extends SystemService { private static final String TAG = "CarServiceHelper"; private static final String CAR_SERVICE_INTERFACE = "android.car.ICar"; private final ICarServiceHelperImpl mHelper = new ICarServiceHelperImpl(); private IBinder mCarService; private final ServiceConnection mCarServiceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { Slog.i(TAG, "**CarService connected**"); mCarService = iBinder; // Cannot depend on ICar which is defined in CarService, so handle binder call directly // instead. // void setCarServiceHelper(in IBinder helper) Parcel data = Parcel.obtain(); data.writeInterfaceToken(CAR_SERVICE_INTERFACE); data.writeStrongBinder(mHelper.asBinder()); try { mCarService.transact(IBinder.FIRST_CALL_TRANSACTION, // setCarServiceHelper data, null, Binder.FLAG_ONEWAY); } catch (RemoteException e) { Slog.w(TAG, "RemoteException from car service", e); handleCarServiceCrash(); } } @Override public void onServiceDisconnected(ComponentName componentName) { handleCarServiceCrash(); } }; public CarServiceHelperService(Context context) { super(context); } @Override public void onStart() { Intent intent = new Intent(); intent.setPackage("com.android.car"); intent.setAction(CAR_SERVICE_INTERFACE); if (!getContext().bindServiceAsUser(intent, mCarServiceConnection, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM)) { Slog.wtf(TAG, "cannot start car service"); } } private void handleCarServiceCrash() { //TODO define recovery bahavior } private class ICarServiceHelperImpl extends ICarServiceHelper.Stub { //TODO } } services/java/com/android/server/SystemServer.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.server.am.ActivityManagerService; import com.android.server.audio.AudioService; import com.android.server.audio.AudioService; import com.android.server.broadcastradio.BroadcastRadioService; import com.android.server.broadcastradio.BroadcastRadioService; import com.android.server.camera.CameraServiceProxy; import com.android.server.camera.CameraServiceProxy; import com.android.server.car.CarServiceHelperService; import com.android.server.clipboard.ClipboardService; import com.android.server.clipboard.ClipboardService; import com.android.server.connectivity.IpConnectivityMetrics; import com.android.server.connectivity.IpConnectivityMetrics; import com.android.server.coverage.CoverageService; import com.android.server.coverage.CoverageService; Loading Loading @@ -219,8 +220,6 @@ public final class SystemServer { "com.google.android.things.services.IoTSystemService"; "com.google.android.things.services.IoTSystemService"; private static final String SLICE_MANAGER_SERVICE_CLASS = private static final String SLICE_MANAGER_SERVICE_CLASS = "com.android.server.slice.SliceManagerService$Lifecycle"; "com.android.server.slice.SliceManagerService$Lifecycle"; private static final String CAR_SERVICE_HELPER_SERVICE_CLASS = "com.google.android.car.CarServiceHelperService"; private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; Loading Loading @@ -1752,7 +1751,7 @@ public final class SystemServer { if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { traceBeginAndSlog("StartCarServiceHelperService"); traceBeginAndSlog("StartCarServiceHelperService"); mSystemServiceManager.startService(CAR_SERVICE_HELPER_SERVICE_CLASS); mSystemServiceManager.startService(CarServiceHelperService.class); traceEnd(); traceEnd(); } } Loading Loading
Android.bp +1 −0 Original line number Original line Diff line number Diff line Loading @@ -373,6 +373,7 @@ java_library { "core/java/com/android/internal/appwidget/IAppWidgetHost.aidl", "core/java/com/android/internal/appwidget/IAppWidgetHost.aidl", "core/java/com/android/internal/backup/IBackupTransport.aidl", "core/java/com/android/internal/backup/IBackupTransport.aidl", "core/java/com/android/internal/backup/IObbBackupService.aidl", "core/java/com/android/internal/backup/IObbBackupService.aidl", "core/java/com/android/internal/car/ICarServiceHelper.aidl", "core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl", "core/java/com/android/internal/inputmethod/IInputContentUriToken.aidl", "core/java/com/android/internal/net/INetworkWatchlistManager.aidl", "core/java/com/android/internal/net/INetworkWatchlistManager.aidl", "core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl", "core/java/com/android/internal/policy/IKeyguardDrawnCallback.aidl", Loading
core/java/com/android/internal/car/ICarServiceHelper.aidl 0 → 100644 +24 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 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.internal.car; /** * Helper API for car service. Only for itneraction between system server and car service. * @hide */ interface ICarServiceHelper { }
services/core/java/com/android/server/car/CarServiceHelperService.java 0 → 100644 +91 −0 Original line number Original line Diff line number Diff line /* * Copyright (C) 2017 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.car; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Binder; import android.os.IBinder; import android.os.Parcel; import android.os.RemoteException; import android.os.UserHandle; import android.util.Slog; import com.android.internal.car.ICarServiceHelper; import com.android.server.SystemService; /** * System service side companion service for CarService. * Starts car service and provide necessary API for CarService. Only for car product. */ public class CarServiceHelperService extends SystemService { private static final String TAG = "CarServiceHelper"; private static final String CAR_SERVICE_INTERFACE = "android.car.ICar"; private final ICarServiceHelperImpl mHelper = new ICarServiceHelperImpl(); private IBinder mCarService; private final ServiceConnection mCarServiceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName componentName, IBinder iBinder) { Slog.i(TAG, "**CarService connected**"); mCarService = iBinder; // Cannot depend on ICar which is defined in CarService, so handle binder call directly // instead. // void setCarServiceHelper(in IBinder helper) Parcel data = Parcel.obtain(); data.writeInterfaceToken(CAR_SERVICE_INTERFACE); data.writeStrongBinder(mHelper.asBinder()); try { mCarService.transact(IBinder.FIRST_CALL_TRANSACTION, // setCarServiceHelper data, null, Binder.FLAG_ONEWAY); } catch (RemoteException e) { Slog.w(TAG, "RemoteException from car service", e); handleCarServiceCrash(); } } @Override public void onServiceDisconnected(ComponentName componentName) { handleCarServiceCrash(); } }; public CarServiceHelperService(Context context) { super(context); } @Override public void onStart() { Intent intent = new Intent(); intent.setPackage("com.android.car"); intent.setAction(CAR_SERVICE_INTERFACE); if (!getContext().bindServiceAsUser(intent, mCarServiceConnection, Context.BIND_AUTO_CREATE, UserHandle.SYSTEM)) { Slog.wtf(TAG, "cannot start car service"); } } private void handleCarServiceCrash() { //TODO define recovery bahavior } private class ICarServiceHelperImpl extends ICarServiceHelper.Stub { //TODO } }
services/java/com/android/server/SystemServer.java +2 −3 Original line number Original line Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.server.am.ActivityManagerService; import com.android.server.audio.AudioService; import com.android.server.audio.AudioService; import com.android.server.broadcastradio.BroadcastRadioService; import com.android.server.broadcastradio.BroadcastRadioService; import com.android.server.camera.CameraServiceProxy; import com.android.server.camera.CameraServiceProxy; import com.android.server.car.CarServiceHelperService; import com.android.server.clipboard.ClipboardService; import com.android.server.clipboard.ClipboardService; import com.android.server.connectivity.IpConnectivityMetrics; import com.android.server.connectivity.IpConnectivityMetrics; import com.android.server.coverage.CoverageService; import com.android.server.coverage.CoverageService; Loading Loading @@ -219,8 +220,6 @@ public final class SystemServer { "com.google.android.things.services.IoTSystemService"; "com.google.android.things.services.IoTSystemService"; private static final String SLICE_MANAGER_SERVICE_CLASS = private static final String SLICE_MANAGER_SERVICE_CLASS = "com.android.server.slice.SliceManagerService$Lifecycle"; "com.android.server.slice.SliceManagerService$Lifecycle"; private static final String CAR_SERVICE_HELPER_SERVICE_CLASS = "com.google.android.car.CarServiceHelperService"; private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; private static final String PERSISTENT_DATA_BLOCK_PROP = "ro.frp.pst"; Loading Loading @@ -1752,7 +1751,7 @@ public final class SystemServer { if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) { traceBeginAndSlog("StartCarServiceHelperService"); traceBeginAndSlog("StartCarServiceHelperService"); mSystemServiceManager.startService(CAR_SERVICE_HELPER_SERVICE_CLASS); mSystemServiceManager.startService(CarServiceHelperService.class); traceEnd(); traceEnd(); } } Loading