Merge "Add back de-flake workaround" into pi-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 707310d..be7653d 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1656,51 +1656,6 @@
         </activity>
         <!-- End sensor tests definitions -->
 
-        <activity android:name=".location.LocationModeOffTestActivity"
-                android:label="@string/location_mode_off_test">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_location" />
-            <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television:android.software.leanback" />
-        </activity>
-        <activity android:name=".location.LocationModeHighAccuracyTestActivity"
-                android:label="@string/location_mode_high_accuracy_test">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_location" />
-            <meta-data android:name="test_required_features"
-                    android:value="android.hardware.location.network:android.hardware.location.gps" />
-            <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television:android.software.leanback" />
-        </activity>
-        <activity android:name=".location.LocationModeBatterySavingTestActivity"
-                android:label="@string/location_mode_battery_saving_test">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_location" />
-            <meta-data android:name="test_required_features" android:value="android.hardware.location.network" />
-            <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television:android.software.leanback" />
-        </activity>
-        <activity android:name=".location.LocationModeDeviceOnlyTestActivity"
-                android:label="@string/location_mode_device_only_test">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.cts.intent.category.MANUAL_TEST" />
-            </intent-filter>
-            <meta-data android:name="test_category" android:value="@string/test_category_location" />
-            <meta-data android:name="test_required_features" android:value="android.hardware.location.gps" />
-            <meta-data android:name="test_excluded_features"
-                    android:value="android.hardware.type.television:android.software.leanback" />
-        </activity>
-
         <activity android:name=".camera.formats.CameraFormatsActivity"
                  android:label="@string/camera_format"
                  android:screenOrientation="landscape">
diff --git a/apps/CtsVerifier/res/layout/location_mode_item.xml b/apps/CtsVerifier/res/layout/location_mode_item.xml
deleted file mode 100644
index 5e8dedb..0000000
--- a/apps/CtsVerifier/res/layout/location_mode_item.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     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.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content" >
-
-    <ImageView
-        android:id="@+id/status"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentLeft="true"
-        android:layout_alignParentTop="true"
-        android:layout_marginTop="10dip"
-        android:contentDescription="@string/pass_button_text"
-        android:padding="10dip"
-        android:src="@drawable/fs_indeterminate" />
-
-    <TextView
-        android:id="@+id/instructions"
-        style="@style/InstructionsSmallFont"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentRight="true"
-        android:layout_alignParentTop="true"
-        android:layout_toRightOf="@id/status"
-        android:text="@string/location_mode_select_high_accuracy" />
-
-    <Button
-        android:id="@+id/launch_settings"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentRight="true"
-        android:layout_below="@id/instructions"
-        android:layout_marginLeft="20dip"
-        android:layout_marginRight="20dip"
-        android:layout_toRightOf="@id/status"
-        android:onClick="launchSettings"
-        android:text="@string/location_mode_start_settings" />
-
-</RelativeLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 660ff84..278aa9f 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1670,57 +1670,6 @@
     <string name="cp_get_rules">Retrieving Automatic Zen Rules</string>
     <string name="cp_get_rule">Retrieving Automatic Zen Rule</string>
 
