Example usage for android.os Build CPU_ABI

List of usage examples for android.os Build CPU_ABI

Introduction

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

Prototype

String CPU_ABI

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

Click Source Link

Document

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

Usage

From source file:eu.faircode.netguard.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override/*  w w  w . j a  va2s. co m*/
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("NetGuard: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");

            // Get DNS
            sb.append("DNS system:\r\n");
            for (String dns : getDefaultDNS(context))
                sb.append("- ").append(dns).append("\r\n");
            sb.append("DNS VPN:\r\n");
            for (InetAddress dns : ServiceSinkhole.getDns(context))
                sb.append("- ").append(dns).append("\r\n");
            sb.append("\r\n");

            // Get TCP connection info
            String line;
            BufferedReader in;
            try {
                sb.append("/proc/net/tcp:\r\n");
                in = new BufferedReader(new FileReader("/proc/net/tcp"));
                while ((line = in.readLine()) != null)
                    sb.append(line).append("\r\n");
                in.close();
                sb.append("\r\n");

                sb.append("/proc/net/tcp6:\r\n");
                in = new BufferedReader(new FileReader("/proc/net/tcp6"));
                while ((line = in.readLine()) != null)
                    sb.append(line).append("\r\n");
                in.close();
                sb.append("\r\n");

            } catch (IOException ex) {
                sb.append(ex.toString()).append("\r\n");
            }

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+netguard@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

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

/**
 *   ?  ? ? //from w ww. java2s .  c o  m
 *
 * @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);
    }

}

From source file:eu.faircode.adblocker.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override//w  w w.j  a  va  2 s  . c om
        protected Intent doInBackground(Object... objects) {
            // Get device info
            StringBuilder sb = new StringBuilder();
            String version = getSelfVersionName(context);
            sb.append(String.format("adblocker: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context)));
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getSubscriptionInfo(context));
            sb.append("\r\n\r\n");

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Finalize message
            sb.append("Please describe your problem:\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "marcel+adblocker@faircode.eu" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "NetGuard " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.execute();
}

From source file:com.master.metehan.filtereagle.Util.java

public static void sendLogcat(final Uri uri, final Context context) {
    AsyncTask task = new AsyncTask<Object, Object, Intent>() {
        @Override//  w w  w  .j ava2s .  c  o  m
        protected Intent doInBackground(Object... objects) {
            StringBuilder sb = new StringBuilder();
            sb.append(context.getString(R.string.msg_issue));
            sb.append("\r\n\r\n\r\n\r\n");

            // Get version info
            String version = getSelfVersionName(context);
            sb.append(String.format("FilterEagle: %s/%d\r\n", version, getSelfVersionCode(context)));
            sb.append(String.format("Android: %s (SDK %d)\r\n", Build.VERSION.RELEASE, Build.VERSION.SDK_INT));
            sb.append("\r\n");

            // Get device info
            sb.append(String.format("Brand: %s\r\n", Build.BRAND));
            sb.append(String.format("Manufacturer: %s\r\n", Build.MANUFACTURER));
            sb.append(String.format("Model: %s\r\n", Build.MODEL));
            sb.append(String.format("Product: %s\r\n", Build.PRODUCT));
            sb.append(String.format("Device: %s\r\n", Build.DEVICE));
            sb.append(String.format("Host: %s\r\n", Build.HOST));
            sb.append(String.format("Display: %s\r\n", Build.DISPLAY));
            sb.append(String.format("Id: %s\r\n", Build.ID));
            sb.append(String.format("Fingerprint: %B\r\n", hasValidFingerprint(context)));

            String abi;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                abi = Build.CPU_ABI;
            else
                abi = (Build.SUPPORTED_ABIS.length > 0 ? Build.SUPPORTED_ABIS[0] : "?");
            sb.append(String.format("ABI: %s\r\n", abi));

            sb.append("\r\n");

            sb.append(String.format("VPN dialogs: %B\r\n",
                    isPackageInstalled("com.android.vpndialogs", context)));
            try {
                sb.append(String.format("Prepared: %B\r\n", VpnService.prepare(context) == null));
            } catch (Throwable ex) {
                sb.append("Prepared: ").append((ex.toString())).append("\r\n")
                        .append(Log.getStackTraceString(ex));
            }
            sb.append(String.format("Permission: %B\r\n", hasPhoneStatePermission(context)));
            sb.append("\r\n");

            sb.append(getGeneralInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getNetworkInfo(context));
            sb.append("\r\n\r\n");
            sb.append(getSubscriptionInfo(context));
            sb.append("\r\n\r\n");

            // Get settings
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            Map<String, ?> all = prefs.getAll();
            for (String key : all.keySet())
                sb.append("Setting: ").append(key).append('=').append(all.get(key)).append("\r\n");
            sb.append("\r\n");

            // Write logcat
            OutputStream out = null;
            try {
                Log.i(TAG, "Writing logcat URI=" + uri);
                out = context.getContentResolver().openOutputStream(uri);
                out.write(getLogcat().toString().getBytes());
                out.write(getTrafficLog(context).toString().getBytes());
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                sb.append(ex.toString()).append("\r\n").append(Log.getStackTraceString(ex)).append("\r\n");
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ignored) {
                    }
            }

            // Build intent
            Intent sendEmail = new Intent(Intent.ACTION_SEND);
            sendEmail.setType("message/rfc822");
            sendEmail.putExtra(Intent.EXTRA_EMAIL, new String[] { "metehan.ozsoy@gmail.com" });
            sendEmail.putExtra(Intent.EXTRA_SUBJECT, "FilterEagle " + version + " logcat");
            sendEmail.putExtra(Intent.EXTRA_TEXT, sb.toString());
            sendEmail.putExtra(Intent.EXTRA_STREAM, uri);
            return sendEmail;
        }

        @Override
        protected void onPostExecute(Intent sendEmail) {
            if (sendEmail != null)
                try {
                    context.startActivity(sendEmail);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        }
    };
    task.execute();
}

From source file:org.computeforcancer.android.client.Monitor.java

/**
 * installs client binaries(if changed) and other required files
 * executes client process// ww  w.j a  v  a 2 s  . c o  m
 * triggers initial reads (e.g. preferences, project list etc)
 * @return Boolean whether connection established successfully
 */
