private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
public void onClick(View v) {
- // Those monkeys kept committing suicide, so we add this property
- // to disable going through with the master clear
- if (!TextUtils.isEmpty(SystemProperties.get("monkey.running"))) {
+ if (Utils.isMonkeyRunning()) {
return;
}
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
public void onClick(View v) {
- // Those monkeys kept committing suicide, so we add this property
- // to disable going through with the format
- if (!TextUtils.isEmpty(SystemProperties.get("monkey.running"))) {
+ if (Utils.isMonkeyRunning()) {
return;
}
IMountService service =
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.os.SystemProperties;
import android.preference.Preference;
import android.preference.PreferenceGroup;
/**
* Finds a matching activity for a preference's intent. If a matching
* activity is not found, it will remove the preference.
- *
+ *
* @param context The context.
* @param parentPreferenceGroup The preference group that contains the
* preference whose intent is being resolved.
*/
public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
-
+
Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
if (preference == null) {
return false;
}
-
+
Intent intent = preference.getIntent();
if (intent != null) {
// Find the activity that is in the system image
ResolveInfo resolveInfo = list.get(i);
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
!= 0) {
-
+
// Replace the intent with this specific activity
preference.setIntent(new Intent().setClassName(
resolveInfo.activityInfo.packageName,
// Set the preference title to the activity's label
preference.setTitle(resolveInfo.loadLabel(pm));
}
-
+
return true;
}
}
// Did not find a matching activity, so remove the preference
parentPreferenceGroup.removePreference(preference);
-
+
return true;
}
-
+
+ /**
+ * Returns true if Monkey is running.
+ */
+ public static boolean isMonkeyRunning() {
+ return SystemProperties.getBoolean("ro.monkey", false);
+ }
+
}