Skip to content

Commit c1ec220

Browse files
Tsu Chiang ChuangAndroid (Google) Code Review
authored andcommitted
Merge "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." into jb-mr1-dev
2 parents 6de76d2 + 35fae68 commit c1ec220

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

core/tests/hosttests/test-apps/DownloadManagerTestApp/Android.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,11 @@ LOCAL_SDK_VERSION := current
2525

2626
LOCAL_PACKAGE_NAME := DownloadManagerTestApp
2727

28+
ifneq ($(TARGET_BUILD_VARIANT),user)
29+
# Need to run as system app to get access to Settings.
30+
LOCAL_CERTIFICATE := platform
31+
else
32+
$(error "This test app will fail to run unless it is built in non-user mode.")
33+
endif
34+
2835
include $(BUILD_PACKAGE)

core/tests/hosttests/test-apps/DownloadManagerTestApp/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
limitations under the License.
1515
-->
1616
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
17-
package="com.android.frameworks.downloadmanagertests">
17+
package="com.android.frameworks.downloadmanagertests"
18+
android:sharedUserId="android.uid.system">
1819

1920
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
2021
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
2122
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
2223
<uses-permission android:name="android.permission.INTERNET" />
2324
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
2425
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
26+
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
2527

2628
<application android:label="DownloadManagerTestApp">
2729
<uses-library android:name="android.test.runner" />

core/tests/hosttests/test-apps/DownloadManagerTestApp/src/com/android/frameworks/downloadmanagertests/DownloadManagerBaseTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ protected void setAirplaneModeOn(boolean enable) throws Exception {
262262
int state = enable ? 1 : 0;
263263

264264
// Change the system setting
265-
Settings.System.putInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON,
265+
Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON,
266266
state);
267267

268268
String timeoutMessage = "Timed out waiting for airplane mode to be " +
@@ -271,7 +271,7 @@ protected void setAirplaneModeOn(boolean enable) throws Exception {
271271
// wait for airplane mode to change state
272272
int currentWaitTime = 0;
273273
while (Settings.System.getInt(mContext.getContentResolver(),
274-
Settings.System.AIRPLANE_MODE_ON, -1) != state) {
274+
Settings.Global.AIRPLANE_MODE_ON, -1) != state) {
275275
timeoutWait(currentWaitTime, DEFAULT_WAIT_POLL_TIME, DEFAULT_MAX_WAIT_TIME,
276276
timeoutMessage);
277277
}

0 commit comments

Comments
 (0)