Merge "Fix RcsManager and add empty RcsThread class"

This commit is contained in:
Sahin Caliskan
2018-11-13 16:17:06 +00:00
committed by Android (Google) Code Review
10 changed files with 185 additions and 4 deletions

View File

@@ -570,7 +570,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",
@@ -601,6 +600,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/INetworkRequestMatchCallback.aidl",
"wifi/java/android/net/wifi/INetworkRequestUserSelectionCallback.aidl",
"wifi/java/android/net/wifi/ISoftApCallback.aidl",

View File

@@ -153,6 +153,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.ArrayMap;
import android.util.Log;
import android.view.ContextThemeWrapper;
@@ -547,6 +548,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

View File

@@ -4366,6 +4366,13 @@ public abstract class Context {
*/
public static final String APP_BINDING_SERVICE = "app_binding";
/**
* 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.

View File

@@ -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;

View File

@@ -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;

View File

@@ -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) {
}
}

View File

@@ -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);
}

19
tests/RcsTests/Android.mk Normal file
View File

@@ -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))

View File

@@ -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>

View File

@@ -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);
}
}