Search in sources :

Example 1 with Tracker

use of com.google.analytics.tracking.android.Tracker in project fqrouter by fqrouter.

the class ExitService method exit.

private void exit() {
    try {
        MainActivity.displayNotification(this, getResources().getString(R.string.status_exiting));
        sendBroadcast(new ExitingIntent());
        long elapsedTime = StartedAtFlag.delete();
        if (elapsedTime > 0) {
            GoogleAnalytics gaInstance = GoogleAnalytics.getInstance(this);
            Tracker gaTracker = gaInstance.getTracker("UA-37740383-2");
            gaTracker.setCustomDimension(1, Build.MODEL);
            gaTracker.setCustomDimension(2, String.valueOf(ShellUtils.isRooted()));
            gaTracker.sendTiming("engagement", elapsedTime, "session", "session");
        }
        LogUtils.i("Exiting, session life " + elapsedTime + "...");
        new Thread(new Runnable() {

            @Override
            public void run() {
                stopService(new Intent(ExitService.this, DownloadService.class));
                stopService(new Intent(ExitService.this, AcquireWifiLockService.class));
                if (ShellUtils.isRooted()) {
                    for (File file : new File[] { IOUtils.ETC_DIR, IOUtils.LOG_DIR, IOUtils.VAR_DIR }) {
                        if (file.listFiles().length > 0) {
                            try {
                                ShellUtils.sudo(ShellUtils.BUSYBOX_FILE + " chmod 666 " + file + "/*");
                            } catch (Exception e) {
                                LogUtils.e("failed to chmod files to non-root", e);
                            }
                        }
                    }
                }
            }
        }).start();
        try {
            ManagerProcess.kill();
        } catch (Exception e) {
            LogUtils.e("failed to kill manager process", e);
        }
        sendBroadcast(new ExitedIntent());
        MainActivity.clearNotification(this);
    } finally {
        MainActivity.isReady = false;
    }
}
Also used : GoogleAnalytics(com.google.analytics.tracking.android.GoogleAnalytics) Tracker(com.google.analytics.tracking.android.Tracker) AcquireWifiLockService(fq.router2.wifi_repeater.AcquireWifiLockService) Intent(android.content.Intent) File(java.io.File) DownloadService(fq.router2.feedback.DownloadService)

Aggregations

Intent (android.content.Intent)1 GoogleAnalytics (com.google.analytics.tracking.android.GoogleAnalytics)1 Tracker (com.google.analytics.tracking.android.Tracker)1 DownloadService (fq.router2.feedback.DownloadService)1 AcquireWifiLockService (fq.router2.wifi_repeater.AcquireWifiLockService)1 File (java.io.File)1