Use old car-lib api on google3
Car-lib is having trouble updating their google3 stubs: b/150724388
So that we're not blocked on them to sync to google3, use the old
car-lib api on google3.
The bug where we first switched to the new api is b/149264077
Fixes: 152645300
Test: Manually
Change-Id: Ic2372b810c5c4506c5ba2a33ed2c408461d1a3a1
diff --git a/car-ui-lib/src/com/android/car/ui/utils/CarUxRestrictionsUtil.java b/car-ui-lib/src/com/android/car/ui/utils/CarUxRestrictionsUtil.java
index dc627a0..e5c7fc9 100644
--- a/car-ui-lib/src/com/android/car/ui/utils/CarUxRestrictionsUtil.java
+++ b/car-ui-lib/src/com/android/car/ui/utils/CarUxRestrictionsUtil.java
@@ -34,6 +34,10 @@
import java.util.Set;
import java.util.WeakHashMap;
+// This can't be in the middle of the rest of the imports on gerrit or it will
+// fail our style checks
+// copybara:insert import android.car.CarNotConnectedException;
+
/**
* Utility class to access Car Restriction Manager.
*
@@ -44,6 +48,10 @@
public class CarUxRestrictionsUtil {
private static final String TAG = "CarUxRestrictionsUtil";
+ /* copybara:insert
+ private final Car mCarApi;
+ private CarUxRestrictionsManager mCarUxRestrictionsManager;
+ */
@NonNull
private CarUxRestrictions mCarUxRestrictions = getDefaultRestrictions();
@@ -65,6 +73,7 @@
}
};
+ // copybara:strip_begin
Car.createCar(context.getApplicationContext(), null, Car.CAR_WAIT_TIMEOUT_DO_NOT_WAIT,
(Car car, boolean ready) -> {
if (ready) {
@@ -79,6 +88,21 @@
listener.onUxRestrictionsChanged(null);
}
});
+ /* copybara:strip_end_and_replace
+ mCarApi = Car.createCar(context.getApplicationContext());
+
+ try {
+ mCarUxRestrictionsManager =
+ (CarUxRestrictionsManager) mCarApi.getCarManager(
+ Car.CAR_UX_RESTRICTION_SERVICE);
+ mCarUxRestrictionsManager.registerListener(listener);
+ listener.onUxRestrictionsChanged(
+ mCarUxRestrictionsManager.getCurrentCarUxRestrictions());
+ } catch (CarNotConnectedException | NullPointerException e) {
+ Log.e(TAG, "Car not connected", e);
+ // mCarUxRestrictions will be the default
+ }
+ */
}
@NonNull