diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-07-27 03:06:56 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-07-27 03:06:56 +0000 |
commit | 85daddef50c306dcd9374cfd5bb962efea208e19 (patch) | |
tree | a2ffd7b98c5be3dd85608396ae80aeadcf783957 | |
parent | 98563bff3eead3f5a1a15e91db17d318c3d8dd96 (diff) | |
parent | a4673b6b5ccbdb09fc65d316497ab39b826fcbfa (diff) | |
download | Car-85daddef50c306dcd9374cfd5bb962efea208e19.tar.gz |
Snap for 4916303 from a4673b6b5ccbdb09fc65d316497ab39b826fcbfa to pi-qpr1-release
Change-Id: I67bafc194b2562c817f6d3a272aa7e76b3f127e8
-rw-r--r-- | car-lib/api/system-current.txt | 1 | ||||
-rw-r--r-- | car-lib/src/android/car/Car.java | 8 | ||||
-rw-r--r-- | car-lib/src/android/car/PortLocationType.java | 35 | ||||
-rw-r--r-- | service/AndroidManifest.xml | 5 | ||||
-rw-r--r-- | service/src/com/android/car/CarUxRestrictionsManagerService.java | 53 | ||||
-rw-r--r-- | service/src/com/android/car/pm/CarPackageManagerService.java | 12 | ||||
-rw-r--r-- | tests/carservice_test/AndroidManifest.xml | 5 | ||||
-rw-r--r-- | tests/carservice_test/src/com/android/car/MockedCarTestBase.java | 2 |
8 files changed, 104 insertions, 17 deletions
diff --git a/car-lib/api/system-current.txt b/car-lib/api/system-current.txt index 725967d46b..df6b85ed98 100644 --- a/car-lib/api/system-current.txt +++ b/car-lib/api/system-current.txt @@ -5,7 +5,6 @@ package android.car { field public static final java.lang.String CAR_DRIVING_STATE_SERVICE = "drivingstate"; field public static final java.lang.String DIAGNOSTIC_SERVICE = "diagnostic"; field public static final java.lang.String HVAC_SERVICE = "hvac"; - field public static final java.lang.String PERMISSION_ADJUST_CAR_CABIN = "android.car.permission.ADJUST_CAR_CABIN"; field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_CLEAR = "android.car.permission.CLEAR_CAR_DIAGNOSTICS"; field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_READ_ALL = "android.car.permission.CAR_DIAGNOSTICS"; field public static final java.lang.String PERMISSION_CAR_DRIVING_STATE = "android.car.permission.CAR_DRIVING_STATE"; diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java index 738a4238ad..c1bf50274d 100644 --- a/car-lib/src/android/car/Car.java +++ b/car-lib/src/android/car/Car.java @@ -281,14 +281,6 @@ public final class Car { "android.car.permission.CONTROL_APP_BLOCKING"; /** - * Permission necessary to access Car Cabin APIs. - * @hide - */ - @SystemApi - public static final String PERMISSION_ADJUST_CAR_CABIN = - "android.car.permission.ADJUST_CAR_CABIN"; - - /** * Permission necessary to access car's engine information. * @hide */ diff --git a/car-lib/src/android/car/PortLocationType.java b/car-lib/src/android/car/PortLocationType.java new file mode 100644 index 0000000000..3006a2969b --- /dev/null +++ b/car-lib/src/android/car/PortLocationType.java @@ -0,0 +1,35 @@ +/* + * 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 android.car; + +/** + * Used by INFO_FUEL_DOOR_LOCATION/INFO_CHARGE_PORT_LOCATION to enumerate fuel door or + * ev port location. + * Use getProperty and setProperty in {@link android.car.hardware.property.CarPropertyManager} to + * set and get this VHAL property. + * @hide + */ +public final class PortLocationType { + public static final int UNKNOWN = 0; + public static final int FRONT_LEFT = 1; + public static final int FRONT_RIGHT = 2; + public static final int REAR_RIGHT = 3; + public static final int REAR_LEFT = 4; + public static final int FRONT = 5; + public static final int REAR = 6; + + private PortLocationType() {} +} diff --git a/service/AndroidManifest.xml b/service/AndroidManifest.xml index 5212448ceb..870ed100d7 100644 --- a/service/AndroidManifest.xml +++ b/service/AndroidManifest.xml @@ -27,11 +27,6 @@ android:description="@string/car_permission_desc" android:label="@string/car_permission_label" /> <permission - android:name="android.car.permission.ADJUST_CAR_CABIN" - android:protectionLevel="system|signature" - android:label="@string/car_permission_label_cabin" - android:description="@string/car_permission_desc_cabin" /> - <permission android:name="android.car.permission.CAR_ENERGY" android:permissionGroup="android.car.permission-group.CAR_MONITORING" android:protectionLevel="dangerous" diff --git a/service/src/com/android/car/CarUxRestrictionsManagerService.java b/service/src/com/android/car/CarUxRestrictionsManagerService.java index a6807d6a66..b90939b320 100644 --- a/service/src/com/android/car/CarUxRestrictionsManagerService.java +++ b/service/src/com/android/car/CarUxRestrictionsManagerService.java @@ -27,11 +27,17 @@ import android.car.hardware.CarPropertyValue; import android.car.hardware.property.CarPropertyEvent; import android.car.hardware.property.ICarPropertyEventListener; import android.content.Context; +import android.content.pm.PackageManager; import android.hardware.automotive.vehicle.V2_0.VehicleProperty; +import android.os.Binder; +import android.os.Build; import android.os.IBinder; +import android.os.Process; import android.os.RemoteException; import android.util.Log; +import com.android.internal.annotations.GuardedBy; + import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; @@ -60,6 +66,9 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S private CarUxRestrictions mCurrentUxRestrictions; private float mCurrentMovingSpeed; private boolean mFallbackToDefaults; + // Flag to disable broadcasting UXR changes - for development purposes + @GuardedBy("this") + private boolean mUxRChangeBroadcastEnabled = true; // For dumpsys logging private final LinkedList<Utils.TransitionLog> mTransitionLogs = new LinkedList<>(); @@ -224,6 +233,42 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S } /** + * Enable/disable UX restrictions change broadcast blocking. + * Setting this to true will stop broadcasts of UX restriction change to listeners. + * This method works only on debug builds and the caller of this method needs to have the same + * signature of the car service. + * + */ + public synchronized void setUxRChangeBroadcastEnabled(boolean enable) { + if (!isDebugBuild()) { + Log.e(TAG, "Cannot set UX restriction change broadcast."); + return; + } + // Check if the caller has the same signature as that of the car service. + if (mContext.getPackageManager().checkSignatures(Process.myUid(), Binder.getCallingUid()) + != PackageManager.SIGNATURE_MATCH) { + throw new SecurityException( + "Caller " + mContext.getPackageManager().getNameForUid(Binder.getCallingUid()) + + " does not have the right signature"); + } + if (enable) { + // if enabling it back, send the current restrictions + mUxRChangeBroadcastEnabled = enable; + handleDispatchUxRestrictions(mDrivingStateService.getCurrentDrivingState().eventValue, + getCurrentSpeed()); + } else { + // fake parked state, so if the system is currently restricted, the restrictions are + // relaxed. + handleDispatchUxRestrictions(CarDrivingStateEvent.DRIVING_STATE_PARKED, 0); + mUxRChangeBroadcastEnabled = enable; + } + } + + private boolean isDebugBuild() { + return Build.IS_USERDEBUG || Build.IS_ENG; + } + + /** * Class that holds onto client related information - listener interface, process that hosts the * binder object etc. * It also registers for death notifications of the host. @@ -282,6 +327,9 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S writer.println( "Requires DO? " + mCurrentUxRestrictions.isRequiresDistractionOptimization()); writer.println("Current UXR: " + mCurrentUxRestrictions.getActiveRestrictions()); + if (isDebugBuild()) { + writer.println("mUxRChangeBroadcastEnabled? " + mUxRChangeBroadcastEnabled); + } mHelper.dump(writer); writer.println("UX Restriction change log:"); for (Utils.TransitionLog tlog : mTransitionLogs) { @@ -377,6 +425,11 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S */ private synchronized void handleDispatchUxRestrictions(@CarDrivingState int currentDrivingState, float speed) { + if (isDebugBuild() && !mUxRChangeBroadcastEnabled) { + Log.d(TAG, "Not dispatching UX Restriction due to setting"); + return; + } + CarUxRestrictions uxRestrictions; // Get UX restrictions from the parsed configuration XML or fall back to defaults if not // available. diff --git a/service/src/com/android/car/pm/CarPackageManagerService.java b/service/src/com/android/car/pm/CarPackageManagerService.java index 198066610e..ed51a78269 100644 --- a/service/src/com/android/car/pm/CarPackageManagerService.java +++ b/service/src/com/android/car/pm/CarPackageManagerService.java @@ -985,8 +985,18 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements } } + /** + * Enable/Disable activity blocking by correspondingly enabling/disabling broadcasting UXR + * changes in {@link CarUxRestrictionsManagerService}. This is only available in + * engineering builds for development convenience. + * + */ @Override public synchronized void setEnableActivityBlocking(boolean enable) { + if (!isDebugBuild()) { + Log.e(CarLog.TAG_PACKAGE, "Cannot enable/disable activity blocking"); + return; + } // Check if the caller has the same signature as that of the car service. if (mPackageManager.checkSignatures(Process.myUid(), Binder.getCallingUid()) != PackageManager.SIGNATURE_MATCH) { @@ -994,7 +1004,7 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements "Caller " + mPackageManager.getNameForUid(Binder.getCallingUid()) + " does not have the right signature"); } - mEnableActivityBlocking = enable; + mCarUxRestrictionsService.setUxRChangeBroadcastEnabled(enable); } /** diff --git a/tests/carservice_test/AndroidManifest.xml b/tests/carservice_test/AndroidManifest.xml index 2be5a8302e..19a5552e2f 100644 --- a/tests/carservice_test/AndroidManifest.xml +++ b/tests/carservice_test/AndroidManifest.xml @@ -19,7 +19,10 @@ <uses-permission android:name="android.Manifest.permission.MODIFY_AUDIO_ROUTING" /> <uses-permission android:name="android.car.permission.CONTROL_CAR_CLIMATE" /> - <uses-permission android:name="android.car.permission.ADJUST_CAR_CABIN" /> + <uses-permission android:name="android.car.permission.CONTROL_CAR_DOORS" /> + <uses-permission android:name="android.car.permission.CONTROL_CAR_WINDOWS" /> + <uses-permission android:name="android.car.permission.CONTROL_CAR_MIRRORS" /> + <uses-permission android:name="android.car.permission.CONTROL_CAR_SEATS" /> <uses-permission android:name="android.car.permission.CAR_ENERGY" /> <uses-permission android:name="android.car.permission.CONTROL_APP_BLOCKING" /> <uses-permission android:name="android.car.permission.CAR_CONTROL_AUDIO_VOLUME" /> diff --git a/tests/carservice_test/src/com/android/car/MockedCarTestBase.java b/tests/carservice_test/src/com/android/car/MockedCarTestBase.java index 3a50b45a9b..c63c980fa4 100644 --- a/tests/carservice_test/src/com/android/car/MockedCarTestBase.java +++ b/tests/carservice_test/src/com/android/car/MockedCarTestBase.java @@ -173,7 +173,7 @@ public class MockedCarTestBase { protected MockContext getCarServiceContext() throws NameNotFoundException { if (mMockContext == null) { mMockContext = new MockContext(getContext() - .createPackageContext("com.android.car", Context.CONTEXT_IGNORE_SECURITY)); + .createPackageContext("com.android.car.test", Context.CONTEXT_IGNORE_SECURITY)); } return mMockContext; } |