summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Periathiruvadi2018-07-19 21:02:06 -0500
committerandroid-build-merger2018-07-19 21:02:06 -0500
commita8295dd75e6996c0d96322c0a962c9de575c289c (patch)
tree37ac9c9660d35c667bc710e8e03125ef35f3cd05
parentca4900a45cc4d99159bbc857098c749d09af07c1 (diff)
parent90ba1f1362aa255945c74c846553a9372bb40146 (diff)
downloadplatform-packages-services-car-a8295dd75e6996c0d96322c0a962c9de575c289c.tar.gz
platform-packages-services-car-a8295dd75e6996c0d96322c0a962c9de575c289c.tar.xz
platform-packages-services-car-a8295dd75e6996c0d96322c0a962c9de575c289c.zip
Merge "Provide an option to disable UxR change broadcast." into pi-dev
am: 90ba1f1362 Change-Id: If9c7609a349ffa788a080d25aca8e394d1417f57
-rw-r--r--service/src/com/android/car/CarUxRestrictionsManagerService.java53
-rw-r--r--service/src/com/android/car/pm/CarPackageManagerService.java12
2 files changed, 64 insertions, 1 deletions
diff --git a/service/src/com/android/car/CarUxRestrictionsManagerService.java b/service/src/com/android/car/CarUxRestrictionsManagerService.java
index a6807d6a..b90939b3 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;
27import android.car.hardware.property.CarPropertyEvent; 27import android.car.hardware.property.CarPropertyEvent;
28import android.car.hardware.property.ICarPropertyEventListener; 28import android.car.hardware.property.ICarPropertyEventListener;
29import android.content.Context; 29import android.content.Context;
30import android.content.pm.PackageManager;
30import android.hardware.automotive.vehicle.V2_0.VehicleProperty; 31import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
32import android.os.Binder;
33import android.os.Build;
31import android.os.IBinder; 34import android.os.IBinder;
35import android.os.Process;
32import android.os.RemoteException; 36import android.os.RemoteException;
33import android.util.Log; 37import android.util.Log;
34 38
39import com.android.internal.annotations.GuardedBy;
40
35import org.xmlpull.v1.XmlPullParserException; 41import org.xmlpull.v1.XmlPullParserException;
36 42
37import java.io.IOException; 43import java.io.IOException;
@@ -60,6 +66,9 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S
60 private CarUxRestrictions mCurrentUxRestrictions; 66 private CarUxRestrictions mCurrentUxRestrictions;
61 private float mCurrentMovingSpeed; 67 private float mCurrentMovingSpeed;
62 private boolean mFallbackToDefaults; 68 private boolean mFallbackToDefaults;
69 // Flag to disable broadcasting UXR changes - for development purposes
70 @GuardedBy("this")
71 private boolean mUxRChangeBroadcastEnabled = true;
63 // For dumpsys logging 72 // For dumpsys logging
64 private final LinkedList<Utils.TransitionLog> mTransitionLogs = new LinkedList<>(); 73 private final LinkedList<Utils.TransitionLog> mTransitionLogs = new LinkedList<>();
65 74
@@ -224,6 +233,42 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S
224 } 233 }
225 234
226 /** 235 /**
236 * Enable/disable UX restrictions change broadcast blocking.
237 * Setting this to true will stop broadcasts of UX restriction change to listeners.
238 * This method works only on debug builds and the caller of this method needs to have the same
239 * signature of the car service.
240 *
241 */
242 public synchronized void setUxRChangeBroadcastEnabled(boolean enable) {
243 if (!isDebugBuild()) {
244 Log.e(TAG, "Cannot set UX restriction change broadcast.");
245 return;
246 }
247 // Check if the caller has the same signature as that of the car service.
248 if (mContext.getPackageManager().checkSignatures(Process.myUid(), Binder.getCallingUid())
249 != PackageManager.SIGNATURE_MATCH) {
250 throw new SecurityException(
251 "Caller " + mContext.getPackageManager().getNameForUid(Binder.getCallingUid())
252 + " does not have the right signature");
253 }
254 if (enable) {
255 // if enabling it back, send the current restrictions
256 mUxRChangeBroadcastEnabled = enable;
257 handleDispatchUxRestrictions(mDrivingStateService.getCurrentDrivingState().eventValue,
258 getCurrentSpeed());
259 } else {
260 // fake parked state, so if the system is currently restricted, the restrictions are
261 // relaxed.
262 handleDispatchUxRestrictions(CarDrivingStateEvent.DRIVING_STATE_PARKED, 0);
263 mUxRChangeBroadcastEnabled = enable;
264 }
265 }
266
267 private boolean isDebugBuild() {
268 return Build.IS_USERDEBUG || Build.IS_ENG;
269 }
270
271 /**
227 * Class that holds onto client related information - listener interface, process that hosts the 272 * Class that holds onto client related information - listener interface, process that hosts the
228 * binder object etc. 273 * binder object etc.
229 * It also registers for death notifications of the host. 274 * It also registers for death notifications of the host.
@@ -282,6 +327,9 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S
282 writer.println( 327 writer.println(
283 "Requires DO? " + mCurrentUxRestrictions.isRequiresDistractionOptimization()); 328 "Requires DO? " + mCurrentUxRestrictions.isRequiresDistractionOptimization());
284 writer.println("Current UXR: " + mCurrentUxRestrictions.getActiveRestrictions()); 329 writer.println("Current UXR: " + mCurrentUxRestrictions.getActiveRestrictions());
330 if (isDebugBuild()) {
331 writer.println("mUxRChangeBroadcastEnabled? " + mUxRChangeBroadcastEnabled);
332 }
285 mHelper.dump(writer); 333 mHelper.dump(writer);
286 writer.println("UX Restriction change log:"); 334 writer.println("UX Restriction change log:");
287 for (Utils.TransitionLog tlog : mTransitionLogs) { 335 for (Utils.TransitionLog tlog : mTransitionLogs) {
@@ -377,6 +425,11 @@ public class CarUxRestrictionsManagerService extends ICarUxRestrictionsManager.S
377 */ 425 */
378 private synchronized void handleDispatchUxRestrictions(@CarDrivingState int currentDrivingState, 426 private synchronized void handleDispatchUxRestrictions(@CarDrivingState int currentDrivingState,
379 float speed) { 427 float speed) {
428 if (isDebugBuild() && !mUxRChangeBroadcastEnabled) {
429 Log.d(TAG, "Not dispatching UX Restriction due to setting");
430 return;
431 }
432
380 CarUxRestrictions uxRestrictions; 433 CarUxRestrictions uxRestrictions;
381 // Get UX restrictions from the parsed configuration XML or fall back to defaults if not 434 // Get UX restrictions from the parsed configuration XML or fall back to defaults if not
382 // available. 435 // available.
diff --git a/service/src/com/android/car/pm/CarPackageManagerService.java b/service/src/com/android/car/pm/CarPackageManagerService.java
index 19806661..ed51a782 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
985 } 985 }
986 } 986 }
987 987
988 /**
989 * Enable/Disable activity blocking by correspondingly enabling/disabling broadcasting UXR
990 * changes in {@link CarUxRestrictionsManagerService}. This is only available in
991 * engineering builds for development convenience.
992 *
993 */
988 @Override 994 @Override
989 public synchronized void setEnableActivityBlocking(boolean enable) { 995 public synchronized void setEnableActivityBlocking(boolean enable) {
996 if (!isDebugBuild()) {
997 Log.e(CarLog.TAG_PACKAGE, "Cannot enable/disable activity blocking");
998 return;
999 }
990 // Check if the caller has the same signature as that of the car service. 1000 // Check if the caller has the same signature as that of the car service.
991 if (mPackageManager.checkSignatures(Process.myUid(), Binder.getCallingUid()) 1001 if (mPackageManager.checkSignatures(Process.myUid(), Binder.getCallingUid())
992 != PackageManager.SIGNATURE_MATCH) { 1002 != PackageManager.SIGNATURE_MATCH) {
@@ -994,7 +1004,7 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements
994 "Caller " + mPackageManager.getNameForUid(Binder.getCallingUid()) 1004 "Caller " + mPackageManager.getNameForUid(Binder.getCallingUid())
995 + " does not have the right signature"); 1005 + " does not have the right signature");
996 } 1006 }
997 mEnableActivityBlocking = enable; 1007 mCarUxRestrictionsService.setUxRChangeBroadcastEnabled(enable);
998 } 1008 }
999 1009
1000 /** 1010 /**