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

Commit 5e8d93f3 authored by /e/ robot's avatar /e/ robot
Browse files

Merge remote-tracking branch 'origin/lineage-17.1' into v1-q

parents f00c36c5 4920fca1
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -100,6 +100,13 @@ public class CallLog {
         */
        public static final String LIMIT_PARAM_KEY = "limit";

        /**
         * Form of {@link #CONTENT_URI} which limits the query results to a single result.
         */
        private static final Uri CONTENT_URI_LIMIT_1 = CONTENT_URI.buildUpon()
                .appendQueryParameter(LIMIT_PARAM_KEY, "1")
                .build();

        /**
         * Query parameter used to specify the starting record to return.
         * <p>
@@ -931,11 +938,11 @@ public class CallLog {
            Cursor c = null;
            try {
                c = resolver.query(
                    CONTENT_URI,
                    CONTENT_URI_LIMIT_1,
                    new String[] {NUMBER},
                    TYPE + " = " + OUTGOING_TYPE,
                    null,
                    DEFAULT_SORT_ORDER + " LIMIT 1");
                    DEFAULT_SORT_ORDER);
                if (c == null || !c.moveToFirst()) {
                    return "";
                }
+1 −0
Original line number Diff line number Diff line
@@ -5951,6 +5951,7 @@ public class NotificationManagerService extends SystemService {
            final PendingIntent pi = PendingIntent.getBroadcast(getContext(),
                    REQUEST_CODE_TIMEOUT,
                    new Intent(ACTION_NOTIFICATION_TIMEOUT)
                            .setPackage(PackageManagerService.PLATFORM_PACKAGE_NAME)
                            .setData(new Uri.Builder().scheme(SCHEME_TIMEOUT)
                                    .appendPath(record.getKey()).build())
                            .addFlags(Intent.FLAG_RECEIVER_FOREGROUND)
+22 −15
Original line number Diff line number Diff line
@@ -618,7 +618,8 @@ public class PermissionManagerService {
        }

        final int callingUid = Binder.getCallingUid();
        final int userId = UserHandle.getUserId(newPackage.applicationInfo.uid);

        for (int userId: mUserManagerInt.getUserIds()) {
            int numRequestedPermissions = newPackage.requestedPermissions.size();
            for (int i = 0; i < numRequestedPermissions; i++) {
                PermissionInfo permInfo = getPermissionInfo(newPackage.requestedPermissions.get(i),
@@ -633,8 +634,14 @@ public class PermissionManagerService {
                                + downgradedSdk + " or newly requested legacy full storage "
                                + newlyRequestsLegacy);

                try {
                    revokeRuntimePermission(permInfo.name, newPackage.packageName,
                            false, userId, permissionCallback);
                } catch (IllegalStateException | SecurityException e) {
                    Log.e(TAG, "unable to revoke " + permInfo.name + " for "
                            + newPackage.packageName + " user " + userId, e);
                }
            }
        }

    }
+8 −27
Original line number Diff line number Diff line
@@ -2132,13 +2132,14 @@ class RootActivityContainer extends ConfigurationContainer
                    final List<TaskRecord> tasks = stack.getAllTasks();
                    for (int taskNdx = tasks.size() - 1; taskNdx >= 0; taskNdx--) {
                        final TaskRecord task = tasks.get(taskNdx);

                        // Check the task for a top activity belonging to userId, or returning a
                        // result to an activity belonging to userId. Example case: a document
                        // picker for personal files, opened by a work app, should still get locked.
                        if (taskTopActivityIsUser(task, userId)) {
                            mService.getTaskChangeNotificationController().notifyTaskProfileLocked(
                                    task.taskId, userId);
                        for (int activityNdx = task.mActivities.size() - 1; activityNdx >= 0;
                                activityNdx--) {
                            final ActivityRecord activity = task.mActivities.get(activityNdx);
                            if (!activity.finishing && activity.mUserId == userId) {
                                mService.getTaskChangeNotificationController()
                                        .notifyTaskProfileLocked(task.taskId, userId);
                                break;
                            }
                        }
                    }
                }
@@ -2148,26 +2149,6 @@ class RootActivityContainer extends ConfigurationContainer
        }
    }

    /**
     * Detects whether we should show a lock screen in front of this task for a locked user.
     * <p>
     * We'll do this if either of the following holds:
     * <ul>
     *   <li>The top activity explicitly belongs to {@param userId}.</li>
     *   <li>The top activity returns a result to an activity belonging to {@param userId}.</li>
     * </ul>
     *
     * @return {@code true} if the top activity looks like it belongs to {@param userId}.
     */
    private boolean taskTopActivityIsUser(TaskRecord task, @UserIdInt int userId) {
        // To handle the case that work app is in the task but just is not the top one.
        final ActivityRecord activityRecord = task.getTopActivity();
        final ActivityRecord resultTo = (activityRecord != null ? activityRecord.resultTo : null);

        return (activityRecord != null && activityRecord.mUserId == userId)
                || (resultTo != null && resultTo.mUserId == userId);
    }

    void cancelInitializingActivities() {
        for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
            final ActivityDisplay display = mActivityDisplays.get(displayNdx);
+26 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ import static org.mockito.Mockito.when;

import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.AlarmManager;
import android.app.AppOpsManager;
import android.app.AutomaticZenRule;
import android.app.IActivityManager;
@@ -147,6 +148,7 @@ import com.android.server.lights.Light;
import com.android.server.lights.LightsManager;
import com.android.server.notification.NotificationManagerService.NotificationAssistants;
import com.android.server.notification.NotificationManagerService.NotificationListeners;
import com.android.server.pm.PackageManagerService;
import com.android.server.uri.UriGrantsManagerInternal;
import com.android.server.wm.WindowManagerInternal;

@@ -243,6 +245,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
    @Mock
    UserManager mUm;

    @Mock
    AlarmManager mAlarmManager;

    // Use a Testable subclass so we can simulate calls from the system without failing.
    private static class TestableNotificationManagerService extends NotificationManagerService {
        int countSystemChecks = 0;
@@ -338,6 +343,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        LocalServices.addService(WindowManagerInternal.class, mWindowManagerInternal);
        LocalServices.removeServiceForTest(ActivityManagerInternal.class);
        LocalServices.addService(ActivityManagerInternal.class, mAmi);
        mContext.addMockSystemService(Context.ALARM_SERVICE, mAlarmManager);

        doNothing().when(mContext).sendBroadcastAsUser(any(), any(), any());

@@ -602,6 +608,26 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
        return nrSummary;
    }

    @Test
    public void testLimitTimeOutBroadcast() {
        NotificationChannel channel = new NotificationChannel("id", "name",
                NotificationManager.IMPORTANCE_HIGH);
        Notification.Builder nb = new Notification.Builder(mContext, channel.getId())
                .setContentTitle("foo")
                .setSmallIcon(android.R.drawable.sym_def_app_icon)
                .setTimeoutAfter(1);

        StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, 8, "tag", mUid, 0,
                nb.build(), UserHandle.getUserHandleForUid(mUid), null, 0);
        NotificationRecord r = new NotificationRecord(mContext, sbn, channel);

        mService.scheduleTimeoutLocked(r);
        ArgumentCaptor<PendingIntent> captor = ArgumentCaptor.forClass(PendingIntent.class);
        verify(mAlarmManager).setExactAndAllowWhileIdle(anyInt(), anyLong(), captor.capture());
        assertEquals(PackageManagerService.PLATFORM_PACKAGE_NAME,
                captor.getValue().getIntent().getPackage());
    }

    @Test
    public void testCreateNotificationChannels_SingleChannel() throws Exception {
        final NotificationChannel channel =
Loading