use of com.yzy.supercleanmaster.model.AutoStartInfo in project superCleanMaster by joyoyao.
the class AutoStartAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = infater.inflate(R.layout.listview_auto_start, null);
holder = new ViewHolder();
holder.appIcon = (ImageView) convertView.findViewById(R.id.app_icon);
holder.appName = (TextView) convertView.findViewById(R.id.app_name);
holder.size = (TextView) convertView.findViewById(R.id.app_size);
holder.disable_switch = (TextView) convertView.findViewById(R.id.disable_switch);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final AutoStartInfo item = (AutoStartInfo) getItem(position);
if (item != null) {
holder.appIcon.setImageDrawable(item.getIcon());
holder.appName.setText(item.getLabel());
if (item.isEnable()) {
holder.disable_switch.setBackgroundResource(R.drawable.switch_on);
holder.disable_switch.setText("已开启");
} else {
holder.disable_switch.setBackgroundResource(R.drawable.switch_off);
holder.disable_switch.setText("已禁止");
}
// holder.size.setText(Formatter.formatShortFileSize(mContext, item.getCacheSize()));
holder.disable_switch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ShellUtils.checkRootPermission()) {
if (item.isEnable()) {
diasableApp(item);
} else {
enableApp(item);
}
} else {
T.showLong(mContext, "该功能需要获取系统root权限,点击允许获取root权限");
}
}
});
holder.packageName = item.getPackageName();
}
return convertView;
}
use of com.yzy.supercleanmaster.model.AutoStartInfo in project superCleanMaster by joyoyao.
the class AutoStartFragment method disableAPP.
private void disableAPP() {
List<String> mSring = new ArrayList<>();
for (AutoStartInfo auto : noSystemAuto) {
if (auto.isEnable()) {
String[] packageReceiverList = auto.getPackageReceiver().toString().split(";");
for (int j = 0; j < packageReceiverList.length; j++) {
String cmd = "pm disable " + packageReceiverList[j];
//部分receiver包含$符号,需要做进一步处理,用"$"替换掉$
cmd = cmd.replace("$", "\"" + "$" + "\"");
//执行命令
mSring.add(cmd);
}
}
}
ShellUtils.CommandResult mCommandResult = ShellUtils.execCommand(mSring, true, true);
if (mCommandResult.result == 0) {
T.showLong(mContext, "应用已经全部禁止");
for (AutoStartInfo auto : noSystemAuto) {
if (auto.isEnable()) {
auto.setEnable(false);
}
}
mAutoStartAdapter.notifyDataSetChanged();
refeshButoom();
} else {
T.showLong(mContext, "该功能需要获取系统root权限,请允许获取root权限");
}
}
use of com.yzy.supercleanmaster.model.AutoStartInfo in project superCleanMaster by joyoyao.
the class AutoStartFragment method refeshButoom.
private void refeshButoom() {
if (position == 0) {
canDisableCom = 0;
for (AutoStartInfo autoS : noSystemAuto) {
if (autoS.isEnable()) {
canDisableCom++;
}
}
if (canDisableCom > 0) {
bottom_lin.setVisibility(View.VISIBLE);
disableButton.setText("可优化" + canDisableCom + "款");
} else {
bottom_lin.setVisibility(View.GONE);
}
}
}
use of com.yzy.supercleanmaster.model.AutoStartInfo in project superCleanMaster by joyoyao.
the class AutoStartFragment method fillData.
private void fillData() {
if (position == 0) {
topText.setText("禁止下列软件自启,可提升运行速度");
} else {
topText.setText("禁止系统核心软件自启,将会影响手机的正常使用,请谨慎操作");
}
List<AutoStartInfo> mAutoStartInfo = BootStartUtils.fetchAutoApps(mContext);
// List<AutoStartInfo> mAutoStartInfo = BootStartUtils.fetchInstalledApps(mContext);
noSystemAuto = new ArrayList<>();
isSystemAuto = new ArrayList<>();
for (AutoStartInfo a : mAutoStartInfo) {
if (a.isSystem()) {
isSystemAuto.add(a);
} else {
noSystemAuto.add(a);
}
}
if (position == 0) {
mAutoStartAdapter = new AutoStartAdapter(mContext, noSystemAuto, mHandler);
listview.setAdapter(mAutoStartAdapter);
refeshButoom();
} else {
mAutoStartAdapter = new AutoStartAdapter(mContext, isSystemAuto, null);
listview.setAdapter(mAutoStartAdapter);
}
}
use of com.yzy.supercleanmaster.model.AutoStartInfo in project superCleanMaster by joyoyao.
the class BootStartUtils method fetchInstalledApps.
/**
* * 获取Android开机启动列表
*/
public static List<AutoStartInfo> fetchInstalledApps(Context mContext) {
PackageManager pm = mContext.getPackageManager();
List<ApplicationInfo> appInfo = pm.getInstalledApplications(0);
Iterator<ApplicationInfo> appInfoIterator = appInfo.iterator();
List<AutoStartInfo> appList = new ArrayList<AutoStartInfo>(appInfo.size());
while (appInfoIterator.hasNext()) {
ApplicationInfo app = appInfoIterator.next();
int flag = pm.checkPermission(BOOT_START_PERMISSION, app.packageName);
if (flag == PackageManager.PERMISSION_GRANTED) {
AutoStartInfo appMap = new AutoStartInfo();
String label = pm.getApplicationLabel(app).toString();
Drawable icon = pm.getApplicationIcon(app);
String packageName = app.packageName;
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
appMap.setSystem(true);
//abAppProcessInfo.isSystem = true;
} else {
appMap.setSystem(false);
// abAppProcessInfo.isSystem = false;
}
// appMap.setDesc(desc);
appMap.setIcon(icon);
appMap.setPackageName(packageName);
appMap.setLabel(label);
appList.add(appMap);
}
}
return appList;
}
Aggregations