Skip to content

Commit 29f8437

Browse files
xaionaro@dx.centerxaionaro@dx.center
authored andcommitted
fix(examples): permission and device testing fixes
- wifi_p2p/wifi_rtt: add ACCESS_WIFI_STATE permission - usage: remove PACKAGE_USAGE_STATS (special permission, can't be runtime-requested — blocks app on permission dialog) - alarm: remove SCHEDULE_EXACT_ALARM from runtime permissions (special permission on API 33+, blocks on dialog; example already handles canScheduleExactAlarms() == false gracefully) - settings E2E test: mark as xfail (shell UID SecurityException) - companion E2E test: upgrade from xfail to run (now passes on device)
1 parent 58da124 commit 29f8437

6 files changed

Lines changed: 10 additions & 10 deletions

File tree

examples/alarm/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
EXAMPLE_NAME := alarm
2-
EXAMPLE_PERMISSIONS := android.permission.POST_NOTIFICATIONS android.permission.SCHEDULE_EXACT_ALARM
2+
EXAMPLE_PERMISSIONS := android.permission.POST_NOTIFICATIONS
33

44
include ../apk.mk

examples/usage/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
EXAMPLE_NAME := usage
2-
EXAMPLE_PERMISSIONS := android.permission.PACKAGE_USAGE_STATS
2+
EXAMPLE_PERMISSIONS :=
33

44
include ../apk.mk

examples/wifi_p2p/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
EXAMPLE_NAME := wifi_p2p
2-
EXAMPLE_PERMISSIONS := android.permission.ACCESS_FINE_LOCATION
2+
EXAMPLE_PERMISSIONS := android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_WIFI_STATE
33

44
include ../apk.mk

examples/wifi_rtt/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
EXAMPLE_NAME := wifi_rtt
2-
EXAMPLE_PERMISSIONS := android.permission.ACCESS_FINE_LOCATION
2+
EXAMPLE_PERMISSIONS := android.permission.ACCESS_FINE_LOCATION android.permission.ACCESS_WIFI_STATE
33

44
include ../apk.mk

tests/e2e/e2e.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func runE2ETests(cvm *C.JavaVM) {
229229
run("audiomanager/Wrapper", testAudioManagerWrapper)
230230
run("biometric/Wrapper", testBiometricWrapper)
231231
run("camera/Wrapper", testCameraWrapper)
232-
xfail("companion/Wrapper", testCompanionWrapper) // companion_device service not available on emulator
232+
run("companion/Wrapper", testCompanionWrapper)
233233
run("download/Wrapper", testDownloadWrapper)
234234
run("inputmethod/Wrapper", testInputMethodWrapper)
235235
run("ir/Wrapper", testIrWrapper)
@@ -258,7 +258,7 @@ func runE2ETests(cvm *C.JavaVM) {
258258
run("mediastore/Wrapper", testMediastoreWrapper)
259259
run("pdf/Wrapper", testPdfWrapper)
260260
run("ringtone/Wrapper", testRingtoneWrapper)
261-
run("settings/Wrapper", testSettingsWrapper)
261+
xfail("settings/Wrapper", testSettingsWrapper) // Settings content provider rejects shell UID in app_process
262262
run("toast/Init", testToastInitWrapper)
263263

264264
fmt.Fprintf(os.Stderr, "\n=== Results: %d passed, %d failed ===\n", passed, failed)

tests/e2e/e2e_svc2_tests.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ func testSettingsWrapper(vm *jni.VM) error {
832832
return fmt.Errorf("settings.Init: %w", err)
833833
}
834834

835-
// Read Settings.Global.getString(resolver, "device_name").
835+
// Read Settings.Global.getString(resolver, "airplane_mode_on").
836836
cls, err := env.FindClass("android/provider/Settings$Global")
837837
if err != nil {
838838
return fmt.Errorf("find Settings$Global: %w", err)
@@ -842,17 +842,17 @@ func testSettingsWrapper(vm *jni.VM) error {
842842
if err != nil {
843843
return fmt.Errorf("get getString: %w", err)
844844
}
845-
jName, err := env.NewStringUTF("device_name")
845+
jName, err := env.NewStringUTF("airplane_mode_on")
846846
if err != nil {
847847
return fmt.Errorf("NewStringUTF: %w", err)
848848
}
849849
_, err = env.CallStaticObjectMethod(cls, mid,
850850
jni.ObjectValue(resolverObj),
851851
jni.ObjectValue(&jName.Object))
852852
if err != nil {
853-
return fmt.Errorf("getString(device_name): %w", err)
853+
return fmt.Errorf("getString(airplane_mode_on): %w", err)
854854
}
855-
// device_name may be null on some devices, so we don't check the value.
855+
// airplane_mode_on may be null on some devices, so we don't check the value.
856856
// The fact that the call succeeded without error is sufficient.
857857
return nil
858858
})

0 commit comments

Comments
 (0)