Merge "Remove phoneId from ImsUceManager"
This commit is contained in:
@@ -18,16 +18,9 @@ package com.android.ims.internal.uce.uceservice;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.HandlerThread;
|
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
|
||||||
import android.os.ServiceManager;
|
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.ServiceManager;
|
||||||
import java.util.HashMap;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImsUceManager Declaration
|
* ImsUceManager Declaration
|
||||||
@@ -49,55 +42,25 @@ public class ImsUceManager {
|
|||||||
private IUceService mUceService = null;
|
private IUceService mUceService = null;
|
||||||
private UceServiceDeathRecipient mDeathReceipient = new UceServiceDeathRecipient();
|
private UceServiceDeathRecipient mDeathReceipient = new UceServiceDeathRecipient();
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private int mPhoneId;
|
private static final Object sLock = new Object();
|
||||||
/**
|
private static ImsUceManager sUceManager;
|
||||||
* Stores the UceManager instaces of Clients identified by
|
|
||||||
* phoneId
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
private static HashMap<Integer, ImsUceManager> sUceManagerInstances =
|
|
||||||
new HashMap<Integer, ImsUceManager>();
|
|
||||||
|
|
||||||
public static final String ACTION_UCE_SERVICE_UP =
|
public static final String ACTION_UCE_SERVICE_UP =
|
||||||
"com.android.ims.internal.uce.UCE_SERVICE_UP";
|
"com.android.ims.internal.uce.UCE_SERVICE_UP";
|
||||||
public static final String ACTION_UCE_SERVICE_DOWN =
|
public static final String ACTION_UCE_SERVICE_DOWN =
|
||||||
"com.android.ims.internal.uce.UCE_SERVICE_DOWN";
|
"com.android.ims.internal.uce.UCE_SERVICE_DOWN";
|
||||||
|
|
||||||
/** Uce Service status received in IUceListener.setStatus()
|
|
||||||
* callback
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static final int UCE_SERVICE_STATUS_FAILURE = 0;
|
|
||||||
/** indicate UI to call Presence/Options API. */
|
|
||||||
public static final int UCE_SERVICE_STATUS_ON = 1;
|
|
||||||
/** Indicate UI destroy Presence/Options */
|
|
||||||
public static final int UCE_SERVICE_STATUS_CLOSED = 2;
|
|
||||||
/** Service up and trying to register for network events */
|
|
||||||
public static final int UCE_SERVICE_STATUS_READY = 3;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Part of the ACTION_UCE_SERVICE_UP or _DOWN intents. A long
|
|
||||||
* value; the phone ID corresponding to the IMS service coming up or down.
|
|
||||||
* Internal use only.
|
|
||||||
* @hide
|
|
||||||
*/
|
|
||||||
public static final String EXTRA_PHONE_ID = "android:phone_id";
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the instance of UCE Manager
|
* Gets the instance of UCE Manager
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static ImsUceManager getInstance(Context context, int phoneId) {
|
public static ImsUceManager getInstance(Context context) {
|
||||||
//if (DBG) Log.d (LOG_TAG, "GetInstance Called");
|
synchronized (sLock) {
|
||||||
synchronized (sUceManagerInstances) {
|
if (sUceManager == null && context != null) {
|
||||||
if (sUceManagerInstances.containsKey(phoneId)) {
|
sUceManager = new ImsUceManager(context);
|
||||||
return sUceManagerInstances.get(phoneId);
|
|
||||||
} else {
|
|
||||||
ImsUceManager uceMgr = new ImsUceManager(context, phoneId);
|
|
||||||
sUceManagerInstances.put(phoneId, uceMgr);
|
|
||||||
return uceMgr;
|
|
||||||
}
|
}
|
||||||
|
return sUceManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +68,9 @@ public class ImsUceManager {
|
|||||||
* Constructor
|
* Constructor
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
private ImsUceManager(Context context, int phoneId) {
|
private ImsUceManager(Context context) {
|
||||||
//if (DBG) Log.d (LOG_TAG, "Constructor");
|
//if (DBG) Log.d (LOG_TAG, "Constructor");
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPhoneId = phoneId;
|
|
||||||
createUceService(true);
|
createUceService(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +91,7 @@ public class ImsUceManager {
|
|||||||
* Gets the UCE service name
|
* Gets the UCE service name
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
private String getUceServiceName(int phoneId) {
|
private String getUceServiceName() {
|
||||||
return UCE_SERVICE;
|
return UCE_SERVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,14 +105,14 @@ public class ImsUceManager {
|
|||||||
public void createUceService(boolean checkService) {
|
public void createUceService(boolean checkService) {
|
||||||
//if (DBG) Log.d (LOG_TAG, "CreateUceService Called");
|
//if (DBG) Log.d (LOG_TAG, "CreateUceService Called");
|
||||||
if (checkService) {
|
if (checkService) {
|
||||||
IBinder binder = ServiceManager.checkService(getUceServiceName(mPhoneId));
|
IBinder binder = ServiceManager.checkService(getUceServiceName());
|
||||||
|
|
||||||
if (binder == null) {
|
if (binder == null) {
|
||||||
//if (DBG)Log.d (LOG_TAG, "Unable to find IBinder");
|
//if (DBG)Log.d (LOG_TAG, "Unable to find IBinder");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IBinder b = ServiceManager.getService(getUceServiceName(mPhoneId));
|
IBinder b = ServiceManager.getService(getUceServiceName());
|
||||||
|
|
||||||
if (b != null) {
|
if (b != null) {
|
||||||
try {
|
try {
|
||||||
@@ -174,12 +136,10 @@ public class ImsUceManager {
|
|||||||
private class UceServiceDeathRecipient implements IBinder.DeathRecipient {
|
private class UceServiceDeathRecipient implements IBinder.DeathRecipient {
|
||||||
@Override
|
@Override
|
||||||
public void binderDied() {
|
public void binderDied() {
|
||||||
//if (DBG) Log.d (LOG_TAG, "found IBinder/IUceService Service Died");
|
|
||||||
mUceService = null;
|
mUceService = null;
|
||||||
|
|
||||||
if (mContext != null) {
|
if (mContext != null) {
|
||||||
Intent intent = new Intent(ACTION_UCE_SERVICE_DOWN);
|
Intent intent = new Intent(ACTION_UCE_SERVICE_DOWN);
|
||||||
intent.putExtra(EXTRA_PHONE_ID, mPhoneId);
|
|
||||||
mContext.sendBroadcast(new Intent(intent));
|
mContext.sendBroadcast(new Intent(intent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user