Android Open Source - Rashr Report Dialog






From Project

Back to project page Rashr.

License

The source code is released under:

GNU General Public License

If you think the Android project Rashr listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.mkrtchyan.recoverytools;
/* w  w  w . j a v a  2  s.  c  o m*/
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Build;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import org.sufficientlysecure.rootcommands.Shell;
import org.sufficientlysecure.rootcommands.Toolbox;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;

import de.mkrtchyan.utils.Common;

/**
 * Copyright (c) 2014 Aschot Mkrtchyan
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
public class ReportDialog extends Dialog {

    public ReportDialog(final RashrActivity activity, String message) {
        super(activity);
        final Shell shell = activity.getShell();
        final Device device = activity.getDevice();
        final Toolbox toolbox = activity.getToolbox();
        final ArrayList<String> errors = activity.getErrors();
        setTitle(R.string.comment);
        setContentView(R.layout.dialog_comment);
        final EditText text = (EditText) findViewById(R.id.etComment);
        if (!message.equals("")) text.setText(message);
        new Thread(new Runnable() {
            @Override
            public void run() {
                /** Creates a report Email including a Comment and important device infos */
                final Button bGo = (Button) findViewById(R.id.bGo);
                bGo.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {

                        if (!Common.getBooleanPref(activity, Constants.PREF_NAME,
                                Constants.PREF_KEY_ADS))
                            Toast
                                    .makeText(activity, R.string.please_ads, Toast.LENGTH_SHORT)
                                    .show();
                        Toast
                                .makeText(activity, R.string.donate_to_support, Toast.LENGTH_SHORT)
                                .show();
                        try {
                            ArrayList<File> files = new ArrayList<>();
                            File TestResults = new File(activity.getFilesDir(), "results.txt");
                            try {
                                if (TestResults.exists()) {
                                    if (TestResults.delete()) {
                                        FileOutputStream fos = activity.openFileOutput(
                                                TestResults.getName(), Context.MODE_PRIVATE);
                                        fos.write(("Rashr:\n\n" + shell
                                                .execCommand("ls -lR " + Constants.PathToRashr.getAbsolutePath()) +
                                                "\nCache Tree:\n" + shell
                                                .execCommand("ls -lR /cache") + "\n" +
                                                "\nMTD result:\n" + shell
                                                .execCommand("cat /proc/mtd") + "\n" +
                                                "\nDevice Tree:\n\n" + shell
                                                .execCommand("ls -lR /dev")).getBytes());
                                    }
                                    files.add(TestResults);
                                }
                            } catch (Exception e) {
                                activity.addError(Constants.RASHR_TAG, e, false);
                            }
                            if (activity.getPackageManager() != null) {
                                PackageInfo pInfo = activity.getPackageManager()
                                        .getPackageInfo(activity.getPackageName(), 0);

                                String comment = "";
                                if (text.getText() != null) comment = text.getText().toString();
                                Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
                                intent.setType("text/plain");
                                intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"ashotmkrtchyan1995@gmail.com"});
                                intent.putExtra(Intent.EXTRA_SUBJECT, "Rashr " + pInfo.versionCode + " report");
                                String message = "Package Infos:" +
                                        "\n\nName: " + pInfo.packageName +
                                        "\nVersion Name: " + pInfo.versionName;
                                message +=
                                        "\n\n\nProduct Info: " +
                                                "\n\nManufacture: " + Build.MANUFACTURER + " (" + device.getManufacture() + ") " +
                                                "\nDevice: " + Build.DEVICE + " (" + device.getName() + ")" +
                                                "\nBoard: " + Build.BOARD +
                                                "\nBrand: " + Build.BRAND +
                                                "\nModel: " + Build.MODEL +
                                                "\nFingerprint: " + Build.FINGERPRINT +
                                                "\nAndroid SDK Level: " + Build.VERSION.CODENAME + " (" + Build.VERSION.SDK_INT + ")";

                                if (device.isRecoverySupported()) {
                                    message += "\n\nRecovery Path: " + device.getRecoveryPath() +
                                            "\nRecovery Version: " + device.getRecoveryVersion() +
                                            "\nRecovery MTD: " + device.isRecoveryMTD() +
                                            "\nRecovery DD: " + device.isRecoveryDD() +
                                            "\nStock: " + device.isStockRecoverySupported() +
                                            "\nCWM: " + device.isCwmRecoverySupported() +
                                            "\nTWRP: " + device.isTwrpRecoverySupported() +
                                            "\nPHILZ: " + device.isPhilzRecoverySupported();
                                }
                                if (device.isKernelSupported()) {
                                    message += "\n\nKernel Path: " + device.getKernelPath() +
                                            "\nKernel Version: " + device.getKernelVersion() +
                                            "\nKernel MTD: " + device.isKernelMTD() +
                                            "\nKernel DD: " + device.isKernelDD();
                                }
                                if (!comment.equals("")) {
                                    message +=
                                            "\n\n\n===========COMMENT==========\n"
                                                    + comment +
                                                    "\n=========COMMENT END========\n";
                                }
                                message +=
                                        "\n===========PREFS==========\n"
                                                + activity.getAllPrefs() +
                                                "\n=========PREFS END========\n";
                                files.add(new File(activity.getFilesDir(), Shell.Logs));
                                files.add(new File(activity.getFilesDir(), "last_log.txt"));
                                ArrayList<Uri> uris = new ArrayList<>();
                                File tmpFolder = new File(activity.getFilesDir(), "tmp");
                                if (tmpFolder.mkdir()) tmpFolder.deleteOnExit();
                                for (File i : files) {
                                    try {
                                        File tmp = new File(tmpFolder, i.getName());
                                        toolbox.setFilePermissions(tmp, "777");
                                        toolbox.copyFile(i, tmp, true, false);
                                        toolbox.setFilePermissions(tmp, "777");
                                        uris.add(Uri.fromFile(tmp));
                                    } catch (Exception e) {
                                        activity.addError(Constants.RASHR_TAG, e, false);
                                    }
                                }
                                if (errors.size() > 0) {
                                    message += "ERRORS:\n";
                                    for (String error : errors) {
                                        message += error + "\n";
                                    }
                                }

                                intent.putExtra(Intent.EXTRA_TEXT, message);
                                intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
                                activity.startActivity(Intent.createChooser(intent, "Send over Gmail"));
                                dismiss();
                            }
                        } catch (Exception e) {
                            dismiss();
                            activity.addError(Constants.RASHR_TAG, e, false);
                        }
                    }
                });
            }
        }).start();
    }
}




