summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/lockclock/weather/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/cyanogenmod/lockclock/weather/Utils.java')
-rw-r--r--src/com/cyanogenmod/lockclock/weather/Utils.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/com/cyanogenmod/lockclock/weather/Utils.java b/src/com/cyanogenmod/lockclock/weather/Utils.java
index 411fe29..6c95867 100644
--- a/src/com/cyanogenmod/lockclock/weather/Utils.java
+++ b/src/com/cyanogenmod/lockclock/weather/Utils.java
@@ -19,6 +19,7 @@ package com.cyanogenmod.lockclock.weather;
import android.content.Context;
import android.content.res.Resources;
import com.cyanogenmod.lockclock.R;
+import cyanogenmod.app.CMContextConstants;
import cyanogenmod.providers.WeatherContract;
import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.NOT_AVAILABLE;
@@ -42,6 +43,9 @@ public final class Utils {
private static final double DIRECTION_WEST = 293d;
private static final double DIRECTION_NORTH_WEST = 338d;
+ private static boolean weatherServiceFeatureCached;
+ private static boolean weatherServiceAvailable;
+
/**
* Returns a localized string of the wind direction
* @param context Application context to access resources
@@ -178,4 +182,18 @@ public final class Utils {
return NOT_AVAILABLE;
}
}
+
+ /**
+ * Checks if the CM Weather service is available in this device
+ * @param context
+ * @return true if service is available, false otherwise
+ */
+ public static boolean isWeatherServiceAvailable(Context context) {
+ if (!weatherServiceFeatureCached) {
+ weatherServiceAvailable = context.getPackageManager()
+ .hasSystemFeature(CMContextConstants.CM_WEATHER_SERVICE);
+ weatherServiceFeatureCached = true;
+ }
+ return weatherServiceAvailable;
+ }
}