Still use ro.monkey
http://b/issue?id=1681101 So just some refactoring.
This commit is contained in:
@@ -74,9 +74,7 @@ public class DevelopmentSettings extends PreferenceActivity
|
|||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||||
|
|
||||||
// Those monkeys kept committing suicide, so we add this property
|
if (Utils.isMonkeyRunning()) {
|
||||||
// to disable this functionality
|
|
||||||
if (!TextUtils.isEmpty(SystemProperties.get("monkey.running"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -204,9 +204,7 @@ public class LanguageSettings extends PreferenceActivity {
|
|||||||
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
|
||||||
|
|
||||||
// Input Method stuff
|
// Input Method stuff
|
||||||
// Those monkeys kept committing suicide, so we add this property
|
if (Utils.isMonkeyRunning()) {
|
||||||
// to disable this functionality
|
|
||||||
if (!TextUtils.isEmpty(SystemProperties.get("monkey.running"))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,9 +61,7 @@ public class MasterClear extends Activity {
|
|||||||
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
// Those monkeys kept committing suicide, so we add this property
|
if (Utils.isMonkeyRunning()) {
|
||||||
// to disable going through with the master clear
|
|
||||||
if (!TextUtils.isEmpty(SystemProperties.get("monkey.running"))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,9 +61,7 @@ public class MediaFormat extends Activity {
|
|||||||
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
||||||
// Those monkeys kept committing suicide, so we add this property
|
if (Utils.isMonkeyRunning()) {
|
||||||
// to disable going through with the format
|
|
||||||
if (!TextUtils.isEmpty(SystemProperties.get("monkey.running"))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMountService service =
|
IMountService service =
|
||||||
|
@@ -21,6 +21,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
|
import android.os.SystemProperties;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceGroup;
|
import android.preference.PreferenceGroup;
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ public class Utils {
|
|||||||
/**
|
/**
|
||||||
* Finds a matching activity for a preference's intent. If a matching
|
* Finds a matching activity for a preference's intent. If a matching
|
||||||
* activity is not found, it will remove the preference.
|
* activity is not found, it will remove the preference.
|
||||||
*
|
*
|
||||||
* @param context The context.
|
* @param context The context.
|
||||||
* @param parentPreferenceGroup The preference group that contains the
|
* @param parentPreferenceGroup The preference group that contains the
|
||||||
* preference whose intent is being resolved.
|
* preference whose intent is being resolved.
|
||||||
@@ -50,12 +51,12 @@ public class Utils {
|
|||||||
*/
|
*/
|
||||||
public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
|
public static boolean updatePreferenceToSpecificActivityOrRemove(Context context,
|
||||||
PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
|
PreferenceGroup parentPreferenceGroup, String preferenceKey, int flags) {
|
||||||
|
|
||||||
Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
|
Preference preference = parentPreferenceGroup.findPreference(preferenceKey);
|
||||||
if (preference == null) {
|
if (preference == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = preference.getIntent();
|
Intent intent = preference.getIntent();
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
// Find the activity that is in the system image
|
// Find the activity that is in the system image
|
||||||
@@ -66,7 +67,7 @@ public class Utils {
|
|||||||
ResolveInfo resolveInfo = list.get(i);
|
ResolveInfo resolveInfo = list.get(i);
|
||||||
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
|
if ((resolveInfo.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
|
||||||
!= 0) {
|
!= 0) {
|
||||||
|
|
||||||
// Replace the intent with this specific activity
|
// Replace the intent with this specific activity
|
||||||
preference.setIntent(new Intent().setClassName(
|
preference.setIntent(new Intent().setClassName(
|
||||||
resolveInfo.activityInfo.packageName,
|
resolveInfo.activityInfo.packageName,
|
||||||
@@ -76,7 +77,7 @@ public class Utils {
|
|||||||
// Set the preference title to the activity's label
|
// Set the preference title to the activity's label
|
||||||
preference.setTitle(resolveInfo.loadLabel(pm));
|
preference.setTitle(resolveInfo.loadLabel(pm));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,8 +85,15 @@ public class Utils {
|
|||||||
|
|
||||||
// Did not find a matching activity, so remove the preference
|
// Did not find a matching activity, so remove the preference
|
||||||
parentPreferenceGroup.removePreference(preference);
|
parentPreferenceGroup.removePreference(preference);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if Monkey is running.
|
||||||
|
*/
|
||||||
|
public static boolean isMonkeyRunning() {
|
||||||
|
return SystemProperties.getBoolean("ro.monkey", false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user