Giter VIP home page Giter VIP logo

unbounce-android's Introduction

For the most up-to-date conversation, check the Xda-Developers thread.

Please target all pull requests to the "develop" branch. Thanks!

Builds

develop build : develop branch (Latest experimental)

master build : master branch (Latest stable)

FAQ

I have a bug or feature request.

Cool. Thanks for helping out! Please go file the issue here, on GitHub. You can also upvote bugs and feature requests there.

I'd like to help with translations

Awesome! We could use the help! To start, check here, on the translation site.

Why is Play Services such a battery killer:

  1. If Google Location Services are turned on, it sets an alarm to wakeup every 60 seconds, check the network location, and broadcast ALARM_WAKEUP_LOCATOR.

  2. Everytime ALARM_WAKEUP_LOCATOR fires, Google Search receives the broadcast and grabs an NlpWakeLock and NlpCollectorWakeLock.

  3. Those wakelocks hold the keep the device on for 5-15 seconds. This means that the device is actually awake for about 15 seconds per minute, or 25% of the time!

Why was this such a pain to fix?

First, Google Play Services is obfuscated, making it really hard to tell what's happening in the code. Second, the value of 60 seconds for the wakelock is hardcoded in classes2.dex, which isn't accessible by the Xposed framework. I had to follow the usage of that into a place where it's accessible by Xposed and change it there.

What are the consequences of reducing that alarm frequency?

There aren't likely any side effects. You can completely disable the alarm altogether by disabling Google Location Services. Simply reducing the alarm lets you keep Google Location Services on, but balances the benefit with your battery life.

Cool, but I have a different battery killer. Can you fix mine?

Totally. I'd like this to become a one-stop shop for battery life, especially as impacted by Google Now (Google Search) and Google Play Services. Give me a dump of your Better Battery Stats and I'll see what I can do.

I still get a ton of NlpWakeLocks and NlpCollectorWakeLocks

After looking at the code, there looks to be a google bug where any broadcast that includes the word "collector" triggers a Play Services NlpCollectorWakeLock. NlpUnbounce also has settings to temper these wakelocks. Try using that if the alarms by themselves don't solve the problem.

Why is it called Unbounce?

Debouncing is the process of taking a signal that's "bouncing" and interpreting it as a single "hit". This is a similar concept to what termpering the wakelocks does. It let's one of them come through, then turns them off for a certain amount of time. After I fixed the wakelocks, I realized that the alarms were causing them and I could actually stop the device from even waking up by killing the alarm. If DEbounce is a good term for denying the wakelock, UNbounce seemed like a good term for stopping them at the source.

Where's the change log?

It's here: https://bitbucket.org/cryptyk/nlpunbounce/commits/branch/master

How can I tell it's working?

First, your battery life should be better when Location Services is turned on. If you really want to evaluate the change, here's how you can see it in action:

  1. Before you install the module, check your alarm frequency by running: adb logcat -v time | grep "ALARM_WAKEUP_LOCATOR|ALARM_WAKEUP_ACTIVITY_DETEC TION|NlpWakeLock|NlpCollectorWakeLock"

  2. Note the frequency of those alarms (I was getting them every minute)

  3. Install the mod and reboot.

  4. To watch the fix in action, run: adb logcat -v time | grep "NlpUnbounce"

  5. Watch your ADB for messages showing that Unbounce is patching the intervals.

What are the best settings?

There is no "best". What you're trying to do is make everything work like it's supposed to without allowing these alarms and wakelocks to kill your battery. It makes sense to start with the least intrusive methods and work your way up. If you really want to tune, do this:

  1. Turn the module off and use BBS and record the number of ALARM_WAKEUP_LOCATOR and ALARM_WAKEUP_DETECTION alarms you get per hour. Also record how much time is spent in NlpWakeLock and NlpCollectorWakeLock.

  2. Turn the module on and set the settings to:

    a) ALARM_WAKEUP_LOCATOR = 240

    b) ALARM_WAKEUP_DETECTION = 240

    c) NlpWakeLock = 0 (to disable the modification and use stock settings)

    d) NlpCollectorWakeLock = 0 (to disable the modification and use stock settings)

  3. Now go back to step 1. If you're happy with the results, you're all done! If you still have a lot of time spent in NlpWakeLock and NlpCollectorWakeLock, change those settings to 240, also.

What's an alarm vs. a wakelock, and how are they related with regards to Nlp (Network Location Provider)?

An alarm wakes your device from deep sleep, scheduled using the RTC (Real Time Clock). For example, Google Play Services schedules an alarm every 60 seconds to wake up the device with the ALARM_WAKEUP_LOCATOR alarm. That's why I didn't try to stop the wakelocks at first, but instead tried to stop the alarms. I don't even want the device to wakeup in the first place! Once the alarm fires, the Nlp service wants to get your location and send it back to google. This requires keeping the device awake for a few (5-15) seconds. To keep the device awake, Google Play Services grabs the NlpWakeLock. This is the second point we can modify the system, but it only puts the device back to sleep once it's already awake. A couple of other things: This is why I recommend starting with just the alarms. It's less intrusive, and stops the device from waking up at all. Most people will probably be fine with the settings 240, 240, 0, 0. There are other things that can cause an NlpWakeLock, though, including third party apps. If the alarms don't work by themselves for you, you can also slow down the frequency of the wakelocks directly in the settings.

