Mac上获取耗电量相关信息

1.获取记录各种设备耗电量的文件;


http://www.jb51.net/article/46875.htm

系统的设置–>电池–>使用情况中,统计的能耗的使用情况也是以power_profile.xml的value作为基础参数的

1、我的手机中power_profile.xml的内容: HTC t328w

复制代码代码如下:



    0
    100
    142
    0.3
    35690
    160
    4
    120
    220
    88
    88
    300
    170
    1390
    70
   
        3
        3
   

   
        245000
        384000
        460800
        499200
        576000
        614400
        652800
        691200
        768000
        806400
        844800
        998400
   

    2.8
   
        66.6
        84
        90.8
        96
        105
        111.5
        117.3
        123.6
        134.5
        141.8
        148.5
        168.4
   


2、获取的方法: 先从手机上获取framework-res.apk,然后使用apktool工具反编译

该文件位于手机目录: /system/framework/framework-res.apk,在linux下进入终端,执行一下命令:

复制代码代码如下:

adb  pull  /system/framework/framework-res.apk ./

这就将 framework-res.apk 拉到本地pc上了,下面使用apktool进行反编译。

复制代码代码如下:

dell@OptiPlex-7010:~/apktool/apktool-install-linux-r05-ibot$ ls
aapt  apktool  apktool.jar  framework-res.apk
dell@OptiPlex-7010:~/apktool/apktool-install-linux-r05-ibot$ ./apktool d framework-res.apk newapk
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...
dell@OptiPlex-7010:~/apktool/apktool-install-linux-r05-ibot$ ls
aapt  apktool  apktool.jar  framework-res.apk  newapk
dell@OptiPlex-7010:~/apktool/apktool-install-linux-r05-ibot/newapk/res/xml$ ls
apns.xml                         password_kbd_qwerty_shifted.xml  storage_list.xml
autotext.xml                     password_kbd_qwerty.xml          time_zones_by_country.xml
eri.xml                          password_kbd_symbols_shift.xml   zzz_cdmaapns.xml
password_kbd_extension.xml       password_kbd_symbols.xml         zzz_m_pdp_limit.xml
password_kbd_numeric.xml         power_profile.xml
password_kbd_popup_template.xml  preferred_time_zones.xml

power_profile.xml在framework-res.apk的目录:/res/xml/power_profile.xml



mac下APKtool的安装:

参考文章:

http://www.cnblogs.com/anee/p/4153411.html

http://blog.csdn.net/yanzi1225627/article/details/48215549


1,在官网链接里找到如下所示: 
这里写图片描述
基本上按照上面的6个步骤就ok了。第一步是下载一个shell脚本,保存的名字就是”apktool”,不要带.sh后缀。可以复制到sublimetext,然后保存下。 

第四步不是必须的,保存文件可以在任意目录下,但建议移动到/usr/local/bin目录,这样直接执行"apktool d ***.apk"命令即可,如果不移动需要进到目录下才能够执行apktool命令,且需要加"./apktool d **.apk" ,较为麻烦。需要注意的是Apktool2需要java1.7及以上版本,已验证java1.8可用。


具体步骤如下:

1、apktool文件内容如下,复制以下代码,保存到apktool(不要加任何后缀名)

复制代码
#!/bin/bash
#
# Copyright (C) 2007 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script is a wrapper for smali.jar, so you can simply call "smali",
# instead of java -jar smali.jar. It is heavily based on the "dx" script
# from the Android SDK

# Set up prog to be the path of this script, including following symlinks,
# and set up progdir to be the fully-qualified pathname of its directory.
prog="$0"
while [ -h "${prog}" ]; do
    newProg=`/bin/ls -ld "${prog}"`
    echo ${newProg}


    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
    if expr "x${newProg}" : 'x/' >/dev/null; then
        prog="${newProg}"
    else
        progdir=`dirname "${prog}"`
        prog="${progdir}/${newProg}"
    fi
done
oldwd=`pwd`
progdir=`dirname "${prog}"`
cd "${progdir}"
progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`
cd "${oldwd}"


jarfile=apktool.jar
libdir="$progdir"
if [ ! -r "$libdir/$jarfile" ]
then
    echo `basename "$prog"`": can't find $jarfile"
    exit 1
fi

javaOpts=""

# If you want DX to have more memory when executing, uncomment the following
# line and adjust the value accordingly. Use "java -X" for a list of options
# you can pass here.
# 
javaOpts="-Xmx256M"

# Alternatively, this will extract any parameter "-Jxxx" from the command line
# and pass them to Java (instead of to dx). This makes it possible for you to
# add a command-line parameter such as "-JXmx256M" in your ant scripts, for
# example.
while expr "x$1" : 'x-J' >/dev/null; do
    opt=`expr "$1" : '-J\(.*\)'`
    javaOpts="${javaOpts} -${opt}"
    shift
done

if [ "$OSTYPE" = "cygwin" ] ; then
    jarpath=`cygpath -w  "$libdir/$jarfile"`
else
    jarpath="$libdir/$jarfile"
fi

# add current location to path for aapt
PATH=$PATH:`pwd`;
export PATH;
exec java $javaOpts -Djava.awt.headless=true -jar "$jarpath" "$@"
复制代码

2(/3)、下载apktool2.jar,墙内的同学戳这里。解压,修改文件名为apktool.jar

4、将apktool和Apktool.jar文件移动到/usr/local/bin目录下;

5、chmod +x  apktool,修改为可执行

6、apktool d xx.apk,执行

成功反编译出xml文件


运行 apktool version即可查看相关信息:

fangjun03deMBP:apktool maoxiaojie$ apk version

-bash: apk: command not found

fangjun03deMBP:apktool maoxiaojie$ apktool version

Apktool v2.0.0-RC3 - a tool for reengineering Android apk files

with smali v2.0.3 and baksmali v2.0.3

Copyright 2014 Ryszard Wiśniewski

Updated by Connor Tumbleson


usage: apktool

 -advance,--advanced   prints advance information.

 -version,--version    prints the version then exits

usage: apktool if|install-framework [options]

 -p,--frame-path

  Stores framework files into .

 -t,--tag           Tag frameworks using .

usage: apktool d[ecode] [options]

 -f,--force              Force delete destination directory.

 -o,--output

      The name of folder that gets written. Default is apk.out

 -p,--frame-path

  Uses framework files located in .

 -r,--no-res             Do not decode resources.

 -s,--no-src             Do not decode sources.

 -t,--frame-tag     Uses framework files tagged by .

usage: apktool b[uild] [options]

 -f,--force-all          Skip changes detection and build all files.

 -o,--output

      The name of apk that gets written. Default is dist/name.apk

 -p,--frame-path

  Uses framework files located in .


For additional info, see: http://code.google.com/p/android-apktool/ 

For smali/baksmali info, see: http://code.google.com/p/smali/



 

注意:apktool2必须jdk 1.7+

下载http://pan.baidu.com/s/1i302CAD

安装

java -version查看版本是否变化


你可能感兴趣的:(Mac上获取耗电量相关信息)