Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35fae68c authored by Tsu Chiang Chuang's avatar Tsu Chiang Chuang
Browse files

Change the way how airplane mode is set, since it has been moved to

Settings.Global namespace. Also run as a system app, since only system
apps can change airplane mode.

Change-Id: I317f9c94361cfca182356fd292e5b0b41553d1ab
parent 7b6ec1f6
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -25,4 +25,11 @@ LOCAL_SDK_VERSION := current


LOCAL_PACKAGE_NAME := DownloadManagerTestApp
LOCAL_PACKAGE_NAME := DownloadManagerTestApp


ifneq ($(TARGET_BUILD_VARIANT),user)
# Need to run as system app to get access to Settings.
LOCAL_CERTIFICATE := platform
else
$(error "This test app will fail to run unless it is built in non-user mode.")
endif

include $(BUILD_PACKAGE)
include $(BUILD_PACKAGE)
+3 −1
Original line number Original line Diff line number Diff line
@@ -14,7 +14,8 @@
     limitations under the License.
     limitations under the License.
-->
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.frameworks.downloadmanagertests">
       package="com.android.frameworks.downloadmanagertests"
       android:sharedUserId="android.uid.system">


    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
@@ -22,6 +23,7 @@
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />


    <application android:label="DownloadManagerTestApp">
    <application android:label="DownloadManagerTestApp">
            <uses-library android:name="android.test.runner" />
            <uses-library android:name="android.test.runner" />
+2 −2
Original line number Original line Diff line number Diff line
@@ -262,7 +262,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
        int state = enable ? 1 : 0;
        int state = enable ? 1 : 0;


        // Change the system setting
        // Change the system setting
        Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
        Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,
                state);
                state);


        String timeoutMessage = "Timed out waiting for airplane mode to be " +
        String timeoutMessage = "Timed out waiting for airplane mode to be " +
@@ -271,7 +271,7 @@ public class DownloadManagerBaseTest extends InstrumentationTestCase {
        // wait for airplane mode to change state
        // wait for airplane mode to change state
        int currentWaitTime = 0;
        int currentWaitTime = 0;
        while (Settings.System.getInt(mContext.getContentResolver(),
        while (Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.AIRPLANE_MODE_ON, -1) != state) {
                Settings.Global.AIRPLANE_MODE_ON, -1) != state) {
            timeoutWait(currentWaitTime, DEFAULT_WAIT_POLL_TIME, DEFAULT_MAX_WAIT_TIME,
            timeoutWait(currentWaitTime, DEFAULT_WAIT_POLL_TIME, DEFAULT_MAX_WAIT_TIME,
                    timeoutMessage);
                    timeoutMessage);
        }
        }