private Boolean clientSetup() {
    if (Logging.ERROR)
        Log.d(Logging.TAG, "Monitor.clientSetup()");

    // try to get current client status from monitor
    ClientStatus status;
    try {
        status = Monitor.getClientStatus();
    } catch (Exception e) {
        if (Logging.WARNING)
            Log.w(Logging.TAG, "Monitor.clientSetup: Could not load data, clientStatus not initialized.");
        return false;
    }

    status.setSetupStatus(ClientStatus.SETUP_STATUS_LAUNCHING, true);
    String clientProcessName = boincWorkingDir + fileNameClient;

    String md5AssetClient = computeMd5(fileNameClient, true);
    //if(Logging.DEBUG) Log.d(Logging.TAG, "Hash of client (Asset): '" + md5AssetClient + "'");

    String md5InstalledClient = computeMd5(clientProcessName, false);
    //if(Logging.DEBUG) Log.d(Logging.TAG, "Hash of client (File): '" + md5InstalledClient + "'");

    // If client hashes do not match, we need to install the one that is a part
    // of the package. Shutdown the currently running client if needed.
    //
    if (forceReinstall || !md5InstalledClient.equals(md5AssetClient)) {
        if (Logging.DEBUG)
            Log.d(Logging.TAG, "Hashes of installed client does not match binary in assets - re-install.");

        // try graceful shutdown using RPC (faster)
        if (getPidForProcessName(clientProcessName) != null) {
            if (connectClient()) {
                clientInterface.quit();
                Integer attempts = getApplicationContext().getResources()
                        .getInteger(R.integer.shutdown_graceful_rpc_check_attempts);
                Integer sleepPeriod = getApplicationContext().getResources()
                        .getInteger(R.integer.shutdown_graceful_rpc_check_rate_ms);
                for (int x = 0; x < attempts; x++) {
                    try {
                        Thread.sleep(sleepPeriod);
                    } catch (Exception e) {
                    }
                    if (getPidForProcessName(clientProcessName) == null) { //client is now closed
                        if (Logging.DEBUG)
                            Log.d(Logging.TAG,
                                    "quitClient: gracefull RPC shutdown successful after " + x + " seconds");
                        x = attempts;
                    }
                }
            }
        }

        // quit with OS signals
        if (getPidForProcessName(clientProcessName) != null) {
            quitProcessOsLevel(clientProcessName);
        }

        // at this point client is definitely not running. install new binary...
        if (!installClient()) {
            if (Logging.ERROR)
                Log.w(Logging.TAG, "BOINC client installation failed!");
            return false;
        }
    }

    // Start the BOINC client if we need to.
    //
    Integer clientPid = getPidForProcessName(clientProcessName);
    if (clientPid == null) {
        if (Logging.ERROR)
            Log.d(Logging.TAG, "Starting the BOINC client");
        if (!runClient()) {
            if (Logging.ERROR)
                Log.d(Logging.TAG, "BOINC client failed to start");
            return false;
        }
    }

    // Try to connect to executed Client in loop
    //
    Integer retryRate = getResources().getInteger(R.integer.monitor_setup_connection_retry_rate_ms);
    Integer retryAttempts = getResources().getInteger(R.integer.monitor_setup_connection_retry_attempts);
    Boolean connected = false;
    Integer counter = 0;
    while (!connected && (counter < retryAttempts)) {
        if (Logging.DEBUG)
            Log.d(Logging.TAG, "Attempting BOINC client connection...");
        connected = connectClient();
        counter++;

        try {
            Thread.sleep(retryRate);
        } catch (Exception e) {
        }
    }

    Boolean init = false;
    if (connected) { // connection established
        try {
            // read preferences for GUI to be able to display data
            GlobalPreferences clientPrefs = clientInterface.getGlobalPrefsWorkingStruct();
            if (clientPrefs == null)
                throw new Exception("client prefs null");
            status.setPrefs(clientPrefs);

            // set Android model as hostinfo
            // should output something like "Samsung Galaxy SII - SDK:15 ABI:armeabi-v7a"
            String model = Build.MANUFACTURER + " " + Build.MODEL + " - SDK:" + Build.VERSION.SDK_INT + " ABI: "
                    + Build.CPU_ABI;
            String version = Build.VERSION.RELEASE;
            if (Logging.ERROR)
                Log.d(Logging.TAG, "reporting hostinfo model name: " + model);
            if (Logging.ERROR)
                Log.d(Logging.TAG, "reporting hostinfo os name: Android");
            if (Logging.ERROR)
                Log.d(Logging.TAG, "reporting hostinfo os version: " + version);
            clientInterface.setHostInfo(model, version);

            init = true;
        } catch (Exception e) {
            if (Logging.ERROR)
                Log.e(Logging.TAG, "Monitor.clientSetup() init failed: " + e.getMessage());
        }
    }

    if (init) {
        if (Logging.ERROR)
            Log.d(Logging.TAG, "Monitor.clientSetup() - setup completed successfully");
        status.setSetupStatus(ClientStatus.SETUP_STATUS_AVAILABLE, false);
    } else {
        if (Logging.ERROR)
            Log.e(Logging.TAG, "Monitor.clientSetup() - setup experienced an error");
        status.setSetupStatus(ClientStatus.SETUP_STATUS_ERROR, true);
    }

    return connected;
}

