use of com.google.analytics.tracking.android.GoogleAnalytics in project fqrouter by fqrouter.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
setTitle("fqrouter " + LaunchService.getMyVersion(this));
LaunchedIntent.register(this);
LaunchingIntent.register(this);
UpdateFoundIntent.register(this);
ExitedIntent.register(this);
DownloadingIntent.register(this);
DownloadedIntent.register(this);
DownloadFailedIntent.register(this);
HandleFatalErrorIntent.register(this);
DnsPollutedIntent.register(this);
HandleAlertIntent.register(this);
ExitingIntent.register(this);
SocksVpnConnectedIntent.register(this);
gestureDetector = new GestureDetectorCompat(this, new MyGestureDetector());
Button fullPowerButton = (Button) findViewById(R.id.fullPowerButton);
GoogleAnalytics gaInstance = GoogleAnalytics.getInstance(MainActivity.this);
gaTracker = gaInstance.getTracker("UA-37740383-2");
CookieSyncManager.createInstance(this);
fullPowerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
gaTracker.sendEvent("more-power", "click", "", new Long(0));
if (Build.VERSION.SDK_INT < 14) {
Uri uri = Uri.parse("http://127.0.0.1:" + ConfigUtils.getHttpManagerPort());
startActivity(new Intent(Intent.ACTION_VIEW, uri));
} else {
showWebView();
}
}
});
if (isReady) {
onReady();
showWebView();
} else {
LaunchService.execute(this);
}
}
use of com.google.analytics.tracking.android.GoogleAnalytics 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;
}
}
Aggregations