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

Commit ff0d2890 authored by Tarandeep Singh's avatar Tarandeep Singh Committed by Android (Google) Code Review
Browse files

Merge "Remove PER_PROFILE_IME_ENABLED property"

parents d1ce8ebd cf5ff82f
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ import android.util.ArraySet;
import android.util.Log;
import android.util.MemoryIntArray;
import android.view.Display;
import android.view.inputmethod.InputMethodSystemProperty;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.widget.ILockSettings;
@@ -9298,13 +9297,6 @@ public final class Settings {
            CLONE_TO_MANAGED_PROFILE.add(LOCATION_MODE);
            CLONE_TO_MANAGED_PROFILE.add(LOCATION_PROVIDERS_ALLOWED);
            CLONE_TO_MANAGED_PROFILE.add(SHOW_IME_WITH_HARD_KEYBOARD);
            if (!InputMethodSystemProperty.PER_PROFILE_IME_ENABLED) {
                CLONE_TO_MANAGED_PROFILE.add(DEFAULT_INPUT_METHOD);
                CLONE_TO_MANAGED_PROFILE.add(ENABLED_INPUT_METHODS);
                CLONE_TO_MANAGED_PROFILE.add(SELECTED_INPUT_METHOD_SUBTYPE);
                CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER);
                CLONE_TO_MANAGED_PROFILE.add(SELECTED_SPELL_CHECKER_SUBTYPE);
            }
        }
        /** @hide */
