@Override protected void onOpen() { super.onOpen(); regular = new Thread(new Runnable() { @Override public void run() { synchronized (regular) { while (!regular.isInterrupted()) { try { regular.wait(60000); } catch (InterruptedException e) { return; } Location location = LocationHelper.create("random", random.nextDouble() * 90, random.nextDouble() * 90, random.nextFloat() * 90); Log.d(TAG, "Just reported: " + location); report(location); } } } }); regular.start(); }
@Override public void open(LocationCallback callback) throws RemoteException { LocationBackendService.this.callback = callback; if (waiting != null) { callback.report(waiting); waiting = null; } onOpen(); }
/** * We are starting to run, get the resources we need to do our job. */ @Override protected void onOpen() { Log.d(TAG, "onOpen() entry."); super.onOpen(); instance = this; nextReportTime = 0; nextMobileScanTime = 0; nextWlanScanTime = 0; wifiBroadcastReceiverRegistered = false; wifiScanInprogress = false; if (emitterCache == null) emitterCache = new Cache(this); permissionsOkay = true; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Check our needed permissions, don't run unless we can. for (String s : myPerms) { permissionsOkay &= (checkSelfPermission(s) == PackageManager.PERMISSION_GRANTED); } } if (permissionsOkay) { setgpsMonitorRunning(true); this.registerReceiver(wifiBroadcastReceiver, wifiBroadcastFilter); wifiBroadcastReceiverRegistered = true; } else { Log.d(TAG, "onOpen() - Permissions not granted, soft fail."); } }