Return result after RIL set auto network selection

Our RIL was only returning the result of set network selection automatic
if the SIM card is absent. On other types of failure or success nothing
was returned. This results in a timeout in the upper RIL layers because
they never get to know if the request was successful or not.

Return results for successful or failed requests based on the modem's
response.  This fixes tests that rely on the return code to know whether
the operation succeeded or not.

BUG: 110212792
Test: run vts -m VtsHalRadioV1_0Target -t
VtsHalRadioV1_0Target#RadioHidlTest.setNetworkSelectionModeAutomatic

Merged-In: I82569285fb4f5274d4be72802aad00cffd5a91ec
(cherry picked from commit 950c5dc4d947c70c151bc92fb597c41902b36dc4)
diff --git a/ril/reference-ril.c b/ril/reference-ril.c
index 3bca581..03c9897 100644
--- a/ril/reference-ril.c
+++ b/ril/reference-ril.c
@@ -780,6 +780,27 @@
     at_response_free(p_response);
 }
 
+static void setNetworkSelectionAutomatic(RIL_Token t)
+{
+    int err;
+    ATResponse *p_response = NULL;
+
+    if (getSIMStatus() == SIM_ABSENT) {
+        RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
+        return;
+    }
+
+    err = at_send_command("AT+COPS=0", &p_response);
+
+    if (err < 0 || p_response == NULL || p_response->success == 0) {
+        RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
+    } else {
+        RIL_onRequestComplete(t, RIL_E_SUCCESS, NULL, 0);
+    }
+
+    at_response_free(p_response);
+}
+
 static void requestQueryNetworkSelectionMode(
                 void *data __unused, size_t datalen __unused, RIL_Token t)
 {
@@ -2585,11 +2606,7 @@
             break;
 
         case RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC:
-            if (getSIMStatus() == SIM_ABSENT) {
-                RIL_onRequestComplete(t, RIL_E_RADIO_NOT_AVAILABLE, NULL, 0);
-            } else {
-                at_send_command("AT+COPS=0", NULL);
-            }
+            setNetworkSelectionAutomatic(t);
             break;
 
         case RIL_REQUEST_DATA_CALL_LIST: