aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Vidal <lvidal@cyngn.com>2016-04-08 13:19:48 -0700
committerLuis Vidal <lvidal@cyngn.com>2016-04-08 13:19:48 -0700
commit34bf4866db96a1b250edc05e6e0b0fdb296f0aae (patch)
tree49fcf5da6aa1b50f149395780fa0edbd78d00084
parentbaaf4a1bafb652b5d49e739e5378087144a6e410 (diff)
downloadvendor_cmsdk-34bf4866db96a1b250edc05e6e0b0fdb296f0aae.zip
vendor_cmsdk-34bf4866db96a1b250edc05e6e0b0fdb296f0aae.tar.gz
vendor_cmsdk-34bf4866db96a1b250edc05e6e0b0fdb296f0aae.tar.bz2
Fix nomenclature for RequestInfo types [1/2]
- Renamed TYPE_GEO_LOCATION_REQ to TYPE_WEATHER_BY_GEO_LOCATION_REQ and TYPE_WEATHER_LOCATION_REQ to TYPE_WEATHER_BY_WEATHER_LCATION_REQ - Prevent null argument on setter methods. Documentation updated to warn user of IllegalArgumentException if null is passed Change-Id: I6ba8fb7fb3a10d8c964414b58e00d9ce77a74e84 TICKET: CYNGNOS-2377
-rw-r--r--api/cm_current.txt4
-rw-r--r--cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java8
-rw-r--r--sdk/src/java/cyanogenmod/weather/RequestInfo.java54
-rw-r--r--sdk/src/java/cyanogenmod/weatherservice/ServiceRequest.java8
-rw-r--r--system-api/cm_system-current.txt4
5 files changed, 46 insertions, 32 deletions
diff --git a/api/cm_current.txt b/api/cm_current.txt
index 4242d32..b0e7678 100644
--- a/api/cm_current.txt
+++ b/api/cm_current.txt
@@ -1335,9 +1335,9 @@ package cyanogenmod.weather {
method public cyanogenmod.weather.WeatherLocation getWeatherLocation();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<cyanogenmod.weather.RequestInfo> CREATOR;
- field public static final int TYPE_GEO_LOCATION_REQ = 1; // 0x1
field public static final int TYPE_LOOKUP_CITY_NAME_REQ = 3; // 0x3
- field public static final int TYPE_WEATHER_LOCATION_REQ = 2; // 0x2
+ field public static final int TYPE_WEATHER_BY_GEO_LOCATION_REQ = 1; // 0x1
+ field public static final int TYPE_WEATHER_BY_WEATHER_LOCATION_REQ = 2; // 0x2
}
public final class WeatherInfo implements android.os.Parcelable {
diff --git a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java
index aa8358e..cf79c9b 100644
--- a/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java
+++ b/cm/lib/main/java/org/cyanogenmod/platform/internal/CMWeatherManagerService.java
@@ -91,8 +91,8 @@ public class CMWeatherManagerService extends SystemService{
final int requestType = requestInfo.getRequestType();
switch (requestType) {
- case RequestInfo.TYPE_GEO_LOCATION_REQ:
- case RequestInfo.TYPE_WEATHER_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
if (!isValidRequestInfoState(requestType, state)) {
//We received an invalid state, silently disregard the request
mIsProcessingRequest = false;
@@ -142,8 +142,8 @@ public class CMWeatherManagerService extends SystemService{
private boolean isValidRequestInfoState(int requestType, int state) {
switch (requestType) {
- case RequestInfo.TYPE_GEO_LOCATION_REQ:
- case RequestInfo.TYPE_WEATHER_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
switch (state) {
case CMWeatherManager.WEATHER_REQUEST_COMPLETED:
case CMWeatherManager.WEATHER_REQUEST_SUBMITTED_TOO_SOON:
diff --git a/sdk/src/java/cyanogenmod/weather/RequestInfo.java b/sdk/src/java/cyanogenmod/weather/RequestInfo.java
index 4086c62..bb05301 100644
--- a/sdk/src/java/cyanogenmod/weather/RequestInfo.java
+++ b/sdk/src/java/cyanogenmod/weather/RequestInfo.java
@@ -42,11 +42,11 @@ public final class RequestInfo implements Parcelable {
/**
* A request to update the weather data using a geographical {@link android.location.Location}
*/
- public static final int TYPE_GEO_LOCATION_REQ = 1;
+ public static final int TYPE_WEATHER_BY_GEO_LOCATION_REQ = 1;
/**
* A request to update the weather data using a {@link WeatherLocation}
*/
- public static final int TYPE_WEATHER_LOCATION_REQ = 2;
+ public static final int TYPE_WEATHER_BY_WEATHER_LOCATION_REQ = 2;
/**
* A request to look up a city name
@@ -70,9 +70,13 @@ public final class RequestInfo implements Parcelable {
/**
* Sets the city name and identifies this request as a {@link #TYPE_LOOKUP_CITY_NAME_REQ}
- * request. If set, will null out the location and weather location.
+ * request. If set, will null out the location and weather location. Attempting to set
+ * a null city name will get you an IllegalArgumentException
*/
public Builder setCityName(String cityName) {
+ if (cityName == null) {
+ throw new IllegalArgumentException("City name can't be null");
+ }
this.mCityName = cityName;
this.mRequestType = TYPE_LOOKUP_CITY_NAME_REQ;
this.mLocation = null;
@@ -81,26 +85,36 @@ public final class RequestInfo implements Parcelable {
}
/**
- * Sets the Location and identifies this request as a {@link #TYPE_GEO_LOCATION_REQ}. If
- * set, will null out the city name and weather location.
+ * Sets the Location and identifies this request as a
+ * {@link #TYPE_WEATHER_BY_GEO_LOCATION_REQ}. If set, will null out the city name and
+ * weather location. Attempting to set a null location will get you an
+ * IllegalArgumentException
*/
public Builder setLocation(Location location) {
+ if (location == null) {
+ throw new IllegalArgumentException("Location can't be null");
+ }
this.mLocation = new Location(location);
this.mCityName = null;
this.mWeatherLocation = null;
- this.mRequestType = TYPE_GEO_LOCATION_REQ;
+ this.mRequestType = TYPE_WEATHER_BY_GEO_LOCATION_REQ;
return this;
}
/**
* Sets the weather location and identifies this request as a
- * {@link #TYPE_WEATHER_LOCATION_REQ}. If set, will null out the location and city name
+ * {@link #TYPE_WEATHER_BY_WEATHER_LOCATION_REQ}. If set, will null out the location and
+ * city name. Attempting to set a null weather location will get you an
+ * IllegalArgumentException
*/
public Builder setWeatherLocation(WeatherLocation weatherLocation) {
+ if (weatherLocation == null) {
+ throw new IllegalArgumentException("WeatherLocation can't be null");
+ }
this.mWeatherLocation = weatherLocation;
this.mLocation = null;
this.mCityName = null;
- this.mRequestType = TYPE_WEATHER_LOCATION_REQ;
+ this.mRequestType = TYPE_WEATHER_BY_WEATHER_LOCATION_REQ;
return this;
}
@@ -130,8 +144,8 @@ public final class RequestInfo implements Parcelable {
*/
public Builder queryOnly() {
switch (mRequestType) {
- case TYPE_GEO_LOCATION_REQ:
- case TYPE_WEATHER_LOCATION_REQ:
+ case TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
this.mIsQueryOnly = true;
break;
default:
@@ -175,11 +189,11 @@ public final class RequestInfo implements Parcelable {
mKey = parcel.readInt();
mRequestType = parcel.readInt();
switch (mRequestType) {
- case TYPE_GEO_LOCATION_REQ:
+ case TYPE_WEATHER_BY_GEO_LOCATION_REQ:
mLocation = Location.CREATOR.createFromParcel(parcel);
mTempUnit = parcel.readInt();
break;
- case TYPE_WEATHER_LOCATION_REQ:
+ case TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
mWeatherLocation = WeatherLocation.CREATOR.createFromParcel(parcel);
mTempUnit = parcel.readInt();
break;
@@ -238,8 +252,8 @@ public final class RequestInfo implements Parcelable {
*/
public int getTemperatureUnit() {
switch (mRequestType) {
- case TYPE_GEO_LOCATION_REQ:
- case TYPE_WEATHER_LOCATION_REQ:
+ case TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
return mTempUnit;
default:
return -1;
@@ -253,8 +267,8 @@ public final class RequestInfo implements Parcelable {
*/
public boolean isQueryOnlyWeatherRequest() {
switch (mRequestType) {
- case TYPE_GEO_LOCATION_REQ:
- case TYPE_WEATHER_LOCATION_REQ:
+ case TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
return mIsQueryOnly;
default:
return false;
@@ -287,11 +301,11 @@ public final class RequestInfo implements Parcelable {
dest.writeInt(mKey);
dest.writeInt(mRequestType);
switch (mRequestType) {
- case TYPE_GEO_LOCATION_REQ:
+ case TYPE_WEATHER_BY_GEO_LOCATION_REQ:
mLocation.writeToParcel(dest, 0);
dest.writeInt(mTempUnit);
break;
- case TYPE_WEATHER_LOCATION_REQ:
+ case TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
mWeatherLocation.writeToParcel(dest, 0);
dest.writeInt(mTempUnit);
break;
@@ -311,7 +325,7 @@ public final class RequestInfo implements Parcelable {
StringBuilder builder = new StringBuilder();
builder.append("{ Request for ");
switch (mRequestType) {
- case TYPE_GEO_LOCATION_REQ:
+ case TYPE_WEATHER_BY_GEO_LOCATION_REQ:
builder.append("Location: ").append(mLocation);
builder.append(" Temp Unit: ");
if (mTempUnit == WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT) {
@@ -320,7 +334,7 @@ public final class RequestInfo implements Parcelable {
builder.append(" Celsius");
}
break;
- case TYPE_WEATHER_LOCATION_REQ:
+ case TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
builder.append("WeatherLocation: ").append(mWeatherLocation);
builder.append(" Temp Unit: ");
if (mTempUnit == WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT) {
diff --git a/sdk/src/java/cyanogenmod/weatherservice/ServiceRequest.java b/sdk/src/java/cyanogenmod/weatherservice/ServiceRequest.java
index e43218d..bc2f38d 100644
--- a/sdk/src/java/cyanogenmod/weatherservice/ServiceRequest.java
+++ b/sdk/src/java/cyanogenmod/weatherservice/ServiceRequest.java
@@ -56,8 +56,8 @@ public final class ServiceRequest {
try {
final int requestType = mInfo.getRequestType();
switch (requestType) {
- case RequestInfo.TYPE_GEO_LOCATION_REQ:
- case RequestInfo.TYPE_WEATHER_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
if (result.getWeatherInfo() == null) {
throw new IllegalStateException("The service request result does not"
+ " contain a valid WeatherInfo object");
@@ -91,8 +91,8 @@ public final class ServiceRequest {
try {
final int requestType = mInfo.getRequestType();
switch (requestType) {
- case RequestInfo.TYPE_GEO_LOCATION_REQ:
- case RequestInfo.TYPE_WEATHER_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_GEO_LOCATION_REQ:
+ case RequestInfo.TYPE_WEATHER_BY_WEATHER_LOCATION_REQ:
mClient.setServiceRequestState(mInfo, null,
CMWeatherManager.WEATHER_REQUEST_FAILED);
break;
diff --git a/system-api/cm_system-current.txt b/system-api/cm_system-current.txt
index 4242d32..b0e7678 100644
--- a/system-api/cm_system-current.txt
+++ b/system-api/cm_system-current.txt
@@ -1335,9 +1335,9 @@ package cyanogenmod.weather {
method public cyanogenmod.weather.WeatherLocation getWeatherLocation();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<cyanogenmod.weather.RequestInfo> CREATOR;
- field public static final int TYPE_GEO_LOCATION_REQ = 1; // 0x1
field public static final int TYPE_LOOKUP_CITY_NAME_REQ = 3; // 0x3
- field public static final int TYPE_WEATHER_LOCATION_REQ = 2; // 0x2
+ field public static final int TYPE_WEATHER_BY_GEO_LOCATION_REQ = 1; // 0x1
+ field public static final int TYPE_WEATHER_BY_WEATHER_LOCATION_REQ = 2; // 0x2
}
public final class WeatherInfo implements android.os.Parcelable {