unbounce-android's People

Contributors

bloezjax avatar chhapil avatar gaich avatar kagwind avatar rsteckler avatar wedydq10 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unbounce-android's Issues

Numbers of only up to 5 digits are allowed to be set for the interval.

Please make it to where we can enter up to 6 or maybe 7 digit numbers to block the alarms. It used to allow up to 6 digits meaning 999,999 seconds =11.574 days. Now it only allows 99,999 seconds1.157 days. Better yet 9,999,999 seconds = 115.740 days, THAT would be awesome I would never have to worry about any alarm again! See what you can do, thank you for your time, help & support!


NoSuchMethodError for 4.1.2 device (nlpunbounce version 1.1 beta)

NoSuchMethodError for 4.1.2 device (nlpunbounce version 1.1 beta)

My device is running 4.1.2 (LG Nitro P930), it throw following Errors:

I can see there is 2 problems in the log:

  1. de.robv.android.xposed.XposedHelpers$ClassNotFoundError error is not covered by try catch of NoSuchMethodError. This one is minor and just one time error.

  2. PendingIntent.getIntent() is not available in 4.1.2. This is a major problem.

Thanks.


ERROR : Unsupported Android version trying to hook wakelocks

Hi ,

I was using build patched xordos for 4.1.2 and it worked good. Now I uninstalled it and upgraded to v1.1.1 . But it is throwing error -
NlpUnbounce:Unsupported Android version trying to hook wakelocks

and there are no messages which earlier in 4.1.2-patch showed when the alarm was delayed or allowed. Please check attached screenshot.

Phones Android version - Stock 4.3


ERROR : Unsupported Android version trying to hook wakelocks

Hi ,

I was using build patched xordos for 4.1.2 and it worked good. Now I uninstalled it and upgraded to v1.1.1 . But it is throwing error -
NlpUnbounce:Unsupported Android version trying to hook wakelocks

and there are no messages which earlier in 4.1.2-patch showed when the alarm was delayed or allowed. Please check attached screenshot.

Phones Android version - Stock 4.3


NoSuchMethodError for 4.1.2 device (nlpunbounce version 1.1 beta)

NoSuchMethodError for 4.1.2 device (nlpunbounce version 1.1 beta)

My device is running 4.1.2 (LG Nitro P930), it throw following Errors:

I can see there is 2 problems in the log:

  1. de.robv.android.xposed.XposedHelpers$ClassNotFoundError error is not covered by try catch of NoSuchMethodError. This one is minor and just one time error.

  2. PendingIntent.getIntent() is not available in 4.1.2. This is a major problem.

Thanks.


Sometimes the seconds setting comes back invalid

...and is set to the 240000 default. See this log:
09-04 13:40:49.622 I/Xposed ( 1196): NlpUnbounce: Preventing NlpCollectorWakeLock. Max Interval: 300000 Time since last granted: 278843
09-04 13:40:49.632 I/Xposed ( 1196): NlpUnbounce: Allowing NlpCollectorWakeLock. Max Interval: 240000 Time since last granted: 278861

Perhaps a threading issue?


com.google.android.gsf

com.google.android.gsf (): Wakeups: 9 (24.5 / hr.)
Alarms: 8, Intent: com.google.android.intent.action.GTALK_RECONNECT
Alarms: 1, Intent: com.google.android.intent.action.SEND_IDLE

The problem is GTALK and m.talk.goggle.com


Filter / Group / Blacklist alarms and wakelock

More and more people seems to be using this module.

I gathered some information from different posts to create this feature request that contains related features

Implement a filtering engine (someone proposed to have something like XPrivacy):

  • filter by text search
    • search in description
    • name
    • group name
  • filter by category/group
  • invert filters

Group alarms/wakelocks by category

  • edited
  • proved safe to edit
  • unknow
  • unsafe to edit

Blacklist or completely remove unsafe to edit wakelocks or alarms. Some people seemed to have modified ALARMMANAGER and got into a boot loop.

  1. Expand / Collapse groups

Put a button or something in the group header to expand or collapse a group. I suggest that by default, only edited alarms or wakelocks to be expanded. All other groups should be collapsed.


Variable Throttle Durations

Not sure if this is viable but, could you add another timeout option that is used when you are connected to WiFi ?

For example: normal conditions, driving around will use location wakelock of 240 secs as it does currently. But when I get home or to work and connect to WiFi I don't need it to check my location every 240 secs - I am not moving - once an hour or even not at all (until I disconnect from WiFi) would be more than sufficient!

