Snap for 5706892 from dfd3c50eebad42f175611e07b5e7bf7369ed25b7 to qt-release

Change-Id: Id62e4ec38b60031f7ee8b2fc6b080fdae693caf9
diff --git a/car-apps-common/src/com/android/car/apps/common/CarUxRestrictionsUtil.java b/car-apps-common/src/com/android/car/apps/common/CarUxRestrictionsUtil.java
index 2fb5e17..ed219ae 100644
--- a/car-apps-common/src/com/android/car/apps/common/CarUxRestrictionsUtil.java
+++ b/car-apps-common/src/com/android/car/apps/common/CarUxRestrictionsUtil.java
@@ -17,7 +17,6 @@
 
 import static android.car.drivingstate.CarUxRestrictions.UX_RESTRICTIONS_LIMIT_STRING_LENGTH;
 
-import android.annotation.Nullable;
 import android.car.Car;
 import android.car.CarNotConnectedException;
 import android.car.drivingstate.CarUxRestrictions;
@@ -26,6 +25,9 @@
 import android.content.Context;
 import android.util.Log;
 
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
 import java.util.Collections;
 import java.util.Set;
 import java.util.WeakHashMap;
@@ -40,32 +42,51 @@
 public class CarUxRestrictionsUtil {
     private static final String TAG = "CarUxRestrictionsUtil";
 
-    private Car mCarApi;
+    private final Car mCarApi;
     private CarUxRestrictionsManager mCarUxRestrictionsManager;
-    private CarUxRestrictions mCarUxRestrictions;
+    @NonNull
+    private CarUxRestrictions mCarUxRestrictions = getDefaultRestrictions();
 
     private Set<OnUxRestrictionsChangedListener> mObservers;
     private static CarUxRestrictionsUtil sInstance = null;
 
     private CarUxRestrictionsUtil(Context context) {
         CarUxRestrictionsManager.OnUxRestrictionsChangedListener listener = (carUxRestrictions) -> {
-            mCarUxRestrictions = carUxRestrictions;
-            notify(carUxRestrictions);
-        };
-        mCarApi = Car.createCar(context);
+            if (carUxRestrictions == null) {
+                mCarUxRestrictions = getDefaultRestrictions();
+            } else {
+                mCarUxRestrictions = carUxRestrictions;
+            }
 
+            for (OnUxRestrictionsChangedListener observer : mObservers) {
+                observer.onRestrictionsChanged(mCarUxRestrictions);
+            }
+        };
+
+        mCarApi = Car.createCar(context);
         mObservers = Collections.newSetFromMap(new WeakHashMap<>());
 
         try {
             mCarUxRestrictionsManager = (CarUxRestrictionsManager) mCarApi
                     .getCarManager(Car.CAR_UX_RESTRICTION_SERVICE);
             mCarUxRestrictionsManager.registerListener(listener);
-            mCarUxRestrictions = mCarUxRestrictionsManager.getCurrentCarUxRestrictions();
+            listener.onUxRestrictionsChanged(
+                    mCarUxRestrictionsManager.getCurrentCarUxRestrictions());
         } catch (CarNotConnectedException e) {
             Log.e(TAG, "Car not connected", e);
+            // mCarUxRestrictions will be the default
+        } catch (NullPointerException e) {
+            Log.e(TAG, "Car not connected", e);
+            // mCarUxRestrictions will be the default
         }
     }
 
+    @NonNull
+    private CarUxRestrictions getDefaultRestrictions() {
+        return new CarUxRestrictions.Builder(true,
+                CarUxRestrictions.UX_RESTRICTIONS_FULLY_RESTRICTED, 0).build();
+    }
+
     /**
      * Listener interface used to update clients on UxRestrictions changes
      */
@@ -73,12 +94,13 @@
         /**
          * Called when CarUxRestrictions changes
          */
-        void onRestrictionsChanged(CarUxRestrictions carUxRestrictions);
+        void onRestrictionsChanged(@NonNull CarUxRestrictions carUxRestrictions);
     }
 
     /**
      * Returns the singleton instance of this class
      */