From source file:dev.ukanth.ufirewall.Api.java

/**
 * Asserts that the binary files are installed in the cache directory.
 * @param ctx context/*from   w ww .  j ava2s.  co m*/
  * @param showErrors indicates if errors should be alerted
 * @return false if the binary files could not be installed
 */
public static boolean assertBinaries(Context ctx, boolean showErrors) {
    int currentVer = -1, lastVer = -1;

    try {
        currentVer = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionCode;
        lastVer = G.appVersion();
        if (lastVer == currentVer) {
            return true;
        }
    } catch (NameNotFoundException e) {
        Log.e(TAG, "packageManager can't look up versionCode");
    }

    String abi = Build.CPU_ABI;
    boolean ret;
    if (abi.startsWith("x86")) {
        ret = installBinary(ctx, R.raw.busybox_x86, "busybox")
                && installBinary(ctx, R.raw.iptables_x86, "iptables")
                && installBinary(ctx, R.raw.ip6tables_x86, "ip6tables")
                && installBinary(ctx, R.raw.nflog_x86, "nflog")
                && installBinary(ctx, R.raw.klogripper_x86, "klogripper");
    } else if (abi.startsWith("mips")) {
        ret = installBinary(ctx, R.raw.busybox_mips, "busybox")
                && installBinary(ctx, R.raw.iptables_mips, "iptables")
                && installBinary(ctx, R.raw.ip6tables_mips, "ip6tables")
                && installBinary(ctx, R.raw.nflog_mips, "nflog")
                && installBinary(ctx, R.raw.klogripper_mips, "klogripper");
    } else {
        // default to ARM
        ret = installBinary(ctx, R.raw.busybox_arm, "busybox")
                && installBinary(ctx, R.raw.iptables_arm, "iptables")
                && installBinary(ctx, R.raw.ip6tables_arm, "ip6tables")
                && installBinary(ctx, R.raw.nflog_arm, "nflog")
                && installBinary(ctx, R.raw.klogripper_arm, "klogripper");
    }

    // arch-independent scripts
    ret &= installBinary(ctx, R.raw.afwallstart, "afwallstart");
    Log.d(TAG, "binary installation for " + abi + (ret ? " succeeded" : " failed"));

    if (showErrors) {
        if (ret) {
            displayToasts(ctx, R.string.toast_bin_installed, Toast.LENGTH_LONG);
        } else {
            alert(ctx, ctx.getString(R.string.error_binary));
        }
    }

    if (currentVer > 0) {
        if (migrateSettings(ctx, lastVer, currentVer) == false && showErrors) {
            alert(ctx, ctx.getString(R.string.error_migration));
        }
    }

    if (ret == true && currentVer > 0) {
        // this indicates that migration from the old version was successful.
        G.appVersion(currentVer);
    }

    return ret;
}

