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

Commit 37a8312d authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Merge cherrypicks of [15058924, 15066183] into sc-release

Change-Id: Ie69ffa42c10f78195e073b9864db27e6ee7a6a3c
parents 2952a2f9 d516e416
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -1285,14 +1285,20 @@ public class AlarmManager {
    }

    /**
     * Called to check if the caller has the permission
     * {@link Manifest.permission#SCHEDULE_EXACT_ALARM}.
     *
     * Apps can start {@link android.provider.Settings#ACTION_REQUEST_SCHEDULE_EXACT_ALARM} to
     * Called to check if the caller can schedule exact alarms.
     * <p>
     * Apps targeting {@link Build.VERSION_CODES#S} or higher can schedule exact alarms if they
     * have the {@link Manifest.permission#SCHEDULE_EXACT_ALARM} permission. These apps can also
     * start {@link android.provider.Settings#ACTION_REQUEST_SCHEDULE_EXACT_ALARM} to
     * request this from the user.
     * <p>
     * Apps targeting lower sdk versions, can always schedule exact alarms.
     *
     * @return {@code true} if the caller has the permission, {@code false} otherwise.
     * @return {@code true} if the caller can schedule exact alarms.
     * @see android.provider.Settings#ACTION_REQUEST_SCHEDULE_EXACT_ALARM
     * @see #setExact(int, long, PendingIntent)
     * @see #setExactAndAllowWhileIdle(int, long, PendingIntent)
     * @see #setAlarmClock(AlarmClockInfo, PendingIntent)
     */
    public boolean canScheduleExactAlarms() {
        return hasScheduleExactAlarm(mContext.getOpPackageName(), mContext.getUserId());
+3 −0
Original line number Diff line number Diff line
@@ -2572,6 +2572,9 @@ public class AlarmManagerService extends SystemService {
                throw new SecurityException("Uid " + callingUid
                        + " cannot query hasScheduleExactAlarm for uid " + uid);
            }
            if (!isExactAlarmChangeEnabled(packageName, userId)) {
                return true;
            }
            return (uid > 0) ? hasScheduleExactAlarmInternal(packageName, uid) : false;
        }

+3 −1
Original line number Diff line number Diff line
@@ -482,8 +482,10 @@ public class OneHandedController implements RemoteCallable<OneHandedController>

    @VisibleForTesting
    void notifyExpandNotification() {
        if (mEventCallback != null) {
            mMainExecutor.execute(() -> mEventCallback.notifyExpandNotification());
        }
    }

    @VisibleForTesting
    void notifyUserConfigChanged(boolean success) {
+13 −0
Original line number Diff line number Diff line
@@ -435,4 +435,17 @@ public class OneHandedControllerTest extends OneHandedTestCase {

        verify(mSpiedOneHandedController).notifyShortcutState(anyInt());
    }

    @Test
    public void testNotifyExpandNotification_withNullCheckProtection() {
        when(mSpiedOneHandedController.isOneHandedEnabled()).thenReturn(false);
        when(mSpiedTransitionState.getState()).thenReturn(STATE_NONE);
        when(mSpiedTransitionState.isTransitioning()).thenReturn(false);
        when(mSpiedOneHandedController.isSwipeToNotificationEnabled()).thenReturn(true);
        mSpiedOneHandedController.setOneHandedEnabled(true);
        mSpiedOneHandedController.notifyExpandNotification();

        // Verify no NPE crash and mMockShellMainExecutor never be execute.
        verify(mMockShellMainExecutor, never()).execute(any());
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -1914,11 +1914,11 @@ public class AlarmManagerServiceTest {
    public void hasScheduleExactAlarmBinderCallChangeDisabled() throws RemoteException {
        mockChangeEnabled(AlarmManager.REQUIRE_EXACT_ALARM_PERMISSION, false);

        mockExactAlarmPermissionGrant(true, false, MODE_DEFAULT);
        assertFalse(mBinder.hasScheduleExactAlarm(TEST_CALLING_PACKAGE, TEST_CALLING_USER));
        mockExactAlarmPermissionGrant(false, true, MODE_DEFAULT);
        assertTrue(mBinder.hasScheduleExactAlarm(TEST_CALLING_PACKAGE, TEST_CALLING_USER));

        mockExactAlarmPermissionGrant(true, true, MODE_ALLOWED);
        assertFalse(mBinder.hasScheduleExactAlarm(TEST_CALLING_PACKAGE, TEST_CALLING_USER));
        mockExactAlarmPermissionGrant(true, false, MODE_ERRORED);
        assertTrue(mBinder.hasScheduleExactAlarm(TEST_CALLING_PACKAGE, TEST_CALLING_USER));
    }

    private void mockChangeEnabled(long changeId, boolean enabled) {