Merge "Return<*> getStatus().isOk() -> isOk()"
diff --git a/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp b/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp
index c42141a..17a6c297 100644
--- a/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp
+++ b/services/core/jni/com_android_server_HardwarePropertiesManagerService.cpp
@@ -37,6 +37,8 @@
 using hardware::thermal::V1_0::Temperature;
 using hardware::thermal::V1_0::ThermalStatus;
 using hardware::thermal::V1_0::ThermalStatusCode;
+template<typename T>
+using Return = hardware::Return<T>;
 
 // ---------------------------------------------------------------------------
 
@@ -76,7 +78,7 @@
     }
 
     hidl_vec<CoolingDevice> list;
-    Status status = gThermalModule->getCoolingDevices(
+    Return<void> ret = gThermalModule->getCoolingDevices(
             [&list](ThermalStatus status, hidl_vec<CoolingDevice> devices) {
                 if (status.code == ThermalStatusCode::SUCCESS) {
                     list = std::move(devices);
@@ -84,10 +86,10 @@
                     ALOGE("Couldn't get fan speeds because of HAL error: %s",
                           status.debugMessage.c_str());
                 }
-            }).getStatus();
+            });
 
-    if (!status.isOk()) {
-        ALOGE("getCoolingDevices failed status: %d", status.exceptionCode());
+    if (!ret.isOk()) {
+        ALOGE("getCoolingDevices failed status: %s", ret.description().c_str());
     }
 
     float values[list.size()];
@@ -106,7 +108,7 @@
         return env->NewFloatArray(0);
     }
     hidl_vec<Temperature> list;
-    Status status = gThermalModule->getTemperatures(
+    Return<void> ret = gThermalModule->getTemperatures(
             [&list](ThermalStatus status, hidl_vec<Temperature> temperatures) {
                 if (status.code == ThermalStatusCode::SUCCESS) {
                     list = std::move(temperatures);
@@ -114,10 +116,10 @@
                     ALOGE("Couldn't get temperatures because of HAL error: %s",
                           status.debugMessage.c_str());
                 }
-            }).getStatus();
+            });
 
-    if (!status.isOk()) {
-        ALOGE("getDeviceTemperatures failed status: %d", status.exceptionCode());
+    if (!ret.isOk()) {
+        ALOGE("getDeviceTemperatures failed status: %s", ret.description().c_str());
     }
 
     jfloat values[list.size()];
@@ -151,7 +153,7 @@
         return env->NewObjectArray(0, gCpuUsageInfoClassInfo.clazz, nullptr);
     }
     hidl_vec<CpuUsage> list;
-    Status status = gThermalModule->getCpuUsages(
+    Return<void> ret = gThermalModule->getCpuUsages(
             [&list](ThermalStatus status, hidl_vec<CpuUsage> cpuUsages) {
                 if (status.code == ThermalStatusCode::SUCCESS) {
                     list = std::move(cpuUsages);
@@ -159,10 +161,10 @@
                     ALOGE("Couldn't get CPU usages because of HAL error: %s",
                           status.debugMessage.c_str());
                 }
-            }).getStatus();
+            });
 
-    if (!status.isOk()) {
-        ALOGE("getCpuUsages failed status: %d", status.exceptionCode());
+    if (!ret.isOk()) {
+        ALOGE("getCpuUsages failed status: %s", ret.description().c_str());
     }
 
     jobjectArray cpuUsages = env->NewObjectArray(list.size(), gCpuUsageInfoClassInfo.clazz,
diff --git a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
index 0c5729e..7790d15 100644
--- a/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
+++ b/services/core/jni/com_android_server_hdmi_HdmiCecController.cpp
@@ -185,14 +185,14 @@
           mLooper(looper) {
     mHdmiCecCallback = new HdmiCecCallback(this);
     Return<void> ret = mHdmiCec->setCallback(mHdmiCecCallback);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to set a cec callback.");
     }
 }
 
 HdmiCecController::~HdmiCecController() {
     Return<void> ret = mHdmiCec->setCallback(nullptr);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to set a cec callback.");
     }
 }
@@ -200,7 +200,7 @@
 int HdmiCecController::sendMessage(const CecMessage& message) {
     // TODO: propagate send_message's return value.
     Return<SendMessageResult> ret = mHdmiCec->sendMessage(message);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to send CEC message.");
         return static_cast<int>(SendMessageResult::FAIL);
     }
