am ed92f012: Merge "Test case where SettingsInjectorService.getStatus() errors out" into klp-dev
* commit 'ed92f0123a23efa10c802a9023f51f46a2dcf2c1': Test case where SettingsInjectorService.getStatus() errors out
This commit is contained in:
@@ -49,6 +49,16 @@
|
|||||||
android:resource="@xml/disabled_injected_location_setting" />
|
android:resource="@xml/disabled_injected_location_setting" />
|
||||||
</service>
|
</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" >
|
<service android:name="com.example.android.injector.SlowInjectorService" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="com.android.settings.InjectedLocationSetting" />
|
<action android:name="com.android.settings.InjectedLocationSetting" />
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
<string name="my_injected_setting_label">Injected setting</string>
|
<string name="my_injected_setting_label">Injected setting</string>
|
||||||
<string name="disabled_setting_label">Disabled 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="slow_setting_label">Slow injected setting</string>
|
||||||
<string name="updating_setting_label">Updating injected setting</string>
|
<string name="updating_setting_label">Updating injected setting</string>
|
||||||
|
|
||||||
|
|||||||
@@ -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"
|
||||||
|
/>
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
// 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(UPDATE_INTENT);
|
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 new Status(String.valueOf(System.currentTimeMillis()), true);
|
||||||
|
|||||||
Reference in New Issue
Block a user