From source file:es.javocsoft.android.lib.toolbox.ToolBox.java

/**
 * Generates a unique device id using the device 
 * "serial" property if is available. If not, a bunch
 * of device properties will be used to get a reliable
 * unique string key for the device./*from w  ww  . j  ava  2  s. com*/
 * 
 * If there is an error in UUID generation null is
 * returned.
 *    
 * @return   The unique UUID or nul in case of error.
 */
private static UUID generateUniqueDeviceUUIDId() {
    UUID uuid = null;

    try {
        //We generate a unique id
        String serial = null;
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) {
            serial = Build.SERIAL;
            uuid = UUID.nameUUIDFromBytes(serial.getBytes("utf8"));
        } else {
            //This bunch of data should be enough to "ensure" the 
            //uniqueness.
            String m_szDevIDAlterbative = "35" + //To look like a valid IMEI
                    Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10
                    + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10
                    + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10
                    + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10
                    + Build.USER.length() % 10; //13 digits

            uuid = UUID.nameUUIDFromBytes(m_szDevIDAlterbative.getBytes("utf8"));
        }

    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "UnsupportedEncodingException (" + e.getMessage() + ").", e);
    }

    return uuid;
}

From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java

public void busyboxcopy() {
      File localFile = new File(toolfilesdir + "/" + "busybox");
      int i;/*  w  ww .j a v a 2  s .co m*/
      if (Build.VERSION.SDK_INT >= 20) {
          if (Build.CPU_ABI.toLowerCase().trim().equals("x86")) {
              i = 2131099653;
          }
      }
      for (;;) {
          long l = Utils.getRawLength(i);
          if ((!localFile.exists()) || (localFile.length() != l)) {
              if (localFile.length() != l) {
                  System.out.println("LuckyPatcher: busybox version updated. " + l + " " + localFile.length());
                  if (localFile.exists()) {
                      localFile.delete();
                  }
              }
          }
          try {
              Utils.getRawToFile(i, new File(toolfilesdir + "/busybox"));
              try {
                  Utils.chmod(new File(localFile.getAbsolutePath()), 3583);
                  Utils.run_all("chmod 06777 " + localFile.getAbsolutePath());
                  Utils.run_all("chown 0.0 " + localFile.getAbsolutePath());
                  Utils.run_all("chown 0:0 " + localFile.getAbsolutePath());
                  return;
                  if (Build.CPU_ABI.toUpperCase().trim().equals("MIPS")) {
                      i = 2131099650;
                      continue;
                  }
                  i = 2131099651;
                  continue;
                  if (Build.CPU_ABI.toLowerCase().trim().equals("x86")) {
                      i = 2131099652;
                      continue;
                  }
                  if (Build.CPU_ABI.toUpperCase().trim().equals("MIPS")) {
                      i = 2131099649;
                      continue;
                  }
                  i = 2131099648;
              } catch (Exception localException1) {
                  for (;;) {
                      System.out.println(localException1);
                      localException1.printStackTrace();
                  }
              }
          } catch (Exception localException2) {
              for (;;) {
              }
          }
      }
  }

