Changes to "Alarms and Reminders" permission
Calling AlarmManager to know the state of the permission, which is now the source of truth, as the logic deciding the state of the permission may change. Also killing the app when the permission changes to denied, this avoids the app maintaining stale state about this permission. Test: make -j RunSettingsRoboTests atest SettingsUnitTests:AppStateAlarmsAndRemindersBridgeTest Manually: Toggle the state of an app to "Not allowed" and check the logs for activity manager kill messages. Bug: 181152252 Bug: 183136253 Change-Id: I438782eaef4caae50fd76685c675a3e45ee28d9f
This commit is contained in:
@@ -27,7 +27,6 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
|
||||
import com.android.settings.applications.AppStateAlarmsAndRemindersBridge;
|
||||
import com.android.settings.applications.AppStateAppOpsBridge;
|
||||
import com.android.settingslib.RestrictedSwitchPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -48,7 +47,7 @@ public class AlarmsAndRemindersDetailsTest {
|
||||
@Mock
|
||||
private AppStateAlarmsAndRemindersBridge mAppStateBridge;
|
||||
@Mock
|
||||
private AppStateAppOpsBridge.PermissionState mPermissionState;
|
||||
private AppStateAlarmsAndRemindersBridge.AlarmsAndRemindersState mPermissionState;
|
||||
|
||||
private AlarmsAndRemindersDetails mFragment = new AlarmsAndRemindersDetails();
|
||||
|
||||
@@ -96,12 +95,12 @@ public class AlarmsAndRemindersDetailsTest {
|
||||
mPackageInfo.applicationInfo = new ApplicationInfo();
|
||||
when(mAppStateBridge.createPermissionState(nullable(String.class), anyInt()))
|
||||
.thenReturn(mPermissionState);
|
||||
mPermissionState.permissionDeclared = false;
|
||||
when(mPermissionState.shouldBeVisible()).thenReturn(false);
|
||||
|
||||
mFragment.refreshUi();
|
||||
verify(mSwitchPref).setEnabled(false);
|
||||
|
||||
mPermissionState.permissionDeclared = true;
|
||||
when(mPermissionState.shouldBeVisible()).thenReturn(true);
|
||||
|
||||
mFragment.refreshUi();
|
||||
verify(mSwitchPref).setEnabled(true);
|
||||
@@ -114,11 +113,11 @@ public class AlarmsAndRemindersDetailsTest {
|
||||
when(mAppStateBridge.createPermissionState(nullable(String.class), anyInt()))
|
||||
.thenReturn(mPermissionState);
|
||||
|
||||
when(mPermissionState.isPermissible()).thenReturn(true);
|
||||
when(mPermissionState.isAllowed()).thenReturn(true);
|
||||
mFragment.refreshUi();
|
||||
verify(mSwitchPref).setChecked(true);
|
||||
|
||||
when(mPermissionState.isPermissible()).thenReturn(false);
|
||||
when(mPermissionState.isAllowed()).thenReturn(false);
|
||||
mFragment.refreshUi();
|
||||
verify(mSwitchPref).setChecked(false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user