+0 −26
Original line number Diff line number Diff line
@@ -43,17 +43,6 @@ public class InputMethodSystemProperty {
     */
    private static final String PROP_DEBUG_MULTI_CLIENT_IME = "persist.debug.multi_client_ime";

    /**
     * System property key for debugging purpose. The value must be empty, "1", or "0".
     *
     * <p>Values 'y', 'yes', '1', 'true' or 'on' are considered true.</p>
     *
     * <p>To set, run "adb root && adb shell setprop persist.debug.per_profile_ime 1".</p>
     *
     * <p>This value will be ignored when {@link Build#IS_DEBUGGABLE} returns {@code false}.</p>
     */
    private static final String PROP_DEBUG_PER_PROFILE_IME = "persist.debug.per_profile_ime";

    @Nullable
    private static ComponentName getMultiClientImeComponentName() {
        if (Build.IS_DEBUGGABLE) {
@@ -91,19 +80,4 @@ public class InputMethodSystemProperty {
     */
    @TestApi
    public static final boolean MULTI_CLIENT_IME_ENABLED = (sMultiClientImeComponentName != null);

    /**
     * {@code true} when per-profile IME is enabled.
     * @hide
     */
    public static final boolean PER_PROFILE_IME_ENABLED;
    static {
        if (MULTI_CLIENT_IME_ENABLED) {
            PER_PROFILE_IME_ENABLED = true;
        } else if (Build.IS_DEBUGGABLE) {
            PER_PROFILE_IME_ENABLED = SystemProperties.getBoolean(PROP_DEBUG_PER_PROFILE_IME, true);
        } else {
            PER_PROFILE_IME_ENABLED = true;
        }
    }
}
+2 −8
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.server.inputmethod;

import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.inputmethod.InputMethodSystemProperty.PER_PROFILE_IME_ENABLED;

import static java.lang.annotation.RetentionPolicy.SOURCE;

@@ -1036,9 +1035,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                // sender userId can be a real user ID or USER_ALL.
                final int senderUserId = pendingResult.getSendingUserId();
                if (senderUserId != UserHandle.USER_ALL) {
                    final int resolvedUserId = PER_PROFILE_IME_ENABLED
                            ? senderUserId : mUserManagerInternal.getProfileParentId(senderUserId);
                    if (resolvedUserId != mSettings.getCurrentUserId()) {
                    if (senderUserId != mSettings.getCurrentUserId()) {
                        // A background user is trying to hide the dialog. Ignore.
                        return;
                    }
@@ -1662,9 +1659,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        if (userId == mSettings.getCurrentUserId()) {
            return true;
        }
        if (!PER_PROFILE_IME_ENABLED && mSettings.isCurrentProfile(userId)) {
            return true;
        }

        // Caveat: A process which has INTERACT_ACROSS_USERS_FULL gets results for the
        // foreground user, not for the user of that process. Accordingly InputMethodManagerService
@@ -3005,7 +2999,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            return InputBindResult.INVALID_USER;
        }

        if (PER_PROFILE_IME_ENABLED && userId != mSettings.getCurrentUserId()) {
        if (userId != mSettings.getCurrentUserId()) {
            switchUserLocked(userId);
        }
        // Master feature flag that overrides other conditions and forces IME preRendering.
+2 −19
Original line number Diff line number Diff line
@@ -35,13 +35,11 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.IntArray;
import android.util.Pair;
import android.util.Printer;
import android.util.Slog;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
import android.view.inputmethod.InputMethodSystemProperty;
import android.view.textservice.SpellCheckerInfo;

import com.android.internal.annotations.GuardedBy;
@@ -1303,9 +1301,6 @@ final class InputMethodUtils {
     * Converts a user ID, which can be a pseudo user ID such as {@link UserHandle#USER_ALL} to a
     * list of real user IDs.
     *
     * <p>This method also converts profile user ID to profile parent user ID unless
     * {@link InputMethodSystemProperty#PER_PROFILE_IME_ENABLED} is {@code true}.</p>
     *
     * @param userIdToBeResolved A user ID. Two pseudo user ID {@link UserHandle#USER_CURRENT} and
     *                           {@link UserHandle#USER_ALL} are also supported
     * @param currentUserId A real user ID, which will be used when {@link UserHandle#USER_CURRENT}
@@ -1320,18 +1315,8 @@ final class InputMethodUtils {
                LocalServices.getService(UserManagerInternal.class);

        if (userIdToBeResolved == UserHandle.USER_ALL) {
            if (InputMethodSystemProperty.PER_PROFILE_IME_ENABLED) {
            return userManagerInternal.getUserIds();
        }
            final IntArray result = new IntArray();
            for (int userId : userManagerInternal.getUserIds()) {
                final int parentUserId = userManagerInternal.getProfileParentId(userId);
                if (result.indexOf(parentUserId) < 0) {
                    result.add(parentUserId);
                }
            }
            return result.toArray();
        }

        final int sourceUserId;
        if (userIdToBeResolved == UserHandle.USER_CURRENT) {
@@ -1353,8 +1338,6 @@ final class InputMethodUtils {
            }
            return new int[]{};
        }
        final int resolvedUserId = InputMethodSystemProperty.PER_PROFILE_IME_ENABLED
                ? sourceUserId : userManagerInternal.getProfileParentId(sourceUserId);
        return new int[]{resolvedUserId};
        return new int[]{sourceUserId};
    }
}
+0 −64
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.textservices;

import android.annotation.NonNull;
import android.util.SparseIntArray;

import java.util.function.IntUnaryOperator;

/**
 * Simple int-to-int key-value-store that is to be lazily initialized with the given
 * {@link IntUnaryOperator}.
 */
final class LazyIntToIntMap {

    private final SparseIntArray mMap = new SparseIntArray();

    @NonNull
    private final IntUnaryOperator mMappingFunction;

    /**
     * @param mappingFunction int to int mapping rules to be (lazily) evaluated
     */
    public LazyIntToIntMap(@NonNull IntUnaryOperator mappingFunction) {
        mMappingFunction = mappingFunction;
    }

    /**
     * Deletes {@code key} and associated value.
     * @param key key to be deleted
     */
    public void delete(int key) {
        mMap.delete(key);
    }

    /**
     * @param key key associated with the value
     * @return value associated with the {@code key}. If this is the first time to access
     * {@code key}, then {@code mappingFunction} passed to the constructor will be evaluated
     */
    public int get(int key) {
        final int index = mMap.indexOfKey(key);
        if (index >= 0) {
            return mMap.valueAt(index);
        }
        final int value = mMappingFunction.applyAsInt(key);
        mMap.append(key, value);
        return value;
    }
}
Loading