diff --git a/README.md b/README.md index 2d76829..1232918 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,8 @@ Mappings as of this writing (RAM is a ceiling): | | 1.8GHz+ | 2013 | | 2GB| | 2013 | | 3GB| | 2014 | -| more| | 2015 | +| 5GB| | 2015 | +| more| | 2016 | ## Integration diff --git a/yearclass/src/main/java/com/facebook/device/yearclass/YearClass.java b/yearclass/src/main/java/com/facebook/device/yearclass/YearClass.java index ad07bb7..8295e36 100644 --- a/yearclass/src/main/java/com/facebook/device/yearclass/YearClass.java +++ b/yearclass/src/main/java/com/facebook/device/yearclass/YearClass.java @@ -23,6 +23,7 @@ public class YearClass { public static final int CLASS_2013 = 2013; public static final int CLASS_2014 = 2014; public static final int CLASS_2015 = 2015; + public static final int CLASS_2016 = 2016; private static final long MB = 1024 * 1024; private static final int MHZ_IN_KHZ = 1000; @@ -78,7 +79,10 @@ private static int categorizeByYear2016Method(Context c) { if (totalRam <= 2048 * MB) { return CLASS_2013; } - return totalRam <= 3 * 1024 * MB ? CLASS_2014 : CLASS_2015; + if (totalRam <= 3 * 1024 * MB) { + return CLASS_2014; + } + return totalRam <= 5 * 1024 * MB ? CLASS_2015 : CLASS_2016; } /** diff --git a/yearclass/src/test/java/com/facebook/device/yearclass/YearClassTest.java b/yearclass/src/test/java/com/facebook/device/yearclass/YearClassTest.java index 5fd712a..eac617a 100644 --- a/yearclass/src/test/java/com/facebook/device/yearclass/YearClassTest.java +++ b/yearclass/src/test/java/com/facebook/device/yearclass/YearClassTest.java @@ -97,6 +97,23 @@ public void testTotalRAM() { assertEquals(YearClass.CLASS_2013, yearClass); } + @PrepareForTest(DeviceInfo.class) + @Test + public void testGetYearCategoryS7() { + // CPU, frequency, RAM, and YearClass values from Samsung Galaxy Note8 (USA edition). + int yearClass = getYearClass(8, 2350000, 6144L * 1024 * 1024); + assertEquals(YearClass.CLASS_2016, yearClass); + } + + @PrepareForTest(DeviceInfo.class) + @Test + public void testTotalRAM() { + //Test with only total RAM information available. + int yearClass = getYearClass(DeviceInfo.DEVICEINFO_UNKNOWN, + DeviceInfo.DEVICEINFO_UNKNOWN, 6144L * 1024 * 1024); + assertEquals(YearClass.CLASS_2016, yearClass); + } + private int getYearClass(int numCores, int maxFreqKHz, long memoryBytes) { mockStatic(DeviceInfo.class); when(DeviceInfo.getNumberOfCPUCores()).thenReturn(numCores);