Merge "Import account name and type for PhoneNumber" into pi-car-dev
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;
- }
-}