• android点滴(6)之获取Android系统中所有的开机自启动项


    获取Android系统中所有的开机自启动项

     

    绿水本无忧,因风皱面;青山原不老,为雪白头。

     

    思路:

    a.获取系统中安装的所有的应用程序的信息(ApplicationInfo)

    b.检查应用程序的Permission中是否有RECEIVE_BOOT_COMPLETED

     

    需要使用PackageManagerApplicationInfo类,

    PM类的文档如下:

                Class for retrieving various kinds of information related to the application packages that are currently installed on the device. You can find this class through getPackageManager().

                    中文:PM类可以用来获取安装在设备上的应用程序包相关的各种信息。可以通过getPackageManager()获取对象。

    ApplicationInfo类的文档如下:

                Information you can retrieve about a particular application. This corresponds to information collected from the AndroidManifest.xml's <application> tag.

                    中文:使用ApplicationInfo类你可以返回关于一个特定的应用程序的信息。这些信息是从AndroidManifest.xml<application>标签收集来的。

     

    例子:

     

    public class BootAppEnumUtils {

     

          private Context mContext;

          private static final String permName = "android.permission.RECEIVE_BOOT_COMPLETED";

          public BootAppEnumUtils(Context context){

                this.mContext = context;

          }

         

          public List<String> listBootApps(){

                List<String> bootAppNames = new ArrayList<String>();

                PackageManager pm = mContext.getPackageManager();

                //获取所有安装的App的信息

                List<ApplicationInfo> appInfos = pm.getInstalledApplications       (PackageManager.GET_UNINSTALLED_PACKAGES);

                for(ApplicationInfo appInfo : appInfos){

                      int iBoot = pm.checkPermission(permName, appInfo.packageName);

                      if(iBoot == PackageManager.PERMISSION_GRANTED ){

                            String appName = pm.getApplicationLabel(appInfo).toString();

                            bootAppNames.add(appName);

                      }

                }

                return bootAppNames;

          }

    }

     

    狂奔的蝸牛

    9/29/2011

     

     

  • 相关阅读:
    [WP]XCTF-Reversing-Newbie_calculations
    [WP]BUUCTF-Reverse-基础题(1-12)
    [WP]XCTF-notsequence
    [WP]XCTF-easyre-153
    [WP]XCTF- 攻防世界-crypto-新手练习区
    [WP]XCTF-simple-check-100
    [WP]XCTF-SignIn
    [WP]XCTF-666
    [WP]XCTF-Reversing-x64Elf-100
    [WP]XCTF-流浪者
  • 原文地址:https://www.cnblogs.com/cody1988/p/2195701.html
Copyright © 2020-2023  润新知