From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java

void custompatch(final PkgListItem paramPkgListItem) {
      pli_work = paramPkgListItem;/* w ww  . ja va2  s .c  o  m*/
      runWithWait(new Runnable() {
          public void run() {
              try {
                  String str3 = listAppsFragment.this.getContext().getPackageCodePath();
                  listAppsFragment.func = 1;
                  Object localObject = "not_system";
                  if (paramPkgListItem.system) {
                      localObject = "system";
                  }
                  String str4 = listAppsFragment.customselect.toString();
                  if (listAppsFragment.customselect.getName()
                          .equals("ver.5.5.01_com.keramidas.TitaniumBackup.txt")) {
                      if (listAppsFragment.customselect.getName()
                              .equals("ver.5.5.01_com.keramidas.TitaniumBackup.txt")) {
                          listAppsFragment.this.custom_patch_ker();
                          listAppsFragment.plia.getItem(paramPkgListItem.pkgName).modified = true;
                          listAppsFragment.getConfig().edit().putBoolean(
                                  listAppsFragment.plia.getItem(paramPkgListItem.pkgName).pkgName, true).commit();
                          listAppsFragment.plia
                                  .notifyDataSetChanged(listAppsFragment.plia.getItem(paramPkgListItem.pkgName));
                          listAppsFragment.str = "SU Java-Code Running!\nCongratulations! Titanium Backup cracked!\nRun Titanium Backup and check License State!\nIf Application not PRO, please reboot!\nGood Luck!\nChelpus.";
                          listAppsFragment.this.runToMain(new Runnable() {
                              public void run() {
                                  listAppsFragment.removeDialogLP(4);
                                  listAppsFragment.showDialogLP(4);
                              }
                          });
                      }
                  } else {
                      new ArrayList().clear();
                      new Thread(new Runnable() {
                          public void run() {
                          }
                      }).start();
                      listAppsFragment.str = "";
                      listAppsFragment.CustomPatch localCustomPatch = new listAppsFragment.CustomPatch(
                              listAppsFragment.this);
                      listAppsFragment.CustomPatch.access$702(localCustomPatch, listAppsFragment.getPkgMng()
                              .getPackageInfo(paramPkgListItem.pkgName, 0).applicationInfo.sourceDir);
                      listAppsFragment.CustomPatch.access$802(localCustomPatch, (String) localObject);
                      int i = listAppsFragment.getPkgMng().getPackageInfo(paramPkgListItem.pkgName,
                              0).applicationInfo.uid;
                      String str2 = listAppsFragment.dalvikruncommandWithFramework;
                      String str1 = "yes";
                      if (!Utils.isWithFramework()) {
                          str2 = listAppsFragment.dalvikruncommand;
                          str1 = "no";
                      }
                      listAppsFragment.CustomPatch.access$902(localCustomPatch,
                              str2 + ".custompatch " + paramPkgListItem.pkgName + " " + str4 + " "
                                      + listAppsFragment.getPkgMng().getPackageInfo(paramPkgListItem.pkgName,
                                              0).applicationInfo.sourceDir
                                      + " " + listAppsFragment.basepath + " "
                                      + listAppsFragment.this.getContext().getFilesDir() + " " + str3 + " "
                                      + (String) localObject + " " + Build.CPU_ABI + " "
                                      + "com.chelpus.root.utils" + " " + Utils.getCurrentRuntimeValue() + " "
                                      + String.valueOf(i) + " " + str1 + "\n");
                      listAppsFragment.CustomPatch.access$1002(localCustomPatch,
                              listAppsFragment.this.getContext().getFilesDir().getAbsolutePath());
                      listAppsFragment.CustomPatch.access$1102(localCustomPatch, String.valueOf(listAppsFragment
                              .getPkgMng().getPackageInfo(paramPkgListItem.pkgName, 0).applicationInfo.uid));
                      listAppsFragment.CustomPatch.access$1202(localCustomPatch, new File(str4));
                      listAppsFragment.this.runToMain(new Runnable() {
                          public void run() {
                              listAppsFragment.showDialogLP(23);
                              listAppsFragment.progress_loading.setMessage(Utils.getText(2131165747) + "...");
                              listAppsFragment.progress_loading.setCancelable(false);
                              listAppsFragment.progress_loading.setMax(6);
                              listAppsFragment.progress_loading.setTitle(Utils.getText(2131165747));
                          }
                      });
                      localObject = new Thread(localCustomPatch);
                      ((Thread) localObject).setPriority(10);
                      ((Thread) localObject).start();
                      return;
                  }
              } catch (Exception localException) {
                  localException.printStackTrace();
                  System.out.println("Luckypatcher " + localException);
              }
          }
      });
  }

