Example usage for android.os Build CPU_ABI2

List of usage examples for android.os Build CPU_ABI2

Introduction

In this page you can find the example usage for android.os Build CPU_ABI2.

Prototype

String CPU_ABI2

To view the source code for android.os Build CPU_ABI2.

Click Source Link

Document

The name of the second instruction set (CPU type + ABI convention) of native code.

Usage

From source file:Main.java

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.FROYO)//from   ww  w.  j  a v a  2 s .  co m
public static String[] getABIList() {
    final boolean hasABI2 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO;
    final String[] abis = new String[hasABI2 ? 2 : 1];
    abis[0] = android.os.Build.CPU_ABI;
    if (hasABI2)
        abis[1] = android.os.Build.CPU_ABI2;
    return abis;
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static String[] getABIList() {
    final String[] abis = new String[2];
    abis[0] = android.os.Build.CPU_ABI;// w  w w  . j a va 2 s  . c  o  m
    abis[1] = android.os.Build.CPU_ABI2;
    return abis;
}

From source file:de.schildbach.wallet.util.CrashReporter.java

public static void appendDeviceInfo(final Appendable report, final Context context) throws IOException {
    final Resources res = context.getResources();
    final android.content.res.Configuration config = res.getConfiguration();
    final ActivityManager activityManager = (ActivityManager) context
            .getSystemService(Context.ACTIVITY_SERVICE);
    final DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
            .getSystemService(Context.DEVICE_POLICY_SERVICE);

    report.append("Device Model: " + Build.MODEL + "\n");
    report.append("Android Version: " + Build.VERSION.RELEASE + "\n");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
        report.append("Android security patch level: ").append(Build.VERSION.SECURITY_PATCH).append("\n");
    report.append("ABIs: ").append(Joiner.on(", ").skipNulls().join(Strings.emptyToNull(Build.CPU_ABI),
            Strings.emptyToNull(Build.CPU_ABI2))).append("\n");
    report.append("Board: " + Build.BOARD + "\n");
    report.append("Brand: " + Build.BRAND + "\n");
    report.append("Device: " + Build.DEVICE + "\n");
    report.append("Display: " + Build.DISPLAY + "\n");
    report.append("Finger Print: " + Build.FINGERPRINT + "\n");
    report.append("Host: " + Build.HOST + "\n");
    report.append("ID: " + Build.ID + "\n");
    report.append("Product: " + Build.PRODUCT + "\n");
    report.append("Tags: " + Build.TAGS + "\n");
    report.append("Time: " + Build.TIME + "\n");
    report.append("Type: " + Build.TYPE + "\n");
    report.append("User: " + Build.USER + "\n");
    report.append("Configuration: " + config + "\n");
    report.append("Screen Layout: size "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK) + " long "
            + (config.screenLayout & android.content.res.Configuration.SCREENLAYOUT_LONG_MASK) + "\n");
    report.append("Display Metrics: " + res.getDisplayMetrics() + "\n");
    report.append("Memory Class: " + activityManager.getMemoryClass() + "/"
            + activityManager.getLargeMemoryClass()
            + (ActivityManagerCompat.isLowRamDevice(activityManager) ? " (low RAM device)" : "") + "\n");
    report.append("Storage Encryption Status: " + devicePolicyManager.getStorageEncryptionStatus() + "\n");
    report.append("Bluetooth MAC: " + bluetoothMac() + "\n");
    report.append("Runtime: ").append(System.getProperty("java.vm.name")).append(" ")
            .append(System.getProperty("java.vm.version")).append("\n");
}

