diff --git a/yearclass-sample/src/main/java/com/facebook/device/yearclass/sample/MainActivity.java b/yearclass-sample/src/main/java/com/facebook/device/yearclass/sample/MainActivity.java index 4fb4b4c..cf1c8e1 100644 --- a/yearclass-sample/src/main/java/com/facebook/device/yearclass/sample/MainActivity.java +++ b/yearclass-sample/src/main/java/com/facebook/device/yearclass/sample/MainActivity.java @@ -14,6 +14,7 @@ import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; +import android.os.StrictMode; import android.widget.TextView; import com.facebook.device.yearclass.YearClass; @@ -24,6 +25,18 @@ public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { + if (BuildConfig.DEBUG) { + StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() + .detectAll() + .penaltyLog() + .build()); + StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() + .detectAll() + .penaltyLog() + .penaltyDeath() + .build()); + } + super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); diff --git a/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java b/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java index ee9fd23..259d29a 100644 --- a/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java +++ b/yearclass/src/main/java/com/facebook/device/yearclass/DeviceInfo.java @@ -68,6 +68,7 @@ private static int getCoresFromFileInfo(String fileLocation) { InputStream is = new FileInputStream(fileLocation); BufferedReader buf = new BufferedReader(new InputStreamReader(is)); String fileContents = buf.readLine(); + buf.close(); return getCoresFromFileString(fileContents); } catch (IOException e) { return DEVICEINFO_UNKNOWN;