-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to block NlpWakelock #1
Comments
I am also using cm11, let me try it tmr. did you enable Google now?
|
Yeah the Nlp wakelocks seem to occur only if google now is enabled and you have location services set to high accuracy. I tried blocking wakelocks on Google Search app too but it didnt help. Disabling GPS location services (battery saving mode under location settings) seems to stop the locks, but then all other apps (like weather widgets) also lose the GPS privilege and don't update location. |
my xposed module can prevent an app to acquire wakelock if the app is
|
I noticed this posted on reddit claiming to be able to do it https://play.google.com/store/apps/details?id=in.andro.wlt But I'm skeptical of installing a closed source module from an unknown dev |
good! I will try it tomorrow, since now is midnight in my timezone. longer battery life is always my goal. thanks for your information!
|
private static final String CLASS_WAKELOCK = "android.os.PowerManager.WakeLock";
private XSharedPreferences prefs;
public void initZygote(IXposedHookZygoteInit.StartupParam paramStartupParam) throws Throwable{
prefs = new XSharedPreferences(Common.PACKAGE_NAME, "WLTSettings");
}
public void handleLoadPackage(final XC_LoadPackage.LoadPackageParam lpparam) throws Throwable{
Class WakeLockClass = XposedHelpers.findClass(CLASS_WAKELOCK , lpparam.classLoader);
XposedHelpers.findAndHookMethod(WakeLockClass , "acquire", new XC_MethodHook(){
protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
String tag = (String) XposedHelpers.getObjectField(param.thisObject, "mTag");
String sett = prefs.getString(lpparam.packageName + "/filterWakeLockTags", "-1");
if (sett.equals(""))
sett = "-1";
if ((sett.equals("-1")) || (sett.contains(tag))){
XposedBridge.log("WLT UNBLK:" + lpparam.packageName + " and aquire wakelock:" + tag);
}
}
);
} Similar hook for method "release" If you want you can collect wakelock tags and make black/whitelist (above app doesn't do it) Context context = XposedHelpers.getObjectField(param.thisObject, "mContext");
Intent i = new Intent(SettingsReceiver.ACTION_NEW_WAKELOCK);
i.setExtra(SettingsReceiver.EXTRA_TAG, tag);
context.sendBroadcast(i); Disclaimer as above. SettingsReceiver is simply class which extends BroadcastReceiver and is mentioned in AndroidManifest.xml Sorry for my english. I'm learning. I accept all criticism. I really want to learn it. |
Oh I didnt know you could just hook the base PowerManager class! This would be a great solution, I'll try and test it out if I get a chance. I also like the idea of logging the wakelock usage (denied and accepted both), would make it much easier to block / whitelist them. Another suggestion would be to only allow certain wakelocks when the screen is on, which should prevent functionality from breaking without sacrificing battery. P.S. your English is fine, understood what you meant perfectly. |
@t2k269 If you want an example of code that you notify me. I have such a thing implemented in a private project. My project wants shared with other users, but just as I'm done it. Other method to get context:
Disclaimer as above. I do not know how it affects the system ie. whether it is at all times correct, but I think so. |
I have given up on the NLP wakelock issue basically, since I don't want to do system wise hacking. I just want to affect the behavior per app, this can prevent system failure. Therefore, for this issue, I think the best method to reduce NLP wakelock is writing a app to listen on Location service, and disable it if it didn't use it for a specific idle period. Now, I am trying to improve my sleep quality. Due to my job nature, my phone can't be silent at all. I am very appreciate the app group profile feature of CM. The feature works perfectly except Whatsapp, I try to force it to use notification volume but failed. The reason may be that the setAudioStreamType method is native in AudioManager. I am really need to solve this asap. So, this issue will be first priority. If you want to contribute on this module, please feel free to commit changes. Since this is my first repository in github, if you need me to so something for you, please let me know. Thanks! |
Did you try Whatsapp+? Maybe he already has the desired changes? |
You really need to hook this function? I think you could also other to avoid problem. XposedHelpers.findAndHookMethod(Notification.Builder.class, "build", new XC_MethodHook(){
protected void afterHookedMethod(MethodHookParam param) throws Throwable{
Notification builder = (Notification) parma.getResult();
Notification.audioStreamType = Notification.STREAM_DEFAULT;
}
}
) I'm sorry, but I do not have enough time to look closely at it In addition WhatsApps not working for me |
Dzakus, I know the actual problem already... after digging in the CM code, I found that the CM profile only applied to android.media.Ringtone, absolutely not implemented in android.media.MediaPlayer. So I am trying to skip the "start()" method in "android.media.MediaPlayer" if CM profile is muting the package. In addition, I will use your code XposedHelpers.findAndHookMethod(Application.class, "onCreate", new XC_MethodHook(){
protected void beforeHookedMethod(MethodHookParam param) throws Throwable{
AppContext = param.thisObject;
}
}) to implement it (Thank you very much) |
How about delaying alarm of Google Play Service instead of blocking wakelock and alarm of the Service? It doesn't work either? I love location based services of Google Now, but I think it reports location too frequently to drain battery too much. No need to block it completely, just adjusting its frequency would suffice... So now I'm testing with Alarm Multiplier set to x10.. I'll check and see Alarm Count and battery usage. |
I've set my Alarm Multiplier to x5 and after a reboot and monitoring for an hour didn't notice any decrease in frequency (alarm still seems to be scheduled about once per minute...) |
I'm running CM11 on an Htc One. This mod doesnt seem to have any effect on the Nlp Wakelock in Google Play Services (location service stuff). I blocked both wakelock and alarms for the Google Play Services app, but battery stats still show it waking the phone while its off. Any ideas what can cause this ?
The text was updated successfully, but these errors were encountered: