Android no lock wifi

Android WifiLock is not working correctly on Android

I’m trying to lock wifi after connected to an access point but device switch to another network after 2 to 3 minutes. Here is how I’m trying to do.

 private static final String TAG = BuildConfig.APPLICATION_ID + ":WAKE_LOCK_TAG"; public MyWifiManager() < mWifiLock = ((WifiManager) App.getContext().getApplicationContext().getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF ,"MyWifiManager:mWifiLock"); PowerManager powerManager = (PowerManager) App.getContext().getSystemService(App.getContext().POWER_SERVICE); wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG) >public void acquireWifiLock() < if (mWifiLock != null && !mWifiLock.isHeld())< mWifiLock.acquire(); >> public void releaseWifiLock() < if( mWifiLock != null && mWifiLock.isHeld() )< mWifiLock.release(); >> public void acquireWakeLock() < if (wakeLock != null && !wakeLock.isHeld())< wakeLock.acquire(); >> public void releaseWakeLock() < if( wakeLock != null && wakeLock.isHeld() )< wakeLock.release(); >> 

2 Answers 2

WifiLock has a different purpose. It is used for keeping the Wi-Fi radio on and is not meant for locking to a particular network.

WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); wifiLock = wm.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF , "MyWifiLock"); wifiLock.acquire(); PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE); wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakeLock"); wakeLock.acquire(); 

And release the locks in onDestroy method:

if (wakeLock != null) < if (wakeLock.isHeld()) < wakeLock.release(); >> if (wifiLock != null) < if (wifiLock.isHeld()) < wifiLock.release(); >> 

That’s my mistake, I didn’t add code of wake lock of PowerManager in the description. Now That’s updated.

Источник

Как заблокировать Wi-Fi на телефоне и планшете Android?

WiFiGid

Пользу Интернета в 21 веке сложно недооценить. Он требуется повсюду. В связи с этим все современные гаджеты оснащаются средствами для выхода в Сеть. Иногда это может причинить много вреда. Это могут быть непреднамеренные траты со счета, переход по вирусным ссылкам, доступ к нежелательному контенту и т. д.

Чтобы избежать лишних трат или для ограничения детей требуется заблокировать подключение. Как заблокировать Вай-Фай на телефоне описано ниже.

Существует несколько способов блокировки Wi-Fi, которые отличаются, прежде всего, надежностью и сложностью.

При помощи встроенных средств

В функционал операционной системы смартфонов на Андроид входит несколько способов блокирования Wi-Fi. Но ввиду того, что производители не учитывают возможность нежелательного использования Интернета, действительно надежных защит не предусмотрено.

Через настройки ОС

Первый способ – самый простой, но также самый ненадежный. Необходимо зайти в настройки ОС, затем перейти в пункт Wi-Fi. Далее нужно нажать на кнопку деактивации. Список найденных подключений тут же пропадет. Если устройство в этот момент было подключено к Wi-Fi, соединение будет разорвано.

Как заблокировать Wi-Fi на телефоне и планшете Android?

Дополнительно можно ограничить доступ к Сети для отдельного приложения, которое нужно заблокировать от детей. Для этого нужно в разделе «Использование данных» выбрать нужное приложение и отметить его.

Как заблокировать Wi-Fi на телефоне и планшете Android?

Как можно заметить, способ прост. Но от нежелательного выхода в Интернет он не убережет. Для блокировки от детей такой способ будет явно неэффективен. Ведь ребенку достаточно просто зайти в настройки и поставить соответствующую галочку. А учитывая, что современные дети могут разбираться в этом вопросе куда лучше родителей, лучше подыскать решение понадежнее.

Читайте также:  Точка доступа вай фай юбикьюти

Включение автономного режима

Более кардинальное решение, которое поможет заблокировать Wi-Fi – переключение устройства в автономный режим. На Android выполняется долгим нажатием на кнопку включения, а потом выбирают соответствующий пункт.

Как заблокировать Wi-Fi на телефоне и планшете Android?

