Android - диспетчер пакетов отключить/включить

У меня проблема с отключением приложения через функцию отключения/включения диспетчера пакетов. В андроид терминале все правильно, а в этом приложении нет. Однако " Runtime.getRuntime().exec("su"); " функционирует нормально и выполняет свою деятельность.

public class AppInfoAdapter extends BaseAdapter {
private Context aContext;
private List<ApplicationInfo> aListAppInfo;
private PackageManager aPackManager;
private CheckBox chAppStat ;






public AppInfoAdapter(Context c, List<ApplicationInfo> list, PackageManager pm) {
    aContext = c;
    aListAppInfo = list;
    aPackManager = pm;
}

@Override
public int getCount() {
    return aListAppInfo.size();
}

@Override
public Object getItem(int position) {
    return aListAppInfo.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}                                                                                       

@Override                                                                                   
public View getView(int position, View convertView, ViewGroup parent) {

    ApplicationInfo entry = aListAppInfo.get(position);

    //positon = position;
    View v = convertView;                                                                   // convertView

                                                                                            // recyklovace
    if(v == null) {
        LayoutInflater inflater = LayoutInflater.from(aContext);
        v = inflater.inflate(R.layout.layout_appinfo, null);
    }
                                                                                            // nahrat layout
    ImageView ivAppIcon = (ImageView)v.findViewById(R.id.ivIcon);
    TextView tvAppName = (TextView)v.findViewById(R.id.tvName);
    TextView tvPkgName = (TextView)v.findViewById(R.id.tvPack);
    chAppStat = (CheckBox)v.findViewById(R.id.chBox);
    //text = entry.packageName;
    chAppStat.setTag(entry.packageName);

    chAppStat.setOnCheckedChangeListener(aListener); 


                                                                                            // privest na vystup

        ivAppIcon.setImageDrawable(entry.loadIcon(aPackManager));
        tvAppName.setText(entry.loadLabel(aPackManager));
        tvPkgName.setText(entry.packageName);



                                                                                            // navrat view
    return v;
}
OnCheckedChangeListener aListener = new CompoundButton.OnCheckedChangeListener () {

     public void onCheckedChanged( CompoundButton buttonView, boolean isChecked) {   
        if(isChecked = true){


            try {
                Runtime.getRuntime().exec("su");
                Runtime.getRuntime().exec("pm disable "+ buttonView.getTag());

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
        else{
                try {
                    Runtime.getRuntime().exec("pm enable "+ buttonView.getTag());
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
        }
     }
};




}

Резюме: проблема заключается в отключении/включении функции диспетчера пакетов в приложении. НО в терминале правильно "pm disable some.name.package"

try {
                Runtime.getRuntime().exec("su");
                Runtime.getRuntime().exec("pm disable "+ buttonView.getTag());

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }

person user3248215    schedule 06.02.2014    source источник
comment
Здесь вы запускаете два процесса. Второй (выполнение pm ...) не будет работать от имени пользователя root.   -  person Henry    schedule 07.02.2014
comment
Мне нужно что-то, чтобы порождать обе команды в одном процессе?   -  person user3248215    schedule 07.02.2014
comment
Да, посмотрите здесь, например, stackoverflow.com/questions/7666349/understanding-su-request   -  person Henry    schedule 07.02.2014
comment
Вау, спасибо мастеру своей работы. И небольшой вопрос, если я отключу какое-то приложение, как мое приложение узнает, что отключено? нужно что-то, чтобы сохранить значение состояния? Пример логического?   -  person user3248215    schedule 07.02.2014