am 6ae72772: React to split of getStatus() into onGetSummary() and onGetEnabled()
* commit '6ae72772c076b602eb71c3e0b680d6b514323c07': React to split of getStatus() into onGetSummary() and onGetEnabled()
This commit is contained in:
@@ -31,14 +31,18 @@ public class DisabledInjectorService extends SettingInjectorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Status getStatus() {
|
protected String onGetSummary() {
|
||||||
try {
|
try {
|
||||||
// Simulate a delay while reading the setting from disk
|
// Simulate a delay while reading the setting from disk
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.e(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new Status(null, false);
|
@Override
|
||||||
|
protected boolean onGetEnabled() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,12 +26,20 @@ public class FailingInjectorService extends SettingInjectorService {
|
|||||||
|
|
||||||
private static final String TAG = "FailingInjectorService";
|
private static final String TAG = "FailingInjectorService";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to actually throw an exception here. Pretty disruptive when true, because it causes
|
||||||
|
* a "Unfortunately, My Setting Activity! has stopped" dialog to appear and also blocks the
|
||||||
|
* update of other settings from this app. So only set true when need to test the handling
|
||||||
|
* of the exception.
|
||||||
|
*/
|
||||||
|
private static final boolean ACTUALLY_THROW = false;
|
||||||
|
|
||||||
public FailingInjectorService() {
|
public FailingInjectorService() {
|
||||||
super(TAG);
|
super(TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Status getStatus() {
|
protected String onGetSummary() {
|
||||||
try {
|
try {
|
||||||
// Simulate a delay while reading the setting from disk
|
// Simulate a delay while reading the setting from disk
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
@@ -39,6 +47,14 @@ public class FailingInjectorService extends SettingInjectorService {
|
|||||||
Log.e(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new RuntimeException("Simulated failure reading setting");
|
if (ACTUALLY_THROW) {
|
||||||
|
throw new RuntimeException("Simulated failure reading setting");
|
||||||
|
}
|
||||||
|
return "Decided not to throw exception after all";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean onGetEnabled() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,18 @@ public class MyInjectorService extends SettingInjectorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Status getStatus() {
|
protected String onGetSummary() {
|
||||||
try {
|
try {
|
||||||
// Simulate a delay while reading the setting from disk
|
// Simulate a delay while reading the setting from disk
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.e(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
}
|
}
|
||||||
|
return "Example status value";
|
||||||
|
}
|
||||||
|
|
||||||
return new Status("Example status value", true);
|
@Override
|
||||||
|
protected boolean onGetEnabled() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,18 @@ public class SlowInjectorService extends SettingInjectorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Status getStatus() {
|
protected String onGetSummary() {
|
||||||
try {
|
try {
|
||||||
// Simulate a delay while reading the setting from disk
|
// Simulate a delay while reading the setting from disk
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Log.e(TAG, "", e);
|
Log.e(TAG, "", e);
|
||||||
}
|
}
|
||||||
|
return "Dang that took a long time!";
|
||||||
|
}
|
||||||
|
|
||||||
return new Status("Dang that took a long time!", true);
|
@Override
|
||||||
|
protected boolean onGetEnabled() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,13 +32,18 @@ public class UpdatingInjectorService extends SettingInjectorService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Status getStatus() {
|
protected String onGetSummary() {
|
||||||
// Every time it asks for our status, we tell it the setting has just changed. This will
|
// Every time it asks for our status, we tell it the setting has just changed. This will
|
||||||
// test the handling of races where we're getting many UPDATE_INTENT broadcasts in a short
|
// test the handling of races where we're getting many UPDATE_INTENT broadcasts in a short
|
||||||
// period of time
|
// period of time
|
||||||
Intent intent = new Intent(ACTION_INJECTED_SETTING_CHANGED);
|
Intent intent = new Intent(ACTION_INJECTED_SETTING_CHANGED);
|
||||||
sendBroadcast(intent);
|
sendBroadcast(intent);
|
||||||
Log.d(TAG, "Broadcasting: " + intent);
|
Log.d(TAG, "Broadcasting: " + intent);
|
||||||
return new Status(String.valueOf(System.currentTimeMillis()), true);
|
return String.valueOf(System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean onGetEnabled() {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user