Check Whether Lock Was Enabled or Not

Check if lock is held but not lock it if it is free

You may use ReadWriteLock.

  • Incrementing threads acquire read lock before incrementing value.
  • Cleaning thread acquire write lock.

You still need individual locks for each counter.

Android 4.3 : How can I check if user has lock enabled?

Ok, so it seems it is possible with some reflection. Not the best solution, but at least it works on the devices we tried:

        Class<?> clazz = Class.forName("com.android.internal.widget.LockPatternUtils");
Constructor<?> constructor = clazz.getConstructor(Context.class);
constructor.setAccessible(true);
Object utils = constructor.newInstance(context);
Method method = clazz.getMethod("isSecure");
return (Boolean)method.invoke(utils);

can i check if any security for lock screen active?

Hello and welcome on stackoverflow.

Here, you can't just ask like this, you have to do some research before.

I give you some help for you'r futur research on cordova :

When you want to know if a plugin exist, you have to check first the official cordova website.

Then, if this not successful, you will search the native functonnality cause if there don't exist, plugin can't exist too.

So in you'r case i do this search : android apps checking which lock screen set and i found this : How to detect/identify if device Lock Screen setting is set to None?

On this topic they are talking about KeyguardManager on android native code.

Next step : google -> cordova KeyguardManager plugin and you can find this plugin : https://github.com/kitolog/cordova-plugin-screen-locker

Ok is only work on android but now, you can search alone the perfect plugin you need.

Have a nice day.

How to check for file lock?

No, unfortunately, and if you think about it, that information would be worthless anyway since the file could become locked the very next second (read: short timespan).

Why specifically do you need to know if the file is locked anyway? Knowing that might give us some other way of giving you good advice.

If your code would look like this:

if not locked then
open and update file

Then between the two lines, another process could easily lock the file, giving you the same problem you were trying to avoid to begin with: exceptions.



Related Topics



Leave a reply



Submit