Такой метод прервет соединение с Интернетом и ограничит звонки, а также прием и отправку сообщений.

Запрещаем доступ через APN

Запретить доступ к Интернету на смартфонах и планшетах возможно через APN. На Android для этого нужно в настройках перейти в раздел «Подключения» / «Мобильные сети». После этого во вкладке «Точки доступа» необходимо добавить новый APN.

Как заблокировать Wi-Fi на телефоне и планшете Android?

При создании новой точки доступа и присваивании ей имени необходимо учесть, что для блокировки она должна быть некорректной. После создания точки доступа ее нужно выбрать в настройках сети. В силу некорректности, выход в Интернет будет недоступен.

Такой способ можно считать надежным, так как в подобных мелочах мало кто разбирается. Бонусом можно считать возможность закрытия нежелательных приложений и полное отсутствие синхронизации. Для обхода такой блокировки человеку нужно знать о ее существовании.

Еще несколько способов, которые помогут уберечь ребенка от нежелательного контента и приложений, описаны в следующем видео:

Блокировка при помощи стороннего ПО

Популярным способом блокировки сети является использование специального программного обеспечения. Примером может стать Internet (Data/WiFi) Lock. Это специальное приложение, которое позволяет обезопасить подключение к Интернету. Оно способно заблокировать Wi-Fi на телефоне лицам (в том числе и детям), которые не знают специального пароля.

Как заблокировать Wi-Fi на телефоне и планшете Android?

Приложение поддерживается любыми устройствами на Android. Простой интерфейс позволит быстро и надежно ограничить выход в Сеть через Wi-Fi, а также 3G/4G.

После установки и запуска приложения необходимо выбрать тип защиты. Их представлено три:

  • Wi-Fi + Data (пароль для Wi-Fi и мобильного доступа).
  • Wi-Fi Only (блокировка кодом только Wi-Fi).
  • Data Only (пароль только для мобильного Интернета).

Как заблокировать Wi-Fi на телефоне и планшете Android?

После выбора нужно придумать PIN код, который будет открывать доступ к сетям. Он не будет никому виден и обеспечит надежную защиту от ненужных подключений. Блокировку можно включать и выключать в любой момент. Можно также менять сам PIN. Но для этого понадобится ввести код, установленный ранее.

Надежность этого способа значительно выше, чем у предыдущих решений. Для обмана приложения будет недостаточно продвинутых знаний в этой сфере. Также приложение лишено ряда недостатков, которыми обладают предусмотренные системой способы.

Программа не расходует ресурсы устройства, потребляя очень мало оперативной памяти и не нагружая процессор. Благодаря небольшим размерам и функционалу приложение Internet (Data/WiFi) Lock завоевало признание огромного количества пользователей.

Скачать приложение можно в Play Market. Бесплатная версия традиционно будет с периодической рекламой. Отключить навязчивые ролики можно, купив версию без рекламы.

А какие способы ограничения доступа знаете и используете вы? Делитесь опытом, задавайте вопросы! Мы очень рады обратной связи!

Источник

How to restrict WiFi on Android phones (NO ROOT)

Imagem de capa

This is a solution to disable access to WiFi on an Android device without requiring root privileges. Access to the WiFi settings on the phone can be controlled via password or secret patterns. We make use of applications that are available for free on the Play Store to achieve this — AppLock and Automate.

The first app we use is called AppLock. This is an app which restricts access to any other installed app on the phone. The user will have to provide a password in order to gain access.

Читайте также:  Wifi hdd card reader

We can successfully block access to the Settings screen of the Android OS using just this app.

However, during my testing, I discovered the quick toggle tiles are not blocked by this method (the ones which can be pulled down from the top of the screen). This is probably because it is not part of the Android Settings app.

The second app that we will use, to complement AppLock is Automate. Automate is like Tasker, but with a more intuitive interface. It allows you to automate actions on the phone which can be trigerred by various events.

In simple terms, we will create a workflow with an action — disable WiFi for the event — enable WiFi. This effectively keeps the WiFi turned off at all times!

