summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRam Periathiruvadi2018-07-17 20:01:31 -0500
committerRam Periathiruvadi2018-07-19 14:36:55 -0500
commitcdee12016c0cae41ae68c8f44a70b8f6d1271603 (patch)
tree12ffabb8a7cbaa4108042825f29a325646db0a11
parent44d57dcc48310e4a3e697e16fc89238ee78370ce (diff)
downloadplatform-packages-services-car-cdee12016c0cae41ae68c8f44a70b8f6d1271603.tar.gz
platform-packages-services-car-cdee12016c0cae41ae68c8f44a70b8f6d1271603.tar.xz
platform-packages-services-car-cdee12016c0cae41ae68c8f44a70b8f6d1271603.zip
Provide an option to disable UxR change broadcast.
This is an option in debug builds to be able to turn off broadcasting UX restriction changes, so non-drive-optimized apps will not be blocked by the system in a restricted state. In other words, this turns off the UX restriction engine. Bug: 111515554 Test: Test if previously blocked apps and activities can run when UX restriction engine is disabled. Change-Id: I6e6af550bade5fb5e84603e3bf5c962e94a881ef
-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 3f3f0516..a6dbfea3 100644
--- a/service/src/com/android/car/pm/CarPackageManagerService.java
+++ b/service/src/com/android/car/pm/CarPackageManagerService.java
@@ -977,8 +977,18 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements
977 } 977 }
978 } 978 }
979 979
980 /**
981 * Enable/Disable activity blocking by correspondingly enabling/disabling broadcasting UXR
982 * changes in {@link CarUxRestrictionsManagerService}. This is only available in
983 * engineering builds for development convenience.
984 *
985 */
980 @Override 986 @Override
981 public synchronized void setEnableActivityBlocking(boolean enable) { 987 public synchronized void setEnableActivityBlocking(boolean enable) {
988 if (!isDebugBuild()) {
989 Log.e(CarLog.TAG_PACKAGE, "Cannot enable/disable activity blocking");
990 return;
991 }
982 // Check if the caller has the same signature as that of the car service. 992 // Check if the caller has the same signature as that of the car service.
983 if (mPackageManager.checkSignatures(Process.myUid(), Binder.getCallingUid()) 993 if (mPackageManager.checkSignatures(Process.myUid(), Binder.getCallingUid())
984 != PackageManager.SIGNATURE_MATCH) { 994 != PackageManager.SIGNATURE_MATCH) {
@@ -986,7 +996,7 @@ public class CarPackageManagerService extends ICarPackageManager.Stub implements
986 "Caller " + mPackageManager.getNameForUid(Binder.getCallingUid()) 996 "Caller " + mPackageManager.getNameForUid(Binder.getCallingUid())
987 + " does not have the right signature"); 997 + " does not have the right signature");
988 } 998 }
989 mEnableActivityBlocking = enable; 999 mCarUxRestrictionsService.setUxRChangeBroadcastEnabled(enable);
990 } 1000 }
991 1001
992 /** 1002 /**