diff options
author | Tom O'Neill <tomo@google.com> | 2013-08-27 10:30:30 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-08-27 10:30:30 -0700 |
commit | a05612a244750473d1f101e1d76dc0705aa3cad8 (patch) | |
tree | 9ff7f93dcb8cd5395d153808ad465150f53156d6 /apps | |
parent | 515d41ee4b2ed7c17bde99ef64025509e1477258 (diff) | |
parent | 1073385f866a59797cb5d7dbac988f2ba08e753c (diff) | |
download | android_development-a05612a244750473d1f101e1d76dc0705aa3cad8.tar.gz android_development-a05612a244750473d1f101e1d76dc0705aa3cad8.tar.bz2 android_development-a05612a244750473d1f101e1d76dc0705aa3cad8.zip |
am 1073385f: am ed92f012: Merge "Test case where SettingsInjectorService.getStatus() errors out" into klp-dev
* commit '1073385f866a59797cb5d7dbac988f2ba08e753c':
Test case where SettingsInjectorService.getStatus() errors out
Diffstat (limited to 'apps')
5 files changed, 63 insertions, 1 deletions
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" /> </service> + <service android:name="com.example.android.injector.FailingInjectorService" > + <intent-filter> + <action android:name="com.android.settings.InjectedLocationSetting" /> + </intent-filter> + + <meta-data + android:name="com.android.settings.InjectedLocationSetting" + android:resource="@xml/failing_injected_location_setting" /> + </service> + <service android:name="com.example.android.injector.SlowInjectorService" > <intent-filter> <action android:name="com.android.settings.InjectedLocationSetting" /> 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 @@ <string name="my_injected_setting_label">Injected setting</string> <string name="disabled_setting_label">Disabled injected setting</string> + <string name="failing_setting_label">Failing injected setting</string> <string name="slow_setting_label">Slow injected setting</string> <string name="updating_setting_label">Updating injected setting</string> 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 @@ +<?xml version="1.0" encoding="utf-8"?> + +<injected-location-setting xmlns:android="http://schemas.android.com/apk/res/android" + android:label="@string/failing_setting_label" + android:icon="@drawable/ic_launcher" + android:settingsActivity="com.example.android.injector.MySettingActivity" +/> 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); |