summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-04-29 11:56:44 (GMT)
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-05-10 10:29:37 (GMT)
commit3112fb87dd6977ac36a23e7c4b79abff4a4b34c4 (patch)
tree58ee011461688b5cf7c18d7662f1df97d4d42c9e
parentf6f8b3a845fe4593605a386bcb40d055e0bdda17 (diff)
downloadandroid_packages_apps_PhoneCommon-3112fb87dd6977ac36a23e7c4b79abff4a4b34c4.zip
android_packages_apps_PhoneCommon-3112fb87dd6977ac36a23e7c4b79abff4a4b34c4.tar.gz
android_packages_apps_PhoneCommon-3112fb87dd6977ac36a23e7c4b79abff4a4b34c4.tar.bz2
Cleanup.
Use isEmpty() for emptiness check, and follow naming conventions. Change-Id: I003873f76874f87bbaa321c35b72bd5da2b6cce7
-rw-r--r--src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java41
1 files changed, 20 insertions, 21 deletions
diff --git a/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java b/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java
index dc1aca3..b199a5e 100644
--- a/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java
+++ b/src-ambient/com/android/phone/common/ambient/AmbientDataSubscription.java
@@ -50,39 +50,38 @@ public abstract class AmbientDataSubscription<M> {
// Holder for plugin object
private HashMap<ComponentName, M> mPluginInfo;
- private static boolean mDataHasBeenBroadcastPreviously = false;
+ private static boolean sDataHasBeenBroadcastPreviously = false;
// A list of our registered clients, who all register with the CallMethodReceiver
- private static HashMap<String, PluginChanged> mRegisteredClients = new HashMap<>();
+ private static final HashMap<String, PluginChanged> sRegisteredClients = new HashMap<>();
// A map of our components and if they have have enabled IInterface listeners. This is to keep
// track of if listeners should be added or removed.
- private static HashMap<ComponentName, Boolean> mEnabledListeners = new HashMap<>();
+ private static final HashMap<ComponentName, Boolean> sEnabledListeners = new HashMap<>();
// Wait up to 60 seconds for data to return. Mimicks what PluginBinderManager does.
private static final long TIMEOUT_MILLISECONDS = 60000L;
// Bootstrap is the initial callback to get your installed plugins.
// this is the only item that executes ASAP and has no componentname tied to it
- public ResultCallback BOOTSTRAP = new ResultCallback<Result>() {
+ public final ResultCallback BOOTSTRAP = new ResultCallback<Result>() {
@Override
public void onResult(Result result) {
List<ComponentName> installedPlugins = getPluginComponents(result);
- if (installedPlugins.size() != 0) {
+ if (installedPlugins.isEmpty()) {
+ // We want to tell our subscribers that we have no plugins to worry about
+ broadcast();
+ sDataHasBeenBroadcastPreviously = true;
+ } else {
for (ComponentName cn : installedPlugins) {
ArrayList<TypedPendingResult> apiCallbacks = new ArrayList<>();
getPluginInfo().put(cn, getNewModObject(cn));
requestedModInfo(apiCallbacks, cn);
executeAll(apiCallbacks, cn);
}
- } else {
- // We want to tell our subscribers that we have no plugins to worry about
- broadcast();
- mDataHasBeenBroadcastPreviously = true;
}
}
-
};
public AmbientDataSubscription(Context context) {
@@ -155,21 +154,21 @@ public abstract class AmbientDataSubscription<M> {
protected abstract M getNewModObject(ComponentName componentName);
private void enablePluginListeners(ComponentName cn) {
- if (!mEnabledListeners.containsKey(cn) || !mEnabledListeners.get(cn)) {
+ if (!sEnabledListeners.containsKey(cn) || !sEnabledListeners.get(cn)) {
M plugin = getPluginIfExists(cn);
if (plugin != null) {
enableListeners(plugin);
- mEnabledListeners.put(cn, true);
+ sEnabledListeners.put(cn, true);
}
}
}
private void disablePluginListeners(ComponentName cn) {
- if (mEnabledListeners.containsKey(cn) && mEnabledListeners.get(cn)) {
+ if (sEnabledListeners.containsKey(cn) && sEnabledListeners.get(cn)) {
M plugin = getPluginIfExists(cn);
disableListeners(plugin);
- mEnabledListeners.put(cn, false);
+ sEnabledListeners.put(cn, false);
}
}
@@ -181,7 +180,7 @@ public abstract class AmbientDataSubscription<M> {
@Override
public void run() {
if (DEBUG) Log.d(TAG, "broadcast");
- for (PluginChanged client : mRegisteredClients.values()) {
+ for (PluginChanged client : sRegisteredClients.values()) {
client.onChanged(mPluginInfo);
}
}
@@ -197,9 +196,9 @@ public abstract class AmbientDataSubscription<M> {
* @return boolean isempty
*/
public boolean subscribe(String id, PluginChanged cmr) {
- mRegisteredClients.put(id, cmr);
+ sRegisteredClients.put(id, cmr);
if (DEBUG) Log.v("TAG", "subscribed: " + id);
- return mDataHasBeenBroadcastPreviously;
+ return sDataHasBeenBroadcastPreviously;
}
/**
@@ -208,8 +207,8 @@ public abstract class AmbientDataSubscription<M> {
* @param id of the client to remove
*/
public void unsubscribe(String id) {
- mRegisteredClients.remove(id);
- if (mRegisteredClients.isEmpty()) {
+ sRegisteredClients.remove(id);
+ if (sRegisteredClients.isEmpty()) {
for (ComponentName cn : mPluginInfo.keySet()) {
disablePluginListeners(cn);
}
@@ -282,7 +281,7 @@ public abstract class AmbientDataSubscription<M> {
}
public static boolean infoReady() {
- return mDataHasBeenBroadcastPreviously;
+ return sDataHasBeenBroadcastPreviously;
}
private void maybeBroadcastToSubscribers(ArrayList<PendingResult> apiCallbacks) {
@@ -311,7 +310,7 @@ public abstract class AmbientDataSubscription<M> {
// if it's just a critical broadcast to prevent extra work from our subscribers
// once our long running calls are broadcast then this will be true.
if (!critical) {
- mDataHasBeenBroadcastPreviously = true;
+ sDataHasBeenBroadcastPreviously = true;
}
}
}