Java Source Code List

com.fima.cardsui.StackAdapter.java
com.fima.cardsui.SwipeDismissTouchListener.java
com.fima.cardsui.Utils.java
com.fima.cardsui.objects.AbstractCard.java
com.fima.cardsui.objects.CardFactory.java
com.fima.cardsui.objects.CardModel.java
com.fima.cardsui.objects.CardStack.java
com.fima.cardsui.objects.Card.java
com.fima.cardsui.objects.RecyclableCard.java
com.fima.cardsui.views.CardUI.java
com.fima.cardsui.views.MyCard.java
com.fima.cardsui.views.MyImageCard.java
com.fima.cardsui.views.MyPlayCard.java
com.fima.cardsui.views.QuickReturnListView.java
de.mkrtchyan.recoverytools.BackupRestoreFragment.java
de.mkrtchyan.recoverytools.Constants.java
de.mkrtchyan.recoverytools.Device.java
de.mkrtchyan.recoverytools.FlashAsFragment.java
de.mkrtchyan.recoverytools.FlashFragment.java
de.mkrtchyan.recoverytools.FlashUtil.java
de.mkrtchyan.recoverytools.NavigationDrawerFragment.java
de.mkrtchyan.recoverytools.RashrActivity.java
de.mkrtchyan.recoverytools.ReportDialog.java
de.mkrtchyan.recoverytools.ScriptManagerFragment.java
de.mkrtchyan.recoverytools.SettingsFragment.java
de.mkrtchyan.utils.Common.java
de.mkrtchyan.utils.Downloader.java
de.mkrtchyan.utils.FileChooserDialog.java
de.mkrtchyan.utils.FileListView.java
de.mkrtchyan.utils.Notifyer.java
de.mkrtchyan.utils.SHA1.java
de.mkrtchyan.utils.Unzipper.java
donations.DonationsFragment.java
donations.google.util.Base64DecoderException.java
donations.google.util.Base64.java
donations.google.util.IabException.java
donations.google.util.IabHelper.java
donations.google.util.IabResult.java
donations.google.util.Inventory.java
donations.google.util.Purchase.java
donations.google.util.Security.java
donations.google.util.SkuDetails.java
org.sufficientlysecure.rootcommands.Mount.java
org.sufficientlysecure.rootcommands.Remounter.java
org.sufficientlysecure.rootcommands.RootCommands.java
org.sufficientlysecure.rootcommands.Shell.java
org.sufficientlysecure.rootcommands.SystemCommands.java
org.sufficientlysecure.rootcommands.Toolbox.java
org.sufficientlysecure.rootcommands.command.BinaryCommand.java
org.sufficientlysecure.rootcommands.command.Command.java
org.sufficientlysecure.rootcommands.command.SimpleBinaryCommand.java
org.sufficientlysecure.rootcommands.command.SimpleCommand.java
org.sufficientlysecure.rootcommands.util.BrokenBusyboxException.java
org.sufficientlysecure.rootcommands.util.FailedExecuteCommand.java
org.sufficientlysecure.rootcommands.util.Log.java
org.sufficientlysecure.rootcommands.util.RootAccessDeniedException.java
org.sufficientlysecure.rootcommands.util.UnsupportedArchitectureException.java
org.sufficientlysecure.rootcommands.util.Utils.java