Verify that non-system processes cannot set the time zone.
/**
* Attempt to set several predefined time zones, verifying that the system
* system default time zone has not actually changed from its prior state
* after each attempt.
*/
int max = (mZones.length > 10) ? mZones.length : 10;
assertTrue("No system-defined time zones - test invalid", max > 0);
for (int i = 0; i < max; i++) {
String tz = mZones[i];
try {
mAlarm.setTimeZone(tz);
} catch (SecurityException se) {
// Expected failure; no need to handle specially since we're
// about to assert that the test invariant holds: no change
// to the system time zone.
}
String newZone = TimeZone.getDefault().getID();
assertEquals("AlarmManager.setTimeZone() succeeded despite lack of permission",
mCurrentZone,
newZone);
}