.. | .. |
---|
537 | 537 | return defaultValue; |
---|
538 | 538 | } |
---|
539 | 539 | |
---|
| 540 | + public static boolean setSystemProperty(String property, String value) { |
---|
| 541 | + if (TextUtils.isEmpty(property) || TextUtils.isEmpty(value)) { |
---|
| 542 | + return false; |
---|
| 543 | + } |
---|
| 544 | + try { |
---|
| 545 | + Class clazz = Class.forName("android.os.SystemProperties"); |
---|
| 546 | + Method setter = clazz.getDeclaredMethod("set", String.class, String.class); |
---|
| 547 | + setter.invoke(null, property, value); |
---|
| 548 | + return true; |
---|
| 549 | + } catch (Exception e) { |
---|
| 550 | + Log.d(TAG, "Failed to set property: " + e.getMessage()); |
---|
| 551 | + return false; |
---|
| 552 | + } |
---|
| 553 | + } |
---|
| 554 | + |
---|
540 | 555 | /** |
---|
541 | 556 | * Ensures that a value is within given bounds. Specifically: |
---|
542 | 557 | * If value is less than lowerBound, return lowerBound; else if value is greater than upperBound, |
---|