The advantage of using Automate to control WiFi access is that it only depends on the current state of the WiFi, and not the app which requested the state change. So, it wouldn’t matter if you tried to enable WiFi using quick tiles or network settings or another completely independent app. In contrast, with AppLock we will have to lock every single app which could possibly control the WiFi state.

Now once this is done, we use AppLock again to restrict access to Automate, so that the user cannot modify the settings created in Automate.

We can simplify the entire solution and purely depend on Automate’s workflow to keep the WiFi disabled, as it covers all scenarios in which the WiFi can move to the enabled state. AppLock can be purely used to restrict access to Automate.

What if the apps AppLock and Automate were to be uninstalled by the user? Yes, once these apps are uninstalled, the restriction on WiFi is removed, but there is a way to prevent the apps from being uninstalled.

Android Device Administrator — I discovered, while doing this research that there is a concept called device administrator apps, built right into Android. What this does is that it gives some apps special permissions to perform admin like tasks on the device. As a side effect of being device admin app, those apps cannot be uninstalled. So how do we register our apps as device admins? Well, that’s upto the app developers actually, and luckily both AppLock and Automate have the option of becoming device admin apps.

After setting up these apps in this way, WiFi is effectively disabled unless the user opens Automate (via AppLock password) and stops the workflow that turns the WiFi off. Otherwise, every other action that causes the WiFi to turn ON, would trigger the Automate workflow which will turn the WiFi back OFF.

Источник

Android Smart Lock: Why is there no option to use WiFi?

I am surprised that there is no option to use a trusted WiFi network.

Читайте также:  Чем отличается wifi от провода

Some forums state the risk for the WiFi network to be spoofed. I don’t understand how the risk is different: an attacker could spoof a Bluetooth device as well.

What could be reasons for not allowing a WiFi-based unlocking while allowing Bluetooth-based unlocking?

I honestly believe this question can be answered along technical lines without the need of introducing opinion. I request close voters to please let us know why do you disagree?

@Firelord wasn’t me, but «why» questions tend to be opinion-based. We can come up with reasons why *we» would do X – but unless there’s an official statement from those devs, we never know. Further, it rises the question: «What problem shall be solved here?» 😉 // Not saying it must be closed, just trying to shed some «opinion based light» on possible reasons of voters 🙂

2 Answers 2

Some forums state the risk for the WiFi network to be spoofed. I don’t understand how the risk is different: an attacker could spoof a Bluetooth device as well.

The risk is different. It’s not possible to spoof a paired Bluetooth device. The Bluetooth peripheral and the phone exchange keys as part of the pairing process, so both of them can securely identify the other. When the devices connect, they each challenge the other to prove they have the secret keys. If it didn’t work this way, it would be trivial to «man-in-the-middle» attack the connection by pretending to be the peripheral. Then the attacker could eavesdrop your phone calls or music, or whatever it is you’re sending over Bluetooth.

Authentication works a bit differently in Wi-Fi. See this question on our sister site Super User for more discussion on that. In open networks, and networks authenticated using WEP, WPA, or WPA2-PSK, the network doesn’t authenticate to the phone at all. The phone has to prove that it has the secret key (the network password), but the network doesn’t have to prove anything. There are no «trusted Wi-Fi networks» in this sense. Only networks authenticated with WPA2-Enterprise, which use a certificate pair, prove their identity to the phone, by showing a certificate signed by a certificate authority (just like HTTPS websites). Presumably, Google didn’t think it was worth adding an option that would only work with the least common type of Wi-Fi network, and the confusion it would cause their users.

Interestingly, Wi-Fi spoofing is already a security issue for the «trusted place» option. The location system uses visible Wi-Fi networks as one input to determine where you are, and as we’ve seen, that can cause huge inaccuracies. Spoofing this deliberately means looking at the networks that are visible in your «trusted place» and spoofing several at once. Your neighbourhood phone-snatcher won’t be able to unlock your phone this way, but government agencies and organised industrial spies probably can: especially if they also use a screened room to block GPS and cellular signals.

Источник

Оцените статью
Adblock
detector