-    <string name="location_mode_high_accuracy_test">High Accuracy Mode Test</string>
-    <string name="location_mode_high_accuracy_info">
-        This test checks that the Location Mode API is consistent with the
-        Location Provider API when the device is in High Accuracy location mode.
-    </string>
-    <string name="location_mode_select_high_accuracy">
-        Please select the \"High accuracy\" mode at Settings > Location
-        (hint: tap the "Mode" item) and return here.
-    </string>
-    <string name="location_mode_battery_saving_test">Battery Saving Mode Test</string>
-    <string name="location_mode_battery_saving_info">
-        This test checks that the Location Mode API is consistent with the
-        Location Provider API when the device is in Battery Saving location mode.
-    </string>
-    <string name="location_mode_select_battery_saving">
-        Please select the \"Battery Saving\" mode at Settings > Location
-        (hint: tap the "Mode" item) and return here.
-    </string>
-    <string name="location_mode_device_only_test">Device Only Mode Test</string>
-    <string name="location_mode_device_only_info">
-        This test checks that the Location Mode API is consistent with the
-        Location Provider API when the device is in Device Only location mode.
-    </string>
-    <string name="location_mode_select_device_only">
-        Please select the \"Device Only\" mode at
-        Settings > Location (hint: tap the "Mode" item) and return here.
-    </string>
-    <string name="location_mode_off_test">Location Mode Off Test</string>
-    <string name="location_mode_off_info">
-        This test checks that the Location Mode API is consistent with the
-        Location Provider API when the device is in the Off location mode.
-    </string>
-
-    <string name="location_mode_start_settings">Launch Settings</string>
-    <string name="location_mode_turn_on">
-        Please turn ON location access (the switch at the top of Settings > Location)
-        and return here.
-    </string>
-    <string name="location_mode_turn_off">
-        Please turn OFF location access (the switch at the top of Settings > Location)
-        and return here.
-    </string>
-    <string name="location_mode_secure_gps_on">GPS provider should be ON in secure settings.</string>
-    <string name="location_mode_secure_gps_off">GPS provider should be OFF in secure settings.</string>
-    <string name="location_mode_secure_nlp_on">Network location provider should be ON in secure settings.</string>
-    <string name="location_mode_secure_nlp_off">Network location provider should be OFF in secure settings.</string>
-    <string name="location_mode_manager_gps_on">GPS provider should be ON in LocationManager.</string>
-    <string name="location_mode_manager_gps_off">GPS provider should be OFF in LocationManager.</string>
-    <string name="location_mode_manager_nlp_on">Network location provider should be ON in LocationManager.</string>
-    <string name="location_mode_manager_nlp_off">Network location provider should be OFF in LocationManager.</string>
-
     <string name="cacert_test">CA Cert Notification Test</string>
     <string name="cacert_info">This test checks that when a CA Certificate is installed, the user is notified.</string>
     <string name="cacert_do_something">Do it</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeBatterySavingTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeBatterySavingTestActivity.java
