summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Bird <sbird@cyngn.com>2016-06-13 19:27:39 (GMT)
committerStephen Bird <sbird@cyngn.com>2016-06-13 19:27:43 (GMT)
commit59574f3875747ebce0515bff9e0aa34c3725bc3b (patch)
tree755e8812af7160c3c3ebe1c9df2d5353cc2b809a
parent8e21a141a5bcd4a058c6ec0ede38c92866a698ba (diff)
downloadandroid_packages_apps_PhoneCommon-59574f3875747ebce0515bff9e0aa34c3725bc3b.zip
android_packages_apps_PhoneCommon-59574f3875747ebce0515bff9e0aa34c3725bc3b.tar.gz
android_packages_apps_PhoneCommon-59574f3875747ebce0515bff9e0aa34c3725bc3b.tar.bz2
AmbientDataSubscription: Allow subscriptions to run different queries
If a plugin is disabled or enabled, let our subscriptions run different ambient queries. This is to address situations where extra work is done when the plugin is disabled. Change-Id: I8c95d58fa55761121481db4730e8d4ece2a2d14a Ticket: CD-682
-rw-r--r--src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java34
-rw-r--r--src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java8
-rw-r--r--src-ambient/com/android/phone/common/incall/DialerDataSubscription.java33
3 files changed, 68 insertions, 7 deletions
diff --git a/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java b/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java
index 4227239..2fee4cd 100644
--- a/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java
+++ b/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java
@@ -75,15 +75,25 @@ public abstract class AmbientDataSubscription<M> {
mDataHasBeenBroadcastPreviously = true;
} else {
for (ComponentName cn : installedPlugins) {
- ArrayList<TypedPendingResult> apiCallbacks = new ArrayList<>();
getPluginInfo().put(cn, getNewModObject(cn));
- requestedModInfo(apiCallbacks, cn);
- executeAll(apiCallbacks, cn);
+ getPluginStatus(cn);
}
}
}
};
+ public void getDisabledModInfo(ComponentName cn) {
+ ArrayList<TypedPendingResult> apiCallbacks = new ArrayList<>();
+ disabledModInfo(apiCallbacks, cn);
+ executeAll(apiCallbacks, cn);
+ }
+
+ public void getEnabledModInfo(ComponentName cn) {
+ ArrayList<TypedPendingResult> apiCallbacks = new ArrayList<>();
+ enabledModInfo(apiCallbacks, cn);
+ executeAll(apiCallbacks, cn);
+ }
+
public AmbientDataSubscription(Context context) {
mContext = context;
mClient = AmbientConnection.CLIENT.get(context);
@@ -115,14 +125,30 @@ public abstract class AmbientDataSubscription<M> {
/**
* Gets the required queries for all our plugins
*
+ * @param componentName ComponentName of the plugin we will be querying
+ */
+ protected abstract void getPluginStatus(ComponentName componentName);
+
+ /**
+ * Gets the enabled queries for all our plugins
+ *
* @param queries ArrayList for us to add TypedPendingResults to
* @param componentName ComponentName of the plugin we will be querying
*/
- protected abstract void requestedModInfo(ArrayList<TypedPendingResult> queries,
+ protected abstract void enabledModInfo(ArrayList<TypedPendingResult> queries,
ComponentName componentName);
/**
+ * Gets the disabled queries for all our plugins
+ *
+ * @param queries ArrayList for us to add TypedPendingResults to
+ * @param componentName ComponentName of the plugin we will be querying
+ */
+ protected abstract void disabledModInfo(ArrayList<TypedPendingResult> queries,
+ ComponentName componentName);
+
+ /**
* Action that takes place when a refresh is requested.
*/
protected abstract void onRefreshRequested();
diff --git a/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java b/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
index a96047b..762cf22 100644
--- a/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
+++ b/src-ambient/com/android/phone/common/incall/ContactsDataSubscription.java
@@ -93,7 +93,13 @@ public class ContactsDataSubscription extends DialerDataSubscription {
}
@Override
- protected void requestedModInfo(ArrayList<TypedPendingResult> queries,
+ protected void disabledModInfo(ArrayList<TypedPendingResult> queries,
+ ComponentName componentName) {
+ // Stubbed out, Contacts doesn't do anything if we don't have a plugin enabled.
+ }
+
+ @Override
+ protected void enabledModInfo(ArrayList<TypedPendingResult> queries,
ComponentName componentName) {
queries.add(InCallQueries.getCallMethodInfo(mClient, componentName));
diff --git a/src-ambient/com/android/phone/common/incall/DialerDataSubscription.java b/src-ambient/com/android/phone/common/incall/DialerDataSubscription.java
index 5fd4a23..441e408 100644
--- a/src-ambient/com/android/phone/common/incall/DialerDataSubscription.java
+++ b/src-ambient/com/android/phone/common/incall/DialerDataSubscription.java
@@ -27,6 +27,7 @@ import com.android.phone.common.incall.api.InCallQueries;
import com.android.phone.common.incall.api.InCallResults;
import com.android.phone.common.nudge.api.NudgeQueries;
import com.cyanogen.ambient.common.api.Result;
+import com.cyanogen.ambient.common.api.ResultCallback;
import com.cyanogen.ambient.discovery.results.BundleResult;
import com.cyanogen.ambient.discovery.util.NudgeKey;
import com.cyanogen.ambient.incall.extension.GetCreditInfoResult;
@@ -96,11 +97,30 @@ public class DialerDataSubscription extends AmbientDataSubscription<CallMethodIn
}
@Override
- protected void requestedModInfo(ArrayList<TypedPendingResult> queries,
+ protected void getPluginStatus(final ComponentName componentName) {
+ InCallQueries.getCallMethodStatus(mClient, componentName).setResultCallback(
+ new ResultCallback<PluginStatusResult>() {
+ @Override
+ public void onResult(PluginStatusResult result) {
+ CallMethodInfo cmi = getPluginInfo().get(componentName);
+ InCallResults.gotStatus(cmi, result);
+ switch (cmi.mStatus) {
+ case PluginStatus.ENABLED:
+ getEnabledModInfo(componentName);
+ break;
+ case PluginStatus.DISABLED:
+ getDisabledModInfo(componentName);
+ break;
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void enabledModInfo(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));
@@ -118,6 +138,15 @@ public class DialerDataSubscription extends AmbientDataSubscription<CallMethodIn
}
@Override
+ protected void disabledModInfo(ArrayList<TypedPendingResult> queries,
+ ComponentName componentName) {
+
+ queries.add(InCallQueries.getCallMethodInfo(mClient, componentName));
+ queries.add(InCallQueries.getSettingsIntent(mClient, componentName));
+ }
+
+
+ @Override
protected CallMethodInfo getNewModObject(ComponentName componentName) {
CallMethodInfo callMethodInfo = new CallMethodInfo();
callMethodInfo.mComponent = componentName;