Manually convert to unary where coccinelle could not

Test: build
Change-Id: I7b5ea758b94bf225e8776f64256d644c3e96b198
diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc
index b66b1b5..283ea88 100644
--- a/system/bta/dm/bta_dm_act.cc
+++ b/system/bta/dm/bta_dm_act.cc
@@ -2090,8 +2090,7 @@
       ((bta_dm_search_cb.p_btm_inq_info == NULL) ||
        (bta_dm_search_cb.p_btm_inq_info &&
         (!bta_dm_search_cb.p_btm_inq_info->appl_knows_rem_name)))) {
-    if (bta_dm_read_remote_device_name(bta_dm_search_cb.peer_bdaddr,
-                                       transport) == true)
+    if (bta_dm_read_remote_device_name(bta_dm_search_cb.peer_bdaddr, transport))
       return;
 
     /* starting name discovery failed */
@@ -2107,7 +2106,7 @@
     bta_dm_search_cb.uuid_to_search = bta_dm_search_cb.num_uuid;
     if ((bta_dm_search_cb.p_btm_inq_info != NULL) &&
         bta_dm_search_cb.services != BTA_USER_SERVICE_MASK &&
-        (bta_dm_search_cb.sdp_search == false)) {
+        (!bta_dm_search_cb.sdp_search)) {
       /* check if EIR provides the information of supported services */
       bta_dm_eir_search_services(&bta_dm_search_cb.p_btm_inq_info->results,
                                  &bta_dm_search_cb.services_to_search,
diff --git a/system/bta/gatt/bta_gatts_api.cc b/system/bta/gatt/bta_gatts_api.cc
index 97eb421..a2d203c 100644
--- a/system/bta/gatt/bta_gatts_api.cc
+++ b/system/bta/gatt/bta_gatts_api.cc
@@ -80,7 +80,7 @@
       (tBTA_GATTS_API_REG*)osi_malloc(sizeof(tBTA_GATTS_API_REG));
 
   /* register with BTA system manager */
-  if (bta_sys_is_register(BTA_ID_GATTS) == false)
+  if (!bta_sys_is_register(BTA_ID_GATTS))
     bta_sys_register(BTA_ID_GATTS, &bta_gatts_reg);
 
   p_buf->hdr.event = BTA_GATTS_API_REG_EVT;
diff --git a/system/bta/sys/bta_sys_main.cc b/system/bta/sys/bta_sys_main.cc
index 79162b7..f7542a5 100644
--- a/system/bta/sys/bta_sys_main.cc
+++ b/system/bta/sys/bta_sys_main.cc
@@ -43,7 +43,7 @@
 #include "osi/include/thread.h"
 #include "utl.h"
 
-#if (defined BTA_AR_INCLUDED) && (BTA_AR_INCLUDED == true)
+#if (defined BTA_AR_INCLUDED) && (BTA_AR_INCLUDED == TRUE)
 #include "bta_ar_api.h"
 #endif
 
@@ -187,7 +187,7 @@
   /* register for BTM notifications */
   BTM_RegisterForDeviceStatusNotif((tBTM_DEV_STATUS_CB*)&bta_sys_hw_btm_cback);
 
-#if (defined BTA_AR_INCLUDED) && (BTA_AR_INCLUDED == true)
+#if (defined BTA_AR_INCLUDED) && (BTA_AR_INCLUDED == TRUE)
   bta_ar_init();
 #endif
 }
diff --git a/system/btif/co/bta_av_co.cc b/system/btif/co/bta_av_co.cc
index e931714..445ba91 100644
--- a/system/btif/co/bta_av_co.cc
+++ b/system/btif/co/bta_av_co.cc
@@ -532,8 +532,7 @@
   if (num_protect != 0) {
 #if (BTA_AV_CO_CP_SCMS_T == TRUE)
     /* If CP is supported */
-    if ((num_protect != 1) ||
-        (bta_av_co_cp_is_scmst(p_protect_info) == false)) {
+    if ((num_protect != 1) || (!bta_av_co_cp_is_scmst(p_protect_info))) {
       APPL_TRACE_ERROR("%s: wrong CP configuration", __func__);
       status = A2DP_BAD_CP_TYPE;
       category = AVDT_ASC_PROTECT;
diff --git a/system/btif/src/bluetooth.cc b/system/btif/src/bluetooth.cc
index fa0d25f..8c9b7ae 100644
--- a/system/btif/src/bluetooth.cc
+++ b/system/btif/src/bluetooth.cc
@@ -215,7 +215,7 @@
 int get_remote_service_record(const RawAddress& remote_addr,
                               const bluetooth::Uuid& uuid) {
   /* sanity check */
-  if (interface_ready() == false) return BT_STATUS_NOT_READY;
+  if (!interface_ready()) return BT_STATUS_NOT_READY;
 
   return btif_get_remote_service_record(remote_addr, uuid);
 }
diff --git a/system/btif/src/btif_av.cc b/system/btif/src/btif_av.cc
index 14d4444..393beeb 100644
--- a/system/btif/src/btif_av.cc
+++ b/system/btif/src/btif_av.cc
@@ -811,8 +811,7 @@
           __func__, p_av->start.status, p_av->start.suspending,
           p_av->start.initiator, btif_av_cb.flags);
 
-      if ((p_av->start.status == BTA_SUCCESS) &&
-          (p_av->start.suspending == true))
+      if ((p_av->start.status == BTA_SUCCESS) && p_av->start.suspending)
         return true;
 
       /* if remote tries to start a2dp when DUT is a2dp source
diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc
index 245675b..1f30d7f 100644
--- a/system/btif/src/btif_dm.cc
+++ b/system/btif/src/btif_dm.cc
@@ -854,7 +854,7 @@
 
   /* check for auto pair possiblity only if bond was initiated by local device
    */
-  if (pairing_cb.is_local_initiated && (p_pin_req->min_16_digit == false)) {
+  if (pairing_cb.is_local_initiated && !p_pin_req->min_16_digit) {
     if (check_cod(&bd_addr, COD_AV_HEADSETS) ||
         check_cod(&bd_addr, COD_AV_HEADPHONES) ||
         check_cod(&bd_addr, COD_AV_PORTABLE_AUDIO) ||
@@ -1336,7 +1336,7 @@
        * but instead wait for the cancel_cmpl_evt via the Busy Level
        *
        */
-      if (btif_dm_inquiry_in_progress == false) {
+      if (!btif_dm_inquiry_in_progress) {
         btgatt_filt_param_setup_t adv_filt_param;
         memset(&adv_filt_param, 0, sizeof(btgatt_filt_param_setup_t));
         do_in_bta_thread(
@@ -1625,7 +1625,7 @@
       btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
 
 /*special handling for HID devices */
-#if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == true))
+#if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE))
       btif_hh_remove_device(bd_addr);
 #endif
 #if (defined(BTA_HD_INCLUDED) && (BTA_HD_INCLUDED == TRUE))
diff --git a/system/btif/src/btif_rc.cc b/system/btif/src/btif_rc.cc
index 3a94bb7..318af9d 100644
--- a/system/btif/src/btif_rc.cc
+++ b/system/btif/src/btif_rc.cc
@@ -88,7 +88,7 @@
 
 #define CHECK_RC_CONNECTED(p_dev)                                          \
   do {                                                                     \
-    if ((p_dev) == NULL || (p_dev)->rc_connected == false) {               \
+    if ((p_dev) == NULL || !(p_dev)->rc_connected) {                       \
       BTIF_TRACE_WARNING("%s: called when RC is not connected", __func__); \
       return BT_STATUS_NOT_READY;                                          \
     }                                                                      \
@@ -96,7 +96,7 @@
 
 #define CHECK_BR_CONNECTED(p_dev)                                          \
   do {                                                                     \
-    if ((p_dev) == NULL || (p_dev)->br_connected == false) {               \
+    if ((p_dev) == NULL || !(p_dev)->br_connected) {                       \
       BTIF_TRACE_WARNING("%s: called when BR is not connected", __func__); \
       return BT_STATUS_NOT_READY;                                          \
     }                                                                      \
@@ -1892,7 +1892,7 @@
       continue;
     }
 
-    if (btif_rc_cb.rc_multi_cb[idx].rc_notif[event_id - 1].bNotify == false) {
+    if (!btif_rc_cb.rc_multi_cb[idx].rc_notif[event_id - 1].bNotify) {
       BTIF_TRACE_WARNING(
           "%s: Avrcp Event id is not registered: event_id: %x, handle: 0x%x",
           __func__, event_id, btif_rc_cb.rc_multi_cb[idx].rc_handle);
@@ -5259,7 +5259,7 @@
 
   /* Determine if this is a valid label */
   if (lbl < MAX_TRANSACTIONS_PER_SESSION) {
-    if (false == device.transaction[lbl].in_use) {
+    if (!device.transaction[lbl].in_use) {
       transaction = NULL;
     } else {
       transaction = &(device.transaction[lbl]);
@@ -5284,7 +5284,7 @@
 
   // Check for unused transactions
   for (uint8_t i = 0; i < MAX_TRANSACTIONS_PER_SESSION; i++) {
-    if (false == device.transaction[i].in_use) {
+    if (!device.transaction[i].in_use) {
       BTIF_TRACE_DEBUG("%s: Got transaction.label: %d", __func__,
                        device.transaction[i].lbl);
       device.transaction[i].in_use = true;
diff --git a/system/stack/a2dp/a2dp_api.cc b/system/stack/a2dp/a2dp_api.cc
index 3c2f1bb..b33741a 100644
--- a/system/stack/a2dp/a2dp_api.cc
+++ b/system/stack/a2dp/a2dp_api.cc
@@ -295,7 +295,7 @@
   result = SDP_InitDiscoveryDb(a2dp_cb.find.p_db, p_db->db_len, 1, &uuid_list,
                                p_db->num_attr, p_db->p_attrs);
 
-  if (result == true) {
+  if (result) {
     /* store service_uuid */
     a2dp_cb.find.service_uuid = service_uuid;
     a2dp_cb.find.p_cback = p_cback;
@@ -303,7 +303,7 @@
     /* perform service search */
     result = SDP_ServiceSearchAttributeRequest(bd_addr, a2dp_cb.find.p_db,
                                                a2dp_sdp_cback);
-    if (false == result) {
+    if (!result) {
       a2dp_cb.find.service_uuid = 0;
     }
   }
diff --git a/system/stack/avdt/avdt_api.cc b/system/stack/avdt/avdt_api.cc
index 4593bb3..3f738fb 100644
--- a/system/stack/avdt/avdt_api.cc
+++ b/system/stack/avdt/avdt_api.cc
@@ -1006,7 +1006,7 @@
       /* could not allocate channel control block */
       result = AVDT_NO_RESOURCES;
     }
-  } else if (p_ccb->ll_opened == false) {
+  } else if (!p_ccb->ll_opened) {
     AVDT_TRACE_WARNING("AVDT_ConnectReq: CCB LL is in the middle of opening");
 
     /* ccb was already allocated for the incoming signalling. */
diff --git a/system/stack/avrc/avrc_bld_tg.cc b/system/stack/avrc/avrc_bld_tg.cc
index 3939a8a..6a7b35f 100644
--- a/system/stack/avrc/avrc_bld_tg.cc
+++ b/system/stack/avrc/avrc_bld_tg.cc
@@ -1519,4 +1519,4 @@
   return status;
 }
 
-#endif /* (AVRC_METADATA_INCLUDED == true)*/
+#endif /* (AVRC_METADATA_INCLUDED == TRUE)*/
diff --git a/system/stack/avrc/avrc_pars_tg.cc b/system/stack/avrc/avrc_pars_tg.cc
index cc5ec1d..45159b3 100644
--- a/system/stack/avrc/avrc_pars_tg.cc
+++ b/system/stack/avrc/avrc_pars_tg.cc
@@ -546,4 +546,4 @@
   return status;
 }
 
-#endif /* (AVRC_METADATA_INCLUDED == true) */
+#endif /* (AVRC_METADATA_INCLUDED == TRUE) */
diff --git a/system/stack/avrc/avrc_sdp.cc b/system/stack/avrc/avrc_sdp.cc
index 0527fa3..627ddae 100644
--- a/system/stack/avrc/avrc_sdp.cc
+++ b/system/stack/avrc/avrc_sdp.cc
@@ -131,7 +131,7 @@
   result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list,
                                p_db->num_attr, p_db->p_attrs);
 
-  if (result == true) {
+  if (result) {
     /* store service_uuid and discovery db pointer */
     avrc_cb.p_db = p_db->p_db;
     avrc_cb.service_uuid = service_uuid;
diff --git a/system/stack/btm/btm_acl.cc b/system/stack/btm/btm_acl.cc
index 4617dce..78f0cc6 100644
--- a/system/stack/btm/btm_acl.cc
+++ b/system/stack/btm/btm_acl.cc
@@ -565,7 +565,7 @@
   /* Check if there is any SCO Active on this BD Address */
   is_sco_active = btm_is_sco_active_by_bdaddr(remote_bd_addr);
 
-  if (is_sco_active == true) return (BTM_NO_RESOURCES);
+  if (is_sco_active) return (BTM_NO_RESOURCES);
 #endif
 
   /* Ignore role switch request if the previous request was not completed */
diff --git a/system/stack/btm/btm_ble.cc b/system/stack/btm/btm_ble.cc
index 2711447..cd295c1 100644
--- a/system/stack/btm/btm_ble.cc
+++ b/system/stack/btm/btm_ble.cc
@@ -2178,7 +2178,7 @@
     ret = aes_cipher_msg_auth_code(p_rec->ble.keys.lcsrk, p_buf,
                                    (uint16_t)(len + 4), BTM_CMAC_TLEN_SIZE,
                                    p_mac);
-    if (ret == true) {
+    if (ret) {
       btm_ble_increment_sign_ctr(bd_addr, true);
     }
 
diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc
index d8a3bc3..ed5b3e5 100644
--- a/system/stack/btm/btm_ble_gap.cc
+++ b/system/stack/btm/btm_ble_gap.cc
@@ -435,7 +435,7 @@
                              ? BTM_BLE_SCAN_MODE_ACTI
                              : p_inq->scan_type;
 /* assume observe always not using white list */
-#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == true)
+#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
       /* enable resolving list */
       btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
 #endif
diff --git a/system/stack/btm/btm_ble_multi_adv.cc b/system/stack/btm/btm_ble_multi_adv.cc
index afc8e8b..917651c 100644
--- a/system/stack/btm/btm_ble_multi_adv.cc
+++ b/system/stack/btm/btm_ble_multi_adv.cc
@@ -896,7 +896,7 @@
 
     VLOG(1) << "reneabling advertising";
 
-    if (p_inst->in_use == true) {
+    if (p_inst->in_use) {
       // TODO(jpawlowski): we don't really allow to do directed advertising
       // right now. This should probably be removed, check with Andre.
       if ((p_inst->advertising_event_properties & 0x0C) == 0) {
@@ -997,9 +997,9 @@
 
   manager->RecomputeTimeout(&test1, end);
 
-  CHECK(timeout_triggered == true);
+  CHECK(timeout_triggered);
   timeout_triggered = false;
-  CHECK(test1.enable_status == false);
+  CHECK(!test1.enable_status);
 }
 
 // verify that duration and maxExtAdvEvents are properly adjusted when
@@ -1019,8 +1019,8 @@
 
   manager->RecomputeTimeout(&test1, end);
 
-  CHECK(timeout_triggered == false);
-  CHECK(test1.enable_status == true);
+  CHECK(!timeout_triggered);
+  CHECK(test1.enable_status);
   CHECK(test1.duration == 25);
   CHECK(test1.maxExtAdvEvents == 25);
 }
@@ -1041,7 +1041,7 @@
 
   manager->RecomputeTimeout(&test1, end);
 
-  CHECK(timeout_triggered == true);
+  CHECK(timeout_triggered);
   timeout_triggered = false;
-  CHECK(test1.enable_status == false);
+  CHECK(!test1.enable_status);
 }
diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc
index f90e13a..cb053d1 100644
--- a/system/stack/btm/btm_sec.cc
+++ b/system/stack/btm/btm_sec.cc
@@ -800,7 +800,7 @@
 
   if ((btm_cb.pairing_flags & BTM_PAIR_FLAGS_WE_STARTED_DD) &&
       (p_dev_rec->hci_handle == BTM_SEC_INVALID_HANDLE) &&
-      (btm_cb.security_mode_changed == false)) {
+      (!btm_cb.security_mode_changed)) {
     /* This is start of the dedicated bonding if local device is 2.0 */
     btm_cb.pin_code_len = pin_len;
     memcpy(btm_cb.pin_code, p_pin, pin_len);
@@ -2010,7 +2010,7 @@
          btm_cb.security_mode == BTM_SEC_MODE_LINK) ||
         (BTM_SM4_KNOWN == p_dev_rec->sm4) ||
         (BTM_SEC_IS_SM4(p_dev_rec->sm4) &&
-         (btm_sec_is_upgrade_possible(p_dev_rec, is_originator) == false))) {
+         (!btm_sec_is_upgrade_possible(p_dev_rec, is_originator)))) {
       /* legacy mode - local is legacy or local is lisbon/peer is legacy
        * or SM4 with no possibility of link key upgrade */
       if (is_originator) {
@@ -2313,7 +2313,7 @@
          btm_cb.security_mode == BTM_SEC_MODE_LINK) ||
         (BTM_SM4_KNOWN == p_dev_rec->sm4) ||
         (BTM_SEC_IS_SM4(p_dev_rec->sm4) &&
-         (btm_sec_is_upgrade_possible(p_dev_rec, is_originator) == false))) {
+         (!btm_sec_is_upgrade_possible(p_dev_rec, is_originator)))) {
       /* legacy mode - local is legacy or local is lisbon/peer is legacy
        * or SM4 with no possibility of link key upgrade */
       if (is_originator) {
@@ -3445,8 +3445,7 @@
       }
       /* else BTM_NOT_AUTHORIZED means when the app wants to reject the req
        * right now */
-    } else if ((event == BTM_SP_CFM_REQ_EVT) &&
-               (evt_data.cfm_req.just_works == true)) {
+    } else if ((event == BTM_SP_CFM_REQ_EVT) && (evt_data.cfm_req.just_works)) {
       /* automatically reply with just works if no sp_cback */
       status = BTM_SUCCESS;
     }
diff --git a/system/stack/gap/gap_ble.cc b/system/stack/gap/gap_ble.cc
index 62f12aa..e42d1d5 100644
--- a/system/stack/gap/gap_ble.cc
+++ b/system/stack/gap/gap_ble.cc
@@ -123,7 +123,7 @@
   for (const tGAP_ATTR& db_attr : gatt_attr) {
     const tGAP_BLE_ATTR_VALUE& attr_value = db_attr.attr_value;
     if (handle == db_attr.handle) {
-      if (db_attr.uuid != GATT_UUID_GAP_DEVICE_NAME && is_long == true)
+      if (db_attr.uuid != GATT_UUID_GAP_DEVICE_NAME && is_long)
         return GATT_NOT_LONG;
 
       switch (db_attr.uuid) {
diff --git a/system/stack/gap/gap_conn.cc b/system/stack/gap/gap_conn.cc
index 7d75986..512e07b 100644
--- a/system/stack/gap/gap_conn.cc
+++ b/system/stack/gap/gap_conn.cc
@@ -701,8 +701,7 @@
   /* See if we have a CCB listening for the connection */
   for (xx = 0, p_ccb = conn.ccb_pool; xx < GAP_MAX_CONNECTIONS; xx++, p_ccb++) {
     if ((p_ccb->con_state == GAP_CCB_STATE_LISTENING) && (p_ccb->psm == psm) &&
-        ((p_ccb->rem_addr_specified == false) ||
-         (bd_addr == p_ccb->rem_dev_address)))
+        (!p_ccb->rem_addr_specified || (bd_addr == p_ccb->rem_dev_address)))
       break;
   }
 
diff --git a/system/stack/gatt/gatt_sr.cc b/system/stack/gatt/gatt_sr.cc
index d1db4e8..90ae8a4 100644
--- a/system/stack/gatt/gatt_sr.cc
+++ b/system/stack/gatt/gatt_sr.cc
@@ -635,7 +635,7 @@
   // TODO: we assume theh value is UUID, there is no such requirement in spec
   Uuid value = Uuid::kEmpty;
   if (op_code == GATT_REQ_FIND_TYPE_VALUE) {
-    if (gatt_parse_uuid_from_cmd(&value, len, &p_data) == false) {
+    if (!gatt_parse_uuid_from_cmd(&value, len, &p_data)) {
       gatt_send_error_rsp(tcb, GATT_INVALID_PDU, op_code, s_hdl, false);
     }
   }
diff --git a/system/stack/l2cap/l2c_api.cc b/system/stack/l2cap/l2c_api.cc
index 67a57e8..ef197bf 100644
--- a/system/stack/l2cap/l2c_api.cc
+++ b/system/stack/l2cap/l2c_api.cc
@@ -256,8 +256,7 @@
     /* No link. Get an LCB and start link establishment */
     p_lcb = l2cu_allocate_lcb(p_bd_addr, false, BT_TRANSPORT_BR_EDR);
     /* currently use BR/EDR for ERTM mode l2cap connection */
-    if ((p_lcb == NULL) ||
-        (l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR) == false)) {
+    if ((p_lcb == NULL) || (!l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR))) {
       L2CAP_TRACE_WARNING(
           "L2CAP - conn not started for PSM: 0x%04x  p_lcb: 0x%08x", psm,
           p_lcb);
@@ -465,7 +464,7 @@
     p_lcb = l2cu_allocate_lcb(p_bd_addr, false, BT_TRANSPORT_LE);
     if ((p_lcb == NULL)
         /* currently use BR/EDR for ERTM mode l2cap connection */
-        || (l2cu_create_conn(p_lcb, BT_TRANSPORT_LE) == false)) {
+        || (!l2cu_create_conn(p_lcb, BT_TRANSPORT_LE))) {
       L2CAP_TRACE_WARNING("%s conn not started for PSM: 0x%04x  p_lcb: 0x%08x",
                           __func__, psm, p_lcb);
       return 0;
@@ -904,7 +903,7 @@
       L2CAP_TRACE_WARNING("L2CAP - no LCB for L2CA_ping");
       return (false);
     }
-    if (l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR) == false) {
+    if (!l2cu_create_conn(p_lcb, BT_TRANSPORT_BR_EDR)) {
       return (false);
     }
 
diff --git a/system/stack/rfcomm/port_api.cc b/system/stack/rfcomm/port_api.cc
index c949c3c..e6fe666 100644
--- a/system/stack/rfcomm/port_api.cc
+++ b/system/stack/rfcomm/port_api.cc
@@ -145,7 +145,7 @@
     p_port = port_find_port(dlci, bd_addr);
     if (p_port != NULL) {
       /* if existing port is also a client port */
-      if (p_port->is_server == false) {
+      if (!p_port->is_server) {
         RFCOMM_TRACE_ERROR(
             "%s - already opened state:%d, RFC state:%d, MCB state:%d",
             __func__, p_port->state, p_port->rfc.state,
diff --git a/system/vendor_libs/test_vendor_lib/src/bt_address.cc b/system/vendor_libs/test_vendor_lib/src/bt_address.cc
index 4deffb3..68fdcc9 100644
--- a/system/vendor_libs/test_vendor_lib/src/bt_address.cc
+++ b/system/vendor_libs/test_vendor_lib/src/bt_address.cc
@@ -40,7 +40,7 @@
   std::string tok;
   std::istringstream iss(str);
 
-  if (IsValid(str) == false) return false;
+  if (!IsValid(str)) return false;
 
   address_ = 0;
   for (size_t i = 0; i < kOctets; i++) {