Tweaks to CarStorageMonitoring:
- add an API to retrieve the current wear estimates
- protect API by system permission

Test: KitchenSink and runtest -x packages/services/Car/tests/carservice_test/src/com/android/car/CarStorageMonitoringTest.java
Bug: 32512551
Change-Id: I2a937dbc525d86c10f6c546b63eb992513807e54
diff --git a/tests/carservice_test/src/com/android/car/CarStorageMonitoringTest.java b/tests/carservice_test/src/com/android/car/CarStorageMonitoringTest.java
index 532bc1c..cd104f8 100644
--- a/tests/carservice_test/src/com/android/car/CarStorageMonitoringTest.java
+++ b/tests/carservice_test/src/com/android/car/CarStorageMonitoringTest.java
@@ -18,6 +18,7 @@
 
 import android.car.Car;
 import android.car.storagemonitoring.CarStorageMonitoringManager;
+import android.car.storagemonitoring.WearEstimate;
 import android.test.suitebuilder.annotation.MediumTest;
 import com.android.car.storagemonitoring.WearInformation;
 
@@ -26,14 +27,14 @@
 public class CarStorageMonitoringTest extends MockedCarTestBase {
     private static final String TAG = CarStorageMonitoringTest.class.getSimpleName();
 
+    private static final WearInformation DEFAULT_WEAR_INFORMATION =
+        new WearInformation(10, 0, WearInformation.PRE_EOL_INFO_NORMAL);
+
     private CarStorageMonitoringManager mCarStorageMonitoringManager;
 
     @Override
     protected synchronized void configureFakeSystemInterface() {
-        setFlashWearInformation(new WearInformation(
-            WearInformation.UNKNOWN_LIFETIME_ESTIMATE,
-            WearInformation.UNKNOWN_LIFETIME_ESTIMATE,
-            WearInformation.PRE_EOL_INFO_NORMAL));
+        setFlashWearInformation(DEFAULT_WEAR_INFORMATION);
     }
 
     @Override
@@ -45,7 +46,15 @@
     }
 
     public void testReadPreEolInformation() throws Exception {
-        assertEquals(WearInformation.PRE_EOL_INFO_NORMAL,
+        assertEquals(DEFAULT_WEAR_INFORMATION.preEolInfo,
                 mCarStorageMonitoringManager.getPreEolIndicatorStatus());
     }
+
+    public void testReadWearEstimate() throws Exception {
+        final WearEstimate wearEstimate = mCarStorageMonitoringManager.getWearEstimate();
+
+        assertNotNull(wearEstimate);
+        assertEquals(DEFAULT_WEAR_INFORMATION.lifetimeEstimateA, wearEstimate.typeA);
+        assertEquals(DEFAULT_WEAR_INFORMATION.lifetimeEstimateB, wearEstimate.typeB);
+    }
 }