Implement PeopleApiPhoneLookup

This CL rewrites com.google.android.dialer.reverselookup and uses gRPC instead to perform People API queries.

Bug: 70355819
Test: PeopleApiPhoneLookupTest, PeopleApiPHoneLookupInfoTransformerTest
PiperOrigin-RevId: 179122466
Change-Id: I769c8b420b9d71b9787d844380b2aceb7ff2c63c
diff --git a/java/com/android/dialer/function/Consumer.java b/java/com/android/dialer/function/Consumer.java
new file mode 100644
index 0000000..fafe3ee
--- /dev/null
+++ b/java/com/android/dialer/function/Consumer.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.dialer.function;
+
+/** Functional interface for consuming generic values. */
+public interface Consumer<T> {
+
+  /** Consumes a value. */
+  void accept(T value);
+}
diff --git a/java/com/android/dialer/phonelookup/PhoneLookupSelector.java b/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
index af8b849..0fe9893 100644
--- a/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
+++ b/java/com/android/dialer/phonelookup/PhoneLookupSelector.java
@@ -46,6 +46,9 @@
         return firstLocalContact.getName();
       }
     }
+    if (phoneLookupInfo.hasPeopleApiInfo()) {
+      return phoneLookupInfo.getPeopleApiInfo().getDisplayName();
+    }
     return "";
   }
 
diff --git a/java/com/android/dialer/phonelookup/phone_lookup_info.proto b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
index 36596c1..4e62d67 100644
--- a/java/com/android/dialer/phonelookup/phone_lookup_info.proto
+++ b/java/com/android/dialer/phonelookup/phone_lookup_info.proto
@@ -50,4 +50,36 @@
     optional bool is_spam = 1;
   }
   optional ApdlInfo apdl_info = 2;
+
+  // Message for PeopleApi, including G+ contacts and nearby places
+  message PeopleApiInfo {
+    // Best display name determined by people API if available, first display
+    // name otherwise.
+    optional string display_name = 1;
+
+    // The type of the number, for example "phone" or "home".
+    optional string number_type = 2;
+
+    // The number_type label in human readable string, for example "Phone".
+    // The UI should display known number_type with string resources if possible
+    // but if number_type is unrecognized formatted_number_type. For example
+    // if the user set an custom type label.
+    optional string formatted_number_type = 3;
+
+    // URL to the contact's full size photo.
+    optional string image_url = 4;
+
+    // The primary key of the contact in people API.
+    optional string person_id = 5;
+
+    enum InfoType {
+      UNKNOWN = 0;
+      CONTACT = 1;          // the result is a saved contact in people API
+      NEARBY_BUSINESS = 2;  // the result is found through nearby places
+    }
+    // The type of the lookup result, for example, a saved contact or a nearby
+    // business.
+    optional InfoType info_type = 6;
+  }
+  optional PeopleApiInfo people_api_info = 3;
 }
\ No newline at end of file