use of com.genonbeta.TrebleShot.util.NsdDiscovery in project TrebleShot by genonbeta.
the class CommunicationService method onCreate.
@Override
public void onCreate() {
super.onCreate();
mNotificationHelper = new CommunicationNotificationHelper(this);
mDatabase = new AccessDatabase(this);
mNsdDiscovery = new NsdDiscovery(getApplicationContext(), getDatabase());
mMediaScanner = new MediaScannerConnection(this, null);
mHotspotUtils = HotspotUtils.getInstance(this);
mWifiLock = ((WifiManager) getApplicationContext().getSystemService(Service.WIFI_SERVICE)).createWifiLock(TAG);
mReceive.setNotifyDelay(AppConfig.DEFAULT_NOTIFICATION_DELAY);
mReceive.setBlockingObject(mBlockingObject);
mSend.setNotifyDelay(AppConfig.DEFAULT_NOTIFICATION_DELAY);
mSend.setBlockingObject(mBlockingObject);
mMediaScanner.connect();
mNsdDiscovery.registerService();
if (getWifiLock() != null)
getWifiLock().acquire();
updateServiceState(getPreferences().getBoolean("trust_always", false));
if (!AppUtils.checkRunningConditions(this) || !mCommunicationServer.start() || !mSeamlessServer.start())
stopSelf();
if (getHotspotUtils() instanceof HotspotUtils.OreoAPI && Build.VERSION.SDK_INT >= 26)
((HotspotUtils.OreoAPI) getHotspotUtils()).setSecondaryCallback(new WifiManager.LocalOnlyHotspotCallback() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onStarted(WifiManager.LocalOnlyHotspotReservation reservation) {
super.onStarted(reservation);
sendHotspotStatus(reservation.getWifiConfiguration());
if (getPreferences().getBoolean("hotspot_trust", false))
updateServiceState(true);
}
});
}
use of com.genonbeta.TrebleShot.util.NsdDiscovery in project TrebleShot by genonbeta.
the class NetworkDeviceListFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mHotspotUtils = HotspotUtils.getInstance(getContext());
mWifiManager = mHotspotUtils.getWifiManager();
mConnectivityManager = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
mLocationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
mIntentFilter.addAction(DeviceScannerService.ACTION_SCAN_STARTED);
mIntentFilter.addAction(CommunicationService.ACTION_HOTSPOT_STATUS);
mIntentFilter.addAction(DeviceScannerService.ACTION_DEVICE_SCAN_COMPLETED);
mIntentFilter.addAction(NetworkStatusReceiver.WIFI_AP_STATE_CHANGED);
mIntentFilter.addAction(AccessDatabase.ACTION_DATABASE_CHANGE);
mIntentFilter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);
mIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
mNsdDiscovery = new NsdDiscovery(getContext(), getAdapter().getDatabase());
}
Aggregations