From source file:org.namelessrom.devicecontrol.device.DeviceInformationGeneralFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    addPreferencesFromResource(R.xml.device_information_general);

    final Device device = Device.get();

    // Platform/*from www  .  j  av a  2s  .  c o  m*/
    PreferenceCategory category = (PreferenceCategory) findPreference("platform");

    addPreference(category, KEY_PLATFORM_VERSION, R.string.version, device.platformVersion).setSelectable(true); // selectable because of the easter egg
    addPreference(category, "platform_id", R.string.build_id, device.platformId);
    addPreference(category, "platform_type", R.string.type, device.platformType);
    addPreference(category, "platform_tags", R.string.tags, device.platformTags);
    addPreference(category, "platform_build_date", R.string.build_date, device.platformBuildType);

    // Runtime
    category = (PreferenceCategory) findPreference("runtime");

    addPreference(category, "vm_library", R.string.type, device.vmLibrary);
    addPreference(category, "vm_version", R.string.version, device.vmVersion);

    // Device
    category = (PreferenceCategory) findPreference("device_information");

    // TODO: save / restore / check --> ANDROID ID
    addPreference(category, KEY_ANDROID_ID, R.string.android_id, device.androidId);
    addPreference(category, "device_manufacturer", R.string.manufacturer, device.manufacturer);
    addPreference(category, "device_model", R.string.model, device.model);
    addPreference(category, "device_product", R.string.product, device.product);
    addPreference(category, "device_board", R.string.board, device.board);
    addPreference(category, "device_bootloader", R.string.bootloader, device.bootloader);
    addPreference(category, "device_radio_version", R.string.radio_version, device.radio);

    // eMMC
    category = (PreferenceCategory) findPreference("emmc");
    addPreference(category, "emmc_name", R.string.name, Emmc.get().getName());
    addPreference(category, "emmc_cid", R.string.emmc_cid, Emmc.get().getCid());
    addPreference(category, "emmc_mid", R.string.emmc_mid, Emmc.get().getMid());
    addPreference(category, "emmc_rev", R.string.emmc_rev, Emmc.get().getRev());
    addPreference(category, "emmc_date", R.string.emmc_date, Emmc.get().getDate());
    String tmp = Emmc.get().canBrick() ? getString(R.string.emmc_can_brick_true)
            : getString(R.string.emmc_can_brick_false);
    tmp = String.format("%s\n%s", tmp, getString(R.string.press_learn_more));
    addPreference(category, "emmc_can_brick", R.string.emmc_can_brick, tmp).setSelectable(true);

    // Processor
    category = (PreferenceCategory) findPreference("processor");

    final String cpuAbi = getString(R.string.cpu_abi);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        final int bitResId = Build.SUPPORTED_64_BIT_ABIS.length == 0 ? R.string.bit_32 : R.string.bit_64;
        addPreference(category, "cpu_bit", R.string.arch, getString(bitResId));
        for (int i = 0; i < Build.SUPPORTED_ABIS.length; i++) {
            addPreference(category, String.format("cpu_abi%s", i + 1), cpuAbi + String.valueOf(i + 1),
                    Build.SUPPORTED_ABIS[i]);
        }
    } else {
        //noinspection deprecation
        addPreference(category, "cpu_abi", cpuAbi, Build.CPU_ABI);
        //noinspection deprecation
        addPreference(category, "cpu_abi2", cpuAbi + "2", Build.CPU_ABI2);
    }
    new CpuInfoTask(category).execute();

    // Kernel
    category = (PreferenceCategory) findPreference("kernel");
    new KernelInfoTask(category).execute();

    // Memory
    category = (PreferenceCategory) findPreference("memory");
    new MemoryInfoTask(category).execute();

    if (category.getPreferenceCount() == 0) {
        getPreferenceScreen().removePreference(category);
    }
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "Get some device information", example = "")
@ProtoMethodParam(params = { "" })
public DeviceInfo info() {
    DeviceInfo deviceInfo = new DeviceInfo();

    // density dpi
    DisplayMetrics metrics = new DisplayMetrics();

    //TODO reenable this
    //contextUi.get().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    deviceInfo.screenDpi = metrics.densityDpi;

    // id//from   w  w w .  j ava2  s.  co m
    deviceInfo.androidId = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);

    // imei
    deviceInfo.imei = ((TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE))
            .getDeviceId();

    deviceInfo.versionRelease = Build.VERSION.RELEASE;
    deviceInfo.versionRelease = Build.VERSION.INCREMENTAL;
    deviceInfo.sdk = Build.VERSION.SDK;
    deviceInfo.board = Build.BOARD;
    deviceInfo.brand = Build.BRAND;
    deviceInfo.device = Build.DEVICE;
    deviceInfo.fingerPrint = Build.FINGERPRINT;
    deviceInfo.host = Build.HOST;
    deviceInfo.id = Build.ID;
    deviceInfo.cpuAbi = Build.CPU_ABI;
    deviceInfo.cpuAbi2 = Build.CPU_ABI2;

    return deviceInfo;
}

From source file:de.schildbach.wallet.ui.ReportIssueDialogFragment.java

@SuppressWarnings("deprecation")
private static String[] supportedAbisKitKat() {
    return new String[] { Strings.emptyToNull(Build.CPU_ABI), Strings.emptyToNull(Build.CPU_ABI2) };
}

From source file:syncthing.android.service.SyncthingInstance.java

void ensureBinaries() {
    final String[] abis;
    if (VersionUtils.hasLollipop()) {
        abis = Build.SUPPORTED_ABIS;//from w  w  w  . j  a  va 2 s.  co  m
    } else {
        abis = new String[] { Build.CPU_ABI, Build.CPU_ABI2 };
    }
    String ext = null;
    for (String abi : abis) {
        if (StringUtils.equals(abi, "x86_64")) {
            Timber.i("Found abi %s", abi);
            ext = "amd64";
            break;
        } else if (StringUtils.equals(abi, "x86")) {
            Timber.i("Found abi %s", abi);
            ext = "386";
            break;
        } else if (StringUtils.equals(abi, "armeabi-v7a")) {
            Timber.i("Found abi %s", abi);
            ext = "arm";
            break;
        }
    }
    if (ext == null)
        throw new RuntimeException("Unable to find supported arch in " + Arrays.toString(abis));
    ensureBinary("syncthing" + "." + ext, SyncthingUtils.getSyncthingBinaryPath(this));
    ensureBinary("syncthing-inotify" + "." + ext, SyncthingUtils.getSyncthingInotifyBinaryPath(this));
}

From source file:jp.ne.sakura.kkkon.android.exceptionhandler.testapp.ExceptionHandlerReportApp.java