@@ -209,7 +209,7 @@
 
 int HdmiCecController::addLogicalAddress(CecLogicalAddress address) {
     Return<Result> ret = mHdmiCec->addLogicalAddress(address);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to add a logical address.");
         return static_cast<int>(Result::FAILURE_UNKNOWN);
     }
@@ -218,7 +218,7 @@
 
 void HdmiCecController::clearLogicaladdress() {
     Return<void> ret = mHdmiCec->clearLogicalAddress();
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to clear logical address.");
     }
 }
@@ -230,7 +230,7 @@
             result = res;
             addr = paddr;
         });
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to get physical address.");
         return INVALID_PHYSICAL_ADDRESS;
     }
@@ -239,7 +239,7 @@
 
 int HdmiCecController::getVersion() {
     Return<int32_t> ret = mHdmiCec->getCecVersion();
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to get cec version.");
     }
     return ret;
@@ -247,7 +247,7 @@
 
 uint32_t HdmiCecController::getVendorId() {
     Return<uint32_t> ret = mHdmiCec->getVendorId();
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to get vendor id.");
     }
     return ret;
@@ -267,7 +267,7 @@
     Return<void> ret = mHdmiCec->getPortInfo([&ports](hidl_vec<HdmiPortInfo> list) {
             ports = list;
         });
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to get port information.");
         return NULL;
     }
@@ -287,14 +287,14 @@
 
 void HdmiCecController::setOption(OptionKey key, bool enabled) {
     Return<void> ret = mHdmiCec->setOption(key, enabled);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to set option.");
     }
 }
 
 void HdmiCecController::setLanguage(hidl_string language) {
     Return<void> ret = mHdmiCec->setLanguage(language);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to set language.");
     }
 }
@@ -302,7 +302,7 @@
 // Enable audio return channel.
 void HdmiCecController::enableAudioReturnChannel(int port, bool enabled) {
     Return<void> ret = mHdmiCec->enableAudioReturnChannel(port, enabled);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to enable/disable ARC.");
     }
 }
@@ -310,7 +310,7 @@
 // Whether to hdmi device is connected to the given port.
 bool HdmiCecController::isConnected(int port) {
     Return<bool> ret = mHdmiCec->isConnected(port);
-    if (!ret.getStatus().isOk()) {
+    if (!ret.isOk()) {
         ALOGE("Failed to get connection info.");
     }
     return ret;
diff --git a/services/core/jni/com_android_server_lights_LightsService.cpp b/services/core/jni/com_android_server_lights_LightsService.cpp
index a3ab8f6..cf7f1cb 100644
--- a/services/core/jni/com_android_server_lights_LightsService.cpp
+++ b/services/core/jni/com_android_server_lights_LightsService.cpp
@@ -117,8 +117,7 @@
         ALOGD_IF_SLOW(50, "Excessive delay setting light");
         Return<Status> ret = gLight->setLight(type, state);
 
-        // TODO(b/31348667): this is transport specific status
-        if (!ret.getStatus().isOk()) {
+        if (!ret.isOk()) {
             ALOGE("Failed to issue set light command.");
             return;
         }
diff --git a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
index b7032db..93c7cd5 100644
--- a/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
+++ b/services/core/jni/com_android_server_location_GnssLocationProvider.cpp
@@ -892,7 +892,7 @@
             gnssXtraIface = xtraIface;
         });
 
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to Xtra");
         }
 
@@ -900,7 +900,7 @@
             agnssRilIface = rilIface;
         });
 
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to AGnssRil");
         }
 
@@ -908,7 +908,7 @@
             agnssIface = assistedGnssIface;
         });
 
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to AGnss");
         }
 
@@ -917,7 +917,7 @@
             gnssNavigationMessageIface = navigationMessageIface;
         });
 
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to GnssNavigationMessage");
         }
 
@@ -925,35 +925,35 @@
                 const sp<IGnssMeasurement>& measurementIface) {
             gnssMeasurementIface = measurementIface;
         });
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to GnssMeasurement");
         }
 
         result = gnssHal->getExtensionGnssDebug([](const sp<IGnssDebug>& debugIface) {
             gnssDebugIface = debugIface;
         });
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to GnssDebug");
         }
 
         result = gnssHal->getExtensionGnssNi([](const sp<IGnssNi>& niIface) {
             gnssNiIface = niIface;
         });
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to GnssNi");
         }
 
         result = gnssHal->getExtensionGnssConfiguration([](const sp<IGnssConfiguration>& configIface) {
             gnssConfigurationIface = configIface;
         });
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to GnssConfiguration");
         }
 
         result = gnssHal->getExtensionGnssGeofencing([](const sp<IGnssGeofencing>& geofenceIface) {
             gnssGeofencingIface = geofenceIface;
         });
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGD("Unable to get a handle to GnssGeofencing");
         }
 
