Example usage for android.util Log getStackTraceString

List of usage examples for android.util Log getStackTraceString

Introduction

In this page you can find the example usage for android.util Log getStackTraceString.

Prototype

public static String getStackTraceString(Throwable tr) 

Source Link

Document

Handy function to get a loggable stack trace from a Throwable

Usage

From source file:org.alfresco.mobile.android.application.providers.storage.StorageAccessDocumentsProvider.java

public static boolean copyFile(InputStream src, long size, File dest, CancellationSignal signal) {
    IOUtils.ensureOrCreatePathAndFile(dest);
    OutputStream os = null;//w ww  .  j a  va 2  s  .c  o  m
    boolean copied = true;
    int downloaded = 0;

    try {
        os = new BufferedOutputStream(new FileOutputStream(dest));

        byte[] buffer = new byte[MAX_BUFFER_SIZE];

        while (size - downloaded > 0) {
            if (size - downloaded < MAX_BUFFER_SIZE) {
                buffer = new byte[(int) (size - downloaded)];
            }

            int read = src.read(buffer);
            if (read == -1) {
                break;
            }

            os.write(buffer, 0, read);
            downloaded += read;
            if (signal != null && signal.isCanceled()) {
                signal.throwIfCanceled();
            }
        }
    } catch (Exception e) {
        Log.e(TAG, Log.getStackTraceString(e));
        copied = false;
    } finally {
        IOUtils.closeStream(src);
        IOUtils.closeStream(os);
    }
    return copied;
}

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

