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.proninyaroslav.libretorrent.fragments.DetailTorrentFragment.java

private void forceRecheckRequest() {
    if (!bound || serviceCallback == null) {
        return;/*  w ww .ja  va 2  s .com*/
    }

    ArrayList<String> list = new ArrayList<>();
    list.add(torrentId);

    try {
        ipc.sendForceRecheck(serviceCallback, list);

    } catch (RemoteException e) {
        Log.e(TAG, Log.getStackTraceString(e));
    }
}

From source file:com.keylesspalace.tusky.ComposeActivity.java

private boolean onCommitContentInternal(InputContentInfoCompat inputContentInfo, int flags) {
    if ((flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
        try {//  w w w. j  a v a2  s.  co  m
            inputContentInfo.requestPermission();
        } catch (Exception e) {
            Log.e(TAG, "InputContentInfoCompat#requestPermission() failed." + e.getMessage());
            return false;
        }
    }

    // Determine the file size before putting handing it off to be put in the queue.
    Uri uri = inputContentInfo.getContentUri();
    long mediaSize;
    AssetFileDescriptor descriptor = null;
    try {
        descriptor = getContentResolver().openAssetFileDescriptor(uri, "r");
    } catch (FileNotFoundException e) {
        Log.d(TAG, Log.getStackTraceString(e));
        // Eat this exception, having the descriptor be null is sufficient.
    }
    if (descriptor != null) {
        mediaSize = descriptor.getLength();
        try {
            descriptor.close();
        } catch (IOException e) {
            // Just eat this exception.
        }
    } else {
        mediaSize = MediaUtils.MEDIA_SIZE_UNKNOWN;
    }
    pickMedia(uri, mediaSize);

    currentInputContentInfo = inputContentInfo;
    currentFlags = flags;

    return true;
}

From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFragment.java

private void forceAnnounceRequest() {
    if (!bound || serviceCallback == null) {
        return;/* w  w w  . j av a 2 s  .  com*/
    }

    ArrayList<String> list = new ArrayList<>();
    list.add(torrentId);

    try {
        ipc.sendForceAnnounce(serviceCallback, list);

    } catch (RemoteException e) {
        Log.e(TAG, Log.getStackTraceString(e));
    }
}

From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFragment.java

private void pauseResumeTorrentRequest() {
    if (!bound || serviceCallback == null) {
        return;/*  w  w  w  .j ava2s.  co  m*/
    }

    ArrayList<String> list = new ArrayList<>();
    list.add(torrentId);

    try {
        ipc.sendPauseResumeTorrents(serviceCallback, list);

    } catch (RemoteException e) {
        Log.e(TAG, Log.getStackTraceString(e));
    }
}

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

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private ParcelFileDescriptor startVPN(Builder builder) throws SecurityException {
    try {/*  ww w.  j  a va  2s .c  o  m*/
        return builder.establish();
    } catch (SecurityException ex) {
        throw ex;
    } catch (Throwable ex) {
        Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        return null;
    }
}

From source file:org.proninyaroslav.libretorrent.fragments.DetailTorrentFragment.java

private void getMagnetRequest() {
    if (!bound || serviceCallback == null) {
        return;/*from  w w w . j a v  a 2s. c  om*/
    }

    try {
        ipc.sendGetMagnet(serviceCallback, clientCallback, torrentId);

    } catch (RemoteException e) {
        Log.e(TAG, Log.getStackTraceString(e));
    }
}

From source file:eu.operando.operandoapp.OperandoProxyStatus.java

private void DownloadInitialSettings() {

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getBoolean("firstTime", true) && haveNetworkConnection()) {
        // run one time code here
        final File tmp = new File(getFilesDir(), "domainfilters_" + System.currentTimeMillis());
        try {/* w ww. j a  va 2  s .  co  m*/
            new DownloadTask(MainActivity.this, new URL(DatabaseHelper.serverUrl + "/blocked_urls"), tmp,
                    new DownloadTask.Listener() {
                        @Override
                        public void onCompleted() {
                            new AsyncTask<Void, Void, Integer>() {
                                ProgressDialog dialog;

                                @Override
                                protected void onPreExecute() {
                                    dialog = ProgressDialog.show(MainActivity.this, null,
                                            "Applying up to date settings for your convenience, to keep you safe.\nThis might take while...");
                                    dialog.setCancelable(false);
                                }

                                @Override
                                protected Integer doInBackground(Void... params) {
                                    new DatabaseHelper(MainActivity.this)
                                            .deleteDomainFilterFile(DatabaseHelper.serverUrl);
                                    Integer count = 0;
                                    BufferedReader br = null;
                                    try {
                                        br = new BufferedReader(new FileReader(tmp));
                                        String line;
                                        while ((line = br.readLine()) != null) {
                                            int hash = line.indexOf('#');
                                            if (hash >= 0)
                                                line = line.substring(0, hash);
                                            line = line.trim();
                                            try {
                                                String blockedDomain = line;
                                                if (blockedDomain.equals("local")
                                                        || StringUtils.containsAny(blockedDomain, "localhost",
                                                                "127.0.0.1", "broadcasthost"))
                                                    continue;
                                                DomainFilter domainFilter = new DomainFilter();
                                                domainFilter.setContent(blockedDomain);
                                                domainFilter.setSource(DatabaseHelper.serverUrl);
                                                domainFilter.setIsWildcard(false);
                                                new DatabaseHelper(MainActivity.this)
                                                        .createDomainFilter(domainFilter);
                                                count++;
                                            } catch (Exception e) {
                                                Log.i("Error", "Invalid hosts file line: " + line);
                                            }
                                        }
                                        Log.i("Error", count + " entries read");
                                    } catch (IOException ex) {
                                        Log.e("Error", ex.toString() + "\n" + Log.getStackTraceString(ex));
                                    } finally {
                                        if (br != null)
                                            try {
                                                br.close();
                                            } catch (IOException exex) {
                                                Log.e("Error",
                                                        exex.toString() + "\n" + Log.getStackTraceString(exex));
                                            }
                                    }
                                    return count;
                                }

                                @Override
                                protected void onPostExecute(Integer count) {
                                    dialog.dismiss();
                                    // mark first time has runned.
                                    SharedPreferences.Editor editor = prefs.edit();
                                    editor.putBoolean("firstTime", false);
                                    editor.commit();
                                }
                            }.execute();
                        }

                        @Override
                        public void onCancelled() {
                            if (tmp.exists())
                                tmp.delete();
                        }

                        @Override
                        public void onException(Throwable ex) {
                            if (tmp.exists())
                                tmp.delete();

                            ex.printStackTrace();
                            Toast.makeText(MainActivity.this, ex.getMessage(), Toast.LENGTH_LONG).show();
                        }
                    }).execute();
        } catch (MalformedURLException mue) {
            mue.getMessage();
        }
    } else if (!haveNetworkConnection()) {
        Toast.makeText(MainActivity.this, "You don't seem to have a working Internet Connection.",
                Toast.LENGTH_LONG).show();
    }
}

