Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab156196 authored by Steven Moreland's avatar Steven Moreland Committed by Android (Google) Code Review
Browse files

Merge "Return<*> getStatus().isOk() -> isOk()"

parents 11fa7f3d d002a8b0
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ using hardware::thermal::V1_0::IThermal;
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 @@ static jfloatArray nativeGetFanSpeeds(JNIEnv *env, jclass /* clazz */) {
    }

    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 @@ static jfloatArray nativeGetFanSpeeds(JNIEnv *env, jclass /* clazz */) {
                    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 @@ static jfloatArray nativeGetDeviceTemperatures(JNIEnv *env, jclass /* clazz */,
        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 @@ static jfloatArray nativeGetDeviceTemperatures(JNIEnv *env, jclass /* clazz */,
                    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 @@ static jobjectArray nativeGetCpuUsages(JNIEnv *env, jclass /* clazz */) {
        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 @@ static jobjectArray nativeGetCpuUsages(JNIEnv *env, jclass /* clazz */) {
                    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,
+13 −13
Original line number Diff line number Diff line
@@ -185,14 +185,14 @@ HdmiCecController::HdmiCecController(sp<IHdmiCec> hdmiCec,
          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 @@ HdmiCecController::~HdmiCecController() {
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::sendMessage(const CecMessage& message) {

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 @@ int HdmiCecController::addLogicalAddress(CecLogicalAddress address) {

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 @@ int HdmiCecController::getPhysicalAddress() {
            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::getPhysicalAddress() {

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 @@ int HdmiCecController::getVersion() {

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 @@ jobjectArray HdmiCecController::getPortInfos() {
    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 @@ jobjectArray HdmiCecController::getPortInfos() {

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 @@ void HdmiCecController::setLanguage(hidl_string language) {
// 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 @@ void HdmiCecController::enableAudioReturnChannel(int port, bool enabled) {
// 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;
+1 −2
Original line number Diff line number Diff line
@@ -117,8 +117,7 @@ static void setLight_native(
        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;
        }
+36 −36
Original line number Diff line number Diff line
@@ -892,7 +892,7 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
            gnssXtraIface = xtraIface;
        });

        if (!result.getStatus().isOk()) {
        if (!result.isOk()) {
            ALOGD("Unable to get a handle to Xtra");
        }

@@ -900,7 +900,7 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
            agnssRilIface = rilIface;
        });

        if (!result.getStatus().isOk()) {
        if (!result.isOk()) {
            ALOGD("Unable to get a handle to AGnssRil");
        }

@@ -908,7 +908,7 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
            agnssIface = assistedGnssIface;
        });

        if (!result.getStatus().isOk()) {
        if (!result.isOk()) {
            ALOGD("Unable to get a handle to AGnss");
        }

@@ -917,7 +917,7 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
            gnssNavigationMessageIface = navigationMessageIface;
        });

        if (!result.getStatus().isOk()) {
        if (!result.isOk()) {
            ALOGD("Unable to get a handle to GnssNavigationMessage");
        }

@@ -925,35 +925,35 @@ static void android_location_GnssLocationProvider_class_init_native(JNIEnv* env,
                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 @@ static jboolean android_location_GnssLocationProvider_init(JNIEnv* env, jobject
    }

    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 @@ static jboolean android_location_GnssLocationProvider_init(JNIEnv* env, jobject
        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 @@ static jboolean android_location_GnssLocationProvider_set_position_mode(JNIEnv*
                                     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_set_position_mode(JNIEnv*
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_start(JNIEnv* /* env */, j
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 @@ static void android_location_GnssLocationProvider_delete_aiding_data(JNIEnv* /*
                                                                    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 @@ static void android_location_GnssLocationProvider_inject_time(JNIEnv* /* env */,
        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 @@ static void android_location_GnssLocationProvider_inject_location(JNIEnv* /* env
        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 @@ static void android_location_GnssLocationProvider_agps_data_conn_open(
    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 @@ static void android_location_GnssLocationProvider_agps_data_conn_closed(JNIEnv*
    }

    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 @@ static void android_location_GnssLocationProvider_agps_data_conn_failed(JNIEnv*
    }

    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 @@ static void android_location_GnssLocationProvider_set_agps_server(JNIEnv* env, j
    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 @@ static void android_location_GnssLocationProvider_update_network_state(JNIEnv* e
        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 @@ static jboolean android_location_GnssLocationProvider_add_geofence(JNIEnv* /* en
                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 @@ static jboolean android_location_GnssLocationProvider_remove_geofence(JNIEnv* /*
        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 @@ static jboolean android_location_GnssLocationProvider_pause_geofence(JNIEnv* /*
        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 @@ static jboolean android_location_GnssLocationProvider_resume_geofence(JNIEnv* /*
        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 @@ static jboolean android_location_GnssLocationProvider_stop_measurement_collectio
    }

    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 @@ static jboolean android_location_GnssLocationProvider_stop_navigation_message_co
    }

    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 @@ static jboolean android_location_GnssLocationProvider_set_emergency_supl_pdn(JNI
    }

    auto result = gnssConfigurationIface->setEmergencySuplPdn(emergencySuplPdn);
    if (result.getStatus().isOk()) {
    if (result.isOk()) {
        return result;
    } else {
        return JNI_FALSE;
@@ -1532,7 +1532,7 @@ static jboolean android_location_GnssLocationProvider_set_supl_version(JNIEnv*,
        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 @@ static jboolean android_location_GnssLocationProvider_set_supl_es(JNIEnv*,
    }

    auto result = gnssConfigurationIface->setSuplEs(suplEs);
    if (result.getStatus().isOk()) {
    if (result.isOk()) {
        return result;
    } else {
        return JNI_FALSE;
@@ -1564,7 +1564,7 @@ static jboolean android_location_GnssLocationProvider_set_supl_mode(JNIEnv*,
    }

    auto result = gnssConfigurationIface->setSuplMode(mode);
    if (result.getStatus().isOk()) {
    if (result.isOk()) {
        return result;
    } else {
        return JNI_FALSE;
@@ -1580,7 +1580,7 @@ static jboolean android_location_GnssLocationProvider_set_gps_lock(JNIEnv*,
    }

    auto result = gnssConfigurationIface->setGpsLock(gpsLock);
    if (result.getStatus().isOk()) {
    if (result.isOk()) {
        return result;
    } else {
        return JNI_FALSE;
@@ -1597,7 +1597,7 @@ static jboolean android_location_GnssLocationProvider_set_lpp_profile(JNIEnv*,

    auto result = gnssConfigurationIface->setLppProfile(lppProfile);

    if (result.getStatus().isOk()) {
    if (result.isOk()) {
        return result;
    } else {
        return JNI_FALSE;
@@ -1613,7 +1613,7 @@ static jboolean android_location_GnssLocationProvider_set_gnss_pos_protocol_sele
    }

    auto result = gnssConfigurationIface->setGlonassPositioningProtocol(gnssPosProtocol);
    if (result.getStatus().isOk()) {
    if (result.isOk()) {
        return result;
    } else {
        return JNI_FALSE;