private void handleExport(final Intent data) {
    new AsyncTask<Object, Object, Throwable>() {
        @Override/*ww w.  j  a v a 2s . co  m*/
        protected Throwable doInBackground(Object... objects) {
            OutputStream out = null;
            try {
                Uri target = data.getData();
                if (data.hasExtra("org.openintents.extra.DIR_PATH"))
                    target = Uri.parse(target + "/adblocker_"
                            + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".xml");
                Log.i(TAG, "Writing URI=" + target);
                out = getContentResolver().openOutputStream(target);
                xmlExport(out);
                return null;
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                return ex;
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
            }
        }

        @Override
        protected void onPostExecute(Throwable ex) {
            if (running) {
                if (ex == null)
                    Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
                else
                    Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }.execute();
}

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

private Builder getBuilder(List<Rule> listAllowed, List<Rule> listRule) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean tethering = prefs.getBoolean("tethering", false);
    boolean filter = prefs.getBoolean("filter", false);
    boolean system = prefs.getBoolean("manage_system", false);

    // Build VPN service
    Builder builder = new Builder();
    builder.setSession(getString(R.string.app_name));

    // VPN address
    String vpn4 = prefs.getString("vpn4", "10.1.10.1");
    String vpn6 = prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1");
    Log.i(TAG, "vpn4=" + vpn4 + " vpn6=" + vpn6);
    builder.addAddress(vpn4, 32);//from   w  w w  .  j  a  v  a 2  s . c  om
    builder.addAddress(vpn6, 128);

    // DNS address
    if (filter)
        for (InetAddress dns : getDns(ServiceSinkhole.this)) {
            Log.i(TAG, "dns=" + dns);
            builder.addDnsServer(dns);
        }

    if (tethering) {
        // USB Tethering 192.168.42.x
        // Wi-Fi Tethering 192.168.43.x
        // https://en.wikipedia.org/wiki/IPv4#Special-use_addresses
        builder.addRoute("0.0.0.0", 2); // 0-63
        builder.addRoute("64.0.0.0", 3); // 64-95
        builder.addRoute("96.0.0.0", 4); // 96-111
        builder.addRoute("112.0.0.0", 5); // 112-119
        builder.addRoute("120.0.0.0", 6); // 120-123
        builder.addRoute("124.0.0.0", 7); // 124-125
        builder.addRoute("126.0.0.0", 8); // 126
        // skip 127.0.0.0/8 - localhost
        builder.addRoute("128.0.0.0", 2); // 128-191
        builder.addRoute("192.0.0.0", 9); // 192.0-192.127
        builder.addRoute("192.128.0.0", 11); // 192.128-192.159
        builder.addRoute("192.160.0.0", 13); // 192.160-192.167
        builder.addRoute("192.168.0.0", 19); // 192.168.0-192.168.31
        builder.addRoute("192.168.32.0", 21); // 192.168.32-192.168.39
        builder.addRoute("192.168.40.0", 23); // 192.168.40-192.168.41
        // skip 192.168.42 - 192.168.43 - tethering
        builder.addRoute("192.168.44.0", 22); // 192.168.44-192.168.47
        builder.addRoute("192.168.48.0", 20); // 192.168.48-192.168.63
        builder.addRoute("192.168.64.0", 18); // 192.168.64-192.168.127
        builder.addRoute("192.168.128.0", 17); // 192.168.128-192.168.255
        builder.addRoute("192.169.0.0", 16); // 192.169
        builder.addRoute("192.170.0.0", 15); // 192.170-192.171
        builder.addRoute("192.172.0.0", 14); // 192.172-192.175
        builder.addRoute("192.176.0.0", 12); // 192.176-191.191
        builder.addRoute("192.192.0.0", 10); // 192.192-192.255
        builder.addRoute("193.0.0.0", 8); // 193
        builder.addRoute("194.0.0.0", 7); // 194-195
        builder.addRoute("196.0.0.0", 6); // 196-199
        builder.addRoute("200.0.0.0", 5); // 200-207
        builder.addRoute("208.0.0.0", 4); // 208-223

        try {
            builder.addRoute("224.0.0.0", 4); // 224-239
            builder.addRoute("240.0.0.0", 4); // 240-255
        } catch (Throwable ex) {
            // Some Android versions do not accept broadcast addresses
            Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }
    } else
        builder.addRoute("0.0.0.0", 0);

    builder.addRoute("0:0:0:0:0:0:0:0", 0);

    // MTU
    int mtu = jni_get_mtu();
    Log.i(TAG, "MTU=" + mtu);
    builder.setMtu(mtu);

    // Add list of allowed applications
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        if (last_connected && !filter)
            for (Rule rule : listAllowed)
                try {
                    builder.addDisallowedApplication(rule.info.packageName);
                } catch (PackageManager.NameNotFoundException ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        else if (filter)
            for (Rule rule : listRule)
                if (!rule.apply || (!system && rule.system))
                    try {
                        Log.i(TAG, "Not routing " + rule.info.packageName);
                        builder.addDisallowedApplication(rule.info.packageName);
                    } catch (PackageManager.NameNotFoundException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }

    // Build configure intent
    Intent configure = new Intent(this, ActivityMain.class);
    PendingIntent pi = PendingIntent.getActivity(this, 0, configure, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setConfigureIntent(pi);

    return builder;
}

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

private Builder getBuilder(List<Rule> listAllowed, List<Rule> listRule) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean subnet = prefs.getBoolean("subnet", false);
    boolean tethering = prefs.getBoolean("tethering", false);
    boolean lan = prefs.getBoolean("lan", false);
    boolean ip6 = prefs.getBoolean("ip6", true);
    boolean filter = prefs.getBoolean("filter", false);
    boolean system = prefs.getBoolean("manage_system", false);

    // Build VPN service
    Builder builder = new Builder();
    builder.setSession(getString(R.string.app_name));

    // VPN address
    String vpn4 = prefs.getString("vpn4", "10.1.10.1");
    Log.i(TAG, "vpn4=" + vpn4);
    builder.addAddress(vpn4, 32);//from www  . j  ava  2  s.c  o m
    if (ip6) {
        String vpn6 = prefs.getString("vpn6", "fd00:1:fd00:1:fd00:1:fd00:1");
        Log.i(TAG, "vpn6=" + vpn6);
        builder.addAddress(vpn6, 128);
    }

    // DNS address
    if (filter)
        for (InetAddress dns : getDns(ServiceSinkhole.this)) {
            if (ip6 || dns instanceof Inet4Address) {
                Log.i(TAG, "dns=" + dns);
                builder.addDnsServer(dns);
            }
        }

    // Subnet routing
    if (subnet) {
        // Exclude IP ranges
        List<IPUtil.CIDR> listExclude = new ArrayList<>();
        listExclude.add(new IPUtil.CIDR("127.0.0.0", 8)); // localhost

        if (tethering) {
            // USB Tethering 192.168.42.x
            // Wi-Fi Tethering 192.168.43.x
            listExclude.add(new IPUtil.CIDR("192.168.42.0", 23));
        }

        if (lan) {
            try {
                Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
                while (nis.hasMoreElements()) {
                    NetworkInterface ni = nis.nextElement();
                    if (ni != null && ni.isUp() && !ni.isLoopback() && ni.getName() != null
                            && !ni.getName().startsWith("tun"))
                        for (InterfaceAddress ia : ni.getInterfaceAddresses())
                            if (ia.getAddress() instanceof Inet4Address) {
                                IPUtil.CIDR local = new IPUtil.CIDR(ia.getAddress(),
                                        ia.getNetworkPrefixLength());
                                Log.i(TAG, "Excluding " + ni.getName() + " " + local);
                                listExclude.add(local);
                            }
                }
            } catch (SocketException ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }
        }

        Configuration config = getResources().getConfiguration();
        if (config.mcc == 310 && config.mnc == 260) {
            // T-Mobile Wi-Fi calling
            listExclude.add(new IPUtil.CIDR("66.94.2.0", 24));
            listExclude.add(new IPUtil.CIDR("66.94.6.0", 23));
            listExclude.add(new IPUtil.CIDR("66.94.8.0", 22));
            listExclude.add(new IPUtil.CIDR("208.54.0.0", 16));
        }
        listExclude.add(new IPUtil.CIDR("224.0.0.0", 3)); // broadcast

        Collections.sort(listExclude);

        try {
            InetAddress start = InetAddress.getByName("0.0.0.0");
            for (IPUtil.CIDR exclude : listExclude) {
                Log.i(TAG, "Exclude " + exclude.getStart().getHostAddress() + "..."
                        + exclude.getEnd().getHostAddress());
                for (IPUtil.CIDR include : IPUtil.toCIDR(start, IPUtil.minus1(exclude.getStart())))
                    try {
                        builder.addRoute(include.address, include.prefix);
                    } catch (Throwable ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
                start = IPUtil.plus1(exclude.getEnd());
            }
            for (IPUtil.CIDR include : IPUtil.toCIDR("224.0.0.0", "255.255.255.255"))
                try {
                    builder.addRoute(include.address, include.prefix);
                } catch (Throwable ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        } catch (UnknownHostException ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }
    } else
        builder.addRoute("0.0.0.0", 0);

    Log.i(TAG, "IPv6=" + ip6);
    if (ip6)
        builder.addRoute("0:0:0:0:0:0:0:0", 0);

    // MTU
    int mtu = jni_get_mtu();
    Log.i(TAG, "MTU=" + mtu);
    builder.setMtu(mtu);

    // Add list of allowed applications
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        if (last_connected && !filter)
            for (Rule rule : listAllowed)
                try {
                    builder.addDisallowedApplication(rule.info.packageName);
                } catch (PackageManager.NameNotFoundException ex) {
                    Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                }
        else if (filter)
            for (Rule rule : listRule)
                if (!rule.apply || (!system && rule.system))
                    try {
                        Log.i(TAG, "Not routing " + rule.info.packageName);
                        builder.addDisallowedApplication(rule.info.packageName);
                    } catch (PackageManager.NameNotFoundException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }

    // Build configure intent
    Intent configure = new Intent(this, ActivityMain.class);
    PendingIntent pi = PendingIntent.getActivity(this, 0, configure, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setConfigureIntent(pi);

    return builder;
}

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

private void handleExport(final Intent data) {
    new AsyncTask<Object, Object, Throwable>() {
        @Override//from  w  w  w  . j a  v  a2  s .c  o m
        protected Throwable doInBackground(Object... objects) {
            OutputStream out = null;
            try {
                Uri target = data.getData();
                if (data.hasExtra("org.openintents.extra.DIR_PATH"))
                    target = Uri.parse(target + "/netguard_"
                            + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".xml");
                Log.i(TAG, "Writing URI=" + target);
                out = getContentResolver().openOutputStream(target);
                xmlExport(out);
                return null;
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                return ex;
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
            }
        }

        @Override
        protected void onPostExecute(Throwable ex) {
            if (running) {
                if (ex == null)
                    Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
                else
                    Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

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

private void handleHosts(final Intent data) {
    new AsyncTask<Object, Object, Throwable>() {
        @Override// w  ww  . j a  v a 2 s.c  om
        protected Throwable doInBackground(Object... objects) {
            File hosts = new File(getFilesDir(), "host/hosts.txt");

            FileOutputStream out = null;
            InputStream in = null;
            try {
                Log.i(TAG, "Reading URI=" + data.getData());
                in = getContentResolver().openInputStream(data.getData());
                out = new FileOutputStream(hosts);

                int len;
                long total = 0;
                byte[] buf = new byte[4096];
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                    total += len;
                }
                Log.i(TAG, "Copied bytes=" + total);

                return null;
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                return ex;
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
                if (in != null)
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
            }
        }

        @Override
        protected void onPostExecute(Throwable ex) {
            if (running) {
                if (ex == null) {
                    SharedPreferences prefs = PreferenceManager
                            .getDefaultSharedPreferences(ActivitySettings.this);
                    String last = SimpleDateFormat.getDateTimeInstance().format(new Date().getTime());
                    prefs.edit().putString("hosts_last_import", last).apply();

                    if (running) {
                        getPreferenceScreen().findPreference("use_hosts").setEnabled(true);
                        getPreferenceScreen().findPreference("hosts_import")
                                .setSummary(getString(R.string.msg_import_last, last));
                        Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
                    }

                    ServiceSinkhole.reload("hosts import", ActivitySettings.this);
                } else
                    Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }.execute();
}

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

private void handleHosts(final Intent data) {
    new AsyncTask<Object, Object, Throwable>() {
        @Override//from w w  w  . java 2  s.com
        protected Throwable doInBackground(Object... objects) {
            File hosts = new File(getFilesDir(), "hosts.txt");

            FileOutputStream out = null;
            InputStream in = null;
            try {
                Log.i(TAG, "Reading URI=" + data.getData());
                in = getContentResolver().openInputStream(data.getData());
                out = new FileOutputStream(hosts);

                int len;
                long total = 0;
                byte[] buf = new byte[4096];
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                    total += len;
                }
                Log.i(TAG, "Copied bytes=" + total);

                return null;
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                return ex;
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
                if (in != null)
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
            }
        }

        @Override
        protected void onPostExecute(Throwable ex) {
            if (running) {
                if (ex == null) {
                    SharedPreferences prefs = PreferenceManager
                            .getDefaultSharedPreferences(ActivitySettings.this);
                    String last = SimpleDateFormat.getDateTimeInstance().format(new Date().getTime());
                    prefs.edit().putString("hosts_last_import", last).apply();

                    if (running) {
                        getPreferenceScreen().findPreference("use_hosts").setEnabled(true);
                        getPreferenceScreen().findPreference("hosts_import")
                                .setSummary(getString(R.string.msg_import_last, last));
                        Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
                    }

                    ServiceSinkhole.reload("hosts import", ActivitySettings.this);
                } else
                    Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }.execute();
}

From source file:org.alfresco.mobile.android.application.providers.storage.StorageAccessDocumentsProvider.java

private void checkSession(EncodedQueryUri row) {
    // Check Session
    if (session == null) {
        // If no session available, try to retrieve it from
        // ApplicationManager
        sessionManager = SessionManager.getInstance(getContext());
        if (sessionManager != null && sessionManager.getSession(row.accountId) != null) {
            session = sessionManager.getSession(row.accountId);
            sessionIndex.put(row.accountId, session);
        }//from  w  w w  . j a v  a  2  s .c o  m

        // If no session available, try to create a new one
        selectedAccount = accountsIndex.get(row.accountId);
        accountType = selectedAccount.getTypeId();
        selectedUrl = selectedAccount.getUrl();
        try {
            switch (accountType) {
            case AlfrescoAccount.TYPE_ALFRESCO_CLOUD:
                oauthdata = new OAuth2DataImpl(getContext().getString(R.string.oauth_api_key),
                        getContext().getString(R.string.oauth_api_secret), selectedAccount.getAccessToken(),
                        selectedAccount.getRefreshToken());
                session = CloudSession.connect(oauthdata);
                break;
            case AlfrescoAccount.TYPE_ALFRESCO_CMIS:
                session = RepositorySession.connect(selectedUrl, selectedAccount.getUsername(),
                        selectedAccount.getPassword());
                break;
            default:
                break;
            }
            sessionIndex.put(selectedAccount.getId(), session);
        } catch (AlfrescoException e) {
            Log.e(TAG, Log.getStackTraceString(e));
            exception = e;
        }
    }
}

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

private void handleHosts(final Intent data) {
    new AsyncTask<Object, Object, Throwable>() {
        @Override/* ww  w.ja v  a2 s. c  o  m*/
        protected Throwable doInBackground(Object... objects) {
            File hosts = new File(getFilesDir(), "hosts.txt");

            FileOutputStream out = null;
            InputStream in = null;
            try {
                Log.i(TAG, "Reading URI=" + data.getData());
                ContentResolver resolver = getContentResolver();
                String[] streamTypes = resolver.getStreamTypes(data.getData(), "*/*");
                String streamType = (streamTypes == null || streamTypes.length == 0 ? "*/*" : streamTypes[0]);
                AssetFileDescriptor descriptor = resolver.openTypedAssetFileDescriptor(data.getData(),
                        streamType, null);
                in = descriptor.createInputStream();
                out = new FileOutputStream(hosts);

                int len;
                long total = 0;
                byte[] buf = new byte[4096];
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                    total += len;
                }
                Log.i(TAG, "Copied bytes=" + total);

                return null;
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                return ex;
            } finally {
                if (out != null)
                    try {
                        out.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
                if (in != null)
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
            }
        }

        @Override
        protected void onPostExecute(Throwable ex) {
            if (running) {
                if (ex == null) {
                    SharedPreferences prefs = PreferenceManager
                            .getDefaultSharedPreferences(ActivitySettings.this);
                    String last = SimpleDateFormat.getDateTimeInstance().format(new Date().getTime());
                    prefs.edit().putString("hosts_last_import", last).apply();

                    if (running) {
                        getPreferenceScreen().findPreference("hosts_import")
                                .setSummary(getString(R.string.msg_import_last, last));
                        Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
                    }

                    ServiceSinkhole.reload("hosts import", ActivitySettings.this, false);
                } else
                    Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

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

private void handleImport(final Intent data) {
    new AsyncTask<Object, Object, Throwable>() {
        @Override//from w w w. j a  va 2  s.  c o m
        protected Throwable doInBackground(Object... objects) {
            InputStream in = null;
            try {
                Log.i(TAG, "Reading URI=" + data.getData());
                in = getContentResolver().openInputStream(data.getData());
                xmlImport(in);
                return null;
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                return ex;
            } finally {
                if (in != null)
                    try {
                        in.close();
                    } catch (IOException ex) {
                        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
                    }
            }
        }

        @Override
        protected void onPostExecute(Throwable ex) {
            if (running) {
                if (ex == null) {
                    Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show();
                    ServiceSinkhole.reloadStats("import", ActivitySettings.this);
                    // Update theme, request permissions
                    recreate();
                } else
                    Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }.execute();
}