From source file:org.alfresco.mobile.android.api.services.impl.onpremise.OnPremiseWorkflowServiceImpl.java

/** {@inheritDoc} */
public Task updateVariables(Task task, Map<String, Serializable> variables) {
    if (isObjectNull(task)) {
        throw new IllegalArgumentException(
                String.format(Messagesl18n.getString("ErrorCodeRegistry.GENERAL_INVALID_ARG_NULL"), "task"));
    }//from w ww.  jav a 2  s .  c om

    Map<String, Serializable> internalVariables = new HashMap<String, Serializable>();
    if (variables != null) {
        internalVariables.putAll(variables);
    }
    Task resultTask = task;
    try {
        String link = OnPremiseUrlRegistry.getFormTaskUrl(session, task.getIdentifier());
        UrlBuilder url = new UrlBuilder(link);

        // prepare json data
        JSONObject jo = new JSONObject();
        // VARIABLES
        if (internalVariables != null && !internalVariables.isEmpty()) {
            for (Entry<String, Serializable> entry : internalVariables.entrySet()) {
                if (ALFRESCO_TO_WORKFLOW.containsKey(entry.getKey())) {
                    jo.put(ALFRESCO_TO_WORKFLOW.get(entry.getKey()), entry.getValue());
                } else {
                    jo.put(entry.getKey(), entry.getValue());
                }
            }
        }

        final JsonDataWriter dataWriter = new JsonDataWriter(jo);

        // send
        Response resp = post(url, dataWriter.getContentType(), new Output() {
            public void write(OutputStream out) throws IOException {
                dataWriter.write(out);
            }
        }, ErrorCodeRegistry.WORKFLOW_GENERIC);

        Map<String, Object> json = JsonUtils.parseObject(resp.getStream(), resp.getCharset());
        String data = JSONConverter.getString(json, OnPremiseConstant.PERSISTEDOBJECT_VALUE);

        // WorkflowInstance[id=activiti$18328,active=true,def=WorkflowDefinition[
        String taskId = data.split("\\[")[1].split(",")[0].split("=")[1];

        resultTask = getTask(taskId);
    } catch (Exception e) {
        Log.e(TAG, Log.getStackTraceString(e));
        convertException(e);
    }

    return resultTask;
}

