Categorization and Detection of Energy Bugs and Application Tail Energy Bugs in Smartphones