summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard MacGregor <rmacgregor@cyngn.com>2016-01-26 10:25:53 -0800
committerRichard MacGregor <rmacgregor@cyngn.com>2016-04-08 08:53:14 -0700
commitff82047527cc3322876dc0525fc14d1010f4c59f (patch)
treed548ce416aa429f836c69d69f542d26cb7b5800d
parent91d03c80740f1451bc881a5750a57a2184ccc9e4 (diff)
downloadandroid_packages_apps_InCallUI-ff82047527cc3322876dc0525fc14d1010f4c59f.tar.gz
android_packages_apps_InCallUI-ff82047527cc3322876dc0525fc14d1010f4c59f.tar.bz2
android_packages_apps_InCallUI-ff82047527cc3322876dc0525fc14d1010f4c59f.zip
Use CallMethodHelper for plugin info
Simplify contact specific plugin lookup by using CallMethodHelper. Allow CallMethodHelper update broadcasts to update incallui buttons when plugins are loaded. Change-Id: I541944771b9c7787951c51470fa70056df49611d
-rw-r--r--src/com/android/incallui/CallButtonPresenter.java47
-rw-r--r--src/com/android/incallui/ContactInfoCache.java111
-rw-r--r--src/com/android/incallui/InCallPresenter.java57
-rw-r--r--src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java92
4 files changed, 194 insertions, 113 deletions
diff --git a/src/com/android/incallui/CallButtonPresenter.java b/src/com/android/incallui/CallButtonPresenter.java
index cd8c9415..c62d61a2 100644
--- a/src/com/android/incallui/CallButtonPresenter.java
+++ b/src/com/android/incallui/CallButtonPresenter.java
@@ -42,9 +42,11 @@ import android.text.TextUtils;
import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.ContactInfoCache;
import com.android.incallui.ContactInfoCache.ContactCacheEntry;
+import com.android.incallui.ContactInfoCache.ContactInfoCacheCallback;
import com.android.incallui.incallapi.InCallPluginInfo;
import com.android.incallui.InCallCameraManager.Listener;
import com.android.incallui.InCallPresenter.CanAddCallListener;
+import com.android.incallui.InCallPresenter.InCallPluginUpdateListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.incallui.InCallPresenter.IncomingCallListener;
@@ -68,7 +70,7 @@ import java.util.Objects;
public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButtonUi>
implements InCallStateListener, AudioModeListener, IncomingCallListener,
InCallDetailsListener, CanAddCallListener, CallList.ActiveSubChangeListener, Listener,
- StartInCallCallReceiver.Receiver {
+ StartInCallCallReceiver.Receiver, ContactInfoCacheCallback, InCallPluginUpdateListener {
private static final String TAG = CallButtonPresenter.class.getSimpleName();
private static final String KEY_AUTOMATICALLY_MUTED = "incall_key_automatically_muted";
@@ -116,6 +118,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
inCallPresenter.addDetailsListener(this);
inCallPresenter.addCanAddCallListener(this);
inCallPresenter.getInCallCameraManager().addCameraSelectionListener(this);
+ inCallPresenter.addInCallPluginUpdateListener(this);
CallList.getInstance().addActiveSubChangeListener(this);
// Update the buttons state immediately for the current call
@@ -133,6 +136,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
InCallPresenter.getInstance().removeDetailsListener(this);
InCallPresenter.getInstance().getInCallCameraManager().removeCameraSelectionListener(this);
InCallPresenter.getInstance().removeCanAddCallListener(this);
+ InCallPresenter.getInstance().removeInCallPluginUpdateListener(this);
CallList.getInstance().removeActiveSubChangeListener(this);
}
@@ -306,10 +310,15 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
public List<InCallPluginInfo> getContactInCallPluginInfoList() {
List<InCallPluginInfo> inCallPluginInfoList = null;
if (mCall != null) {
- ContactCacheEntry contactInfo =
- ContactInfoCache.getInstance(getUi().getContext()).getInfo(mCall.getId());
- if (contactInfo != null) {
- inCallPluginInfoList = contactInfo.inCallPluginInfoList;
+ final ContactInfoCache cache = ContactInfoCache.getInstance(getUi().getContext());
+ if (cache != null) {
+ ContactCacheEntry contactInfo = cache.getInfo(mCall.getId());
+ if (contactInfo != null) {
+ inCallPluginInfoList = contactInfo.inCallPluginInfoList;
+ }
+ if (inCallPluginInfoList == null) {
+ cache.refreshPluginInfo(mCall, this);
+ }
}
}
return inCallPluginInfoList;
@@ -346,7 +355,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
} else if (inviteIntent != null) {
// Attempt contact invite
if (DEBUG) {
- final com.android.incallui.ContactInfoCache cache =
+ final ContactInfoCache cache =
ContactInfoCache.getInstance(getUi().getContext());
ContactCacheEntry entry = cache.getInfo(mCall.getId());
Uri lookupUri = entry.lookupUri;
@@ -359,7 +368,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
} else {
// Inform user to add contact manually, no invite intent found
if (DEBUG) {
- final com.android.incallui.ContactInfoCache cache =
+ final ContactInfoCache cache =
ContactInfoCache.getInstance(getUi().getContext());
ContactCacheEntry entry = cache.getInfo(mCall.getId());
Uri lookupUri = entry.lookupUri;
@@ -646,6 +655,30 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
mAutomaticallyMuted = false;
}
+ private void contactUpdated() {
+ if (DEBUG) Log.i(this, "contactUpdated");
+ if (getUi() != null && mCall != null) {
+ updateButtonsState(mCall);
+ }
+ }
+
+ @Override
+ public void onInCallPluginUpdated() {
+ if (DEBUG) Log.i(this, "onInCallPluginUpdated");
+ contactUpdated();
+ }
+
+ @Override
+ public void onContactInfoComplete(String callId, ContactInfoCache.ContactCacheEntry entry) {
+ if (DEBUG) Log.i(this, "onContactInfoComplete");
+ contactUpdated();
+ }
+
+ @Override
+ public void onImageLoadComplete(String callId, ContactInfoCache.ContactCacheEntry entry) {
+ // Stub
+ }
+
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
diff --git a/src/com/android/incallui/ContactInfoCache.java b/src/com/android/incallui/ContactInfoCache.java
index e94ea07b..90b63752 100644
--- a/src/com/android/incallui/ContactInfoCache.java
+++ b/src/com/android/incallui/ContactInfoCache.java
@@ -53,6 +53,7 @@ import com.google.common.collect.Sets;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
+import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
@@ -235,22 +236,6 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
sendInfoNotifications(callId, cacheEntry);
if (didLocalLookup) {
- if (!callerInfo.isEmergencyNumber() && cacheEntry.inCallPluginInfoList == null &&
- (cacheEntry.lookupUri != null || !TextUtils.isEmpty(cacheEntry.number))) {
- if (mPluginInfoAsyncTask != null) {
- mPluginInfoAsyncTask.cancel(true);
- mPluginInfoAsyncTask = null;
- }
-
- final InCallPluginInfoAsyncTask.IInCallPostExecute callback =
- new InCallPluginInfoCallback(callId);
- final InCallContactInfo contactInfo = new InCallContactInfo(cacheEntry.name,
- cacheEntry.number, cacheEntry.lookupUri);
- mPluginInfoAsyncTask =
- new InCallPluginInfoAsyncTask(mContext, contactInfo, callback);
- mPluginInfoAsyncTask.execute();
- }
-
// Before issuing a request for more data from other services, we only check that the
// contact wasn't found in the local DB. We don't check the if the cache entry already
// has a name because we allow overriding cnap data with data from other services.
@@ -277,6 +262,69 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
}
}
+ public void refreshPluginInfo(final Call call, ContactInfoCacheCallback callback) {
+ if (call != null) {
+ final String callId = call.getId();
+ ContactCacheEntry entry = mInfoMap.get(callId);
+ if (entry == null) {
+ findInfo(call, call.getState() == Call.State.INCOMING, callback);
+ } else {
+ lookupPluginInfo(callId, entry, callback);
+ }
+ }
+ }
+
+ private boolean lookupPluginInfo(final String callId, ContactCacheEntry cacheEntry,
+ ContactInfoCacheCallback cacheCallback) {
+ if (!cacheEntry.isEmergencyNumber &&
+ (cacheEntry.lookupUri != null || !TextUtils.isEmpty(cacheEntry.number))) {
+ if (mPluginInfoAsyncTask != null) {
+ mPluginInfoAsyncTask.cancel(true);
+ mPluginInfoAsyncTask = null;
+ }
+
+ final InCallPluginInfoAsyncTask.IInCallPostExecute callback =
+ new InCallPluginInfoCallback(callId, cacheCallback);
+ final InCallContactInfo contactInfo = new InCallContactInfo(cacheEntry.name,
+ cacheEntry.number, cacheEntry.lookupUri);
+ mPluginInfoAsyncTask =
+ new InCallPluginInfoAsyncTask(mContext, contactInfo, callback);
+ mPluginInfoAsyncTask.execute();
+ return true;
+ }
+ return false;
+ }
+
+ class InCallPluginInfoCallback implements InCallPluginInfoAsyncTask.IInCallPostExecute {
+ private String mCallId;
+ private WeakReference<ContactInfoCacheCallback> mCallback;
+
+ public InCallPluginInfoCallback(String callId, ContactInfoCacheCallback callback) {
+ mCallId = callId;
+ if (callback != null) {
+ mCallback = new WeakReference<ContactInfoCacheCallback>(callback);
+ }
+ }
+
+ @Override
+ public void onPostExecuteTask(List<InCallPluginInfo> inCallPluginInfoList) {
+ synchronized (mInfoMap) {
+ final ContactCacheEntry oldEntry = mInfoMap.get(mCallId);
+ ContactCacheEntry entry = new ContactCacheEntry(oldEntry);
+ entry.inCallPluginInfoList = inCallPluginInfoList;
+
+ // Add the contact info to the cache.
+ mInfoMap.put(mCallId, entry);
+ if (mCallback != null) {
+ ContactInfoCacheCallback callback = mCallback.get();
+ if (callback != null) {
+ callback.onContactInfoComplete(mCallId, entry);
+ }
+ }
+ }
+ }
+ }
+
class PhoneNumberServiceListener implements PhoneNumberService.NumberLookupListener,
PhoneNumberService.ImageLookupListener {
private final String mCallId;
@@ -343,34 +391,6 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
}
}
- class InCallPluginInfoCallback implements InCallPluginInfoAsyncTask.IInCallPostExecute {
-
- private String mCallId;
-
- public InCallPluginInfoCallback(String callId) {
- mCallId = callId;
- }
-
- @Override
- public void onPostExecuteTask(List<InCallPluginInfo> inCallPluginInfoList) {
- // If we got a miss, return.
- if (inCallPluginInfoList == null || inCallPluginInfoList.isEmpty()) {
- Log.d(TAG, "No InCall plugins associated with this contact.");
- return;
- }
-
- synchronized (mInfoMap) {
- final ContactCacheEntry oldEntry = mInfoMap.get(mCallId);
- ContactCacheEntry entry = new ContactCacheEntry(oldEntry);
- entry.inCallPluginInfoList = inCallPluginInfoList;
-
- // Add the contact info to the cache.
- mInfoMap.put(mCallId, entry);
- sendInfoNotifications(mCallId, entry);
- }
- }
- }
-
/**
* Implemented for ContactsAsyncHelper.OnImageLoadCompleteListener interface.
* make sure that the call state is reflected after the image is loaded.
@@ -563,6 +583,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
cce.location = displayLocation;
cce.label = label;
cce.isSipCall = isSipCall;
+ cce.isEmergencyNumber = info.isEmergencyNumber();
}
/**
@@ -648,6 +669,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
public Uri displayPhotoUri;
public Uri lookupUri; // Sent to NotificationMananger
public String lookupKey;
+ public boolean isEmergencyNumber;
public List<InCallPluginInfo> inCallPluginInfoList;
public ContactCacheEntry() {}
@@ -664,6 +686,7 @@ public class ContactInfoCache implements ContactsAsyncHelper.OnImageLoadComplete
this.displayPhotoUri = entry.displayPhotoUri;
this.lookupUri = entry.lookupUri;
this.lookupKey = entry.lookupKey;
+ this.isEmergencyNumber = entry.isEmergencyNumber;
this.inCallPluginInfoList = entry.inCallPluginInfoList;
}
}
diff --git a/src/com/android/incallui/InCallPresenter.java b/src/com/android/incallui/InCallPresenter.java
index 07da827b..1ca93272 100644
--- a/src/com/android/incallui/InCallPresenter.java
+++ b/src/com/android/incallui/InCallPresenter.java
@@ -18,6 +18,7 @@ package com.android.incallui;
import android.app.ActivityManager.TaskDescription;
import android.app.FragmentManager;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ActivityNotFoundException;
@@ -42,9 +43,12 @@ import com.android.contacts.common.interactions.TouchPointManager;
import com.android.contacts.common.testing.NeededForTesting;
import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.incalluibind.ObjectFactory;
+import com.android.phone.common.incall.CallMethodHelper;
+import com.android.phone.common.incall.CallMethodInfo;
import com.google.common.base.Preconditions;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -61,8 +65,12 @@ import java.util.concurrent.CopyOnWriteArrayList;
* TODO: This class has become more of a state machine at this point. Consider renaming.
*/
public class InCallPresenter implements CallList.Listener,
- CircularRevealFragment.OnCircularRevealCompleteListener {
+ CircularRevealFragment.OnCircularRevealCompleteListener,
+ ContactInfoCache.ContactInfoCacheCallback,
+ CallMethodHelper.CallMethodReceiver {
+ private static final boolean DEBUG = false;
+ private static final String AMBIENT_SUBSCRIPTION_ID = InCallPresenter.class.getSimpleName();
private static final String EXTRA_FIRST_TIME_SHOWN =
"com.android.incallui.intent.extra.FIRST_TIME_SHOWN";
@@ -88,6 +96,9 @@ public class InCallPresenter implements CallList.Listener,
new ConcurrentHashMap<InCallOrientationListener, Boolean>(8, 0.9f, 1));
private final Set<InCallEventListener> mInCallEventListeners = Collections.newSetFromMap(
new ConcurrentHashMap<InCallEventListener, Boolean>(8, 0.9f, 1));
+ private final Set<InCallPluginUpdateListener> mInCallPluginUpdateListeners =
+ Collections.newSetFromMap(
+ new ConcurrentHashMap<InCallPluginUpdateListener, Boolean>(8, 0.9f, 1));
private AudioModeProvider mAudioModeProvider;
private StatusBarNotifier mStatusBarNotifier;
@@ -243,6 +254,8 @@ public class InCallPresenter implements CallList.Listener,
// This only gets called by the service so this is okay.
mServiceConnected = true;
+ CallMethodHelper.subscribe(AMBIENT_SUBSCRIPTION_ID, this);
+
// The final thing we do in this set up is add ourselves as a listener to CallList. This
// will kick off an update and the whole process can start.
mCallList.addListener(this);
@@ -532,6 +545,30 @@ public class InCallPresenter implements CallList.Listener,
wakeUpScreen();
}
+ @Override
+ public void onChanged(HashMap<ComponentName, CallMethodInfo> callMethodInfo) {
+ if (DEBUG) Log.i(this, "InCall plugins updated");
+ // Update ContactInfoCache then notify listeners
+ final CallList calls = CallList.getInstance();
+ final Call call = calls.getFirstCall();
+ if (call != null && mContactInfoCache != null) {
+ mContactInfoCache.refreshPluginInfo(call, this);
+ }
+ }
+
+ @Override
+ public void onContactInfoComplete(String callId, ContactInfoCache.ContactCacheEntry entry) {
+ if (DEBUG) Log.i(this, "onContactInfoComplete");
+ for (InCallPluginUpdateListener listener : mInCallPluginUpdateListeners) {
+ listener.onInCallPluginUpdated();
+ }
+ }
+
+ @Override
+ public void onImageLoadComplete(String callId, ContactInfoCache.ContactCacheEntry entry) {
+ // Stub
+ }
+
/**
* Given the call list, return the state in which the in-call screen should be.
*/
@@ -664,6 +701,17 @@ public class InCallPresenter implements CallList.Listener,
}
}
+ public void addInCallPluginUpdateListener(InCallPluginUpdateListener listener) {
+ Preconditions.checkNotNull(listener);
+ mInCallPluginUpdateListeners.add(listener);
+ }
+
+ public void removeInCallPluginUpdateListener(InCallPluginUpdateListener listener) {
+ if (listener != null) {
+ mInCallPluginUpdateListeners.remove(listener);
+ }
+ }
+
public ProximitySensor getProximitySensor() {
return mProximitySensor;
}
@@ -1394,6 +1442,9 @@ public class InCallPresenter implements CallList.Listener,
mCanAddCallListeners.clear();
mOrientationListeners.clear();
mInCallEventListeners.clear();
+ mInCallPluginUpdateListeners.clear();
+
+ CallMethodHelper.unsubscribe(AMBIENT_SUBSCRIPTION_ID);
Log.d(this, "Finished InCallPresenter.CleanUp");
}
@@ -1773,6 +1824,10 @@ public class InCallPresenter implements CallList.Listener,
public void onDeviceOrientationChanged(int orientation);
}
+ public interface InCallPluginUpdateListener {
+ public void onInCallPluginUpdated();
+ }
+
/**
* Interface implemented by classes that need to know about events which occur within the
* In-Call UI. Used as a means of communicating between fragments that make up the UI.
diff --git a/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java b/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java
index aa22d972..ad4aef37 100644
--- a/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java
+++ b/src/com/android/incallui/incallapi/InCallPluginInfoAsyncTask.java
@@ -30,6 +30,8 @@ import android.provider.ContactsContract.Data;
import android.text.TextUtils;
import android.util.Log;
import com.android.phone.common.ambient.AmbientConnection;
+import com.android.phone.common.incall.CallMethodHelper;
+import com.android.phone.common.incall.CallMethodInfo;
import com.cyanogen.ambient.common.api.AmbientApiClient;
import com.cyanogen.ambient.incall.InCallApi;
import com.cyanogen.ambient.incall.InCallServices;
@@ -85,11 +87,8 @@ public class InCallPluginInfoAsyncTask extends AsyncTask<Void, Void, List<InCall
List<InCallPluginInfo.Builder> inCallPluginInfoBuilderList =
new ArrayList<InCallPluginInfo.Builder>();
Map<String, Integer> pluginIndex = new HashMap<String, Integer>();
- AmbientApiClient client = AmbientConnection.CLIENT.get(mContext.getApplicationContext());
- InCallApi inCallServices = InCallServices.getInstance();
- List<ComponentName> plugins = inCallServices.getInstalledPlugins(client).await().components;
- MimeTypeListResult mimeTypeListResult =
- inCallServices.getVideoCallableMimeTypeList(client).await();
+ HashMap<ComponentName, CallMethodInfo> plugins = CallMethodHelper.getAllCallMethods();
+ String mimeTypes = CallMethodHelper.getAllEnabledVideoCallableMimeTypes();
if (mContactInfo == null) {
return inCallPluginList;
@@ -115,12 +114,11 @@ public class InCallPluginInfoAsyncTask extends AsyncTask<Void, Void, List<InCall
mContactInfo.mLookupUri + "\")");
}
- if (mimeTypeListResult != null && mimeTypeListResult.mimeTypeList != null &&
- !mimeTypeListResult.mimeTypeList.isEmpty() && queryUri != null) {
+ if (!TextUtils.isEmpty(mimeTypes) && queryUri != null) {
Cursor cursor = mContext.getContentResolver().query(
queryUri,
CONTACT_PROJECTION,
- constructSelection(mimeTypeListResult.mimeTypeList),
+ constructSelection(mimeTypes),
null,
null);
if (cursor != null) {
@@ -150,75 +148,47 @@ public class InCallPluginInfoAsyncTask extends AsyncTask<Void, Void, List<InCall
// Fill in plugin Info.
if (plugins != null && !plugins.isEmpty()) {
- PackageManager packageManager = mContext.getPackageManager();
- for (ComponentName component : plugins) {
- PluginStatusResult statusResult =
- inCallServices.getPluginStatus(client, component).await();
- MimeTypeResult mimeTypeResult =
- inCallServices.getVideoCallableMimeType(client, component).await();
-
- if (statusResult.status != PluginStatus.ENABLED) {
- // Contact does not have account with this plugin OR plugin is not enabled.
+ InCallApi inCallServices = InCallServices.getInstance();
+ for (CallMethodInfo callMethod : plugins.values()) {
+ if (callMethod.mStatus != PluginStatus.ENABLED) {
if (DEBUG) {
- Log.d(TAG, "Contact does not have account with this plugin OR plugin is not"
- + " enabled. Component=" + component.flattenToString());
+ Log.e(TAG, "Plugin not enabled." + callMethod.mComponent.flattenToString());
}
continue;
}
-
- if (!pluginIndex.containsKey(mimeTypeResult.mimeType)) {
+ if (!pluginIndex.containsKey(callMethod.mVideoCallableMimeType)) {
if (DEBUG) {
Log.d(TAG, "Contact does not have account with this plugin, looking up" +
- " invite for Component=" + component.flattenToString() + " and Uri="
- + mContactInfo.mLookupUri.toString());
+ " invite for Component=" + callMethod.mComponent.flattenToString() +
+ " and Uri=" + mContactInfo.mLookupUri.toString());
}
PendingIntentResult inviteResult =
- inCallServices.getInviteIntent(client, component, mContactInfo)
- .await();
+ inCallServices.getInviteIntent(
+ AmbientConnection.CLIENT.get(mContext.getApplicationContext()),
+ callMethod.mComponent, mContactInfo).await();
InCallPluginInfo.Builder infoBuilder =
new InCallPluginInfo.Builder().setUserId(null)
- .setMimeType(mimeTypeResult.mimeType)
+ .setMimeType(callMethod.mVideoCallableMimeType)
.setPluginInviteIntent(inviteResult == null ?
null : inviteResult.intent);
inCallPluginInfoBuilderList.add(infoBuilder);
- pluginIndex.put(mimeTypeResult.mimeType,
+ pluginIndex.put(callMethod.mVideoCallableMimeType,
inCallPluginInfoBuilderList.size() - 1);
}
- Resources pluginResources = null;
+ int index = pluginIndex.get(callMethod.mVideoCallableMimeType);
+ InCallPluginInfo.Builder infoBuilder = inCallPluginInfoBuilderList.get(index);
+ infoBuilder.setPluginComponent(callMethod.mComponent)
+ .setPluginTitle(callMethod.mName)
+ .setPluginColorIcon(callMethod.mBrandIcon)
+ .setPluginSingleColorIcon(callMethod.mSingleColorBrandIcon);
+
try {
- pluginResources = packageManager.getResourcesForApplication(
- component.getPackageName());
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "Plugin isn't installed: " + component);
+ inCallPluginList.add(infoBuilder.build());
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "Failed to build InCallPluginInfo object.");
continue;
}
-
- InCallProviderInfoResult providerInfo =
- inCallServices.getProviderInfo(client, component).await();
- if (providerInfo != null && providerInfo.inCallProviderInfo != null &&
- pluginResources != null) {
- int index = pluginIndex.get(mimeTypeResult.mimeType);
- InCallPluginInfo.Builder infoBuilder = inCallPluginInfoBuilderList.get(index);
- infoBuilder.setPluginComponent(component)
- .setPluginTitle(providerInfo.inCallProviderInfo.getTitle());
-
- try {
- infoBuilder.setPluginColorIcon(pluginResources.getDrawable(
- providerInfo.inCallProviderInfo.getBrandIcon(), null))
- .setPluginSingleColorIcon(pluginResources.getDrawable(
- providerInfo.inCallProviderInfo.getSingleColorBrandIcon(),
- null));
-
- inCallPluginList.add(infoBuilder.build());
- } catch (Resources.NotFoundException e) {
- Log.e(TAG, "Unable to retrieve icon for plugin: " + component);
- continue;
- } catch (IllegalStateException e) {
- Log.e(TAG, "Failed to build InCallPluginInfo object.");
- continue;
- }
- }
}
}
return inCallPluginList;
@@ -234,11 +204,11 @@ public class InCallPluginInfoAsyncTask extends AsyncTask<Void, Void, List<InCall
}
}
- private String constructSelection(List<String> mimeTypesList) {
+ private String constructSelection(String mimeTypes) {
StringBuilder selection = new StringBuilder();
- if (mimeTypesList != null && !mimeTypesList.isEmpty()) {
+ if (!TextUtils.isEmpty(mimeTypes)) {
selection.append(Data.MIMETYPE + " IN ('");
- selection.append(Joiner.on("', '").skipNulls().join(mimeTypesList));
+ selection.append(mimeTypes);
selection.append("') AND " + Data.DATA1 + " NOT NULL");
}
return selection.toString();