Merge "Make RcsMessageStore a top level API"

This commit is contained in:
Brad Ebinger
2019-07-12 21:40:40 +00:00
committed by Gerrit Code Review
7 changed files with 29 additions and 64 deletions

View File

@@ -507,7 +507,7 @@ java_defaults {
"telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl", "telephony/java/android/telephony/ims/aidl/IImsServiceController.aidl",
"telephony/java/android/telephony/ims/aidl/IImsServiceControllerListener.aidl", "telephony/java/android/telephony/ims/aidl/IImsServiceControllerListener.aidl",
"telephony/java/android/telephony/ims/aidl/IImsSmsListener.aidl", "telephony/java/android/telephony/ims/aidl/IImsSmsListener.aidl",
"telephony/java/android/telephony/ims/aidl/IRcs.aidl", "telephony/java/android/telephony/ims/aidl/IRcsMessage.aidl",
"telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl", "telephony/java/android/telephony/mbms/IMbmsDownloadSessionCallback.aidl",
"telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl", "telephony/java/android/telephony/mbms/IMbmsStreamingSessionCallback.aidl",
"telephony/java/android/telephony/mbms/IMbmsGroupCallSessionCallback.aidl", "telephony/java/android/telephony/mbms/IMbmsGroupCallSessionCallback.aidl",

View File

@@ -149,7 +149,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.telephony.euicc.EuiccCardManager; import android.telephony.euicc.EuiccCardManager;
import android.telephony.euicc.EuiccManager; import android.telephony.euicc.EuiccManager;
import android.telephony.ims.RcsManager; import android.telephony.ims.RcsMessageManager;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.Log; import android.util.Log;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
@@ -552,11 +552,11 @@ final class SystemServiceRegistry {
return new SubscriptionManager(ctx.getOuterContext()); return new SubscriptionManager(ctx.getOuterContext());
}}); }});
registerService(Context.TELEPHONY_RCS_SERVICE, RcsManager.class, registerService(Context.TELEPHONY_RCS_MESSAGE_SERVICE, RcsMessageManager.class,
new CachedServiceFetcher<RcsManager>() { new CachedServiceFetcher<RcsMessageManager>() {
@Override @Override
public RcsManager createService(ContextImpl ctx) { public RcsMessageManager createService(ContextImpl ctx) {
return new RcsManager(ctx.getOuterContext()); return new RcsMessageManager(ctx.getOuterContext());
} }
}); });

View File

@@ -4290,10 +4290,10 @@ public abstract class Context {
/** /**
* Use with {@link #getSystemService(String)} to retrieve an * Use with {@link #getSystemService(String)} to retrieve an
* {@link android.telephony.ims.RcsManager}. * {@link android.telephony.ims.RcsMessageManager}.
* @hide * @hide
*/ */
public static final String TELEPHONY_RCS_SERVICE = "ircs"; public static final String TELEPHONY_RCS_MESSAGE_SERVICE = "ircsmessage";
/** /**
* Use with {@link #getSystemService(String)} to retrieve an * Use with {@link #getSystemService(String)} to retrieve an

View File

@@ -19,10 +19,11 @@ package android.telephony.ims;
import android.content.Context; import android.content.Context;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.telephony.ims.aidl.IRcs; import android.telephony.ims.aidl.IRcsMessage;
/** /**
* A wrapper class around RPC calls that {@link RcsMessageStore} APIs to minimize boilerplate code. * A wrapper class around RPC calls that {@link RcsMessageManager} APIs to minimize boilerplate
* code.
* *
* @hide - not meant for public use * @hide - not meant for public use
*/ */
@@ -34,13 +35,14 @@ class RcsControllerCall {
} }
<R> R call(RcsServiceCall<R> serviceCall) throws RcsMessageStoreException { <R> R call(RcsServiceCall<R> serviceCall) throws RcsMessageStoreException {
IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_RCS_SERVICE)); IRcsMessage iRcsMessage = IRcsMessage.Stub.asInterface(ServiceManager.getService(
if (iRcs == null) { Context.TELEPHONY_RCS_MESSAGE_SERVICE));
if (iRcsMessage == null) {
throw new RcsMessageStoreException("Could not connect to RCS storage service"); throw new RcsMessageStoreException("Could not connect to RCS storage service");
} }
try { try {
return serviceCall.methodOnIRcs(iRcs, mContext.getOpPackageName()); return serviceCall.methodOnIRcs(iRcsMessage, mContext.getOpPackageName());
} catch (RemoteException exception) { } catch (RemoteException exception) {
throw new RcsMessageStoreException(exception.getMessage()); throw new RcsMessageStoreException(exception.getMessage());
} }
@@ -48,17 +50,17 @@ class RcsControllerCall {
void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall) void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall)
throws RcsMessageStoreException { throws RcsMessageStoreException {
call((iRcs, callingPackage) -> { call((iRcsMessage, callingPackage) -> {
serviceCall.methodOnIRcs(iRcs, callingPackage); serviceCall.methodOnIRcs(iRcsMessage, callingPackage);
return null; return null;
}); });
} }
interface RcsServiceCall<R> { interface RcsServiceCall<R> {
R methodOnIRcs(IRcs iRcs, String callingPackage) throws RemoteException; R methodOnIRcs(IRcsMessage iRcs, String callingPackage) throws RemoteException;
} }
interface RcsServiceCallWithNoReturn { interface RcsServiceCallWithNoReturn {
void methodOnIRcs(IRcs iRcs, String callingPackage) throws RemoteException; void methodOnIRcs(IRcsMessage iRcs, String callingPackage) throws RemoteException;
} }
} }

View File

@@ -1,43 +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 android.telephony.ims;
import android.annotation.SystemService;
import android.content.Context;
/**
* The manager class for RCS related utilities.
*
* @hide
*/
@SystemService(Context.TELEPHONY_RCS_SERVICE)
public class RcsManager {
private final RcsMessageStore mRcsMessageStore;
/**
* @hide
*/
public RcsManager(Context context) {
mRcsMessageStore = new RcsMessageStore(context);
}
/**
* Returns an instance of {@link RcsMessageStore}
*/
public RcsMessageStore getRcsMessageStore() {
return mRcsMessageStore;
}
}

View File

@@ -18,6 +18,7 @@ package android.telephony.ims;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.WorkerThread; import android.annotation.WorkerThread;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
@@ -25,15 +26,20 @@ import android.net.Uri;
import java.util.List; import java.util.List;
/** /**
* RcsMessageStore is the application interface to RcsProvider and provides access methods to * RcsMessageManager is the application interface to RcsProvider and provides access methods to
* RCS related database tables. * RCS related database tables.
* *
* @hide * @hide
*/ */
public class RcsMessageStore { @SystemService(Context.TELEPHONY_RCS_MESSAGE_SERVICE)
public class RcsMessageManager {
RcsControllerCall mRcsControllerCall; RcsControllerCall mRcsControllerCall;
RcsMessageStore(Context context) { /**
* Use {@link Context#getSystemService(String)} to get an instance of this service.
* @hide
*/
public RcsMessageManager(Context context) {
mRcsControllerCall = new RcsControllerCall(context); mRcsControllerCall = new RcsControllerCall(context);
} }

View File

@@ -35,7 +35,7 @@ import android.telephony.ims.RcsThreadQueryResultParcelable;
* RPC definition between RCS storage APIs and phone process. * RPC definition between RCS storage APIs and phone process.
* {@hide} * {@hide}
*/ */
interface IRcs { interface IRcsMessage {
///////////////////////// /////////////////////////
// RcsMessageStore APIs // RcsMessageStore APIs
///////////////////////// /////////////////////////