/** Called when the activity is first created. */
@Override/*  w  w w .  j a v  a 2  s .c o m*/
public void onCreate(Bundle savedInstanceState) {
    final Context context = this.getApplicationContext();

    {
        ExceptionHandler.initialize(context);
        if (ExceptionHandler.needReport()) {
            final String fileName = ExceptionHandler.getBugReportFileAbsolutePath();
            final File file = new File(fileName);
            final File fileZip;
            {
                String strFileZip = file.getAbsolutePath();
                {
                    int index = strFileZip.lastIndexOf('.');
                    if (0 < index) {
                        strFileZip = strFileZip.substring(0, index);
                        strFileZip += ".zip";
                    }
                }
                Log.d(TAG, strFileZip);
                fileZip = new File(strFileZip);
                if (fileZip.exists()) {
                    fileZip.delete();
                }
            }
            if (file.exists()) {
                Log.d(TAG, file.getAbsolutePath());
                InputStream inStream = null;
                ZipOutputStream outStream = null;
                try {
                    inStream = new FileInputStream(file);
                    String strFileName = file.getAbsolutePath();
                    {
                        int index = strFileName.lastIndexOf(File.separatorChar);
                        if (0 < index) {
                            strFileName = strFileName.substring(index + 1);
                        }
                    }
                    Log.d(TAG, strFileName);

                    outStream = new ZipOutputStream(new FileOutputStream(fileZip));
                    byte[] buff = new byte[8124];
                    {
                        ZipEntry entry = new ZipEntry(strFileName);
                        outStream.putNextEntry(entry);

                        int len = 0;
                        while (0 < (len = inStream.read(buff))) {
                            outStream.write(buff, 0, len);
                        }
                        outStream.closeEntry();
                    }
                    outStream.finish();
                    outStream.flush();

                } catch (IOException e) {
                    Log.e(TAG, "got exception", e);
                } finally {
                    if (null != outStream) {
                        try {
                            outStream.close();
                        } catch (Exception e) {
                        }
                    }
                    outStream = null;

                    if (null != inStream) {
                        try {
                            inStream.close();
                        } catch (Exception e) {
                        }
                    }
                    inStream = null;
                }
                Log.i(TAG, "zip created");
            }

            if (file.exists()) {
                // upload or send e-mail
                InputStream inStream = null;
                StringBuilder sb = new StringBuilder();
                try {
                    inStream = new FileInputStream(file);
                    byte[] buff = new byte[8124];
                    int readed = 0;
                    do {
                        readed = inStream.read(buff);
                        for (int i = 0; i < readed; i++) {
                            sb.append((char) buff[i]);
                        }
                    } while (readed >= 0);

                    final String str = sb.toString();
                    Log.i(TAG, str);
                } catch (IOException e) {
                    Log.e(TAG, "got exception", e);
                } finally {
                    if (null != inStream) {
                        try {
                            inStream.close();
                        } catch (Exception e) {
                        }
                    }
                    inStream = null;
                }

                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                final Locale defaultLocale = Locale.getDefault();

                String title = "";
                String message = "";
                String positive = "";
                String negative = "";

                boolean needDefaultLang = true;
                if (null != defaultLocale) {
                    if (defaultLocale.equals(Locale.JAPANESE) || defaultLocale.equals(Locale.JAPAN)) {
                        title = "";
                        message = "?????????";
                        positive = "?";
                        negative = "";
                        needDefaultLang = false;
                    }
                }
                if (needDefaultLang) {
                    title = "ERROR";
                    message = "Got unexpected error. Do you want to send information of error.";
                    positive = "Send";
                    negative = "Cancel";
                }
                alertDialog.setTitle(title);
                alertDialog.setMessage(message);
                alertDialog.setPositiveButton(positive + " mail", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        DefaultUploaderMailClient.upload(context, file,
                                new String[] { "diverKon+sakura@gmail.com" });
                    }
                });
                alertDialog.setNeutralButton(positive + " http", new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        DefaultUploaderWeb.upload(ExceptionHandlerReportApp.this, fileZip,
                                "http://kkkon.sakura.ne.jp/android/bug");
                    }
                });
                alertDialog.setNegativeButton(negative, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface di, int i) {
                        ExceptionHandler.clearReport();
                    }
                });
                alertDialog.show();
            }
            // TODO separate activity for crash report
            //DefaultCheckerAPK.checkAPK( this, null );
        }
        ExceptionHandler.registHandler();
    }

    super.onCreate(savedInstanceState);

    /* Create a TextView and set its content.
     * the text is retrieved by calling a native
     * function.
     */
    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.VERTICAL);

    TextView tv = new TextView(this);
    tv.setText("ExceptionHandler");
    layout.addView(tv);

    Button btn1 = new Button(this);
    btn1.setText("invoke Exception");
    btn1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final int count = 2;
            int[] array = new int[count];
            int value = array[count]; // invoke IndexOutOfBOundsException
        }
    });
    layout.addView(btn1);

    Button btn2 = new Button(this);
    btn2.setText("reinstall apk");
    btn2.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            boolean foundApk = false;
            {
                final String apkPath = context.getPackageCodePath(); // API8
                Log.d(TAG, "PackageCodePath: " + apkPath);
                final File fileApk = new File(apkPath);
                if (fileApk.exists()) {
                    foundApk = true;

                    Intent promptInstall = new Intent(Intent.ACTION_VIEW);
                    promptInstall.setDataAndType(Uri.fromFile(fileApk),
                            "application/vnd.android.package-archive");
                    promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    context.startActivity(promptInstall);
                }
            }

            if (false == foundApk) {
                for (int i = 0; i < 10; ++i) {
                    File fileApk = new File("/data/app/" + context.getPackageName() + "-" + i + ".apk");
                    Log.d(TAG, "check apk:" + fileApk.getAbsolutePath());
                    if (fileApk.exists()) {
                        Log.i(TAG, "apk found. path=" + fileApk.getAbsolutePath());
                        /*
                         * // require parmission
                        {
                        final String strCmd = "pm install -r " + fileApk.getAbsolutePath();
                        try
                        {
                            Runtime.getRuntime().exec( strCmd );
                        }
                        catch ( IOException e )
                        {
                            Log.e( TAG, "got exception", e );
                        }
                        }
                        */
                        Intent promptInstall = new Intent(Intent.ACTION_VIEW);
                        promptInstall.setDataAndType(Uri.fromFile(fileApk),
                                "application/vnd.android.package-archive");
                        promptInstall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        context.startActivity(promptInstall);
                        break;
                    }
                }
            }
        }
    });
    layout.addView(btn2);

    Button btn3 = new Button(this);
    btn3.setText("check apk");
    btn3.setOnClickListener(new View.OnClickListener() {
        private boolean checkApk(final File fileApk, final ZipEntryFilter filter) {
            final boolean[] result = new boolean[1];
            result[0] = true;

            final Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    if (fileApk.exists()) {
                        ZipFile zipFile = null;
                        try {
                            zipFile = new ZipFile(fileApk);
                            List<ZipEntry> list = new ArrayList<ZipEntry>(zipFile.size());
                            for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) {
                                ZipEntry ent = e.nextElement();
                                Log.d(TAG, ent.getName());
                                Log.d(TAG, "" + ent.getSize());
                                final boolean accept = filter.accept(ent);
                                if (accept) {
                                    list.add(ent);
                                }
                            }

                            Log.d(TAG, Build.CPU_ABI); // API 4
                            Log.d(TAG, Build.CPU_ABI2); // API 8

                            final String[] abiArray = { Build.CPU_ABI // API 4
                                    , Build.CPU_ABI2 // API 8
                            };

                            String abiMatched = null;
                            {
                                boolean foundMatched = false;
                                for (final String abi : abiArray) {
                                    if (null == abi) {
                                        continue;
                                    }
                                    if (0 == abi.length()) {
                                        continue;
                                    }

                                    for (final ZipEntry entry : list) {
                                        Log.d(TAG, entry.getName());

                                        final String prefixABI = "lib/" + abi + "/";
                                        if (entry.getName().startsWith(prefixABI)) {
                                            abiMatched = abi;
                                            foundMatched = true;
                                            break;
                                        }
                                    }

                                    if (foundMatched) {
                                        break;
                                    }
                                }
                            }
                            Log.d(TAG, "matchedAbi=" + abiMatched);

                            if (null != abiMatched) {
                                boolean needReInstall = false;

                                for (final ZipEntry entry : list) {
                                    Log.d(TAG, entry.getName());

                                    final String prefixABI = "lib/" + abiMatched + "/";
                                    if (entry.getName().startsWith(prefixABI)) {
                                        final String jniName = entry.getName().substring(prefixABI.length());
                                        Log.d(TAG, "jni=" + jniName);

                                        final String strFileDst = context.getApplicationInfo().nativeLibraryDir
                                                + "/" + jniName;
                                        Log.d(TAG, strFileDst);
                                        final File fileDst = new File(strFileDst);
                                        if (!fileDst.exists()) {
                                            Log.w(TAG, "needReInstall: content missing " + strFileDst);
                                            needReInstall = true;
                                        } else {
                                            assert (entry.getSize() <= Integer.MAX_VALUE);
                                            if (fileDst.length() != entry.getSize()) {
                                                Log.w(TAG, "needReInstall: size broken " + strFileDst);
                                                needReInstall = true;
                                            } else {
                                                //org.apache.commons.io.IOUtils.contentEquals( zipFile.getInputStream( entry ), new FileInputStream(fileDst) );

                                                final int size = (int) entry.getSize();
                                                byte[] buffSrc = new byte[size];

                                                {
                                                    InputStream inStream = null;
                                                    try {
                                                        inStream = zipFile.getInputStream(entry);
                                                        int pos = 0;
                                                        {
                                                            while (pos < size) {
                                                                final int ret = inStream.read(buffSrc, pos,
                                                                        size - pos);
                                                                if (ret <= 0) {
                                                                    break;
                                                                }
                                                                pos += ret;
                                                            }
                                                        }
                                                    } catch (IOException e) {
                                                        Log.d(TAG, "got exception", e);
                                                    } finally {
                                                        if (null != inStream) {
                                                            try {
                                                                inStream.close();
                                                            } catch (Exception e) {
                                                            }
                                                        }
                                                    }
                                                }
                                                byte[] buffDst = new byte[(int) fileDst.length()];
                                                {
                                                    InputStream inStream = null;
                                                    try {
                                                        inStream = new FileInputStream(fileDst);
                                                        int pos = 0;
                                                        {
                                                            while (pos < size) {
                                                                final int ret = inStream.read(buffDst, pos,
                                                                        size - pos);
                                                                if (ret <= 0) {
                                                                    break;
                                                                }
                                                                pos += ret;
                                                            }
                                                        }
                                                    } catch (IOException e) {
                                                        Log.d(TAG, "got exception", e);
                                                    } finally {
                                                        if (null != inStream) {
                                                            try {
                                                                inStream.close();
                                                            } catch (Exception e) {
                                                            }
                                                        }
                                                    }
                                                }

                                                if (Arrays.equals(buffSrc, buffDst)) {
                                                    Log.d(TAG, " content equal " + strFileDst);
                                                    // OK
                                                } else {
                                                    Log.w(TAG, "needReInstall: content broken " + strFileDst);
                                                    needReInstall = true;
                                                }
                                            }

                                        }

                                    }
                                } // for ZipEntry

                                if (needReInstall) {
                                    // need call INSTALL APK
                                    Log.w(TAG, "needReInstall apk");
                                    result[0] = false;
                                } else {
                                    Log.d(TAG, "no need ReInstall apk");
                                }
                            }

                        } catch (IOException e) {
                            Log.d(TAG, "got exception", e);
                        } finally {
                            if (null != zipFile) {
                                try {
                                    zipFile.close();
                                } catch (Exception e) {
                                }
                            }
                        }
                    }
                }

            });
            thread.setName("check jni so");

            thread.start();
            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "check thread.id=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
            AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this );
            final Locale defaultLocale = Locale.getDefault();
                    
            String title = "";
            String message = "";
            String positive = "";
            String negative = "";
                    
            boolean needDefaultLang = true;
            if ( null != defaultLocale )
            {
                if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) )
                {
                    title = "";
                    message = "???????";
                    positive = "?";
                    negative = "";
                    needDefaultLang = false;
                }
            }
            if ( needDefaultLang )
            {
                title = "INFO";
                message = "Now checking installation. Cancel check?";
                positive = "Wait";
                negative = "Cancel";
            }
            alertDialog.setTitle( title );
            alertDialog.setMessage( message );
            alertDialog.setPositiveButton( positive, null);
            alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() {
                    
                @Override
                public void onClick(DialogInterface di, int i) {
                    if ( thread.isAlive() )
                    {
                        Log.d( TAG, "request interrupt" );
                        thread.interrupt();
                    }
                    else
                    {
                        // nothing
                    }
                }
            } );
                    
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            alertDialog.show();
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
            */

            try {
                thread.join();
            } catch (InterruptedException e) {
                Log.d(TAG, "got exception", e);
            }

            return result[0];
        }

        @Override
        public void onClick(View view) {
            boolean foundApk = false;
            {
                final String apkPath = context.getPackageCodePath(); // API8
                Log.d(TAG, "PackageCodePath: " + apkPath);
                final File fileApk = new File(apkPath);
                this.checkApk(fileApk, new ZipEntryFilter() {
                    @Override
                    public boolean accept(ZipEntry entry) {
                        if (entry.isDirectory()) {
                            return false;
                        }

                        final String filename = entry.getName();
                        if (filename.startsWith("lib/")) {
                            return true;
                        }

                        return false;
                    }
                });
            }

        }
    });
    layout.addView(btn3);

    Button btn4 = new Button(this);
    btn4.setText("print dir and path");
    btn4.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            {
                final File file = context.getCacheDir();
                Log.d(TAG, "Ctx.CacheDir=" + file.getAbsoluteFile());
            }
            {
                final File file = context.getExternalCacheDir(); // API 8
                if (null == file) {
                    // no permission
                    Log.d(TAG, "Ctx.ExternalCacheDir=");
                } else {
                    Log.d(TAG, "Ctx.ExternalCacheDir=" + file.getAbsolutePath());
                }
            }
            {
                final File file = context.getFilesDir();
                Log.d(TAG, "Ctx.FilesDir=" + file.getAbsolutePath());
            }
            {
                final String value = context.getPackageResourcePath();
                Log.d(TAG, "Ctx.PackageResourcePath=" + value);
            }
            {
                final String[] files = context.fileList();
                if (null == files) {
                    Log.d(TAG, "Ctx.fileList=" + files);
                } else {
                    for (final String filename : files) {
                        Log.d(TAG, "Ctx.fileList=" + filename);
                    }
                }
            }

            {
                final File file = Environment.getDataDirectory();
                Log.d(TAG, "Env.DataDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getDownloadCacheDirectory();
                Log.d(TAG, "Env.DownloadCacheDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getExternalStorageDirectory();
                Log.d(TAG, "Env.ExternalStorageDirectory=" + file.getAbsolutePath());
            }
            {
                final File file = Environment.getRootDirectory();
                Log.d(TAG, "Env.RootDirectory=" + file.getAbsolutePath());
            }
            {
                final ApplicationInfo appInfo = context.getApplicationInfo();
                Log.d(TAG, "AppInfo.dataDir=" + appInfo.dataDir);
                Log.d(TAG, "AppInfo.nativeLibraryDir=" + appInfo.nativeLibraryDir); // API 9
                Log.d(TAG, "AppInfo.publicSourceDir=" + appInfo.publicSourceDir);
                {
                    final String[] sharedLibraryFiles = appInfo.sharedLibraryFiles;
                    if (null == sharedLibraryFiles) {
                        Log.d(TAG, "AppInfo.sharedLibraryFiles=" + sharedLibraryFiles);
                    } else {
                        for (final String fileName : sharedLibraryFiles) {
                            Log.d(TAG, "AppInfo.sharedLibraryFiles=" + fileName);
                        }
                    }
                }
                Log.d(TAG, "AppInfo.sourceDir=" + appInfo.sourceDir);
            }
            {
                Log.d(TAG, "System.Properties start");
                final Properties properties = System.getProperties();
                if (null != properties) {
                    for (final Object key : properties.keySet()) {
                        String value = properties.getProperty((String) key);
                        Log.d(TAG, " key=" + key + ",value=" + value);
                    }
                }
                Log.d(TAG, "System.Properties end");
            }
            {
                Log.d(TAG, "System.getenv start");
                final Map<String, String> mapEnv = System.getenv();
                if (null != mapEnv) {
                    for (final Map.Entry<String, String> entry : mapEnv.entrySet()) {
                        final String key = entry.getKey();
                        final String value = entry.getValue();
                        Log.d(TAG, " key=" + key + ",value=" + value);
                    }
                }
                Log.d(TAG, "System.getenv end");
            }
        }
    });
    layout.addView(btn4);

    Button btn5 = new Button(this);
    btn5.setText("check INSTALL_NON_MARKET_APPS");
    btn5.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            SettingsCompat.initialize(context);
            if (SettingsCompat.isAllowedNonMarketApps()) {
                Log.d(TAG, "isAllowdNonMarketApps=true");
            } else {
                Log.d(TAG, "isAllowdNonMarketApps=false");
            }
        }
    });
    layout.addView(btn5);

    Button btn6 = new Button(this);
    btn6.setText("send email");
    btn6.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent mailto = new Intent();
            mailto.setAction(Intent.ACTION_SENDTO);
            mailto.setType("message/rfc822");
            mailto.setData(Uri.parse("mailto:"));
            mailto.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
            mailto.putExtra(Intent.EXTRA_SUBJECT, "[BugReport] " + context.getPackageName());
            mailto.putExtra(Intent.EXTRA_TEXT, "body text");
            //mailto.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
            //context.startActivity( mailto );
            Intent intent = Intent.createChooser(mailto, "Send Email");
            if (null != intent) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    context.startActivity(intent);
                } catch (android.content.ActivityNotFoundException e) {
                    Log.d(TAG, "got Exception", e);
                }
            }
        }
    });
    layout.addView(btn6);

    Button btn7 = new Button(this);
    btn7.setText("upload http thread");
    btn7.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Log.d(TAG, "brd=" + Build.BRAND);
            Log.d(TAG, "prd=" + Build.PRODUCT);

            //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
            Log.d(TAG, "fng=" + Build.FINGERPRINT);
            final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
            list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

            final Thread thread = new Thread(new Runnable() {

                @Override
                public void run() {
                    Log.d(TAG, "upload thread tid=" + android.os.Process.myTid());
                    try {
                        HttpPost httpPost = new HttpPost("http://kkkon.sakura.ne.jp/android/bug");
                        //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                        httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
                                new Integer(5 * 1000));
                        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                                new Integer(5 * 1000));
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        // <uses-permission android:name="android.permission.INTERNET"/>
                        // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                        HttpResponse response = httpClient.execute(httpPost);
                        Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
                    } catch (Exception e) {
                        Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
                    }
                    Log.d(TAG, "upload finish");
                }
            });
            thread.setName("upload crash");

            thread.start();
            /*
            while ( thread.isAlive() )
            {
            Log.d( TAG, "thread tid=" + android.os.Process.myTid() + ",state=" + thread.getState() );
            if ( ! thread.isAlive() )
            {
                break;
            }
            AlertDialog.Builder alertDialog = new AlertDialog.Builder( ExceptionHandlerTestApp.this );
            final Locale defaultLocale = Locale.getDefault();
                    
            String title = "";
            String message = "";
            String positive = "";
            String negative = "";
                    
            boolean needDefaultLang = true;
            if ( null != defaultLocale )
            {
                if ( defaultLocale.equals( Locale.JAPANESE ) || defaultLocale.equals( Locale.JAPAN ) )
                {
                    title = "";
                    message = "???????";
                    positive = "?";
                    negative = "";
                    needDefaultLang = false;
                }
            }
            if ( needDefaultLang )
            {
                title = "INFO";
                message = "Now uploading error information. Cancel upload?";
                positive = "Wait";
                negative = "Cancel";
            }
            alertDialog.setTitle( title );
            alertDialog.setMessage( message );
            alertDialog.setPositiveButton( positive, null);
            alertDialog.setNegativeButton( negative, new DialogInterface.OnClickListener() {
                    
                @Override
                public void onClick(DialogInterface di, int i) {
                    if ( thread.isAlive() )
                    {
                        Log.d( TAG, "request interrupt" );
                        thread.interrupt();
                    }
                    else
                    {
                        // nothing
                    }
                }
            } );
                    
            if ( ! thread.isAlive() )
            {
                break;
            }
                    
            alertDialog.show();
                    
            if ( ! Thread.State.RUNNABLE.equals(thread.getState()) )
            {
                break;
            }
                    
            }
            */

            /*
            try
            {
            thread.join(); // must call. leak handle...
            }
            catch ( InterruptedException e )
            {
            Log.d( TAG, "got Exception", e );
            }
            */
        }
    });
    layout.addView(btn7);

    Button btn8 = new Button(this);
    btn8.setText("upload http AsyncTask");
    btn8.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            AsyncTask<String, Void, Boolean> asyncTask = new AsyncTask<String, Void, Boolean>() {

                @Override
                protected Boolean doInBackground(String... paramss) {
                    Boolean result = true;
                    Log.d(TAG, "upload AsyncTask tid=" + android.os.Process.myTid());
                    try {
                        //$(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)
                        Log.d(TAG, "fng=" + Build.FINGERPRINT);
                        final List<NameValuePair> list = new ArrayList<NameValuePair>(16);
                        list.add(new BasicNameValuePair("fng", Build.FINGERPRINT));

                        HttpPost httpPost = new HttpPost(paramss[0]);
                        //httpPost.getParams().setParameter( CoreConnectionPNames.SO_TIMEOUT, new Integer(5*1000) );
                        httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT,
                                new Integer(5 * 1000));
                        httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
                                new Integer(5 * 1000));
                        Log.d(TAG, "socket.timeout="
                                + httpClient.getParams().getIntParameter(CoreConnectionPNames.SO_TIMEOUT, -1));
                        Log.d(TAG, "connection.timeout=" + httpClient.getParams()
                                .getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, -1));
                        // <uses-permission android:name="android.permission.INTERNET"/>
                        // got android.os.NetworkOnMainThreadException, run at UI Main Thread
                        HttpResponse response = httpClient.execute(httpPost);
                        Log.d(TAG, "response=" + response.getStatusLine().getStatusCode());
                    } catch (Exception e) {
                        Log.d(TAG, "got Exception. msg=" + e.getMessage(), e);
                        result = false;
                    }
                    Log.d(TAG, "upload finish");
                    return result;
                }

            };

            asyncTask.execute("http://kkkon.sakura.ne.jp/android/bug");
            asyncTask.isCancelled();
        }
    });
    layout.addView(btn8);

    Button btn9 = new Button(this);
    btn9.setText("call checkAPK");
    btn9.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            final boolean result = DefaultCheckerAPK.checkAPK(ExceptionHandlerReportApp.this, null);
            Log.i(TAG, "checkAPK result=" + result);
        }
    });
    layout.addView(btn9);

    setContentView(layout);
}

