Assigned
Status Update
Comments
ve...@google.com <ve...@google.com>
ra...@gmail.com <ra...@gmail.com> #2
Any news on this issue?
ve...@google.com <ve...@google.com> #3
Thank you for reporting this issue. For us to further investigate this issue, please provide the following additional information:
Android build
Which Android build are you using? (e.g. OPP1.170223.012)
Device used
Which device did you use to reproduce this issue?
Steps to reproduce
What steps are needed to reproduce this issue?
Frequency
How frequently does this issue occur? (e.g 100% of the time, 10% of the time)
Android bug report (to be captured after reproducing the issue)
For steps to capture a bug report, please refer:https://developer.android.com/studio/debug/bug-report#bugreportdevice
Alternate method
Navigate to “Developer options”, ensure “USB debugging” is enabled, then enable “Bug report shortcut”. Capture bug report by holding the power button and selecting the “Take bug report” option.
Screen capture of the issue
Press the volume down and power buttons simultaneously. The image will appear in your gallery. Attach the screenshot file to this issue.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
Android build
Which Android build are you using? (e.g. OPP1.170223.012)
Device used
Which device did you use to reproduce this issue?
Steps to reproduce
What steps are needed to reproduce this issue?
Frequency
How frequently does this issue occur? (e.g 100% of the time, 10% of the time)
Android bug report (to be captured after reproducing the issue)
For steps to capture a bug report, please refer:
Alternate method
Navigate to “Developer options”, ensure “USB debugging” is enabled, then enable “Bug report shortcut”. Capture bug report by holding the power button and selecting the “Take bug report” option.
Screen capture of the issue
Press the volume down and power buttons simultaneously. The image will appear in your gallery. Attach the screenshot file to this issue.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
ad...@google.com <ad...@google.com>
vi...@google.com <vi...@google.com> #4
Please share the details requested in comment #3 , to proceed further with the bug.
be...@gmail.com <be...@gmail.com> #5
Android build:
Happened on every Android version I tested this, i.e. API 21 to API 29
Device used:
Pixel 2 XL as well as several emulated devices in Android Studio
Steps to reproduce:
See original post
Frequency:
Always, i.e. 100%
Android bug report:
N.A.
Screen capture of the issue
N.A.
Happened on every Android version I tested this, i.e. API 21 to API 29
Device used:
Pixel 2 XL as well as several emulated devices in Android Studio
Steps to reproduce:
See original post
Frequency:
Always, i.e. 100%
Android bug report:
N.A.
Screen capture of the issue
N.A.
be...@gmail.com <be...@gmail.com> #6
Facing the same problem. UsageStatsManager.queryUsageStats seems to return unpredictable results. I will post more details later.
vi...@google.com <vi...@google.com> #7
Please provide sample project or apk to reproduce the issue. Also mention the steps to be followed for reproducing the issue with the given sample project or apk.
vi...@google.com <vi...@google.com> #8
Please share the apk requested in comment #7 , to proceed further with the bug.
be...@gmail.com <be...@gmail.com> #9
I created this issue more than a year ago. Back then I did solve this by some workaround / own method. Of course I am now working on something else and cannot develop and provide an extra app for you.
Also please note that this is in fact not anything app-specific but rather a general problem with the Android API (e.g. you might have a look at the multiple threads regardings this onstackoverflow.com ).
Also please note that this is in fact not anything app-specific but rather a general problem with the Android API (e.g. you might have a look at the multiple threads regardings this on
be...@gmail.com <be...@gmail.com> #10
@ <be...@googlemail.com> in comment #9
Are you using **UsageStatsManager.queryEvents** instead of **queryUsageStats** in your workaround / own method?
**queryEvents** is more precise, however, I have to filter the query result and do lots of computation to get the app usage information.
It's some workaround but not a user-friendly solution.
Are you using **UsageStatsManager.queryEvents** instead of **queryUsageStats** in your workaround / own method?
**queryEvents** is more precise, however, I have to filter the query result and do lots of computation to get the app usage information.
It's some workaround but not a user-friendly solution.
vi...@google.com <vi...@google.com> #11
We have passed this to the development team and will update this issue with more information as it becomes available.
ma...@gmail.com <ma...@gmail.com> #12
This is nonsense, it says that i have used viber for 50 minutes today, and i didn't open it even once. When i use queryAndAggregateUsageStats() method it says that 50 minutes are spent on viber which is incorrect, and for the other apps it surprisingly is quite correct. If i use queryEvents, it says that viber is used 0 minutes which is correct, but it says that instagram is used 23 hours, and for the other apps it is correct. And if i use queryUsageStats() all the data is let's say random... I don't understand how app usage stats apps on playstore work that good.
vr...@gmail.com <vr...@gmail.com> #13
Hi Team,
Even I’m facing same issue. I tried many methods, tried to run on different android versions but same result. There is some issue UsageStats manager API itself.
Even I’m facing same issue. I tried many methods, tried to run on different android versions but same result. There is some issue UsageStats manager API itself.
mr...@gmail.com <mr...@gmail.com> #14
Hi
I use the usageStatManager and queryAndAggregateUsageStats in two different devices and try to get the usageStats in several periods. The results are wrong. It gave some usage stats that not exist in the given period.
https://drive.google.com/file/d/1wIDMTEXZFjrrHLgHY-SBsoddzUKg0pQ0/view?usp=drive_web (Screenshot_20200702-202506.jpg)
I use the usageStatManager and queryAndAggregateUsageStats in two different devices and try to get the usageStats in several periods. The results are wrong. It gave some usage stats that not exist in the given period.
vi...@google.com <vi...@google.com> #15
Thank you for your feedback. We assure you that we are doing our best to address all issues reported. For now, we will be closing the issue as won't fix obsolete.
If this issue currently still exists, we request that you log a new issue along with the bug report herehttps://goo.gl/TbMiIO and reference this bug for context.
If this issue currently still exists, we request that you log a new issue along with the bug report here
te...@gmail.com <te...@gmail.com> #16
This API is really weird and hard to use. Can someone please help?
am...@gmail.com <am...@gmail.com> #17
Is there any update regarding this issue?
gu...@gmail.com <gu...@gmail.com> #18
I've got the same issue. Any help please?
[Deleted User] <[Deleted User]> #19
@Google, Is there any fix for this?
wa...@googlemail.com <wa...@googlemail.com> #20
Bump
di...@gmail.com <di...@gmail.com> #21
Bumping this issue. It's been four years still no solution.
th...@gmail.com <th...@gmail.com> #22
Always return 0!
Device:
Pixel 3a
Android OS:
13
Build number:
TP1A.221005.002
Device:
Pixel 3a
Android OS:
13
Build number:
TP1A.221005.002
th...@gmail.com <th...@gmail.com> #23
After restart, it's ok. (before I changed system date to future)
ni...@regainapp.ai <ni...@regainapp.ai> #24
It wasted few days of work. I don't know why it's taking years to fix this??
vi...@google.com <vi...@google.com>
je...@gmail.com <je...@gmail.com> #25
For app uses state you can use usageStatsManager.queryEvent for get accurate result use below code
val stateMap = HashMap<String, AppStateModel>() val usageStatsManager = getSystemService(USAGE_STATS_SERVICE) as UsageStatsManager
val calendar: Calendar = Calendar.getInstance()
calendar.set(Calendar.HOUR_OF_DAY,0)
calendar.set(Calendar.MINUTE,0)
calendar.set(Calendar.SECOND,0)
val calenderEnd = Calendar.getInstance()
calenderEnd.set(Calendar.HOUR_OF_DAY,23)
calenderEnd.set(Calendar.MINUTE,59)
calenderEnd.set(Calendar.SECOND,59)
val eventList = usageStatsManager.queryEvents(calendar.timeInMillis, calenderEnd.timeInMillis)
while(eventList.hasNextEvent()) {
val event = UsageEvents.Event()
eventList.getNextEvent(event)
if (event.eventType == UsageEvents.Event.ACTIVITY_RESUMED) {
val packageCheck = stateMap[event.packageName]
if (packageCheck != null) {
if (stateMap[event.packageName]!!.calssMap[event.className] != null) {
stateMap[event.packageName]!!.className = event.className
stateMap[event.packageName]!!.startTime = event.timeStamp
stateMap[event.packageName]!!.calssMap[event.className]!!.startTime = event.timeStamp
stateMap[event.packageName]!!.calssMap[event.className]!!.isResume = true
} else {
stateMap[event.packageName]!!.className = event.className
stateMap[event.packageName]!!.startTime = event.timeStamp
stateMap[event.packageName]!!.calssMap[event.className] = BoolObj(event.timeStamp, true)
}
} else {
val appStates = AppStateModel(packageName = event.packageName, className = event.className, startTime = event.timeStamp)
appStates.calssMap[event.className] = BoolObj(event.timeStamp, true)
stateMap[event.packageName] = appStates
}
}else if (event.eventType == UsageEvents.Event.ACTIVITY_STOPPED){
val packageCheck = stateMap[event.packageName]
if (packageCheck != null) {
if (stateMap[event.packageName]!!.calssMap[event.className] != null) {
stateMap[event.packageName]!!.totalTime += event.timeStamp - stateMap[event.packageName]!!.calssMap[event.className]!!.startTime
stateMap[event.packageName]!!.calssMap[event.className]!!.isResume = false
}
}
}
}
batteryAppsList.addAll(stateMap.values.toList())
data class AppStateModel( val packageName: String, var startTime: Long = 0, var endTime: Long = 0, var totalTime : Long = 0, var totalCapacity : Double = 0.0, var currentCapacity: Double = 0.0, var isAlreadyResume : Boolean = false, var className : String = "", var calssMap : HashMap<String, BoolObj> = HashMap() )
data class BoolObj(var startTime: Long, var isResume: Boolean)
mo...@gmail.com <mo...@gmail.com> #26
How is it taking 5+ years to solve this. This is unacceptable.
cc...@gmail.com <cc...@gmail.com> #27
It's not taking any-time to not fix issues. As obviously from first replies, it was not going to be fixed ever. yet another ADP.
bh...@techind.co <bh...@techind.co> #28
Hi everyone. I am facing same issue. Any help on this ?
gr...@gmail.com <gr...@gmail.com> #29
Imao, the world is actually a big hot mess
For those who want to get accurate app usage stats, you may use UsageStatsManager#queryEvents API to retrieve timestamps for all foreground/background switch events of an app over an given period of time. Filter out any uncountable events, then separately sum sum the timestamps for "switch to foreground" and "switch to background" events. Subtracting the results will give the total time of the app during that time period.
For those who want to get accurate app usage stats, you may use UsageStatsManager#queryEvents API to retrieve timestamps for all foreground/background switch events of an app over an given period of time. Filter out any uncountable events, then separately sum sum the timestamps for "switch to foreground" and "switch to background" events. Subtracting the results will give the total time of the app during that time period.
sa...@gmail.com <sa...@gmail.com> #30
It would be okay if event queryEvents have correct results but it’s not the case.
On some devices like SONY, Samsung it gave correct results. On pixel it didn’t.
On pixel queryAggregateUsageStats gave correct results but on Samsung and on xiomi it didn’t. It’s totally messed up.
I have never felt so frustrated about an API. But that being said there are good app usage apps in market like AppBlock. I wonder how they’re able to do it
Has anyone tried reverse engineering them?
On some devices like SONY, Samsung it gave correct results. On pixel it didn’t.
On pixel queryAggregateUsageStats gave correct results but on Samsung and on xiomi it didn’t. It’s totally messed up.
I have never felt so frustrated about an API. But that being said there are good app usage apps in market like AppBlock. I wonder how they’re able to do it
Has anyone tried reverse engineering them?
Description
I did some tests with UsageStatsManager.queryUsageStats.
The bucket that are build by that method are however rather unexpected.
For INTERVAL_DAILY I would expect buckets which begin and end at e.g.
2018/10/28 00:00:00 | 2018/10/29 23:59:59
2018/10/29 00:00:00 | 2018/10/29 current time of query
However, UsageStats.firstTimeStamp and UsageStats.lastTimeStamp suggest a different behaviur.
Buckets seem to begin and at just at some "random" time during the day. That is not even the same time for every day on one device. Also, it differs from one device to the next.
The same goes for other INTERVALs.