summaryrefslogtreecommitdiffstats
path: root/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2016-03-31 15:03:11 -0700
committerErica Chang <echang@cyngn.com>2016-04-26 22:38:42 -0700
commitecc708d3c1417b60f316a0387d17f2cf4c67c2b1 (patch)
treefefb202fcf37bb15e301a821b206e02cf0a0e16e /src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
parent33beb0a0b887dbfa9797f7fa97f3cd715bb71a74 (diff)
downloadpackages_apps_PhoneCommon-ecc708d3c1417b60f316a0387d17f2cf4c67c2b1.tar.gz
packages_apps_PhoneCommon-ecc708d3c1417b60f316a0387d17f2cf4c67c2b1.tar.bz2
packages_apps_PhoneCommon-ecc708d3c1417b60f316a0387d17f2cf4c67c2b1.zip
[1/4] Refactor CallMethodHelper
Change-Id: I3b24eedffddbf0960023dc2f1429038e5353de2f
Diffstat (limited to 'src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java')
-rw-r--r--src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java123
1 files changed, 123 insertions, 0 deletions
diff --git a/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java b/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
new file mode 100644
index 0000000..2b38b1e
--- /dev/null
+++ b/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod 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.phone.common.incall;
+
+import android.content.ComponentName;
+import android.content.Context;
+
+import com.android.phone.common.ambient.SingletonHolder;
+import com.android.phone.common.ambient.TypedPendingResult;
+import com.android.phone.common.incall.api.InCallListeners;
+import com.android.phone.common.incall.api.InCallQueries;
+import com.android.phone.common.nudge.api.NudgeQueries;
+import com.cyanogen.ambient.discovery.util.NudgeKey;
+import com.cyanogen.ambient.incall.extension.InCallContactInfo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ContactsDataSubscription extends DialerDataSubscription {
+
+ public ContactsDataSubscription(Context context) {
+ super(context);
+ }
+
+ private static final SingletonHolder<ContactsDataSubscription, Context> sInstance =
+ new SingletonHolder<ContactsDataSubscription, Context>() {
+
+ @Override
+ protected ContactsDataSubscription create(Context context) {
+ // Let's get started here.
+ return new ContactsDataSubscription(context);
+ }
+ };
+
+
+ public static ContactsDataSubscription get(Context context) {
+ return sInstance.get(context);
+ }
+
+ public static boolean isCreated() {
+ return sInstance.isCreated();
+ }
+
+ public static void init(Context context) {
+ ContactsDataSubscription.get(context).refresh();
+ }
+
+ @Override
+ public void onDynamicRefreshRequested(ArrayList<TypedPendingResult> queries,
+ ComponentName componentName) {
+ queries.add(InCallQueries.getCallMethodAuthenticated(mClient, componentName));
+ queries.add(InCallQueries.getCallMethodAccountHandle(mClient, componentName));
+ }
+
+ @Override
+ protected void enableListeners(CallMethodInfo mod) {
+ InCallListeners.enableAuthListener(this, mod);
+ }
+
+ @Override
+ protected void disableListeners(CallMethodInfo mod) {
+ InCallListeners.disableAuthListener(this, mod);
+ }
+
+ @Override
+ protected void requestedModInfo(ArrayList<TypedPendingResult> queries,
+ ComponentName componentName) {
+
+ queries.add(InCallQueries.getCallMethodInfo(mClient, componentName));
+ queries.add(InCallQueries.getCallMethodStatus(mClient, componentName));
+ queries.add(InCallQueries.getCallMethodMimeType(mClient, componentName));
+ queries.add(InCallQueries.getCallMethodVideoCallableMimeType(mClient, componentName));
+ queries.add(InCallQueries.getCallMethodAuthenticated(mClient, componentName));
+ queries.add(InCallQueries.getLoginIntent(mClient, componentName));
+ queries.add(InCallQueries.getDefaultDirectorySearchIntent(mClient, componentName));
+ queries.add(InCallQueries.getCallMethodImMimeType(mClient, componentName));
+
+ TypedPendingResult fragLogin = NudgeQueries.getNudgeConfig(mClient, mContext, componentName,
+ NudgeKey.INCALL_CONTACT_FRAGMENT_LOGIN);
+ if (fragLogin != null) {
+ queries.add(fragLogin);
+ }
+ TypedPendingResult cardLogin = NudgeQueries.getNudgeConfig(mClient, mContext, componentName,
+ NudgeKey.INCALL_CONTACT_CARD_LOGIN);
+ if (cardLogin != null) {
+ queries.add(cardLogin);
+ }
+ TypedPendingResult cardDownload = NudgeQueries.getNudgeConfig(mClient, mContext,
+ componentName, NudgeKey.INCALL_CONTACT_CARD_DOWNLOAD);
+ if (cardDownload != null) {
+ queries.add(cardDownload);
+ }
+ }
+
+ public static void refreshPendingIntents(InCallContactInfo contactInfo) {
+ // TODO: implement
+ }
+
+ public Set<String> getAllPluginComponentNames() {
+ Set<String> names = new HashSet<String>();
+ HashMap<ComponentName, CallMethodInfo> plugins = this.getPluginInfo();
+ for (ComponentName cn : plugins.keySet()) {
+ names.add(cn.flattenToString());
+ }
+ return names;
+ }
+}