You should get the value of "ro.build.product". This is how you should get the codename of a device:
java
public static String getCodename() {
String value = Build.DEVICE;
try {
final Class<?> sp = Class.forName("android.os.SystemProperties");
final Method get = sp.getMethod("get", String.class);
value = (String) get.invoke(null, "ro.build.product");
} catch (Exception ignored) {
}
return value;
}