deleted file mode 100644
index 08fb34d..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeBatterySavingTestActivity.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.android.cts.verifier.location;
-
-import android.location.LocationManager;
-import android.provider.Settings.Secure;
-import com.android.cts.verifier.R;
-
-public class LocationModeBatterySavingTestActivity extends LocationModeTestActivity {
-
-    @Override
-    protected void createTestItems() {
-        createUserItem(R.string.location_mode_turn_on);
-        createUserItem(R.string.location_mode_select_battery_saving);
-        createAutoItem(R.string.location_mode_secure_gps_off);
-        createAutoItem(R.string.location_mode_secure_nlp_on);
-        createAutoItem(R.string.location_mode_manager_gps_off);
-        createAutoItem(R.string.location_mode_manager_nlp_on);
-    }
-
-    @Override
-    protected void setInfoResources() {
-        setInfoResources(R.string.location_mode_battery_saving_test,
-                R.string.location_mode_battery_saving_info, -1);
-    }
-
-    @Override
-    protected void testAdvance(int state) {
-        switch (state) {
-            case 0:
-                testIsOn(0);
-                break;
-            case 1:
-                testIsExpectedMode(1, Secure.LOCATION_MODE_BATTERY_SAVING);
-                break;
-            case 2:
-                testSecureProviderIsDisabled(2, LocationManager.GPS_PROVIDER);
-                break;
-            case 3:
-                testSecureProviderIsEnabled(3, LocationManager.NETWORK_PROVIDER);
-                break;
-            case 4:
-                testManagerProviderIsDisabled(4, LocationManager.GPS_PROVIDER);
-                break;
-            case 5:
-                testManagerProviderIsEnabled(5, LocationManager.NETWORK_PROVIDER);
-                break;
-        }
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeDeviceOnlyTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeDeviceOnlyTestActivity.java
deleted file mode 100644
index 0ba9f76..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeDeviceOnlyTestActivity.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.android.cts.verifier.location;
-
-import android.location.LocationManager;
-import android.provider.Settings.Secure;
-import com.android.cts.verifier.R;
-
-public class LocationModeDeviceOnlyTestActivity extends LocationModeTestActivity {
-
-    @Override
-    protected void createTestItems() {
-        createUserItem(R.string.location_mode_turn_on);
-        createUserItem(R.string.location_mode_select_device_only);
-        createAutoItem(R.string.location_mode_secure_gps_on);
-        createAutoItem(R.string.location_mode_secure_nlp_off);
-        createAutoItem(R.string.location_mode_manager_gps_on);
-        createAutoItem(R.string.location_mode_manager_nlp_off);
-    }
-
-    @Override
-    protected void setInfoResources() {
-        setInfoResources(R.string.location_mode_device_only_test,
-                R.string.location_mode_device_only_info, -1);
-    }
-
-    @Override
-    protected void testAdvance(int state) {
-        switch (state) {
-            case 0:
-                testIsOn(0);
-                break;
-            case 1:
-                testIsExpectedMode(1, Secure.LOCATION_MODE_SENSORS_ONLY);
-                break;
-            case 2:
-                testSecureProviderIsEnabled(2, LocationManager.GPS_PROVIDER);
-                break;
-            case 3:
-                testSecureProviderIsDisabled(3, LocationManager.NETWORK_PROVIDER);
-                break;
-            case 4:
-                testManagerProviderIsEnabled(4, LocationManager.GPS_PROVIDER);
-                break;
-            case 5:
-                testManagerProviderIsDisabled(5, LocationManager.NETWORK_PROVIDER);
-                break;
-        }
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeHighAccuracyTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeHighAccuracyTestActivity.java
deleted file mode 100644
index 9c10705..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeHighAccuracyTestActivity.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.android.cts.verifier.location;
-
-import android.location.LocationManager;
-import android.provider.Settings.Secure;
-import com.android.cts.verifier.R;
-
-public class LocationModeHighAccuracyTestActivity extends LocationModeTestActivity {
-
-    @Override
-    protected void createTestItems() {
-        createUserItem(R.string.location_mode_turn_on);
-        createUserItem(R.string.location_mode_select_high_accuracy);
-        createAutoItem(R.string.location_mode_secure_gps_on);
-        createAutoItem(R.string.location_mode_secure_nlp_on);
-        createAutoItem(R.string.location_mode_manager_gps_on);
-        createAutoItem(R.string.location_mode_manager_nlp_on);
-    }
-
-    @Override
-    protected void setInfoResources() {
-        setInfoResources(R.string.location_mode_high_accuracy_test,
-                R.string.location_mode_high_accuracy_info, -1);
-    }
-
-    @Override
-    protected void testAdvance(int state) {
-        switch (state) {
-            case 0:
-                testIsOn(0);
-                break;
-            case 1:
-                testIsExpectedMode(1, Secure.LOCATION_MODE_HIGH_ACCURACY);
-                break;
-            case 2:
-                testSecureProviderIsEnabled(2, LocationManager.GPS_PROVIDER);
-                break;
-            case 3:
-                testSecureProviderIsEnabled(3, LocationManager.NETWORK_PROVIDER);
-                break;
-            case 4:
-                testManagerProviderIsEnabled(4, LocationManager.GPS_PROVIDER);
-                break;
-            case 5:
-                testManagerProviderIsEnabled(5, LocationManager.NETWORK_PROVIDER);
-                break;
-        }
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeOffTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeOffTestActivity.java
deleted file mode 100644
index 92b0742..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeOffTestActivity.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.android.cts.verifier.location;
-
-import android.location.LocationManager;
-import android.provider.Settings.Secure;
-import com.android.cts.verifier.R;
-
-public class LocationModeOffTestActivity extends LocationModeTestActivity {
-
-    @Override
-    protected void createTestItems() {
-        createUserItem(R.string.location_mode_turn_off);
-        createAutoItem(R.string.location_mode_secure_gps_off);
-        createAutoItem(R.string.location_mode_secure_nlp_off);
-        createAutoItem(R.string.location_mode_manager_gps_off);
-        createAutoItem(R.string.location_mode_manager_nlp_off);
-    }
-
-    @Override
-    protected void setInfoResources() {
-        setInfoResources(R.string.location_mode_off_test,
-                R.string.location_mode_off_info, -1);
-    }
-
-    @Override
-    protected void testAdvance(int state) {
-        switch (state) {
-            case 0:
-                testIsExpectedMode(0, Secure.LOCATION_MODE_OFF);
-                break;
-            case 1:
-                testSecureProviderIsDisabled(1, LocationManager.GPS_PROVIDER);
-                break;
-            case 2:
-                testSecureProviderIsDisabled(2, LocationManager.NETWORK_PROVIDER);
-                break;
-            case 3:
-                testManagerProviderIsDisabled(3, LocationManager.GPS_PROVIDER);
-                break;
-            case 4:
-                testManagerProviderIsDisabled(4, LocationManager.NETWORK_PROVIDER);
-                break;
-        }
-    }
-}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeTestActivity.java
deleted file mode 100644
index 92d41f4..0000000
--- a/apps/CtsVerifier/src/com/android/cts/verifier/location/LocationModeTestActivity.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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.android.cts.verifier.location;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.location.LocationManager;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.provider.Settings.Secure;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ImageView;
-import android.widget.TextView;
-import com.android.cts.verifier.PassFailButtons;
-import com.android.cts.verifier.R;
-
-/**
- * Asks the user to put the device in one of the four location modes and then checks to see if
- * {@link Secure#isLocationProviderEnabled(ContentResolver, String)} and {@link
- * LocationManager#isProviderEnabled(String)} have the expected values for GPS and Wi-Fi. For
- * example in battery saving mode, Wi-Fi should be on but GPS should be off.
- *
- * It would be hard to automate these tests because the {@link Secure#LOCATION_MODE} API is only
- * accessible to apps in the system image. Furthermore, selecting two of the modes requires the user
- * to accept the NLP confirmation dialog.
- */
-public abstract class LocationModeTestActivity
-        extends PassFailButtons.Activity implements Runnable {
-
-    private static final String STATE = "state";
-    protected static final int PASS = 1;
-    protected static final int FAIL = 2;
-    protected static final int WAIT_FOR_USER = 3;
-
-    protected int mState;
-    protected int[] mStatus;
-    private LayoutInflater mInflater;
-    private ViewGroup mItemList;
-    private Runnable mRunner;
-    private View mHandler;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        if (savedInstanceState != null) {
-            mState = savedInstanceState.getInt(STATE, 0);
-        }
-
-        mRunner = this;
-        mInflater = getLayoutInflater();
-        View view = mInflater.inflate(R.layout.location_mode_main, null);
-        mItemList = (ViewGroup) view.findViewById(R.id.test_items);
-        mHandler = mItemList;
-
-        createTestItems();
-        mStatus = new int[mItemList.getChildCount()];
-        setContentView(view);
-
-        setPassFailButtonClickListeners();
-
-        setInfoResources();
-
-        getPassButton().setEnabled(false);
-    }
-
-    @Override
-    protected void onSaveInstanceState(Bundle outState) {
-        outState.putInt(STATE, mState);
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        next();
-    }
-
-    /**
-     * Template method used by the subclass to create the checks corresponding to each value of
-     * {@link #mState}. Subclass should call {@link #createUserItem(int)} and {@link
-     * #createAutoItem(int)} as appropriate to generate each item.
-     */
-    protected abstract void createTestItems();
-
-    /**
-     * Template method used by the subclass to call {@link #setInfoResources(int, int, int)} with
-     * the appropriate resources.
-     */
-    protected abstract void setInfoResources();
-
-    /**
-     * Subclass can call this to create a test step where the user must perform some action such
-     * as setting the location mode.
-     */
-    protected View createUserItem(int stringId) {
-        View item = mInflater.inflate(R.layout.location_mode_item, mItemList, false);
-        TextView instructions = (TextView) item.findViewById(R.id.instructions);
-        instructions.setText(stringId);
-        mItemList.addView(item);
-        return item;
-    }
-
-    /**
-     * Subclass can call this to create a test step where the test automatically evaluates whether
-     * an expected condition is satisfied, such as GPS is off.
-     */
-    protected View createAutoItem(int stringId) {
-        View item = mInflater.inflate(R.layout.location_mode_item, mItemList, false);
-        TextView instructions = (TextView) item.findViewById(R.id.instructions);
-        instructions.setText(stringId);
-        View button = item.findViewById(R.id.launch_settings);
-        button.setVisibility(View.GONE);
-        mItemList.addView(item);
-        return item;
-    }
-
-    /**
-     * Set the visible state of a test item to passed or failed.
-     */
-    private void setItemState(int index, boolean passed) {
-        ViewGroup item = (ViewGroup) mItemList.getChildAt(index);
-        ImageView status = (ImageView) item.findViewById(R.id.status);
-        status.setImageResource(passed ? R.drawable.fs_good : R.drawable.fs_error);
-        View button = item.findViewById(R.id.launch_settings);
-        button.setClickable(false);
-        button.setEnabled(false);
-        status.invalidate();
-    }
-
-    /**
-     * Set the visible state of a test item to waiting.
-     */
-    protected void markItemWaiting(int index) {
-        ViewGroup item = (ViewGroup) mItemList.getChildAt(index);
-        ImageView status = (ImageView) item.findViewById(R.id.status);
-        status.setImageResource(R.drawable.fs_warning);
-        status.invalidate();
-    }
-
-    /**
-     * Advances the state machine.
-     */
-    public void run() {
-        // Advance test state until we find case where it hasn't passed (yet)
-        while (mState < mStatus.length && mStatus[mState] != WAIT_FOR_USER) {
-            if (mStatus[mState] == PASS) {
-                setItemState(mState, true);
-                mState++;
-            } else if (mStatus[mState] == FAIL) {
-                setItemState(mState, false);
-                return;
-            } else {
-                break;
-            }
-        }
-
-        if (mState < mStatus.length && mStatus[mState] == WAIT_FOR_USER) {
-            markItemWaiting(mState);
-        }
-
-        testAdvance(mState);
-
-        if (mState == mStatus.length - 1 && mStatus[mState] == PASS) {
-            // All tests run and pass
-            getPassButton().setEnabled(true);
-        }
-    }
-
-    /**
-     * Launches Locations &gt; Settings so the user can set the location mode. Public because it
-     * is referenced by layout.
-     */
-    public void launchSettings(View button) {
-        startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
-    }
-
-    /**
-     * Return to the state machine to progress through the tests.
-     */
-    protected void next() {
-        mHandler.post(mRunner);
-    }
-
-    /**
-     * Wait for things to settle before returning to the state machine.
-     */
-    protected void delay() {
-        mHandler.postDelayed(mRunner, 2000);
-    }
-
-    // Tests
-
-    private int getLocationMode() {
-        ContentResolver cr = getContentResolver();
-        return Secure.getInt(cr, Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF);
-    }
-
-    protected void testIsOn(int i) {
-        int mode = getLocationMode();
-        boolean passed = mode != Secure.LOCATION_MODE_OFF;
-        if (passed) {
-            mStatus[i] = PASS;
-        } else {
-            mStatus[i] = WAIT_FOR_USER;
-        }
-        next();
-    }
-
-    protected void testIsExpectedMode(int i, int expectedMode) {
-        int mode = getLocationMode();
-        boolean passed = mode == expectedMode;
-        if (passed) {
-            mStatus[i] = PASS;
-            next();
-        } else {
-            mStatus[i] = WAIT_FOR_USER;
-            delay();
-        }
-    }
-
-    protected void testSecureProviderIsEnabled(int i, String provider) {
-        ContentResolver cr = getContentResolver();
-        boolean enabled = Secure.isLocationProviderEnabled(cr, provider);
-        mStatus[i] = enabled ? PASS : FAIL;
-        next();
-    }
-
-    protected void testSecureProviderIsDisabled(int i, String provider) {
-        ContentResolver cr = getContentResolver();
-        boolean enabled = Secure.isLocationProviderEnabled(cr, provider);
-        mStatus[i] = !enabled ? PASS : FAIL;
-        next();
-    }
-
-    protected void testManagerProviderIsEnabled(int i, String gpsProvider) {
-        LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
-        boolean enabled = manager.isProviderEnabled(gpsProvider);
-        mStatus[i] = enabled ? PASS : FAIL;
-        next();
-    }
-
-    protected void testManagerProviderIsDisabled(int i, String gpsProvider) {
-        LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
-        boolean enabled = manager.isProviderEnabled(gpsProvider);
-        mStatus[i] = !enabled ? PASS : FAIL;
-        next();
-    }
-
-    protected abstract void testAdvance(int state);
-}