The only problem could be when connected to a mobile hotspot, as you are moving and might still want the location updated - so maybe an SSID black list would be necessary to ignore those networks.

Hope that makes sense.


PendingIntent.getIntent doesn't exist in 4.2.1

Blocking alarms depends on being able to successfully identify them. This is done by looking at the intent action. Unfortunately, at trigger time, we only have a PendingIntent. In 4.2.2+ we can get the original intent. Prior to that, we can't.
The way the intent is bubbled up through the layers is complex and originates in the c++ native code. Not simple to replicate in AlarmManagerService, PendingIntent, IntentSender, NativeActivityManager, or IIntentSender's implementation.

Perhaps a better way to do this is either:

  1. Find out where the alarm frequency originates. This is how v0.0.1 worked for ALARM_WAKEUP_LOCATOR.
  2. Intercept the alarms when they are set. This requires some additional work to make sure there's only one of each "type" of alarm scheduled, and to make sure that they are at least 240 seconds (or whatever the user sets) apart.

Icon problem...

Hi there,

Thanks for the great effort, so I also use the Xposed Preference Injector module and attached is how the modules icon looks like under Settings menu...

Thanks...


com.google.android.gsf

com.google.android.gsf (): Wakeups: 9 (24.5 / hr.)
Alarms: 8, Intent: com.google.android.intent.action.GTALK_RECONNECT
Alarms: 1, Intent: com.google.android.intent.action.SEND_IDLE

The problem is GTALK and m.talk.goggle.com


PendingIntent.getIntent doesn't exist in 4.2.1

Blocking alarms depends on being able to successfully identify them. This is done by looking at the intent action. Unfortunately, at trigger time, we only have a PendingIntent. In 4.2.2+ we can get the original intent. Prior to that, we can't.
The way the intent is bubbled up through the layers is complex and originates in the c++ native code. Not simple to replicate in AlarmManagerService, PendingIntent, IntentSender, NativeActivityManager, or IIntentSender's implementation.

Perhaps a better way to do this is either:

  1. Find out where the alarm frequency originates. This is how v0.0.1 worked for ALARM_WAKEUP_LOCATOR.
  2. Intercept the alarms when they are set. This requires some additional work to make sure there's only one of each "type" of alarm scheduled, and to make sure that they are at least 240 seconds (or whatever the user sets) apart.

Settings Activity crashing when rotating the screen

Thank's for the awesome module! Minor comment; when rotating the phone the settings UI crashes with the following stack trace:

09-07 21:54:05.683 21256 21256 W dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41632e18)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: FATAL EXCEPTION: main
09-07 21:54:05.683 21256 21256 E AndroidRuntime: Process: com.ryansteckler.nlpunbounce, PID: 21256
09-07 21:54:05.683 21256 21256 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ryansteckler.nlpunbounce/com.ryansteckler.nlpunbounce.SettingsActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.ryansteckler.nlpunbounce.SettingsActivity$PrefsFragment: make sure class name exists, is public, and has an empty constructor that is public
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.ActivityThread.access$900(ActivityThread.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.os.Looper.loop(Looper.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.ryansteckler.nlpunbounce.SettingsActivity$PrefsFragment: make sure class name exists, is public, and has an empty constructor that is public
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.Fragment.instantiate(Fragment.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.Fragment.instantiate(Fragment.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.FragmentState.instantiate(Fragment.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.FragmentManagerImpl.restoreAllState(FragmentManager.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.Activity.onCreate(Activity.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at com.ryansteckler.nlpunbounce.SettingsActivity.onCreate(SettingsActivity.java:28)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: ... 14 more
09-07 21:54:05.683 21256 21256 E AndroidRuntime: Caused by: java.lang.InstantiationException: can't instantiate class com.ryansteckler.nlpunbounce.SettingsActivity$PrefsFragment; no empty constructor
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at java.lang.Class.newInstanceImpl(Native Method)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: at java.lang.Class.newInstance(Class.java)
09-07 21:54:05.683 21256 21256 E AndroidRuntime: ... 22 more
09-07 21:54:05.693 850 1273 E ActivityManager: App crashed! Process: com.ryansteckler.nlpunbounce
09-07 21:54:05.693 20862 20862 D Shoebox : =======DisplayConfig============
09-07 21:54:05.693 850 1273 W ActivityManager: Force finishing activity com.ryansteckler.nlpunbounce/.SettingsActivity

Module itself works as advertised, tons of wakeups saved, battery life improved.


Alarm/Wakelock service specific filters (like wakelock terminator)

Currently if you disable a specific wakelock it disables it completely rather then from that specfic source (ex google play services). Wakelock terminator has the ability to filter specific wakelocks for services not hindering other apps functionality.

Reason for this is when trying to limit googles interaction with the phone i impaired avast anti security locate function when disabling certain alarms/wakelocks.

Wakelock detector shows each app calling certain wakelocks ex (alarmManager, LocationServicemanager, Audioin etc..)


Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.