+    @NonNull
     public static CarUxRestrictionsUtil getInstance(Context context) {
         if (sInstance == null) {
             sInstance = new CarUxRestrictionsUtil(context);
@@ -87,12 +109,6 @@
         return sInstance;
     }
 
-    private void notify(CarUxRestrictions carUxRestrictions) {
-        for (OnUxRestrictionsChangedListener listener : mObservers) {
-            listener.onRestrictionsChanged(carUxRestrictions);
-        }
-    }
-
     /**
      * Registers a listener on this class for updates to CarUxRestrictions.
      * Multiple listeners may be registered.
diff --git a/car-apps-common/src/com/android/car/apps/common/widget/PagedRecyclerView.java b/car-apps-common/src/com/android/car/apps/common/widget/PagedRecyclerView.java
index 8ad23aa..08ba31b 100644
--- a/car-apps-common/src/com/android/car/apps/common/widget/PagedRecyclerView.java
+++ b/car-apps-common/src/com/android/car/apps/common/widget/PagedRecyclerView.java
@@ -51,7 +51,7 @@
 
     private Context mContext;
 
-    private CarUxRestrictionsUtil mCarUxRestrictionsUtil;
+    private final CarUxRestrictionsUtil mCarUxRestrictionsUtil;
     private final CarUxRestrictionsUtil.OnUxRestrictionsChangedListener mListener;
 
     private boolean mScrollBarEnabled;
@@ -206,11 +206,7 @@
     public PagedRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
 
-        try {
-            mCarUxRestrictionsUtil = CarUxRestrictionsUtil.getInstance(context);
-        } catch (NullPointerException e) {
-            // Do nothing, mCarUxRestrictionsUtil will be null
-        }
+        mCarUxRestrictionsUtil = CarUxRestrictionsUtil.getInstance(context);
         mListener = this::updateCarUxRestrictions;
 
         init(context, attrs, defStyle);
@@ -302,17 +298,13 @@
     @Override
     protected void onAttachedToWindow() {
         super.onAttachedToWindow();
-        if (mCarUxRestrictionsUtil != null) {
-            mCarUxRestrictionsUtil.register(mListener);
-        }
+        mCarUxRestrictionsUtil.register(mListener);
     }
 
     @Override
     protected void onDetachedFromWindow() {
         super.onDetachedFromWindow();
-        if (mCarUxRestrictionsUtil != null) {
-            mCarUxRestrictionsUtil.unregister(mListener);
-        }
+        mCarUxRestrictionsUtil.unregister(mListener);
     }
 
     private void updateCarUxRestrictions(CarUxRestrictions carUxRestrictions) {
diff --git a/car-messsaging-lib/Android.mk b/car-messsaging-lib/Android.mk
deleted file mode 100644
index 32e920c..0000000
--- a/car-messsaging-lib/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (C) 2019 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src) $(call all-Iaidl-files-under, src)
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-LOCAL_AIDL_INCLUDES := \
-    $(LOCAL_PATH)/src \
-
-LOCAL_STATIC_ANDROID_LIBRARIES += \
-    androidx.annotation_annotation \
-
-LOCAL_MODULE := car-messaging-lib
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PROGUARD_ENABLED := disabled
-
-LOCAL_USE_AAPT2 := true
-
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
-
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/car-messsaging-lib/AndroidManifest.xml b/car-messsaging-lib/AndroidManifest.xml
deleted file mode 100644
index 0577c35..0000000
--- a/car-messsaging-lib/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-  Copyright (C) 2019 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.
-  -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-          package="com.android.car.messaging">
-</manifest>
diff --git a/car-messsaging-lib/OWNERS b/car-messsaging-lib/OWNERS
deleted file mode 100644
index c74339b..0000000
--- a/car-messsaging-lib/OWNERS
+++ /dev/null
@@ -1,3 +0,0 @@
-# People who can approve changes for submission.
-ritwikam@google.com
-jiayuzhou@google.com
diff --git a/car-messsaging-lib/res/values/strings.xml b/car-messsaging-lib/res/values/strings.xml
deleted file mode 100644
index f98ab23..0000000
--- a/car-messsaging-lib/res/values/strings.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 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.
--->
-
-<resources>
-</resources>
diff --git a/car-messsaging-lib/src/com/android/car/messaging/entity/Action.java b/car-messsaging-lib/src/com/android/car/messaging/entity/Action.java
deleted file mode 100644
index cfd6209..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/entity/Action.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.entity;
-
-import android.app.PendingIntent;
-import android.app.RemoteInput;
-import android.os.Bundle;
-import android.os.Parcel;
-
-import androidx.annotation.Nullable;
-
-/**
- * Semantic actions that 3p can perform.
- */
-public class Action extends BaseEntity {
-    private String mSemanticAction;
-    private PendingIntent mCallback;
-    private Bundle mExtra;
-    private RemoteInput mRemoteInput;
-
-    public static final Creator<Action> CREATOR = new Creator<Action>() {
-        @Override
-        public Action createFromParcel(Parcel in) {
-            return new Action(in);
-        }
-
-        @Override
-        public Action[] newArray(int size) {
-            return new Action[size];
-        }
-    };
-
-    protected Action() {
-        super();
-    }
-
-    protected Action(Parcel in) {
-        super(in);
-        mSemanticAction = in.readString();
-        mCallback = in.readParcelable(PendingIntent.class.getClassLoader());
-        mRemoteInput = in.readParcelable(RemoteInput.class.getClassLoader());
-        mExtra = in.readBundle(getClass().getClassLoader());
-    }
-
-    /**
-     * Returns the semantic action.
-     */
-    @Nullable
-    public String getSemanticAction() {
-        return mSemanticAction;
-    }
-
-    /**
-     * Returns the callback which will be fired when the action is triggered.
-     */
-    public PendingIntent getCallback() {
-        return mCallback;
-    }
-
-    /**
-     * Returns the extra which helps to fulfill the action.
-     */
-    public Bundle getExtra() {
-        return mExtra;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeString(mSemanticAction);
-        dest.writeValue(mCallback);
-        dest.writeValue(mRemoteInput);
-        dest.writeBundle(mExtra);
-    }
-
-    /**
-     * Builder for {@link Action}.
-     */
-    public static class Builder {
-        private String mSemanticAction;
-        private PendingIntent mCallback;
-        private Bundle mExtra;
-
-        public void setSemanticAction(String semanticAction) {
-            mSemanticAction = semanticAction;
-        }
-
-        public void setCallback(PendingIntent callback) {
-            mCallback = callback;
-        }
-
-        public void setExtra(Bundle extra) {
-            mExtra = extra;
-        }
-
-        /**
-         * Build {@link Action}.
-         */
-        public Action build() {
-            Action action = new Action();
-            action.mCallback = mCallback;
-            action.mExtra = mExtra;
-            action.mSemanticAction = mSemanticAction;
-            return action;
-        }
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/entity/BaseEntity.java b/car-messsaging-lib/src/com/android/car/messaging/entity/BaseEntity.java
deleted file mode 100644
index 2083ab8..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/entity/BaseEntity.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.entity;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * The base class for all messaging entities.
- */
-public abstract class BaseEntity implements Parcelable {
-    protected BaseEntity() {}
-
-    protected BaseEntity(Parcel in) {}
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/entity/Conversation.java b/car-messsaging-lib/src/com/android/car/messaging/entity/Conversation.java
deleted file mode 100644
index aac1b2c..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/entity/Conversation.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.entity;
-
-import android.os.Parcel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents a conversation.
- */
-public class Conversation extends BaseEntity {
-    private ConversationMetaData mConversationMetaData;
-    private List<Action> mActions = new ArrayList<>();
-
-    public static final Creator<Conversation> CREATOR = new Creator<Conversation>() {
-        @Override
-        public Conversation createFromParcel(Parcel in) {
-            return new Conversation(in);
-        }
-
-        @Override
-        public Conversation[] newArray(int size) {
-            return new Conversation[size];
-        }
-    };
-
-    protected Conversation(Parcel in) {
-        super(in);
-        mConversationMetaData = in.readParcelable(ConversationMetaData.class.getClassLoader());
-        in.readList(mActions, /* classloader = */ Action.class.getClassLoader());
-    }
-
-    protected Conversation() {
-        super();
-    }
-
-    public ConversationMetaData getConversationMetaData() {
-        return mConversationMetaData;
-    }
-
-    public List<Action> getActions() {
-        return mActions;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeValue(mConversationMetaData);
-        dest.writeList(mActions);
-    }
-
-    /**
-     * Builder for {@link Conversation}.
-     */
-    public static class Builder {
-        private ConversationMetaData mConversationMetaData;
-        private List<Action> mActions = new ArrayList<>();
-
-        /**
-         * Add an Action to the Conversation.
-         */
-        public void addActions(Action action) {
-            mActions.add(action);
-        }
-
-        /**
-         * Builds {@link Conversation}.
-         */
-        public Conversation build() {
-            Conversation conversation = new Conversation();
-            conversation.mConversationMetaData = mConversationMetaData;
-            conversation.mActions.addAll(mActions);
-            return conversation;
-        }
-
-        public void setConversationMetaData(ConversationMetaData conversationMetaData) {
-            mConversationMetaData = conversationMetaData;
-        }
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/entity/ConversationContainer.java b/car-messsaging-lib/src/com/android/car/messaging/entity/ConversationContainer.java
deleted file mode 100644
index 8871b27..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/entity/ConversationContainer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.entity;
-
-import android.os.Parcel;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Contains a list of conversations.
- */
-public class ConversationContainer extends BaseEntity {
-
-    private String mTitle;
-    private List<Conversation> mConversations = new ArrayList<>();
-
-    public static final Creator<ConversationContainer> CREATOR =
-            new Creator<ConversationContainer>() {
-                @Override
-                public ConversationContainer createFromParcel(Parcel in) {
-                    return new ConversationContainer(in);
-                }
-
-                @Override
-                public ConversationContainer[] newArray(int size) {
-                    return new ConversationContainer[size];
-                }
-            };
-
-    protected ConversationContainer(Parcel in) {
-        super(in);
-        mTitle = in.readString();
-        in.readList(mConversations, Conversation.class.getClassLoader());
-    }
-
-    protected ConversationContainer() {}
-
-    public String getTitle() {
-        return mTitle;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeString(mTitle);
-        dest.writeList(mConversations);
-    }
-
-    /**
-     * Builder for {@link ConversationContainer}.
-     */
-    public static class Builder {
-        private String mTitle;
-        private List<Conversation> mConversations = new ArrayList<>();
-
-
-        public void setTitle(String title) {
-            mTitle = title;
-        }
-
-        /**
-         * Adds a conversation to a conversation container.
-         */
-        public void addConversation(Conversation conversation) {
-            mConversations.add(conversation);
-        }
-
-        /**
-         * Builds {@link ConversationContainer}.
-         */
-        public ConversationContainer build() {
-            ConversationContainer conversationContainer = new ConversationContainer();
-            conversationContainer.mTitle = mTitle;
-            conversationContainer.mConversations.addAll(mConversations);
-            return conversationContainer;
-        }
-    }
-
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/entity/ConversationMetaData.java b/car-messsaging-lib/src/com/android/car/messaging/entity/ConversationMetaData.java
deleted file mode 100644
index 1980dc9..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/entity/ConversationMetaData.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.entity;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Contains meta data of a conversation such as conversation title.
- */
-public class ConversationMetaData implements Parcelable {
-    private String mTitle;
-
-    public static final Creator<ConversationMetaData> CREATOR =
-            new Creator<ConversationMetaData>() {
-                @Override
-                public ConversationMetaData createFromParcel(Parcel in) {
-                    return new ConversationMetaData(in);
-                }
-
-                @Override
-                public ConversationMetaData[] newArray(int size) {
-                    return new ConversationMetaData[size];
-                }
-            };
-
-    protected ConversationMetaData(Parcel in) {
-        mTitle = in.readString();
-    }
-
-    protected ConversationMetaData() {}
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeString(mTitle);
-    }
-
-    public String getTitle() {
-        return mTitle;
-    }
-
-    /**
-     * Builder for {@link ConversationMetaData}.
-     */
-    public static class Builder {
-        private String mTitle;
-
-        public void setTitle(String title) {
-            mTitle = title;
-        }
-
-        /**
-         * Builds {@link ConversationContainer}.
-         */
-        public ConversationMetaData build() {
-            ConversationMetaData conversationMetaData = new ConversationMetaData();
-            conversationMetaData.mTitle = mTitle;
-            return conversationMetaData;
-        }
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/entity/Message.java b/car-messsaging-lib/src/com/android/car/messaging/entity/Message.java
deleted file mode 100644
index f764dca..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/entity/Message.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.entity;
-
-import android.os.Parcel;
-
-/**
- * Represents an individual message.
- */
-public class Message extends BaseEntity {
-
-    private String mMessageBody;
-
-    public static final Creator<Message> CREATOR = new Creator<Message>() {
-        @Override
-        public Message createFromParcel(Parcel in) {
-            return new Message(in);
-        }
-
-        @Override
-        public Message[] newArray(int size) {
-            return new Message[size];
-        }
-    };
-
-    protected Message(Parcel in) {
-        super(in);
-        mMessageBody = in.readString();
-    }
-
-    protected Message() {}
-
-    /**
-     * Returns the message body.
-     */
-    public String getMessageBody() {
-        return mMessageBody;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeString(mMessageBody);
-    }
-
-    /**
-     * Builder for {@link Message}.
-     */
-    public static class Builder {
-        private String mMessage;
-
-        public void setMessage(String message) {
-            mMessage = message;
-        }
-
-        /**
-         * Builds a {@link Message}.
-         */
-        public Message build() {
-            Message message = new Message();
-            message.mMessageBody = mMessage;
-            return message;
-        }
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/ConnectionConfig.aidl b/car-messsaging-lib/src/com/android/car/messaging/service/ConnectionConfig.aidl
deleted file mode 100644
index 7e3edb5..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/ConnectionConfig.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (C) 2019 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.car.messaging.service;
-
-parcelable ConnectionConfig;
\ No newline at end of file
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/ConnectionConfig.java b/car-messsaging-lib/src/com/android/car/messaging/service/ConnectionConfig.java
deleted file mode 100644
index 0f9a7c1..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/ConnectionConfig.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.service;
-
-import android.content.pm.PackageManager;
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Contains configuration of {@link MessagingService} connection.
- */
-public class ConnectionConfig implements Parcelable {
-    private int mApiVersion;
-    private String mPackageName;
-
-    private ConnectionConfig() {}
-
-    protected ConnectionConfig(Parcel in) {
-        mApiVersion = in.readInt();
-        mPackageName = in.readString();
-    }
-
-    public static final Creator<ConnectionConfig> CREATOR = new Creator<ConnectionConfig>() {
-        @Override
-        public ConnectionConfig createFromParcel(Parcel in) {
-            return new ConnectionConfig(in);
-        }
-
-        @Override
-        public ConnectionConfig[] newArray(int size) {
-            return new ConnectionConfig[size];
-        }
-    };
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeInt(mApiVersion);
-        dest.writeString(mPackageName);
-    }
-
-    /**
-     * Returns the Api version for the current connection.
-     */
-    public int getApiVersion() {
-        return mApiVersion;
-    }
-
-    /**
-     * Returns the package name of the caller.
-     */
-    public String getPackageName() {
-        return mPackageName;
-    }
-
-    /**
-     * Builds a {@link ConnectionConfig}.
-     */
-    public static class Builder {
-        private int mApiVersion;
-        private String mPackageName;
-
-        /**
-         * Sets the requested api version for the connection.
-         */
-        public void setApiVersion(int apiVersion) {
-            mApiVersion = apiVersion;
-        }
-
-        /**
-         * Sets the package name of the caller. Must be one of the return value of
-         * {@link PackageManager#getPackagesForUid} for the caller's uid.
-         */
-        public void setPackageName(String packageName) {
-            mPackageName = packageName;
-        }
-
-        /**
-         * Builds a {#link ConnectionConfig}.
-         */
-        public ConnectionConfig build() {
-            ConnectionConfig connectionConfig = new ConnectionConfig();
-            connectionConfig.mApiVersion = mApiVersion;
-            connectionConfig.mPackageName = mPackageName;
-            return connectionConfig;
-        }
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/IConnectionCallback.aidl b/car-messsaging-lib/src/com/android/car/messaging/service/IConnectionCallback.aidl
deleted file mode 100644
index d7e8852..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/IConnectionCallback.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright (C) 2019 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.car.messaging.service;
-
-import com.android.car.messaging.service.IMessagingService;
-
-/**
- * A callback which will be called after client tries to connect to a MessagingService.
- */
-oneway interface IConnectionCallback {
-
-    /**
-     * Called when the connection has been established.
-     */
-    void onConnect(IMessagingService service);
-
-    /**
-     * Called when the connection is failed to estabilished, such as client is not authorized or
-     * requested version is incompatible.
-     */
-    void onConnectFailed();
-}
\ No newline at end of file
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/ILoadEntityContentCallback.aidl b/car-messsaging-lib/src/com/android/car/messaging/service/ILoadEntityContentCallback.aidl
deleted file mode 100644
index dea4737..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/ILoadEntityContentCallback.aidl
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Copyright (C) 2019 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.car.messaging.service;
-
-oneway interface ILoadEntityContentCallback {
-    void onEntitiesLoaded(in List entities);
-}
\ No newline at end of file
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/IMessagingService.aidl b/car-messsaging-lib/src/com/android/car/messaging/service/IMessagingService.aidl
deleted file mode 100644
index afd08b4..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/IMessagingService.aidl
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright (C) 2019 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.car.messaging.service;
-
-import android.os.Bundle;
-
-import  com.android.car.messaging.service.ILoadEntityContentCallback;
-
-/**
- * An interface through which clients access to a messaging service.
- */
-interface IMessagingService {
-    /**
-     * Loads the sub content of an entity and subscribes to any changes of the sub content.
-     * Specify the class name of the entity with
-     * {@link MessagingService#EXTRA_SUBSCRIBED_CLASS_NAME} key in the option Bundle.
-     */
-    void subscribeContent(String id, ILoadEntityContentCallback callback, in Bundle options) = 1;
-
-    /**
-     * Unregisters a callback which subscribed to sub content of an entity through
-     * {@link #subscribeContent}.
-     */
-    void unsubscribeContent(String id, ILoadEntityContentCallback callback) = 2;
-}
\ No newline at end of file
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/IMessagingServiceProvider.aidl b/car-messsaging-lib/src/com/android/car/messaging/service/IMessagingServiceProvider.aidl
deleted file mode 100644
index e4515ff..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/IMessagingServiceProvider.aidl
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright (C) 2019 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.car.messaging.service;
-
-import com.android.car.messaging.service.ConnectionConfig;
-import com.android.car.messaging.service.IConnectionCallback;
-import com.android.car.messaging.service.IMessagingService;
-import com.android.car.messaging.service.SupportedVersionInfo;
-
-/**
- * An interface through which clients are authenticated, api version handshaked and connected
- * to a MessagingService.
- */
-interface IMessagingServiceProvider {
-
-    /* @return The versions supported by the API. */
-    SupportedVersionInfo getSupportedApiVersionInfo() = 1;
-
-    /**
-     * Requests to connect to a MessagingService.
-     *
-     * Returns a non-null MessagingService if the client is authenticated and connection is
-     * successful.
-     */
-    oneway void connect(in ConnectionConfig config, IConnectionCallback callback) = 2;
-}
\ No newline at end of file
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/MessagingService.java b/car-messsaging-lib/src/com/android/car/messaging/service/MessagingService.java
deleted file mode 100644
index 6a0eec0..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/MessagingService.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.service;
-
-import android.app.Service;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.os.Binder;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Looper;
-import android.os.RemoteException;
-import android.util.ArrayMap;
-import android.util.Log;
-
-import androidx.annotation.MainThread;
-
-import com.android.car.messaging.entity.BaseEntity;
-import com.android.car.messaging.entity.Conversation;
-import com.android.car.messaging.entity.ConversationContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Base class for messaging apps which enables messaging apps to provide their data to authorized
- * clients.
- */
-public abstract class MessagingService extends Service {
-    private static final String TAG = "MessagingService";
-
-    /**
-     * The key for a client to specify the class name of an entity which the client is
-     * subscribed to.
-     */
-    public static final String EXTRA_SUBSCRIBED_CLASS_NAME = "subscribed_class_name";
-
-    /**
-     * The root id for {@link ConversationContainer}.
-     */
-    public static final String CONVERSATION_CONTAINER_ROOT_ID = "conversation_container_id";
-
-    private MessagingServiceProviderImpl mMessagingServiceProviderImpl;
-    private final Handler mMainThreadHandler = new Handler(Looper.getMainLooper());
-
-    // TODO: Merging these two Maps into one when there are more attributes to store for an ID.
-    private Map<String, List<IBinder>> mIdToSubscriptionMap = new ArrayMap<>();
-    private Map<String, String> mIdToClassNameMap = new ArrayMap<>();
-
-    @Override
-    public void onCreate() {
-        super.onCreate();
-        mMessagingServiceProviderImpl = new MessagingServiceProviderImpl();
-    }
-
-    @Override
-    public IBinder onBind(Intent intent) {
-        return mMessagingServiceProviderImpl;
-    }
-
-    private class MessagingServiceProviderImpl extends IMessagingServiceProvider.Stub {
-        private MessagingServiceImpl mMessagingService = new MessagingServiceImpl();
-
-        @Override
-        public SupportedVersionInfo getSupportedApiVersionInfo() {
-            return new SupportedVersionInfo(/* minVersion = */ 1, /* maxVersion = */ 1);
-        }
-
-        @Override
-        public void connect(ConnectionConfig connectionConfig,
-                IConnectionCallback callback) throws RemoteException {
-            int uid = Binder.getCallingUid();
-            if (isValidPackage(connectionConfig.getPackageName(), uid)) {
-                mMainThreadHandler.post(() -> {
-                    try {
-                        if (onAuthenticate(connectionConfig.getPackageName())) {
-                            callback.onConnect(mMessagingService);
-                        } else {
-                            callback.onConnectFailed();
-                        }
-                    } catch (RemoteException e) {
-                        Log.w(TAG, "Calling IConnectionCallback failed. Ignoring. "
-                                + "pkg=" + connectionConfig.getPackageName());
-                    }
-                });
-            } else {
-                callback.onConnectFailed();
-            }
-        }
-
-        /**
-         * Returns true if the provided package name belongs to the given uid.
-         */
-        private boolean isValidPackage(String pkg, int uid) {
-            if (pkg == null) {
-                return false;
-            }
-
-            final PackageManager pm = getPackageManager();
-            final String[] packages = pm.getPackagesForUid(uid);
-            if (packages == null) {
-                return false;
-            }
-
-            for (String aPackage : packages) {
-                if (aPackage.equals(pkg)) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    private class MessagingServiceImpl extends IMessagingService.Stub {
-
-        @Override
-        public void subscribeContent(
-                String id, ILoadEntityContentCallback callback, Bundle options) {
-            mMainThreadHandler.post(() -> {
-                try {
-                    MessagingService.this.subscribeContent(id, callback, options);
-                } catch (RemoteException e) {
-                    Log.w(TAG, "Unable to subscribe to content. callback = " + callback);
-                    MessagingService.this.unsubscribeContent(id, callback);
-                }
-            });
-        }
-
-        @Override
-        public void unsubscribeContent(String id, ILoadEntityContentCallback callback) {
-            mMainThreadHandler.post(() -> MessagingService.this.unsubscribeContent(id, callback));
-        }
-    }
-
-    @MainThread
-    private void subscribeContent(String id, ILoadEntityContentCallback callback, Bundle options)
-            throws RemoteException {
-        List<IBinder> allSubscriptions = mIdToSubscriptionMap.computeIfAbsent(
-                id, (key) -> new ArrayList<>());
-
-        if (allSubscriptions.contains(callback.asBinder())) {
-            return;
-        }
-
-        allSubscriptions.add(callback.asBinder());
-        String entityClassName = options.getString(EXTRA_SUBSCRIBED_CLASS_NAME);
-        mIdToClassNameMap.put(id, entityClassName);
-        List<? extends BaseEntity> entities = loadEntityContentList(id, entityClassName);
-        callback.onEntitiesLoaded(entities);
-    }
-
-    @MainThread
-    private void unsubscribeContent(String id, ILoadEntityContentCallback callback) {
-        List<IBinder> allSubscriptions = mIdToSubscriptionMap.computeIfAbsent(
-                id, (key) -> new ArrayList<>());
-        allSubscriptions.remove(callback.asBinder());
-        if (allSubscriptions.isEmpty()) {
-            mIdToClassNameMap.remove(id);
-        }
-    }
-
-    private List<? extends BaseEntity> loadEntityContentList(String id, String className) {
-        if (CONVERSATION_CONTAINER_ROOT_ID.equals(id)) {
-            return onLoadAllConversationContainers();
-        } else if (className.equals(ConversationContainer.class.getName())) {
-            return onLoadConversations(id);
-        }
-
-        return new ArrayList<>();
-    }
-
-    /**
-     * Called when a client tries to connect to this {@link MessagingService}. Returns true if
-     * the client is authorized to access
-     *
-     * @param packageName The calling client's package name.
-     */
-    protected abstract boolean onAuthenticate(String packageName);
-
-    /**
-     * Called to load all {@link ConversationContainer}s.
-     */
-    protected abstract List<ConversationContainer> onLoadAllConversationContainers();
-
-    /**
-     * Called to load all conversations in a {@link ConversationContainer}.
-     */
-    protected abstract List<Conversation> onLoadConversations(String containerId);
-
-    /**
-     * Notifies the client that content {@link BaseEntity entities} of a {@link BaseEntity} has
-     * changed.
-     */
-    @MainThread
-    public void notifyContentListChanged(String id) {
-        List<IBinder> allSubscriptions = mIdToSubscriptionMap.get(id);
-        if (allSubscriptions == null) {
-            return;
-        }
-        try {
-            for (IBinder callback : allSubscriptions) {
-                List<? extends BaseEntity> entities =
-                        loadEntityContentList(id, mIdToClassNameMap.get(id));
-                ILoadEntityContentCallback.Stub.asInterface(callback).onEntitiesLoaded(entities);
-            }
-        } catch (RemoteException e) {
-            Log.w(TAG, "Unable to call ILoadEntityContentCallback.");
-        }
-    }
-}
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/SupportedVersionInfo.aidl b/car-messsaging-lib/src/com/android/car/messaging/service/SupportedVersionInfo.aidl
deleted file mode 100644
index 783325a..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/SupportedVersionInfo.aidl
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright (C) 2019 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.car.messaging.service;
-
-parcelable SupportedVersionInfo;
\ No newline at end of file
diff --git a/car-messsaging-lib/src/com/android/car/messaging/service/SupportedVersionInfo.java b/car-messsaging-lib/src/com/android/car/messaging/service/SupportedVersionInfo.java
deleted file mode 100644
index cd74c57..0000000
--- a/car-messsaging-lib/src/com/android/car/messaging/service/SupportedVersionInfo.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2019 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.car.messaging.service;
-
-import android.os.Parcel;
-import android.os.Parcelable;
-
-/**
- * Contains the max and min supported api version.
- */
-public final class SupportedVersionInfo implements Parcelable {
-    private int mMinVersion;
-    private int mMaxVersion;
-
-    public SupportedVersionInfo(int minVersion, int maxVersion) {
-        mMinVersion = minVersion;
-        mMaxVersion = maxVersion;
-    }
-
-    protected SupportedVersionInfo(Parcel in) {
-        mMinVersion = in.readInt();
-        mMaxVersion = in.readInt();
-    }
-
-    public static final Creator<SupportedVersionInfo> CREATOR =
-            new Creator<SupportedVersionInfo>() {
-                @Override
-                public SupportedVersionInfo createFromParcel(Parcel in) {
-                    return new SupportedVersionInfo(in);
-                }
-
-                @Override
-                public SupportedVersionInfo[] newArray(int size) {
-                    return new SupportedVersionInfo[size];
-                }
-            };
-
-    @Override
-    public int describeContents() {
-        return 0;
-    }
-
-    @Override
-    public void writeToParcel(Parcel dest, int flags) {
-        dest.writeInt(mMinVersion);
-        dest.writeInt(mMaxVersion);
-    }
-
-    public int getMinVersion() {
-        return mMinVersion;
-    }
-
-    public int getMaxVersion() {
-        return mMaxVersion;
-    }
-}
diff --git a/car-telephony-common/src/com/android/car/telephony/common/Contact.java b/car-telephony-common/src/com/android/car/telephony/common/Contact.java
index 17337ed..e95cb3e 100644
--- a/car-telephony-common/src/com/android/car/telephony/common/Contact.java
+++ b/car-telephony-common/src/com/android/car/telephony/common/Contact.java
@@ -144,31 +144,13 @@
                 ContactsContract.CommonDataKinds.Phone.PHOTO_THUMBNAIL_URI);
         int lookupKeyColumn = cursor.getColumnIndex(
                 ContactsContract.CommonDataKinds.Phone.LOOKUP_KEY);
-        int typeColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
-        int labelColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
-        int numberColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
-        int rawDataIdColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone._ID);
-        int dataVersionColumn = cursor.getColumnIndex(
-                ContactsContract.CommonDataKinds.Phone.DATA_VERSION);
-        // IS_PRIMARY means primary entry of the raw contact and IS_SUPER_PRIMARY means primary
-        // entry of the aggregated contact. It is guaranteed that only one data entry is super
-        // primary.
-        int isPrimaryColumn = cursor.getColumnIndex(
-                ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY);
 
         Contact contact = new Contact();
         contact.mId = cursor.getLong(contactIdColumn);
         contact.mDisplayName = cursor.getString(displayNameColumn);
         contact.mAltDisplayName = cursor.getString(altDisplayNameColumn);
 
-        PhoneNumber number = PhoneNumber.newInstance(
-                context,
-                cursor.getString(numberColumn),
-                cursor.getInt(typeColumn),
-                cursor.getString(labelColumn),
-                cursor.getInt(isPrimaryColumn) > 0,
-                cursor.getLong(rawDataIdColumn),
-                cursor.getInt(dataVersionColumn));
+        PhoneNumber number = PhoneNumber.fromCursor(context, cursor);
         contact.mPhoneNumbers.add(number);
         if (number.isPrimary()) {
             contact.mPrimaryPhoneNumber = number;
diff --git a/car-telephony-common/src/com/android/car/telephony/common/PhoneNumber.java b/car-telephony-common/src/com/android/car/telephony/common/PhoneNumber.java
index 26884ec..85893e0 100644
--- a/car-telephony-common/src/com/android/car/telephony/common/PhoneNumber.java
+++ b/car-telephony-common/src/com/android/car/telephony/common/PhoneNumber.java
@@ -18,8 +18,10 @@
 
 import android.content.Context;
 import android.content.res.Resources;
+import android.database.Cursor;
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.provider.ContactsContract;
 import android.provider.ContactsContract.CommonDataKinds.Phone;
 
 import androidx.annotation.Nullable;
@@ -39,6 +41,34 @@
     private boolean mIsPrimary;
     private long mId;
     private int mDataVersion;
+    private String mAccountName;
+    private String mAccountType;
+
+    static PhoneNumber fromCursor(Context context, Cursor cursor) {
+        int typeColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE);
+        int labelColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL);
+        int numberColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
+        int rawDataIdColumn = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone._ID);
+        int dataVersionColumn = cursor.getColumnIndex(
+                ContactsContract.CommonDataKinds.Phone.DATA_VERSION);
+        // IS_PRIMARY means primary entry of the raw contact and IS_SUPER_PRIMARY means primary
+        // entry of the aggregated contact. It is guaranteed that only one data entry is super
+        // primary.
+        int isPrimaryColumn = cursor.getColumnIndex(
+                ContactsContract.CommonDataKinds.Phone.IS_SUPER_PRIMARY);
+        int accountNameColumn = cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_NAME);
+        int accountTypeColumn = cursor.getColumnIndex(ContactsContract.RawContacts.ACCOUNT_TYPE);
+        return PhoneNumber.newInstance(
+                context,
+                cursor.getString(numberColumn),
+                cursor.getInt(typeColumn),
+                cursor.getString(labelColumn),
+                cursor.getInt(isPrimaryColumn) > 0,
+                cursor.getLong(rawDataIdColumn),
+                cursor.getString(accountNameColumn),
+                cursor.getString(accountTypeColumn),
+                cursor.getInt(dataVersionColumn));
+    }
 
     /**
      * Creates a new {@link PhoneNumber}.
@@ -54,19 +84,23 @@
      *                    Phone#DATA_VERSION}
      */
     public static PhoneNumber newInstance(Context context, String rawNumber, int type,
-            @Nullable String label, boolean isPrimary, long id, int dataVersion) {
+            @Nullable String label, boolean isPrimary, long id, String accountName,
+            String accountType, int dataVersion) {
         I18nPhoneNumberWrapper i18nPhoneNumber = I18nPhoneNumberWrapper.Factory.INSTANCE.get(
                 context, rawNumber);
-        return new PhoneNumber(i18nPhoneNumber, type, label, isPrimary, id, dataVersion);
+        return new PhoneNumber(i18nPhoneNumber, type, label, isPrimary, id, accountName,
+                accountType, dataVersion);
     }
 
     private PhoneNumber(I18nPhoneNumberWrapper i18nNumber, int type, @Nullable String label,
-            boolean isPrimary, long id, int dataVersion) {
+            boolean isPrimary, long id, String accountName, String accountType, int dataVersion) {
         mI18nPhoneNumber = i18nNumber;
         mType = type;
         mLabel = label;
         mIsPrimary = isPrimary;
         mId = id;
+        mAccountName = accountName;
+        mAccountType = accountType;
         mDataVersion = dataVersion;
     }
 
@@ -131,6 +165,16 @@
         return mId;
     }
 
+    @Nullable
+    public String getAccountName() {
+        return mAccountName;
+    }
+
+    @Nullable
+    public String getAccountType() {
+        return mAccountType;
+    }
+
     /**
      * Each contact may have a few sources with the same phone number. Merge same phone numbers as
      * one.
@@ -144,6 +188,8 @@
                 mDataVersion = phoneNumber.mDataVersion;
                 mId = phoneNumber.mId;
                 mIsPrimary |= phoneNumber.mIsPrimary;
+                mAccountName = phoneNumber.mAccountName;
+                mAccountType = phoneNumber.mAccountType;
             }
         }
         return this;
@@ -174,6 +220,8 @@
         dest.writeParcelable(mI18nPhoneNumber, flags);
         dest.writeBoolean(mIsPrimary);
         dest.writeLong(mId);
+        dest.writeString(mAccountName);
+        dest.writeString(mAccountType);
         dest.writeInt(mDataVersion);
     }
 
@@ -186,9 +234,11 @@
                     I18nPhoneNumberWrapper.class.getClassLoader());
             boolean isPrimary = source.readBoolean();
             long id = source.readLong();
+            String accountName = source.readString();
+            String accountType = source.readString();
             int dataVersion = source.readInt();
             PhoneNumber phoneNumber = new PhoneNumber(i18nPhoneNumberWrapper, type, label,
-                    isPrimary, id, dataVersion);
+                    isPrimary, id, accountName, accountType, dataVersion);
             return phoneNumber;
         }