am 7db79b35: Inject more settings for better testing of SettingsInjector
* commit '7db79b35483922a07a3a144dd3354b1f0d0cc9b3': Inject more settings for better testing of SettingsInjector
This commit is contained in:
@@ -38,5 +38,36 @@
|
||||
android:name="com.android.settings.InjectedLocationSetting"
|
||||
android:resource="@xml/my_injected_location_setting" />
|
||||
</service>
|
||||
|
||||
<service android:name="com.example.android.injector.DisabledInjectorService" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.InjectedLocationSetting" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="com.android.settings.InjectedLocationSetting"
|
||||
android:resource="@xml/disabled_injected_location_setting" />
|
||||
</service>
|
||||
|
||||
<service android:name="com.example.android.injector.SlowInjectorService" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.InjectedLocationSetting" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="com.android.settings.InjectedLocationSetting"
|
||||
android:resource="@xml/slow_injected_location_setting" />
|
||||
</service>
|
||||
|
||||
<service android:name="com.example.android.injector.UpdatingInjectorService" >
|
||||
<intent-filter>
|
||||
<action android:name="com.android.settings.InjectedLocationSetting" />
|
||||
</intent-filter>
|
||||
|
||||
<meta-data
|
||||
android:name="com.android.settings.InjectedLocationSetting"
|
||||
android:resource="@xml/updating_injected_location_setting" />
|
||||
</service>
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
||||
@@ -20,5 +20,7 @@
|
||||
|
||||
<string name="my_injected_setting_label">Injected setting</string>
|
||||
<string name="disabled_setting_label">Disabled injected setting</string>
|
||||
<string name="slow_setting_label">Slow injected setting</string>
|
||||
<string name="updating_setting_label">Updating injected setting</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -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/disabled_setting_label"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:settingsActivity="com.example.android.injector.MySettingActivity"
|
||||
/>
|
||||
@@ -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/slow_setting_label"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:settingsActivity="com.example.android.injector.MySettingActivity"
|
||||
/>
|
||||
@@ -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/updating_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 disabled for an injected setting.
|
||||
*/
|
||||
public class DisabledInjectorService extends SettingInjectorService {
|
||||
|
||||
private static final String TAG = "DisabledInjectorService";
|
||||
|
||||
public DisabledInjectorService() {
|
||||
super(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Status getStatus() {
|
||||
try {
|
||||
// Simulate a delay while reading the setting from disk
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "", e);
|
||||
}
|
||||
|
||||
return new Status(null, false);
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import android.util.Log;
|
||||
*/
|
||||
public class MyInjectorService extends SettingInjectorService {
|
||||
|
||||
private static final String TAG = "ClientService";
|
||||
private static final String TAG = "MyInjectorService";
|
||||
|
||||
public MyInjectorService() {
|
||||
super(TAG);
|
||||
@@ -34,7 +34,7 @@ public class MyInjectorService extends SettingInjectorService {
|
||||
protected Status getStatus() {
|
||||
try {
|
||||
// Simulate a delay while reading the setting from disk
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "", e);
|
||||
}
|
||||
|
||||
@@ -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 SlowInjectorService extends SettingInjectorService {
|
||||
|
||||
private static final String TAG = "SlowInjectorService";
|
||||
|
||||
public SlowInjectorService() {
|
||||
super(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Status getStatus() {
|
||||
try {
|
||||
// Simulate a delay while reading the setting from disk
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
Log.e(TAG, "", e);
|
||||
}
|
||||
|
||||
return new Status("Dang that took a long time!", true);
|
||||
}
|
||||
}
|
||||
@@ -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.content.Intent;
|
||||
import android.location.SettingInjectorService;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Receiver that returns a constantly-updating status for an injected setting.
|
||||
*/
|
||||
public class UpdatingInjectorService extends SettingInjectorService {
|
||||
|
||||
private static final String TAG = "UpdatingInjectorService";
|
||||
|
||||
public UpdatingInjectorService() {
|
||||
super(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Status getStatus() {
|
||||
// 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);
|
||||
sendBroadcast(intent);
|
||||
Log.d(TAG, "Broadcasting: " + intent);
|
||||
return new Status(String.valueOf(System.currentTimeMillis()), true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user