@@ -994,7 +994,7 @@
     }
 
     auto result = gnssHal->setCallback(gnssCbIface);
-    if ((!result) || (!result.getStatus().isOk())) {
+    if ((!result) || (!result.isOk())) {
         ALOGE("SetCallback for Gnss Interface fails\n");
         return JNI_FALSE;
     }
@@ -1004,7 +1004,7 @@
         ALOGE("Unable to initialize GNSS Xtra interface\n");
     } else {
         result = gnssXtraIface->setCallback(gnssXtraCbIface);
-        if ((!result) || (!result.getStatus().isOk())) {
+        if ((!result) || (!result.isOk())) {
             gnssXtraIface = nullptr;
             ALOGE("SetCallback for Gnss Xtra Interface fails\n");
         }
@@ -1049,7 +1049,7 @@
                                      min_interval,
                                      preferred_accuracy,
                                      preferred_time);
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGE("%s: GNSS setPositionMode failed\n", __func__);
             return JNI_FALSE;
         } else {
@@ -1063,7 +1063,7 @@
 static jboolean android_location_GnssLocationProvider_start(JNIEnv* /* env */, jobject /* obj */) {
     if (gnssHal != nullptr) {
         auto result = gnssHal->start();
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             return JNI_FALSE;
         } else {
             return result;
@@ -1076,7 +1076,7 @@
 static jboolean android_location_GnssLocationProvider_stop(JNIEnv* /* env */, jobject /* obj */) {
     if (gnssHal != nullptr) {
         auto result = gnssHal->stop();
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             return JNI_FALSE;
         } else {
             return result;
@@ -1090,7 +1090,7 @@
                                                                     jint flags) {
     if (gnssHal != nullptr) {
         auto result = gnssHal->deleteAidingData(static_cast<IGnss::GnssAidingData>(flags));
-        if (!result.getStatus().isOk()) {
+        if (!result.isOk()) {
             ALOGE("Error in deleting aiding data");
         }
     }
@@ -1191,7 +1191,7 @@
         jlong time, jlong timeReference, jint uncertainty) {
     if (gnssHal != nullptr) {
         auto result = gnssHal->injectTime(time, timeReference, uncertainty);
-        if (!result || !result.getStatus().isOk()) {
+        if (!result || !result.isOk()) {
             ALOGE("%s: Gnss injectTime() failed", __func__);
         }
     }
@@ -1201,7 +1201,7 @@
         jobject /* obj */, jdouble latitude, jdouble longitude, jfloat accuracy) {
     if (gnssHal != nullptr) {
         auto result = gnssHal->injectLocation(latitude, longitude, accuracy);
-        if (!result || !result.getStatus().isOk()) {
+        if (!result || !result.isOk()) {
             ALOGE("%s: Gnss injectLocation() failed", __func__);
         }
     }
@@ -1238,7 +1238,7 @@
     const char *apnStr = env->GetStringUTFChars(apn, NULL);
 
     auto result = agnssIface->dataConnOpen(apnStr, static_cast<IAGnss::ApnIpType>(apnIpType));
-    if ((!result) || (!result.getStatus().isOk())) {
+    if ((!result) || (!result.isOk())) {
         ALOGE("%s: Failed to set APN and its IP type", __func__);
     }
     env->ReleaseStringUTFChars(apn, apnStr);
@@ -1252,7 +1252,7 @@
     }
 
     auto result = agnssIface->dataConnClosed();
-    if ((!result) || (!result.getStatus().isOk())) {
+    if ((!result) || (!result.isOk())) {
         ALOGE("%s: Failed to close AGnss data connection", __func__);
     }
 }
@@ -1265,7 +1265,7 @@
     }
 
     auto result = agnssIface->dataConnFailed();
-    if ((!result) || (!result.getStatus().isOk())) {
+    if ((!result) || (!result.isOk())) {
         ALOGE("%s: Failed to notify unavailability of AGnss data connection", __func__);
     }
 }
@@ -1281,7 +1281,7 @@
     auto result = agnssIface->setServer(static_cast<IAGnssCallback::AGnssType>(type),
                                        c_hostname,
                                        port);
-    if ((!result) || (!result.getStatus().isOk())) {
+    if ((!result) || (!result.isOk())) {
         ALOGE("%s: Failed to set AGnss host name and port", __func__);
     }
 
@@ -1354,13 +1354,13 @@
         auto result = agnssRilIface->updateNetworkState(connected,
                                                        static_cast<IAGnssRil::NetworkType>(type),
                                                        roaming);
-        if ((!result) || (!result.getStatus().isOk())) {
+        if ((!result) || (!result.isOk())) {
             ALOGE("updateNetworkState failed");
         }
 
         const char *c_apn = env->GetStringUTFChars(apn, NULL);
         result = agnssRilIface->updateNetworkAvailability(available, c_apn);
-        if ((!result) || (!result.getStatus().isOk())) {
+        if ((!result) || (!result.isOk())) {
             ALOGE("updateNetworkAvailability failed");
         }
 
@@ -1384,7 +1384,7 @@
                 geofenceId, latitude, longitude, radius,
                 static_cast<IGnssGeofenceCallback::GeofenceTransition>(last_transition),
                 monitor_transition, notification_responsiveness, unknown_timer);
-        return boolToJbool(result.getStatus().isOk());
+        return boolToJbool(result.isOk());
     } else {
         ALOGE("Geofence Interface not available");
     }
@@ -1395,7 +1395,7 @@
         jobject /* obj */, jint geofenceId) {
     if (gnssGeofencingIface != nullptr) {
         auto result = gnssGeofencingIface->removeGeofence(geofenceId);
-        return boolToJbool(result.getStatus().isOk());
+        return boolToJbool(result.isOk());
     } else {
         ALOGE("Geofence interface not available");
     }
@@ -1406,7 +1406,7 @@
         jobject /* obj */, jint geofenceId) {
     if (gnssGeofencingIface != nullptr) {
         auto result = gnssGeofencingIface->pauseGeofence(geofenceId);
-        return boolToJbool(result.getStatus().isOk());
+        return boolToJbool(result.isOk());
     } else {
         ALOGE("Geofence interface not available");
     }
@@ -1417,7 +1417,7 @@
         jobject /* obj */, jint geofenceId, jint monitor_transition) {
     if (gnssGeofencingIface != nullptr) {
         auto result = gnssGeofencingIface->resumeGeofence(geofenceId, monitor_transition);
-        return boolToJbool(result.getStatus().isOk());
+        return boolToJbool(result.isOk());
     } else {
         ALOGE("Geofence interface not available");
     }
@@ -1463,7 +1463,7 @@
     }
 
     auto result = gnssMeasurementIface->close();
-    return boolToJbool(result.getStatus().isOk());
+    return boolToJbool(result.isOk());
 }
 
 static jboolean android_location_GnssLocationProvider_is_navigation_message_supported(
@@ -1505,7 +1505,7 @@
     }
 
     auto result = gnssNavigationMessageIface->close();
-    return boolToJbool(result.getStatus().isOk());
+    return boolToJbool(result.isOk());
 }
 
 static jboolean android_location_GnssLocationProvider_set_emergency_supl_pdn(JNIEnv*,
@@ -1517,7 +1517,7 @@
     }
 
     auto result = gnssConfigurationIface->setEmergencySuplPdn(emergencySuplPdn);
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;
@@ -1532,7 +1532,7 @@
         return JNI_FALSE;
     }
     auto result = gnssConfigurationIface->setSuplVersion(version);
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;
@@ -1548,7 +1548,7 @@
     }
 
     auto result = gnssConfigurationIface->setSuplEs(suplEs);
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;
@@ -1564,7 +1564,7 @@
     }
 
     auto result = gnssConfigurationIface->setSuplMode(mode);
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;
@@ -1580,7 +1580,7 @@
     }
 
     auto result = gnssConfigurationIface->setGpsLock(gpsLock);
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;
@@ -1597,7 +1597,7 @@
 
     auto result = gnssConfigurationIface->setLppProfile(lppProfile);
 
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;
@@ -1613,7 +1613,7 @@
     }
 
     auto result = gnssConfigurationIface->setGlonassPositioningProtocol(gnssPosProtocol);
-    if (result.getStatus().isOk()) {
+    if (result.isOk()) {
         return result;
     } else {
         return JNI_FALSE;