diff --git a/apps/SettingInjectorSample/AndroidManifest.xml b/apps/SettingInjectorSample/AndroidManifest.xml index 3142860ae..dafe131bf 100644 --- a/apps/SettingInjectorSample/AndroidManifest.xml +++ b/apps/SettingInjectorSample/AndroidManifest.xml @@ -49,6 +49,16 @@ android:resource="@xml/disabled_injected_location_setting" /> + + + + + + + + diff --git a/apps/SettingInjectorSample/res/values/strings.xml b/apps/SettingInjectorSample/res/values/strings.xml index a7b73dd3f..665749985 100644 --- a/apps/SettingInjectorSample/res/values/strings.xml +++ b/apps/SettingInjectorSample/res/values/strings.xml @@ -20,6 +20,7 @@ Injected setting Disabled injected setting + Failing injected setting Slow injected setting Updating injected setting diff --git a/apps/SettingInjectorSample/res/xml/failing_injected_location_setting.xml b/apps/SettingInjectorSample/res/xml/failing_injected_location_setting.xml new file mode 100644 index 000000000..c632711ee --- /dev/null +++ b/apps/SettingInjectorSample/res/xml/failing_injected_location_setting.xml @@ -0,0 +1,7 @@ + + + diff --git a/apps/SettingInjectorSample/src/com/example/android/injector/FailingInjectorService.java b/apps/SettingInjectorSample/src/com/example/android/injector/FailingInjectorService.java new file mode 100644 index 000000000..f13d7e040 --- /dev/null +++ b/apps/SettingInjectorSample/src/com/example/android/injector/FailingInjectorService.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.injector; + +import android.location.SettingInjectorService; +import android.util.Log; + +/** + * Receiver that returns the status of the injected setting. + */ +public class FailingInjectorService extends SettingInjectorService { + + private static final String TAG = "FailingInjectorService"; + + public FailingInjectorService() { + super(TAG); + } + + @Override + protected Status getStatus() { + try { + // Simulate a delay while reading the setting from disk + Thread.sleep(100); + } catch (InterruptedException e) { + Log.e(TAG, "", e); + } + + throw new RuntimeException("Simulated failure reading setting"); + } +} diff --git a/apps/SettingInjectorSample/src/com/example/android/injector/UpdatingInjectorService.java b/apps/SettingInjectorSample/src/com/example/android/injector/UpdatingInjectorService.java index e12184e00..632066768 100644 --- a/apps/SettingInjectorSample/src/com/example/android/injector/UpdatingInjectorService.java +++ b/apps/SettingInjectorSample/src/com/example/android/injector/UpdatingInjectorService.java @@ -36,7 +36,7 @@ public class UpdatingInjectorService extends SettingInjectorService { // 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 // period of time - Intent intent = new Intent(UPDATE_INTENT); + Intent intent = new Intent(ACTION_INJECTED_SETTING_CHANGED); sendBroadcast(intent); Log.d(TAG, "Broadcasting: " + intent); return new Status(String.valueOf(System.currentTimeMillis()), true);