use of com.yzy.supercleanmaster.model.AutoStartInfo in project superCleanMaster by joyoyao.
the class BootStartUtils method fetchAutoApps.
public static List<AutoStartInfo> fetchAutoApps(Context mContext) {
PackageManager pm = mContext.getPackageManager();
Intent intent = new Intent(Intent.ACTION_BOOT_COMPLETED);
List<ResolveInfo> resolveInfoList = pm.queryBroadcastReceivers(intent, PackageManager.GET_DISABLED_COMPONENTS);
List<AutoStartInfo> appList = new ArrayList<AutoStartInfo>();
String appName = null;
String packageReceiver = null;
Drawable icon = null;
boolean isSystem = false;
boolean isenable = true;
if (resolveInfoList.size() > 0) {
appName = resolveInfoList.get(0).loadLabel(pm).toString();
packageReceiver = resolveInfoList.get(0).activityInfo.packageName + "/" + resolveInfoList.get(0).activityInfo.name;
icon = resolveInfoList.get(0).loadIcon(pm);
ComponentName mComponentName1 = new ComponentName(resolveInfoList.get(0).activityInfo.packageName, resolveInfoList.get(0).activityInfo.name);
if (pm.getComponentEnabledSetting(mComponentName1) == 2) {
isenable = false;
} else {
isenable = true;
}
if ((resolveInfoList.get(0).activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
isSystem = true;
} else {
isSystem = false;
}
for (int i = 1; i < resolveInfoList.size(); i++) {
AutoStartInfo mAutoStartInfo = new AutoStartInfo();
if (appName.equals(resolveInfoList.get(i).loadLabel(pm).toString())) {
packageReceiver = packageReceiver + ";" + resolveInfoList.get(i).activityInfo.packageName + "/" + resolveInfoList.get(i).activityInfo.name;
} else {
mAutoStartInfo.setLabel(appName);
mAutoStartInfo.setSystem(isSystem);
mAutoStartInfo.setEnable(isenable);
mAutoStartInfo.setIcon(icon);
mAutoStartInfo.setPackageReceiver(packageReceiver);
appList.add(mAutoStartInfo);
appName = resolveInfoList.get(i).loadLabel(pm).toString();
packageReceiver = resolveInfoList.get(i).activityInfo.packageName + "/" + resolveInfoList.get(i).activityInfo.name;
icon = resolveInfoList.get(i).loadIcon(pm);
ComponentName mComponentName2 = new ComponentName(resolveInfoList.get(i).activityInfo.packageName, resolveInfoList.get(i).activityInfo.name);
if (pm.getComponentEnabledSetting(mComponentName2) == 2) {
isenable = false;
} else {
isenable = true;
}
if ((resolveInfoList.get(i).activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
isSystem = true;
} else {
isSystem = false;
}
}
}
AutoStartInfo mAutoStartInfo = new AutoStartInfo();
mAutoStartInfo.setLabel(appName);
mAutoStartInfo.setSystem(isSystem);
mAutoStartInfo.setEnable(isenable);
mAutoStartInfo.setIcon(icon);
mAutoStartInfo.setPackageReceiver(packageReceiver);
appList.add(mAutoStartInfo);
}
return appList;
}
Aggregations