use of com.genonbeta.TrebleShot.util.CommunicationNotificationHelper 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);
}
});
}
Aggregations