Code Monkey home page Code Monkey logo

Comments (29)

milux avatar milux commented on August 23, 2024

This method seems to invoke a method resetStatistics() on a device-specific class com.android.internal.os.BatteryStatsHelper that is only available in the frameworks of this specific devices.
I might be able to call this method via Java Reflection API, will try when I find some time.
I assume that you are willing to serve as a beta tester for this, as I don't have a Nexus device? 😉

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

Sure. I can help beta testing.

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Could you test out the stats reset of this debug version please?
https://www.androidfilehost.com/?fid=889764386195913249
Please report the exception stack trace of LogCat if it doesn't work!

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

Thanks for your attention to this issue.

I uninstalled release Battery Charge Limit version and tried your debug version. I really like the new interface, by the way.

It seems battery stats reset is not working yet. Logcat is attached.
BCL.txt

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Glad you like it. Alright, last round for today:
I did some changes with the information from your exception logs, could you please try this one:
https://mega.nz/#!N0kkGSBK!_NFwcOkJT_BgQLgqP-bDbm2S7KV935tS7NCGZdGMCK8
If this doesn't work, please provide me the new logs.

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

The battery stats reset function of Battery Charge Limit is still not working on newest debug version.

Logcat is attached.
BCL_2.txt

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Oh boy... sorry for the trouble, but I used wrong types for the reflection API this time.
Because of insane stupidity, I give it one last try for today:
https://mega.nz/#!k4VjkJqD!cUSJFJeeFLlBQErT7RoRza5yyutrEsr2lI3b0WSXsDg

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

No problem at all. You're doing the hard work here.

Still no luck. Logcat is attached.
BCL_3.txt

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Alright, this time it was the last instruction causing the Exception... I added something that might have been missing, let's give it one more try. Unfortunately, I'm beginning to run out of ideas.
It's really odd that I call a method "resetStatistics", with no documentation about it on the internet whatsoever... If your phone wasn't finding it, I would wonder if it actually exists...

from batterychargelimit.

milux avatar milux commented on August 23, 2024

https://mega.nz/#!kkMj3KjA!ZSuUwaWB5QRZWtvGLcBSGyFWCUzv0Z6Z5NuS1OAldQs
Make ready for the next stack trace... 😉

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

I really appreciate all your efforts to fix the battery stats reset, milux.

It's still not working. Logcat is attached.
BCL_4.txt

from batterychargelimit.

milux avatar milux commented on August 23, 2024

You're welcome, but this time it might be the end of the road.
Stack trace says "uid 10276 does not have android.permission.RESET_BATTERY_STATS", which is very strange, as the manifest does actually contain this permission.
The only assumption I have right now is that the permission is not correctly handled with an API level < 26 in the apps Manifest file.
This is bad news, because our app won't work on Android O with an API level >= 26 due to the implicit Broadcast ban of Android O.
Just for testing my assumption, please uninstall the recent beta and install this one instead:
https://mega.nz/#!Yw0BAYAJ!S39BOW9g21VcE3QKolm5cvQtlS0-82dCX5I2XFNHKlU
If I'm right, the power (dis)connect detection will not work anymore (rendering the app useless), but the reset might work this way.

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

I uninstalled previous test version and installed the new one. Between two presses of the Battery Stats Reset button of Battery Charge Limit, I also connected and disconnected the USB power cord.

It seems it's all registered at the attached logcat.
BCL_5.txt

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

I just saw this post at the XDA Magisk v13 beta thread and I thought it can be relevant for this issue: https://forum.xda-developers.com/apps/magisk/beta-magisk-v13-0-0980cb6-t3618589/post72904730

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Interesting that it still doesn't work... I don't see any of the power events in the LogCat, so my expectation about Android O seems to be correct. You can check it this way: Close the application, connect the power, and check if the notification is coming up. I guess it won't do. Besides, I just did some experiments with Magisk 13, and it seems there are some indeed some problems. I will wait for the final version of Magisk 13 and see whether the problems persist.
Anyway, I don't think that the issue you pointed me to is related to the SecurityException. I have a question: This PureNexus app that you mentioned in the beginning, is it a user app or a system app?

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

I'm in the road at this moment. Newest PureNexus battery stats function is fused with the normal Android battery information. See the screenshot attached.
screenshot_20170704-112045

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Hm... let me ask differently: Is the app part of the ROM?

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

Yes, it is.

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Alright, then there is one more thing we could try:
Systemize the "normal" debug build of above (not the modified one) with the Magisk App Systemizer:
https://forum.xda-developers.com/apps/magisk/module-app-systemizer-t3477512
Then check again if it works.

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Besides: The App Systemizer is officially made for up to Magisk 12... If it interferes with v13 beta... not my fault, do a backup before! 😉

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

I "systemized" latest "normal" debug build manually with TWRP, by copying it /system/app/BCL/xxx.apk and setting the right permissions. Then I tested the battery stats reset function again two times and plugged and unpuggled the USB power cord in between.

Sadly, the battery stats were no cleared. Logcat is attached.
BCL_6.txt

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Did you uninstall any previous user version of the app in order to make sure that your systemization strategy actually works? I might be wrong (really, I don't know for sure), but I always thought that the APK has to go to /system/app directly...

from batterychargelimit.

milux avatar milux commented on August 23, 2024

And of course, if it's worth the trouble for you, you may check whether the sdk26 version shows a different behavior. You can check yourself: If the logcat contains something like this:
New reset method failed: Caused by: java.lang.SecurityException: uid 10017 does not have android.permission.RESET_BATTERY_STATS.
then it didn't work, look for the permission error.

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

The "systemizer" method I described is the same I use to make Greenify and other regular apps behave like system apps. I'm sure it works.

Let's wait until new Magisk is stable to see if the dumpsys issue is solved. I know the dev is aware of it.

from batterychargelimit.

milux avatar milux commented on August 23, 2024

Alright, then thanks for all your help, a pity that it didn't work. You didn't try to systemize the Android O (sdk26) build, did you?
Unfortunately, my technical understanding tells me that the dumpsys issue is an Android O issue, not a Magisk issue. Therefore, let's wait for the less experimental Android O releases, and hope that we'll see a way to cope with this issue then.

from batterychargelimit.

milux avatar milux commented on August 23, 2024

@aamadorj Starting from version 1.0.0, the app uses a new, more efficient technique to issue root commands.
Some people already reported that the statistics reset now works on their devices, and for me it also works with Magisk 13.3 and Lineage OS 14.1 (7.1.2).
Can you check if it also works for you, please?

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

Thanks for all your work with BCL, @milux. I'll install new version ASAP.

from batterychargelimit.

 avatar commented on August 23, 2024

It seems to work fine on other ROMs... But not PureNexus. Actually, the dumpsys command doesn't work in PureNexus with Magisk at all (not just batterystats --reset). So now the issues with Magisk 13 were solved in BCL and it runs the battery resetting command successfully... But PN errors out at the command (Error dumping service info: (Unknown error -2147483646)).

from batterychargelimit.

aamadorj avatar aamadorj commented on August 23, 2024

Yeap, I confirm @ApertureAndroid findings on latest BCL version: battery stats aren't resetting manually or automatically on PureNexus yet.

But the BCL enabled and BCL disabled toasts are both working now. Yay!!!

from batterychargelimit.

Related Issues (20)

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.