diff options
| -rw-r--r-- | Android.bp | 2 | ||||
| -rw-r--r-- | core/java/android/app/SystemServiceRegistry.java | 9 | ||||
| -rw-r--r-- | core/java/android/content/Context.java | 7 | ||||
| -rw-r--r-- | telephony/java/android/telephony/rcs/RcsManager.java (renamed from telephony/java/android/telephony/RcsManager.java) | 8 | ||||
| -rw-r--r-- | telephony/java/android/telephony/rcs/RcsThread.aidl | 20 | ||||
| -rw-r--r-- | telephony/java/android/telephony/rcs/RcsThread.java | 75 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/rcs/IRcs.aidl (renamed from telephony/java/com/android/internal/telephony/IRcs.aidl) | 6 | ||||
| -rw-r--r-- | tests/RcsTests/Android.mk | 19 | ||||
| -rw-r--r-- | tests/RcsTests/AndroidManifest.xml | 11 | ||||
| -rw-r--r-- | tests/RcsTests/src/com/android/tests/rcs/RcsManagerTest.java | 32 |
10 files changed, 185 insertions, 4 deletions
diff --git a/Android.bp b/Android.bp index c8c89b3cadab..8c0188275067 100644 --- a/Android.bp +++ b/Android.bp @@ -546,7 +546,6 @@ java_defaults { "telephony/java/com/android/internal/telephony/IOnSubscriptionsChangedListener.aidl", "telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl", "telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl", - "telephony/java/com/android/internal/telephony/IRcs.aidl", "telephony/java/com/android/internal/telephony/ISms.aidl", "telephony/java/com/android/internal/telephony/ISub.aidl", "telephony/java/com/android/internal/telephony/IAns.aidl", @@ -577,6 +576,7 @@ java_defaults { "telephony/java/com/android/internal/telephony/euicc/ISetDefaultSmdpAddressCallback.aidl", "telephony/java/com/android/internal/telephony/euicc/ISetNicknameCallback.aidl", "telephony/java/com/android/internal/telephony/euicc/ISwitchToProfileCallback.aidl", + "telephony/java/com/android/internal/telephony/rcs/IRcs.aidl", "wifi/java/android/net/wifi/ISoftApCallback.aidl", "wifi/java/android/net/wifi/IWifiManager.aidl", "wifi/java/android/net/wifi/aware/IWifiAwareDiscoverySessionCallback.aidl", diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index fdda85d5122a..83c43e7b83e1 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -143,6 +143,7 @@ import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.euicc.EuiccCardManager; import android.telephony.euicc.EuiccManager; +import android.telephony.rcs.RcsManager; import android.util.Log; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; @@ -514,6 +515,14 @@ final class SystemServiceRegistry { return new SubscriptionManager(ctx.getOuterContext()); }}); + registerService(Context.TELEPHONY_RCS_SERVICE, RcsManager.class, + new CachedServiceFetcher<RcsManager>() { + @Override + public RcsManager createService(ContextImpl ctx) { + return new RcsManager(); + } + }); + registerService(Context.CARRIER_CONFIG_SERVICE, CarrierConfigManager.class, new CachedServiceFetcher<CarrierConfigManager>() { @Override diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 12aa70dfba5f..049827896fdf 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -4259,6 +4259,13 @@ public abstract class Context { public static final String TIME_ZONE_DETECTOR_SERVICE = "time_zone_detector"; /** + * Use with {@link #getSystemService(String)} to retrieve an + * {@link android.telephony.rcs.RcsManager}. + * @hide + */ + public static final String TELEPHONY_RCS_SERVICE = "ircs"; + + /** * Determine whether the given permission is allowed for a particular * process and user ID running in the system. * diff --git a/telephony/java/android/telephony/RcsManager.java b/telephony/java/android/telephony/rcs/RcsManager.java index 00ce03a1f668..0ef4e1552085 100644 --- a/telephony/java/android/telephony/RcsManager.java +++ b/telephony/java/android/telephony/rcs/RcsManager.java @@ -14,18 +14,22 @@ * limitations under the License. */ -package android.telephony; +package android.telephony.rcs; +import android.annotation.SystemService; +import android.content.Context; import android.os.RemoteException; import android.os.ServiceManager; +import android.telephony.Rlog; -import com.android.internal.telephony.IRcs; +import com.android.internal.telephony.rcs.IRcs; /** * RcsManager is the application interface to RcsProvider and provides access methods to * RCS related database tables. * @hide - TODO make this public */ +@SystemService(Context.TELEPHONY_RCS_SERVICE) public class RcsManager { private static final String TAG = "RcsManager"; private static final boolean VDBG = false; diff --git a/telephony/java/android/telephony/rcs/RcsThread.aidl b/telephony/java/android/telephony/rcs/RcsThread.aidl new file mode 100644 index 000000000000..e2e0da5da347 --- /dev/null +++ b/telephony/java/android/telephony/rcs/RcsThread.aidl @@ -0,0 +1,20 @@ +/* +** +** Copyright 2018, 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 android.telephony; + +parcelable RcsThread;
\ No newline at end of file diff --git a/telephony/java/android/telephony/rcs/RcsThread.java b/telephony/java/android/telephony/rcs/RcsThread.java new file mode 100644 index 000000000000..83eb973ec12b --- /dev/null +++ b/telephony/java/android/telephony/rcs/RcsThread.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2018 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 android.telephony.rcs; + +import android.os.Parcel; +import android.os.Parcelable; +import android.os.RemoteException; +import android.os.ServiceManager; + +import com.android.internal.telephony.rcs.IRcs; + +/** + * RcsThread represents a single RCS conversation thread. It holds messages that were sent and + * received and events that occured on that thread. + * @hide - TODO(sahinc) make this public + */ +public class RcsThread implements Parcelable { + public static final Creator<RcsThread> CREATOR = new Creator<RcsThread>() { + @Override + public RcsThread createFromParcel(Parcel in) { + return new RcsThread(in); + } + + @Override + public RcsThread[] newArray(int size) { + return new RcsThread[size]; + } + }; + + protected RcsThread(Parcel in) { + } + + /** + * Returns the number of messages in this RCS thread. + * + * @hide + */ + public int getMessageCount() { + try { + IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService("ircs")); + if (iRcs != null) { + // TODO(sahinc): substitute to the regular thread id once we have database + // TODO(sahinc): connection in place + return iRcs.getMessageCount(/* rcsThreadId= */ 123); + } + } catch (RemoteException re) { + // TODO(sahinc): Log something meaningful + } + return 0; + } + + /** Implement the Parcelable interface */ + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + } +} diff --git a/telephony/java/com/android/internal/telephony/IRcs.aidl b/telephony/java/com/android/internal/telephony/rcs/IRcs.aidl index ede8695ef08e..4c289acd15ef 100644 --- a/telephony/java/com/android/internal/telephony/IRcs.aidl +++ b/telephony/java/com/android/internal/telephony/rcs/IRcs.aidl @@ -14,8 +14,12 @@ * limitations under the License. */ -package com.android.internal.telephony; +package com.android.internal.telephony.rcs; interface IRcs { + // RcsManager APIs void deleteThread(int threadId); + + // RcsThread APIs + int getMessageCount(int rcsThreadId); }
\ No newline at end of file diff --git a/tests/RcsTests/Android.mk b/tests/RcsTests/Android.mk new file mode 100644 index 000000000000..adc7cab91389 --- /dev/null +++ b/tests/RcsTests/Android.mk @@ -0,0 +1,19 @@ +LOCAL_PATH:= $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE_TAGS := tests + +# Only compile source java files in this apk. +LOCAL_SRC_FILES := $(call all-java-files-under, src) + +LOCAL_PACKAGE_NAME := RcsTests +LOCAL_PRIVATE_PLATFORM_APIS := true + +LOCAL_CERTIFICATE := platform +LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base +LOCAL_STATIC_JAVA_LIBRARIES := junit android-support-test mockito-target-minus-junit4 + +include $(BUILD_PACKAGE) + +# Use the following include to make our test apk. +include $(call all-makefiles-under,$(LOCAL_PATH)) diff --git a/tests/RcsTests/AndroidManifest.xml b/tests/RcsTests/AndroidManifest.xml new file mode 100644 index 000000000000..a7e7d479a4d9 --- /dev/null +++ b/tests/RcsTests/AndroidManifest.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.android.tests.rcs"> + <application android:label="RCS Test"> + <uses-library android:name="android.test.runner" /> + </application> + + <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" + android:targetPackage="com.android.tests.rcs"/> +</manifest> diff --git a/tests/RcsTests/src/com/android/tests/rcs/RcsManagerTest.java b/tests/RcsTests/src/com/android/tests/rcs/RcsManagerTest.java new file mode 100644 index 000000000000..7f5f03e0d5a4 --- /dev/null +++ b/tests/RcsTests/src/com/android/tests/rcs/RcsManagerTest.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2018 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.tests.rcs; + +import android.support.test.runner.AndroidJUnit4; +import android.telephony.rcs.RcsManager; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@RunWith(AndroidJUnit4.class) +public class RcsManagerTest { + //TODO(sahinc): Add meaningful tests once we have more of the implementation in place + @Test + public void testDeleteThreadDoesntCrash() { + RcsManager mRcsManager = new RcsManager(); + mRcsManager.deleteThread(0); + } +} |