From source file:android_network.hetnet.vpn_service.ServiceSinkhole.java

public static List<InetAddress> getDns(Context context) {
    List<InetAddress> listDns = new ArrayList<>();
    List<String> sysDns = Util.getDefaultDNS(context);

    // Get custom DNS servers
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String vpnDns1 = prefs.getString("dns", null);
    String vpnDns2 = prefs.getString("dns2", null);
    Log.i(TAG, "DNS system=" + TextUtils.join(",", sysDns) + " VPN1=" + vpnDns1 + " VPN2=" + vpnDns2);

    if (vpnDns1 != null)
        try {//from  w w  w.j  a  v  a 2 s  .  c  o m
            InetAddress dns = InetAddress.getByName(vpnDns1);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()))
                listDns.add(dns);
        } catch (Throwable ignored) {
        }

    if (vpnDns2 != null)
        try {
            InetAddress dns = InetAddress.getByName(vpnDns2);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()))
                listDns.add(dns);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

    // Use system DNS servers only when no two custom DNS servers specified
    if (listDns.size() <= 1)
        for (String def_dns : sysDns)
            try {
                InetAddress ddns = InetAddress.getByName(def_dns);
                if (!listDns.contains(ddns) && !(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress()))
                    listDns.add(ddns);
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }

    // Remove local DNS servers when not routing LAN
    boolean lan = prefs.getBoolean("lan", false);
    if (lan) {
        List<InetAddress> listLocal = new ArrayList<>();
        try {
            Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
            if (nis != null)
                while (nis.hasMoreElements()) {
                    NetworkInterface ni = nis.nextElement();
                    if (ni != null && ni.isUp() && !ni.isLoopback()) {
                        List<InterfaceAddress> ias = ni.getInterfaceAddresses();
                        if (ias != null)
                            for (InterfaceAddress ia : ias) {
                                InetAddress hostAddress = ia.getAddress();
                                BigInteger host = new BigInteger(1, hostAddress.getAddress());

                                int prefix = ia.getNetworkPrefixLength();
                                BigInteger mask = BigInteger.valueOf(-1)
                                        .shiftLeft(hostAddress.getAddress().length * 8 - prefix);

                                for (InetAddress dns : listDns)
                                    if (hostAddress.getAddress().length == dns.getAddress().length) {
                                        BigInteger ip = new BigInteger(1, dns.getAddress());

                                        if (host.and(mask).equals(ip.and(mask))) {
                                            Log.i(TAG, "Local DNS server host=" + hostAddress + "/" + prefix
                                                    + " dns=" + dns);
                                            listLocal.add(dns);
                                        }
                                    }
                            }
                    }
                }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        List<InetAddress> listDns4 = new ArrayList<>();
        List<InetAddress> listDns6 = new ArrayList<>();
        try {
            listDns4.add(InetAddress.getByName("8.8.8.8"));
            listDns4.add(InetAddress.getByName("8.8.4.4"));
            listDns6.add(InetAddress.getByName("2001:4860:4860::8888"));
            listDns6.add(InetAddress.getByName("2001:4860:4860::8844"));

        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        for (InetAddress dns : listLocal) {
            listDns.remove(dns);
            if (dns instanceof Inet4Address) {
                if (listDns4.size() > 0) {
                    listDns.add(listDns4.get(0));
                    listDns4.remove(0);
                }
            } else {
                if (listDns6.size() > 0) {
                    listDns.add(listDns6.get(0));
                    listDns6.remove(0);
                }
            }
        }
    }

    // Prefer IPv4 addresses
    Collections.sort(listDns, new Comparator<InetAddress>() {
        @Override
        public int compare(InetAddress a, InetAddress b) {
            boolean a4 = (a instanceof Inet4Address);
            boolean b4 = (b instanceof Inet4Address);
            if (a4 && !b4)
                return -1;
            else if (!a4 && b4)
                return 1;
            else
                return 0;
        }
    });

    return listDns;
}

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

public static List<InetAddress> getDns(Context context) {
    List<InetAddress> listDns = new ArrayList<>();
    List<String> sysDns = Util.getDefaultDNS(context);

    // Get custom DNS servers
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    boolean ip6 = prefs.getBoolean("ip6", true);
    String vpnDns1 = prefs.getString("dns", null);
    String vpnDns2 = prefs.getString("dns2", null);
    Log.i(TAG, "DNS system=" + TextUtils.join(",", sysDns) + " VPN1=" + vpnDns1 + " VPN2=" + vpnDns2);

    if (vpnDns1 != null)
        try {//from www  .ja v a2  s . com
            InetAddress dns = InetAddress.getByName(vpnDns1);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()) && (ip6 || dns instanceof Inet4Address))
                listDns.add(dns);
        } catch (Throwable ignored) {
        }

    if (vpnDns2 != null)
        try {
            InetAddress dns = InetAddress.getByName(vpnDns2);
            if (!(dns.isLoopbackAddress() || dns.isAnyLocalAddress()) && (ip6 || dns instanceof Inet4Address))
                listDns.add(dns);
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

    // Use system DNS servers only when no two custom DNS servers specified
    if (listDns.size() <= 1)
        for (String def_dns : sysDns)
            try {
                InetAddress ddns = InetAddress.getByName(def_dns);
                if (!listDns.contains(ddns) && !(ddns.isLoopbackAddress() || ddns.isAnyLocalAddress())
                        && (ip6 || ddns instanceof Inet4Address))
                    listDns.add(ddns);
            } catch (Throwable ex) {
                Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
            }

    // Remove local DNS servers when not routing LAN
    boolean lan = prefs.getBoolean("lan", false);
    boolean use_hosts = prefs.getBoolean("filter", false) && prefs.getBoolean("use_hosts", false);
    if (lan && use_hosts) {
        List<InetAddress> listLocal = new ArrayList<>();
        try {
            Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
            if (nis != null)
                while (nis.hasMoreElements()) {
                    NetworkInterface ni = nis.nextElement();
                    if (ni != null && ni.isUp() && !ni.isLoopback()) {
                        List<InterfaceAddress> ias = ni.getInterfaceAddresses();
                        if (ias != null)
                            for (InterfaceAddress ia : ias) {
                                InetAddress hostAddress = ia.getAddress();
                                BigInteger host = new BigInteger(1, hostAddress.getAddress());

                                int prefix = ia.getNetworkPrefixLength();
                                BigInteger mask = BigInteger.valueOf(-1)
                                        .shiftLeft(hostAddress.getAddress().length * 8 - prefix);

                                for (InetAddress dns : listDns)
                                    if (hostAddress.getAddress().length == dns.getAddress().length) {
                                        BigInteger ip = new BigInteger(1, dns.getAddress());

                                        if (host.and(mask).equals(ip.and(mask))) {
                                            Log.i(TAG, "Local DNS server host=" + hostAddress + "/" + prefix
                                                    + " dns=" + dns);
                                            listLocal.add(dns);
                                        }
                                    }
                            }
                    }
                }
        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        List<InetAddress> listDns4 = new ArrayList<>();
        List<InetAddress> listDns6 = new ArrayList<>();
        try {
            listDns4.add(InetAddress.getByName("8.8.8.8"));
            listDns4.add(InetAddress.getByName("8.8.4.4"));
            if (ip6) {
                listDns6.add(InetAddress.getByName("2001:4860:4860::8888"));
                listDns6.add(InetAddress.getByName("2001:4860:4860::8844"));
            }

        } catch (Throwable ex) {
            Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
        }

        for (InetAddress dns : listLocal) {
            listDns.remove(dns);
            if (dns instanceof Inet4Address) {
                if (listDns4.size() > 0) {
                    listDns.add(listDns4.get(0));
                    listDns4.remove(0);
                }
            } else {
                if (listDns6.size() > 0) {
                    listDns.add(listDns6.get(0));
                    listDns6.remove(0);
                }
            }
        }
    }

    return listDns;
}