cmsdk: Return UNKNOWN for impossible sdk ints.
Change-Id: I77a44abba0db223b031d6714c4fd8beb03a43cdc
This commit is contained in:
parent
6714bfe38b
commit
06fc4498e4
@ -17,6 +17,7 @@
|
||||
package cyanogenmod.os;
|
||||
|
||||
import android.os.SystemProperties;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
|
||||
/**
|
||||
@ -84,9 +85,13 @@ public class Build {
|
||||
/**
|
||||
* Retrieve the name for the SDK int
|
||||
* @param sdkInt
|
||||
* @return name of the SDK int
|
||||
* @return name of the SDK int, {@link #UNKNOWN) if not known
|
||||
*/
|
||||
public static String getNameForSDKInt(int sdkInt) {
|
||||
return sdkMap.get(sdkInt);
|
||||
final String name = sdkMap.get(sdkInt);
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -56,4 +56,11 @@ public class BuildTest extends AndroidTestCase {
|
||||
}
|
||||
assertEquals(0, i);
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testSdkLevelRetrieveNameImpossible() {
|
||||
String name = Build.getNameForSDKInt(Integer.MAX_VALUE);
|
||||
assertNotNull(name);
|
||||
assertEquals(Build.UNKNOWN, name);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user