From source file:org.thoughtcrime.securesms.logsubmit.SubmitLogFragment.java

private static Iterable<String> getSupportedAbis() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return Arrays.asList(Build.SUPPORTED_ABIS);
    } else {//www.  jav  a 2  s .c o m
        LinkedList<String> abis = new LinkedList<>();
        abis.add(Build.CPU_ABI);
        if (Build.CPU_ABI2 != null && !"unknown".equals(Build.CPU_ABI2)) {
            abis.add(Build.CPU_ABI2);
        }
        return abis;
    }
}

From source file:com.droid.app.fotobot.FotoBot.java

/**
 *   ?  ? ? /*from  w w w .j a va  2  s. c  om*/
 *
 * @param h
 * @param str
 */
public void SendMail(Handler h, String str, String fc_str, String bc_video, String fc_video) {

    //        final FotoBot fb = (FotoBot) getApplicationContext();

    Mail m = new Mail(getApplicationContext(), EMail_Sender, EMail_Sender_Password, SMTP_Host, SMTP_Port);

    String[] toArr = { EMail_Recepient };

    String s = "Debug-infos:";
    s += "\n OS Version: " + System.getProperty("os.version") + "(" + android.os.Build.VERSION.INCREMENTAL
            + ")";
    s += "\n OS API Level: " + android.os.Build.VERSION.SDK_INT;
    s += "\n Device: " + android.os.Build.DEVICE;
    s += "\n Model (and Product): " + android.os.Build.MODEL + " (" + android.os.Build.PRODUCT + ")";

    s += "\n RELEASE: " + android.os.Build.VERSION.RELEASE;
    s += "\n BRAND: " + android.os.Build.BRAND;
    s += "\n DISPLAY: " + android.os.Build.DISPLAY;
    s += "\n CPU_ABI: " + android.os.Build.CPU_ABI;
    s += "\n CPU_ABI2: " + android.os.Build.CPU_ABI2;
    s += "\n UNKNOWN: " + android.os.Build.UNKNOWN;
    s += "\n HARDWARE: " + android.os.Build.HARDWARE;
    s += "\n Build ID: " + android.os.Build.ID;
    s += "\n MANUFACTURER: " + android.os.Build.MANUFACTURER;
    s += "\n SERIAL: " + android.os.Build.SERIAL;
    s += "\n USER: " + android.os.Build.USER;
    s += "\n HOST: " + android.os.Build.HOST;

    m.setTo(toArr);
    m.setFrom(EMail_Sender);
    m.setSubject("Fotobot v" + versionName + " " + Camera_Name);

    String email_body = "";

    email_body = "Fotobot v" + versionName + "\n" + "---------------------------------------------\n"
            + "Camera Name" + ": " + Camera_Name + "\n" + getResources().getString(R.string.battery_charge)
            + ": " + battery_level + "%" + "\n" + getResources().getString(R.string.battery_temperature) + ": "
            + battery_temperature + "C" + "\n";

    if (Attached_Info_Detailisation.equals("Normal") || Attached_Info_Detailisation.equals("Detailed")) {

        email_body = email_body + getResources().getString(R.string.gsm) + ": " + GSM_Signal + "ASU    "
                + (2.0 * GSM_Signal - 113) + "dBm" + "\n" + "-50 -82 dbm   -   very good" + "\n"
                + "-83 -86 dbm   -   good" + "\n" + "-87 -91 dbm   -   normal" + "\n" + "-92 -95 dbm   -   bad"
                + "\n" + "-96 -100 dbm   -  almost no signal" + "\n"
                + "---------------------------------------------\n" + "Image Index:" + Image_Index + "\n"
                + "---------------------------------------------\n"
                + getResources().getString(R.string.phone_memory) + ":" + "\n" + "totalMemory: " + totalMemory
                + "\n" + "usedMemory: " + usedMemory + "\n" + "freeMemory: " + freeMemory + "\n"
                + "---------------------------------------------\n"
                + getResources().getString(R.string.email_sending_time) + ": " + email_sending_time + "\n"
                + "---------------------------------------------\n"
                + getResources().getString(R.string.Fotobot_settings) + ":\n" + "Network_Channel: "
                + Network_Channel + "\n" + "Network_Connection_Method: " + Network_Connection_Method + "\n"
                + "Use_Flash: " + Use_Flash + "\n" + "JPEG_Compression: " + JPEG_Compression + "\n"
                + "Photo_Frequency: " + Photo_Frequency + "\n" + "process_delay: " + process_delay + "\n"
                + "Image_Scale: " + Image_Scale + "\n" + "Image_Size: " + Image_Size + "\n" + "EMail_Sender: "
                + EMail_Sender + "\n" + "EMail_Sender_Password: *********" + "\n" + "EMail_Recepient: "
                + EMail_Recepient + "\n" + "Log_Font_Size: " + Log_Font_Size + "\n" + "Config_Font_Size: "
                + Config_Font_Size + "\n" + "Photo_Post_Processing_Method: " + Photo_Post_Processing_Method
                + "\n" + "SMTP_Host: " + SMTP_Host + "\n" + "SMTP_Port: " + SMTP_Port + "\n" + "Log length: "
                + loglength + "\n" + "FLog length: " + floglength + "\n" + "wake_up_interval: "
                + wake_up_interval + "\n" + "---------------------------------------------\n"
                + getResources().getString(R.string.hardware_info) + ":\n" + "Android: " + Build.VERSION.SDK_INT
                + "\n" + s + "\n" + "---------------------------------------------\n"
                + "Available SMS commands: " + "\n" + sms_commands_list() + "\n";
        ;
        if (Attached_Info_Detailisation.equals("Detailed")) {
            email_body = email_body + "\n\n\nActive tasks:\n" + Top + "\n\n\nBack Camera Properties:\n"
                    + Camera_Properties + "\n\n\nFront Camera Properties:\n" + fc_Camera_Properties;
        }

    }

    m.setBody(email_body);

    File attach_file;

    if (make_photo_bc && bc_image_attach) {

        attach_file = new File(str);
        boolean fileExists = attach_file.isFile();

        if (fileExists) {

        } else {
            SendMessage("ERROR: image doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (make_video_bc && bc_video_attach) {

        attach_file = new File(bc_video);
        boolean fileExists = attach_file.isFile();

        if (fileExists) {

        } else {
            SendMessage("ERROR: video " + bc_video + " doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (front_camera && make_photo_fc && fc_image_attach) {

        attach_file = new File(fc_str);
        boolean fc_fileExists = attach_file.isFile();

        if (front_camera && fc_fileExists && make_photo_fc) {

        } else {
            SendMessage("ERROR: front camera image doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (front_camera && make_video_fc && fc_video_attach) {

        attach_file = new File(fc_video);
        boolean fc_fileExists = attach_file.isFile();

        if (front_camera && fc_fileExists && make_photo_fc) {

        } else {
            SendMessage("ERROR: video " + fc_video + " doesn't exist for attaching to email.", MSG_FAIL);
        }
    }

    if (attach_log) {
        attach_file = new File((work_dir + "/logfile.txt"));
        boolean fileExists = attach_file.isFile();

        if (fileExists) {

        } else {
            SendMessage("ERROR: log doesn't exist for attaching to email.", MSG_FAIL);
        }

    }
    try {

        if (make_photo_bc && bc_image_attach) {
            m.addAttachment(str);
        }

        if (front_camera && make_photo_fc && fc_image_attach) {
            m.addAttachment(fc_str);
        }

        if (make_video_bc && bc_image_attach) {
            m.addAttachment(bc_video);
        }

        if (front_camera && make_video_fc && fc_image_attach) {
            m.addAttachment(fc_video);
        }

        if (attach_log) {
            m.addAttachment(work_dir + "/logfile.txt");
        }
        fbpause(h, process_delay);

        if (m.send()) {

            SendMessage(getResources().getString(R.string.foto_sent), MSG_PASS);

            SaveSettings();

        } else {
            SendMessage("ERROR: ?   ", MSG_FAIL);
        }
    } catch (Exception e) {
        SendMessage("Could not send email", MSG_FAIL);
        Log.e("MailApp", "Could not send email", e);
    }

}