Add a system API to get the default phone app.

Change-Id: I59ca863d2af43a3b3c26d18b0279fc6e1e13b9b1
This commit is contained in:
Santos Cordon
2014-06-25 15:30:08 -07:00
parent 9e58b3c61c
commit 6c7a38817c
2 changed files with 35 additions and 2 deletions

View File

@@ -16,7 +16,12 @@
package android.telecomm;
import android.annotation.SystemApi;
import android.content.ComponentName;
import android.content.Context;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
import com.android.internal.telecomm.ITelecommService;
@@ -25,11 +30,14 @@ import com.android.internal.telecomm.ITelecommService;
*/
public class TelecommManager {
private static final String TAG = "TelecommManager";
private static final String TELECOMM_SERVICE_NAME = "telecomm";
private final Context mContext;
private final ITelecommService mService;
/** @hide */
/**
* @hide
*/
public TelecommManager(Context context, ITelecommService service) {
Context appContext = context.getApplicationContext();
if (appContext != null) {
@@ -41,8 +49,27 @@ public class TelecommManager {
mService = service;
}
/** {@hide} */
/**
* @hide
*/
public static TelecommManager from(Context context) {
return (TelecommManager) context.getSystemService(Context.TELECOMM_SERVICE);
}
/**
* @hide
*/
@SystemApi
public ComponentName getDefaultPhoneApp() {
try {
return getTelecommService().getDefaultPhoneApp();
} catch (RemoteException e) {
Log.e(TAG, "RemoteException attempting to get the default phone app.", e);
}
return null;
}
private ITelecommService getTelecommService() {
return ITelecommService.Stub.asInterface(ServiceManager.getService(TELECOMM_SERVICE_NAME));
}
}

View File

@@ -16,6 +16,7 @@
package com.android.internal.telecomm;
import android.content.ComponentName;
import android.telecomm.Subscription;
/**
@@ -55,4 +56,9 @@ interface ITelecommService {
* Sets a given Subscription as the system default.
*/
void setSystemDefault(in Subscription subscription);
/**
* Returns the component name of the default phone application.
*/
ComponentName getDefaultPhoneApp();
}