Merge "Add InputMethodSettings#setAdditionalInputMethodSubtypes()"
This commit is contained in:
committed by
Android (Google) Code Review
commit
fc04107d9b
@@ -178,7 +178,6 @@ import com.android.internal.inputmethod.UnbindReason;
|
||||
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
|
||||
import com.android.internal.notification.SystemNotificationChannels;
|
||||
import com.android.internal.os.TransferPipe;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.util.ConcurrentUtils;
|
||||
import com.android.internal.util.DumpUtils;
|
||||
import com.android.internal.view.IInputMethodManager;
|
||||
@@ -4182,27 +4181,11 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub
|
||||
if (!mSystemReady) {
|
||||
return;
|
||||
}
|
||||
final InputMethodInfo imi = mMethodMap.get(imiId);
|
||||
if (imi == null) return;
|
||||
final String[] packageInfos;
|
||||
try {
|
||||
packageInfos = mIPackageManager.getPackagesForUid(Binder.getCallingUid());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Failed to get package infos");
|
||||
return;
|
||||
}
|
||||
if (ArrayUtils.find(packageInfos,
|
||||
packageInfo -> TextUtils.equals(packageInfo, imi.getPackageName())) == null) {
|
||||
if (!mSettings.setAdditionalInputMethodSubtypes(imiId, toBeAdded,
|
||||
mAdditionalSubtypeMap, mIPackageManager)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (toBeAdded.isEmpty()) {
|
||||
mAdditionalSubtypeMap.remove(imi.getId());
|
||||
} else {
|
||||
mAdditionalSubtypeMap.put(imi.getId(), toBeAdded);
|
||||
}
|
||||
AdditionalSubtypeUtils.save(mAdditionalSubtypeMap, mMethodMap,
|
||||
mSettings.getCurrentUserId());
|
||||
final long ident = Binder.clearCallingIdentity();
|
||||
try {
|
||||
buildInputMethodListLocked(false /* resetDefaultEnabledIme */);
|
||||
|
||||
@@ -24,9 +24,12 @@ import android.app.AppOpsManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
@@ -40,6 +43,7 @@ import android.view.inputmethod.InputMethodSubtype;
|
||||
import android.view.textservice.SpellCheckerInfo;
|
||||
|
||||
import com.android.internal.inputmethod.StartInputFlags;
|
||||
import com.android.internal.util.ArrayUtils;
|
||||
import com.android.server.LocalServices;
|
||||
import com.android.server.pm.UserManagerInternal;
|
||||
import com.android.server.textservices.TextServicesManagerInternal;
|
||||
@@ -868,6 +872,35 @@ final class InputMethodUtils {
|
||||
explicitlyOrImplicitlyEnabledSubtypes, null, null, true);
|
||||
}
|
||||
|
||||
boolean setAdditionalInputMethodSubtypes(@NonNull String imeId,
|
||||
@NonNull ArrayList<InputMethodSubtype> subtypes,
|
||||
@NonNull ArrayMap<String, List<InputMethodSubtype>> additionalSubtypeMap,
|
||||
@NonNull IPackageManager packageManager) {
|
||||
final InputMethodInfo imi = mMethodMap.get(imeId);
|
||||
if (imi == null) {
|
||||
return false;
|
||||
}
|
||||
final String[] packageInfos;
|
||||
try {
|
||||
packageInfos = packageManager.getPackagesForUid(Binder.getCallingUid());
|
||||
} catch (RemoteException e) {
|
||||
Slog.e(TAG, "Failed to get package infos");
|
||||
return false;
|
||||
}
|
||||
if (ArrayUtils.find(packageInfos,
|
||||
packageInfo -> TextUtils.equals(packageInfo, imi.getPackageName())) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (subtypes.isEmpty()) {
|
||||
additionalSubtypeMap.remove(imi.getId());
|
||||
} else {
|
||||
additionalSubtypeMap.put(imi.getId(), subtypes);
|
||||
}
|
||||
AdditionalSubtypeUtils.save(additionalSubtypeMap, mMethodMap, getCurrentUserId());
|
||||
return true;
|
||||
}
|
||||
|
||||
public void dumpLocked(final Printer pw, final String prefix) {
|
||||
pw.println(prefix + "mCurrentUserId=" + mCurrentUserId);
|
||||
pw.println(prefix + "mCurrentProfileIds=" + Arrays.toString(mCurrentProfileIds));
|
||||
|
||||
Reference in New Issue
Block a user