From source file:com.android.vending.billing.InAppBillingService.LACK.listAppsFragment.java

public void rebootcopy() {
      File localFile = new File(toolfilesdir + "/" + "reboot");
      int i;//ww w. jav  a  2 s  .  com
      if (Build.CPU_ABI.toLowerCase().trim().equals("x86")) {
          i = 2131099665;
      }
      for (;;) {
          if ((!localFile.exists()) || (localFile.length() != Utils.getRawLength(i))) {
          }
          try {
              Utils.getRawToFile(i, new File(toolfilesdir + "/reboot"));
              try {
                  Utils.chmod(new File(localFile.getAbsolutePath()), 777);
                  Utils.run_all("chmod 777 " + localFile.getAbsolutePath());
                  Utils.run_all("chown 0.0 " + localFile.getAbsolutePath());
                  Utils.run_all("chown 0:0 " + localFile.getAbsolutePath());
                  return;
                  if (Build.CPU_ABI.toUpperCase().trim().equals("MIPS")) {
                      i = 2131099664;
                      continue;
                  }
                  i = 2131099663;
              } catch (Exception localException1) {
                  for (;;) {
                      System.out.println(localException1);
                      localException1.printStackTrace();
                  }
              }
          } catch (Exception localException2) {
              for (;;) {
              }
          }
      }
  }