aboutsummaryrefslogtreecommitdiff
path: root/car-lib/src/android/car/storagemonitoring
diff options
context:
space:
mode:
authorEnrico Granata <egranata@google.com>2017-09-25 14:46:49 -0700
committerEnrico Granata <egranata@google.com>2017-09-27 12:00:09 -0700
commit286cd8e9cc8ed040d7724e51ea7835eac45b46e6 (patch)
tree7082a320720688d496ff81353c1ffb333a4b0849 /car-lib/src/android/car/storagemonitoring
parent9c1f27227f843f10a2d286ded886464b60854e08 (diff)
downloadCar-286cd8e9cc8ed040d7724e51ea7835eac45b46e6.tar.gz
Implement wear history tracking
Bug: 32512551 Test: runtest -x packages/services/Car/tests/carservice_unit_test/src/com/android/car/storagemonitoring/CarStorageMonitoringTest.java runtest -x packages/services/Car/tests/carservice_test/src/com/android/car/CarStorageMonitoringTest.java Change-Id: Id024f9378e0a762cbdfeead9267deeebfa86fd40
Diffstat (limited to 'car-lib/src/android/car/storagemonitoring')
-rw-r--r--car-lib/src/android/car/storagemonitoring/CarStorageMonitoringManager.java50
-rw-r--r--car-lib/src/android/car/storagemonitoring/ICarStorageMonitoring.aidl6
-rw-r--r--car-lib/src/android/car/storagemonitoring/WearEstimate.java12
3 files changed, 56 insertions, 12 deletions
diff --git a/car-lib/src/android/car/storagemonitoring/CarStorageMonitoringManager.java b/car-lib/src/android/car/storagemonitoring/CarStorageMonitoringManager.java
index aa2ad842a4..7192158a85 100644
--- a/car-lib/src/android/car/storagemonitoring/CarStorageMonitoringManager.java
+++ b/car-lib/src/android/car/storagemonitoring/CarStorageMonitoringManager.java
@@ -15,12 +15,17 @@
*/
package android.car.storagemonitoring;
+import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
-import android.car.CarApiUtil;
+import android.car.Car;
import android.car.CarManagerBase;
import android.car.CarNotConnectedException;
import android.os.IBinder;
import android.os.RemoteException;
+import java.util.Collections;
+import java.util.List;
+
+import static android.car.CarApiUtil.checkCarNotConnectedExceptionFromCarService;
/**
* API for retrieving information and metrics about the flash storage.
@@ -36,12 +41,16 @@ public final class CarStorageMonitoringManager implements CarManagerBase {
public static final int PRE_EOL_INFO_WARNING = 2;
public static final int PRE_EOL_INFO_URGENT = 3;
- /** @hide */
+ /**
+ * @hide
+ */
public CarStorageMonitoringManager(IBinder service) {
mService = ICarStorageMonitoring.Stub.asInterface(service);
}
- /** @hide */
+ /**
+ * @hide
+ */
@Override
public void onCarDisconnected() {
}
@@ -54,14 +63,13 @@ public final class CarStorageMonitoringManager implements CarManagerBase {
*
* It will return either PRE_EOL_INFO_UNKNOWN if the value can't be determined,
* or one of PRE_EOL_INFO_{NORMAL|WARNING|URGENT} depending on the device state.
- * @return
- * @throws CarNotConnectedException
*/
+ @RequiresPermission(value=Car.PERMISSION_STORAGE_MONITORING)
public int getPreEolIndicatorStatus() throws CarNotConnectedException {
try {
return mService.getPreEolIndicatorStatus();
} catch (IllegalStateException e) {
- CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ checkCarNotConnectedExceptionFromCarService(e);
} catch (RemoteException e) {
throw new CarNotConnectedException();
}
@@ -76,19 +84,39 @@ public final class CarStorageMonitoringManager implements CarManagerBase {
* Current technology in common automotive usage offers estimates in 10% increments.
*
* If either or both indicators are not available, they will be reported as UNKNOWN.
- * @return
- * @throws CarNotConnectedException
*/
+ @RequiresPermission(value=Car.PERMISSION_STORAGE_MONITORING)
public WearEstimate getWearEstimate() throws CarNotConnectedException {
try {
return mService.getWearEstimate();
} catch (IllegalStateException e) {
- CarApiUtil.checkCarNotConnectedExceptionFromCarService(e);
+ checkCarNotConnectedExceptionFromCarService(e);
} catch (RemoteException e) {
throw new CarNotConnectedException();
}
- return new WearEstimate(WearEstimate.UNKNOWN, WearEstimate.UNKNOWN);
+ return WearEstimate.UNKNOWN_ESTIMATE;
}
+ /**
+ * This method returns a list of all changes in wear estimate indicators detected during the
+ * lifetime of the system.
+ *
+ * The indicators are not guaranteed to persist across a factory reset.
+ *
+ * The indicators are guaranteed to be a lower-bound on the actual wear of the storage.
+ * Current technology in common automotive usage offers estimates in 10% increments.
+ *
+ * If no indicators are available, an empty list will be returned.
+ */
+ @RequiresPermission(value=Car.PERMISSION_STORAGE_MONITORING)
+ public List<WearEstimateChange> getWearEstimateHistory() throws CarNotConnectedException {
+ try {
+ return mService.getWearEstimateHistory();
+ } catch (IllegalStateException e) {
+ checkCarNotConnectedExceptionFromCarService(e);
+ } catch (RemoteException e) {
+ throw new CarNotConnectedException();
+ }
+ return Collections.emptyList();
+ }
}
-
diff --git a/car-lib/src/android/car/storagemonitoring/ICarStorageMonitoring.aidl b/car-lib/src/android/car/storagemonitoring/ICarStorageMonitoring.aidl
index 61910c50c5..b22e96b7a5 100644
--- a/car-lib/src/android/car/storagemonitoring/ICarStorageMonitoring.aidl
+++ b/car-lib/src/android/car/storagemonitoring/ICarStorageMonitoring.aidl
@@ -17,6 +17,7 @@
package android.car.storagemonitoring;
import android.car.storagemonitoring.WearEstimate;
+import android.car.storagemonitoring.WearEstimateChange;
/** @hide */
interface ICarStorageMonitoring {
@@ -29,4 +30,9 @@ interface ICarStorageMonitoring {
* Returns the current wear estimate indicators.
*/
WearEstimate getWearEstimate() = 2;
+
+ /**
+ * Returns the list of all observed wear estimate changes.
+ */
+ List<WearEstimateChange> getWearEstimateHistory() = 3;
}
diff --git a/car-lib/src/android/car/storagemonitoring/WearEstimate.java b/car-lib/src/android/car/storagemonitoring/WearEstimate.java
index d7abc2b729..507e6edff1 100644
--- a/car-lib/src/android/car/storagemonitoring/WearEstimate.java
+++ b/car-lib/src/android/car/storagemonitoring/WearEstimate.java
@@ -20,10 +20,11 @@ import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.JsonReader;
-import android.util.JsonToken;
import android.util.JsonWriter;
import java.io.IOException;
import java.util.Objects;
+import org.json.JSONException;
+import org.json.JSONObject;
/**
* Wear-out information for flash storage.
@@ -40,6 +41,9 @@ import java.util.Objects;
public class WearEstimate implements Parcelable {
public static final int UNKNOWN = -1;
+ /** @hide */
+ public static final WearEstimate UNKNOWN_ESTIMATE = new WearEstimate(UNKNOWN, UNKNOWN);
+
public static final Parcelable.Creator<WearEstimate> CREATOR =
new Parcelable.Creator<WearEstimate>() {
public WearEstimate createFromParcel(Parcel in) {
@@ -98,6 +102,12 @@ public class WearEstimate implements Parcelable {
this.typeB = typeB;
}
+ /** @hide */
+ public WearEstimate(JSONObject in) throws JSONException {
+ typeA = in.getInt("wearEstimateTypeA");
+ typeB = in.getInt("wearEstimateTypeB");
+ }
+
@Override
public int describeContents() {
return 0;