package fuzion24.device.vulnerability.util;

import android.os.Build;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by fuzion24 on 9/21/15.
 */
public class DeviceInfo {

    private final String kernelVersion;
    private final String buildManufacturer;
    private final String buildBrand;
    private final String buildModel;
    private final String buildRelease;
    private final String buildSDK;
    private final String buildFingerPrint;


    private final String buildID;


    private DeviceInfo(String kVer,
                       String bManufacturer,
                       String bBrand,
                       String bModel,
                       String bRelease,
                       String bSDK,
                       String bFingerPrint,
                       String bID){
        this.kernelVersion = kVer;
        this.buildManufacturer = bManufacturer;
        this.buildBrand = bBrand;
        this.buildModel = bModel;
        this.buildRelease = bRelease;
        this.buildSDK = bSDK;
        this.buildFingerPrint = bFingerPrint;
        this.buildID = bID;
    }

    public static DeviceInfo getDeviceInfo() {

        String kVer = readKernelVersion();
        String bManufac = Build.MANUFACTURER;
        String bBrand = Build.BRAND;
        String bModel = Build.MODEL;
        String bRelease = Build.VERSION.RELEASE;
        String bSdk = Build.VERSION.SDK;
        String bFingerPrint = Build.FINGERPRINT;
        String bID = Build.ID;

        return new DeviceInfo(kVer,
                bManufac,
                bBrand,
                bModel,
                bRelease,
                bSdk,
                bFingerPrint,
                bID
                );
    }

    public static String readKernelVersion() {
        return System.getProperty("os.version");
    }


    public String getKernelVersion() {
        return kernelVersion;
    }

    public String getBuildManufacturer() {
        return buildManufacturer;
    }

    public String getBuildBrand() {
        return buildBrand;
    }

    public String getBuildModel() {
        return buildModel;
    }

    public String getBuildRelease() {
        return buildRelease;
    }

    public String getBuildSDK() {
        return buildSDK;
    }

    public String getBuildFingerPrint() {
        return buildFingerPrint;
    }

    public String getBuildID() {
        return buildID;
    }
}

@@ -503,16 +503,230 @@
 rPrint;%0A
+    private final String buildCpuABI;%0A    private final String buildCpuABI2;%0A    private final String%5B%5D supported32BitABIS;%0A    private final String%5B%5D supported64BitABIS;%0A    private final String%5B%5D supportedABIS;%0A%0A
 %0A%0A    pr
@@ -1065,16 +1065,222 @@
 ring bID
+,%0A                       String bCPUABI,%0A                       String bCPUABI2,%0A                       String%5B%5D bCPU32List,%0A                       String%5B%5D bCPU64List,%0A                       String%5B%5D bABIS
 )%7B%0A     
@@ -1563,24 +1563,227 @@
 ldID = bID;%0A
+        this.buildCpuABI  = bCPUABI;%0A        this.buildCpuABI2 = bCPUABI2;%0A        this.supported32BitABIS = bCPU32List;%0A        this.supported64BitABIS = bCPU64List;%0A        this.supportedABIS = bABIS;%0A
     %7D%0A%0A    p
@@ -1845,16 +1845,30 @@
 ng kVer 
+              
 = readKe
@@ -1906,16 +1906,26 @@
 Manufac 
+          
 = Build.
@@ -1960,16 +1960,28 @@
  bBrand 
+            
 = Build.
@@ -2009,16 +2009,28 @@
  bModel 
+            
 = Build.
@@ -2060,16 +2060,26 @@
 Release 
+          
 = Build.
@@ -2115,16 +2115,30 @@
 ng bSdk 
+              
 = Build.
@@ -2178,16 +2178,22 @@
 erPrint 
+      
 = Build.
@@ -2228,19 +2228,556 @@
 bID 
-= Build.ID;
+               = Build.ID;%0A        String bCPUABI            = Build.CPU_ABI;%0A        String bCPUABI2           = Build.CPU_ABI2;%0A        String%5B%5D bCPU32List       = Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_32_BIT_ABIS :  new String%5B%5D%7B%7D;%0A        String%5B%5D bCPU64List       = Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_64_BIT_ABIS :  new String%5B%5D%7B%7D;%0A        String%5B%5D bABIS            = Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.LOLLIPOP ? Build.SUPPORTED_ABIS        :  new String%5B%5D%7B%7D;%0A%0A
 %0A%0A  
@@ -2981,16 +2981,146 @@
      bID
+,%0A                bCPUABI,%0A                bCPUABI2,%0A                bCPU32List,%0A                bCPU64List,%0A                bABIS
 %0A       

Add ABI info to DeviceInfo