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

Commit 14709af4 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30868961',...

Merge cherrypicks of ['googleplex-android-review.googlesource.com/30868961', 'googleplex-android-review.googlesource.com/30940086'] into 25Q1-release.

Change-Id: I9e230e48dd67f63f135867882e51fe1cfcc4f349
parents e60c8267 8d5d9742
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -2717,17 +2717,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
            return false;
        }

        final InputMethodSettings settings = InputMethodSettingsRepository.get(userId);
        if (Flags.imeSwitcherRevamp()) {
            // The IME switcher button should be shown when the current IME specified a
            // language settings activity.
            final var curImi = settings.getMethodMap().get(settings.getSelectedInputMethod());
            if (curImi != null && curImi.createImeLanguageSettingsActivityIntent() != null) {
                return true;
            }
        }

        return hasMultipleSubtypesForSwitcher(false /* nonAuxOnly */, settings);
        return hasMultipleSubtypesForSwitcher(false /* nonAuxOnly */, userId);
    }

    /**
@@ -2735,10 +2725,11 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
     * across all enabled IMEs for the given user.
     *
     * @param nonAuxOnly whether to check only for non auxiliary subtypes.
     * @param settings   the input method settings under the given user ID.
     * @param userId     the id of the user for which to check the number of subtypes.
     */
    private static boolean hasMultipleSubtypesForSwitcher(boolean nonAuxOnly,
            @NonNull InputMethodSettings settings) {
            @UserIdInt int userId) {
        final var settings = InputMethodSettingsRepository.get(userId);
        List<InputMethodInfo> imes = settings.getEnabledInputMethodListWithFilter(
                InputMethodInfo::shouldShowInInputMethodPicker);
        final int numImes = imes.size();
@@ -4124,8 +4115,7 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
    @GuardedBy("ImfLock.class")
    private void onImeSwitchButtonClickLocked(int displayId, @NonNull UserData userData) {
        final int userId = userData.mUserId;
        final var settings = InputMethodSettingsRepository.get(userId);
        if (hasMultipleSubtypesForSwitcher(true /* nonAuxOnly */, settings)) {
        if (hasMultipleSubtypesForSwitcher(true /* nonAuxOnly */, userId)) {
            switchToNextInputMethodLocked(false /* onlyCurrentIme */, userData);
        } else {
            showInputMethodPickerFromSystem(
+4 −4
Original line number Diff line number Diff line
@@ -559,7 +559,7 @@ public class PreferencesHelper implements RankingConfig {

            if (r.uid == UNKNOWN_UID) {
                if (Flags.persistIncompleteRestoreData()) {
                    r.userId = userId;
                    r.userIdWhenUidUnknown = userId;
                }
                mRestoredWithoutUids.put(unrestoredPackageKey(pkg, userId), r);
            } else {
@@ -756,7 +756,7 @@ public class PreferencesHelper implements RankingConfig {

        if (Flags.persistIncompleteRestoreData() && r.uid == UNKNOWN_UID) {
            out.attributeLong(null, ATT_CREATION_TIME, r.creationTime);
            out.attributeInt(null, ATT_USERID, r.userId);
            out.attributeInt(null, ATT_USERID, r.userIdWhenUidUnknown);
        }

        if (!forBackup) {
@@ -1959,7 +1959,7 @@ public class PreferencesHelper implements RankingConfig {
        ArrayList<ZenBypassingApp> bypassing = new ArrayList<>();
        synchronized (mLock) {
            for (PackagePreferences p : mPackagePreferences.values()) {
                if (p.userId != userId) {
                if (UserHandle.getUserId(p.uid) != userId) {
                    continue;
                }
                int totalChannelCount = p.channels.size();
@@ -3189,7 +3189,7 @@ public class PreferencesHelper implements RankingConfig {
        // Until we enable the UI, we should return false.
        boolean canHavePromotedNotifs = android.app.Flags.uiRichOngoing();

        @UserIdInt int userId;
        @UserIdInt int userIdWhenUidUnknown;

        Delegate delegate = null;
        ArrayMap<String, NotificationChannel> channels = new ArrayMap<>();
+32 −5
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import static com.android.internal.config.sysui.SystemUiSystemPropertiesFlags.No
import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__DENIED;
import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__GRANTED;
import static com.android.internal.util.FrameworkStatsLog.PACKAGE_NOTIFICATION_PREFERENCES__FSI_STATE__NOT_REQUESTED;
import static com.android.server.notification.Flags.FLAG_ALL_NOTIFS_NEED_TTL;
import static com.android.server.notification.Flags.FLAG_NOTIFICATION_VERIFY_CHANNEL_SOUND_URI;
import static com.android.server.notification.Flags.FLAG_PERSIST_INCOMPLETE_RESTORE_DATA;
import static com.android.server.notification.NotificationChannelLogger.NotificationChannelEvent.NOTIFICATION_CHANNEL_UPDATED_BY_USER;
@@ -155,7 +154,6 @@ import android.util.proto.ProtoOutputStream;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.internal.config.sysui.SystemUiSystemPropertiesFlags;
import com.android.internal.config.sysui.TestableFlagResolver;
@@ -167,9 +165,6 @@ import com.android.os.AtomsProto.PackageNotificationPreferences;
import com.android.server.UiServiceTestCase;
import com.android.server.notification.PermissionHelper.PackagePermission;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.protobuf.InvalidProtocolBufferException;
@@ -204,6 +199,9 @@ import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ThreadLocalRandom;

import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
import platform.test.runner.parameterized.Parameters;

@SmallTest
@RunWith(ParameterizedAndroidJunit4.class)
@EnableFlags(FLAG_PERSIST_INCOMPLETE_RESTORE_DATA)
@@ -2639,6 +2637,35 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        assertThat(mHelper.getPackagesBypassingDnd(UserHandle.getUserId(UID_N_MR1))).isEmpty();
    }

    @Test
    public void getPackagesBypassingDnd_multipleUsers() {
        int uidUser1 = UserHandle.getUid(1, UID_P);
        NotificationChannel channelUser1Bypass = new NotificationChannel("id11", "name1",
                NotificationManager.IMPORTANCE_MAX);
        channelUser1Bypass.setBypassDnd(true);
        NotificationChannel channelUser1NoBypass = new NotificationChannel("id12", "name2",
                NotificationManager.IMPORTANCE_MAX);
        channelUser1NoBypass.setBypassDnd(false);

        int uidUser2 = UserHandle.getUid(2, UID_P);
        NotificationChannel channelUser2Bypass = new NotificationChannel("id21", "name1",
                NotificationManager.IMPORTANCE_MAX);
        channelUser2Bypass.setBypassDnd(true);

        mHelper.createNotificationChannel(PKG_P, uidUser1, channelUser1Bypass, true,
                /* hasDndAccess= */ true, uidUser1, false);
        mHelper.createNotificationChannel(PKG_P, uidUser1, channelUser1NoBypass, true,
                /* hasDndAccess= */ true, uidUser1, false);
        mHelper.createNotificationChannel(PKG_P, uidUser2, channelUser2Bypass, true,
                /* hasDndAccess= */ true, uidUser2, false);

        assertThat(mHelper.getPackagesBypassingDnd(0)).isEmpty();
        assertThat(mHelper.getPackagesBypassingDnd(1))
                .containsExactly(new ZenBypassingApp(PKG_P, false));
        assertThat(mHelper.getPackagesBypassingDnd(2))
                .containsExactly(new ZenBypassingApp(PKG_P, true));
    }

    @Test
    public void getPackagesBypassingDnd_oneChannelBypassing_groupBlocked() {
        int uid = UID_N_MR1;