diff options
author | Luis Vidal <lvidal@cyngn.com> | 2016-06-16 17:25:29 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-06-17 15:12:38 -0700 |
commit | 46bed1698db0f663c3950bff294ad1e984e41859 (patch) | |
tree | eea5af307e86c3700ba7fac445175f28291cd70f /sdk/src/java/cyanogenmod | |
parent | ee2dc2db08421b892605c48e28fa3965cf0b82ed (diff) | |
download | vendor_cmsdk-46bed1698db0f663c3950bff294ad1e984e41859.zip vendor_cmsdk-46bed1698db0f663c3950bff294ad1e984e41859.tar.gz vendor_cmsdk-46bed1698db0f663c3950bff294ad1e984e41859.tar.bz2 |
cmsdk: Prevent NPE in CMWeatherManager
Verify that we have an instance of to the weather manager service
before we try to register/unregister a listener or query the
current weather provider.
Change-Id: Iec09073615f85626c6f64e4a55758aae52231ca8
Diffstat (limited to 'sdk/src/java/cyanogenmod')
-rw-r--r-- | sdk/src/java/cyanogenmod/weather/CMWeatherManager.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java index a5f0dd2..b351f8a 100644 --- a/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java +++ b/sdk/src/java/cyanogenmod/weather/CMWeatherManager.java @@ -246,6 +246,8 @@ public class CMWeatherManager { */ public void registerWeatherServiceProviderChangeListener( @NonNull WeatherServiceProviderChangeListener listener) { + if (sWeatherManagerService == null) return; + synchronized (mProviderChangedListeners) { if (mProviderChangedListeners.contains(listener)) { throw new IllegalArgumentException("Listener already registered"); @@ -267,6 +269,8 @@ public class CMWeatherManager { */ public void unregisterWeatherServiceProviderChangeListener( @NonNull WeatherServiceProviderChangeListener listener) { + if (sWeatherManagerService == null) return; + synchronized (mProviderChangedListeners) { if (!mProviderChangedListeners.contains(listener)) { throw new IllegalArgumentException("Listener was never registered"); @@ -287,6 +291,8 @@ public class CMWeatherManager { * @return the service's label */ public String getActiveWeatherServiceProviderLabel() { + if (sWeatherManagerService == null) return null; + try { return sWeatherManagerService.getActiveWeatherServiceProviderLabel(); } catch(RemoteException e){ |