Source:
<code>private void optionApply() { boolean some = false; final List<String> listRestriction = PrivacyManager.getRestrictions(); for (String restrictionName : listRestriction) { String templateName = PrivacyManager.cSettingTemplate + "." + restrictionName; if (PrivacyManager.getSettingBool(null, 0, templateName, true, false)) if (PrivacyManager.getRestriction(null, mAppInfo.getUid(), restrictionName, null, false, false, null)) { some = true; break; } } final boolean restricted = !some; AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityApp.this); alertDialogBuilder.setTitle(getString(restricted ? R.string.menu_apply : R.string.menu_clear_all)); alertDialogBuilder.setMessage(R.string.msg_sure); alertDialogBuilder.setIcon(Util.getThemed(this, R.attr.icon_launcher)); alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { List<Boolean> oldState = PrivacyManager.getListStateRestartHooks(mAppInfo.getUid(), null); for (String restrictionName : listRestriction) { String templateName = PrivacyManager.cSettingTemplate + "." + restrictionName; if (PrivacyManager.getSettingBool(null, 0, templateName, true, false)) PrivacyManager.setRestriction(null, mAppInfo.getUid(), restrictionName, null, restricted); } List<Boolean> newState = PrivacyManager.getListStateRestartHooks(mAppInfo.getUid(), null); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); <START> if (!newState.equals(oldState)) <END> Toast.makeText(ActivityApp.this, getString(R.string.msg_restart), Toast.LENGTH_SHORT).show(); } }); alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }</code><technical_language>items in list compared too? (I idea)</technical_language>

Target:
private void optionApply() { boolean some = false; final List<String> listRestriction = PrivacyManager.getRestrictions(); for (String restrictionName : listRestriction) { String templateName = PrivacyManager.cSettingTemplate + "." + restrictionName; if (PrivacyManager.getSettingBool(null, 0, templateName, true, false)) if (PrivacyManager.getRestriction(null, mAppInfo.getUid(), restrictionName, null, false, false, null)) { some = true; break; } } final boolean restricted = !some; AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityApp.this); alertDialogBuilder.setTitle(getString(restricted ? R.string.menu_apply : R.string.menu_clear_all)); alertDialogBuilder.setMessage(R.string.msg_sure); alertDialogBuilder.setIcon(Util.getThemed(this, R.attr.icon_launcher)); alertDialogBuilder.setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { List<Boolean> oldState = PrivacyManager.getRestartStates(mAppInfo.getUid(), null); for (String restrictionName : listRestriction) { String templateName = PrivacyManager.cSettingTemplate + "." + restrictionName; if (PrivacyManager.getSettingBool(null, 0, templateName, true, false)) PrivacyManager.setRestriction(null, mAppInfo.getUid(), restrictionName, null, restricted); } List<Boolean> newState = PrivacyManager.getRestartStates(mAppInfo.getUid(), null); if (mPrivacyListAdapter != null) mPrivacyListAdapter.notifyDataSetChanged(); if (!newState.equals(oldState)) Toast.makeText(ActivityApp.this, getString(R.string.msg_restart), Toast.LENGTH_SHORT).show(); } }); alertDialogBuilder.setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }