How to set default IME in the code

2,700 views
Skip to first unread message

Morris

unread,
Dec 31, 2009, 5:53:39 AM12/31/09
to android-platform
Hi All:

Now, there are three IMEs in my system and the default IME is not
android keyboard. I would like to set default IME for android soft
keyboard. Please tell me where I could modify it in the code. I try to
find it, but I still don't know the right place.

Thanks a lot.

Sincerely yours,
Morris

nagamatu

unread,
Dec 31, 2009, 7:32:47 AM12/31/09
to android-platform
The default IME setting is stored at the secure system settings. If
you want
to change this settings, you need to have WRITE_SECURE_SETTINGS
permission.

<!-- Allows an application to read or write the secure system
settings. -->
<permission
android:name="android.permission.WRITE_SECURE_SETTINGS"
android:protectionLevel="signatureOrSystem"
android:label="@string/permlab_writeSecureSettings"
android:description="@string/permdesc_writeSecureSettings" />

But this permission's protection level is signatureOrSystem. No 3rd
party
application can not modify it.

BTW, If you are writing your own input method, it is able to use
setInputMethod.

http://developer.android.com/reference/android/view/inputmethod/InputMethodManager.html#setInputMethod(android.os.IBinder,%20java.lang.String)

--
nagamatu

Morris

unread,
Jan 1, 2010, 3:41:46 AM1/1/10
to android-platform
Hi nagamatu:

Thanks for your information.

I have another quesiton and I would like to consult you.

I want to set default IME_A if I have three IMEs, such as IME_A, IME_B
and IME_C.
Originally the default IME is IME_B in the frist system up, but now I
want to set default IME to be IME_A in the first system start.
Would you please tell me where I can set the related code to change
the default IME in the first system start.

Thanks a lot.

Sincerely yours,
Morris

On 2009年12月31日, 下午8時32分, nagamatu <nagam...@gmail.com> wrote:
> The default IME setting is stored at the secure system settings. If
> you want
> to change this settings, you need to have WRITE_SECURE_SETTINGS
> permission.
>
>     <!-- Allows an application to read or write the secure system
> settings. -->
>     <permission
> android:name="android.permission.WRITE_SECURE_SETTINGS"
>         android:protectionLevel="signatureOrSystem"
>         android:label="@string/permlab_writeSecureSettings"
>         android:description="@string/permdesc_writeSecureSettings" />
>
> But this permission's protection level is signatureOrSystem. No 3rd
> party
> application can not modify it.
>
> BTW, If you are writing your own input method, it is able to use
> setInputMethod.
>

> http://developer.android.com/reference/android/view/inputmethod/Input...)


>
> --
> nagamatu
>
> On 12月31日, 午後7:53, Morris <morrischen.c...@gmail.com> wrote:
>
>
>
> > Hi All:
>
> > Now, there are three IMEs in my system and the default IME is not
> > android keyboard. I would like to set default IME for android soft
> > keyboard. Please tell me where I could modify it in the code. I try to
> > find it, but I still don't know the right place.
>
> > Thanks a lot.
>
> > Sincerely yours,

> > Morris- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

Dianne Hackborn

unread,
Jan 1, 2010, 7:42:04 PM1/1/10
to android-...@googlegroups.com
This list is for contributions to the platform; could you move this to android-porting?  Thanks.

2010/1/1 Morris <morrisc...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "android-platform" group.
To post to this group, send email to android-...@googlegroups.com.
To unsubscribe from this group, send email to android-platfo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-platform?hl=en.





--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Hideki Hiura

unread,
Jan 13, 2010, 7:08:34 PM1/13/10
to android-...@googlegroups.com
Although Diane suggested to move to android-porting, there are a couple
of aspects Morris's question led to the issues appropriate for android-platform
list.

1. It is not an odd requirement for applications to switch Input Method, which
can be implemented as switching IMEs.
2. Also, it can be implemented as a single IME container to include multiple
IMEs inside and provide switching mechanism within.
3. What it appears to be sufficient for WRITE_SECURE_SETTINGS permission
is IMF level switching.
4. Present design of only letting IME to switch to another IME appears not to be
optimal idea, as one IME developed by FOO may not know another IME
developed by BAR, and of course, App C who wants to switch IMEs back
and forth depending on the each input fields.

I understand the security concerns as it is really important, but we need to
design something more flexible to meet the IM requirements, as the people
whom need IM to input a character, IM can be one of the mostly used
component/app so its usability drives the impression of android.

--
Hideki Hiura
hiura@{OpenI18N,linuxfoundation,unicode}.org
http://www.openi18n.org, http://linuxfoundaton.org, http://unicode.org

Dianne Hackborn

unread,
Jan 13, 2010, 7:37:17 PM1/13/10
to android-...@googlegroups.com
Applications can not, and will not, be able to directly change the IME.  Sorry.  This would be a huge security hole.

Hideki Hiura

unread,
Jan 13, 2010, 7:51:33 PM1/13/10
to android-...@googlegroups.com
On Thu, Jan 14, 2010 at 9:37 AM, Dianne Hackborn <hac...@android.com> wrote:
> Applications can not, and will not, be able to directly change the IME.
>  Sorry.  This would be a huge security hole.

Not necessarily, as it it proven on so many other platforms like UNIX,
Linux, etc.

We should sort out several different levels of IM stack.
App - IMM - IMF - IME - (sub IMEs or mode)
before killing the discussion by saying " can not, and will not".

How it can always be such a huge security hole in your scenario?

What's the significant difference between
1. application selecting optimal IMEs(mode) which are already installed.
vs
2. installing a dummy IME for just switching among IMEs which are
already installed.

in current design?

Hideki Hiura

unread,
Jan 14, 2010, 2:00:30 AM1/14/10
to android-...@googlegroups.com
To understand the issue here, let's sort out the Android IM design and other IM
designs to get the true issues straight.

a) An application has to access IM via IM API without requiring root privilege.
b) An IM Engine provides IM service via IM SPI without requiring root
privilege.
c) An IMM(IM manager) provides an abstraction to represent and select
an IMF among
IMFs, often implemented as an API/SPI for IMF developers to provide a module
for service consumer side of interface that can be changed on the fly without
requiring root privilege.
d) IM Switcher apps can be a user interface agent to switch IMFs
without requiring
root privilege.
e) Each IMFs can provide IMEs which can be switchied on the fly,
interactively or
programaticlly in applications depending on the IMF architectures without
requiring root privilege.
f) Any applications can request or demant specific IME mode or IME
itself, depending
one the IMF design or IMM design that optimal for apps without
requiring root
privilege.
g) The root privilege is required to install IME, sub IME modules,
dictionaries ,
IMF, IMM, or whatever whichever, whenever, and any kind of installation is
required.

To avoid further unproductive frames, I reluctantly express my opinion
that I really
don't think current IM and IM related security design, description, document and
implementation is optimal from IM experts' point of view.

--
Hideki Hiura
hiura@{OpenI18N,linuxfoundation,unicode}.org
http://www.openi18n.org, http://linuxfoundaton.org, http://unicode.org

Hideki Hiura

unread,
Jan 14, 2010, 2:33:08 AM1/14/10
to android-...@googlegroups.com
it is NOT the only IMM/IMF design in terms of security, but one of the
reasonable
options.

1. By the definition of greater IM, it can take over all input,
output, UI, and further
actions.
2. Therefore, the interface/API/SPI should be controlled/restricted by
the user-visible
explicit privilege control such as RBAC.
3. simplictic model in Android to bind simply UID to Apps and simple
root/other UID
model is NOT optimal, especially, in terms of IM and we should think about
roll based security model instead of over-optimistic UNI UID based
simplistic
security model.
4. Secure APIs are missing for users, Apps, And IMs, to controll IM related
controlls.

--
Hideki Hiura
hiura@{OpenI18N,linuxfoundation,unicode}.org
http://www.openi18n.org, http://linuxfoundaton.org, http://unicode.org

Morris

unread,
Jan 14, 2010, 5:11:53 AM1/14/10
to android-platform
Hi All:

Thanks a lot for your discussion and informaiton.
Now, I have known how to set default IME to show in the first-time
system starting.
You need to modify inputmethodservice.java where it is,
Please see the below.
services/java/com/android/server/InputMethodManagerService.java =>
public InputMethodManagerService(Context context, StatusBarService
statusBar)

Sincerely yours,
Morris

Dianne Hackborn

unread,
Jan 14, 2010, 1:16:12 PM1/14/10
to android-...@googlegroups.com
On Wed, Jan 13, 2010 at 11:33 PM, Hideki Hiura <hi...@openi18n.org> wrote:
it is NOT the only IMM/IMF design in terms of security, but one of the
1. By the definition of greater IM, it can take over all input,
output, UI, and further
   actions.

Yep, it is uber-dangerous.
 
2. Therefore, the interface/API/SPI should be controlled/restricted by
the user-visible
   explicit privilege control such as RBAC.
3. simplictic model in Android to bind simply UID to Apps and simple
root/other UID
   model is NOT optimal, especially, in terms of IM and we should think about
   roll based security model instead of over-optimistic UNI UID based
simplistic
   security model.

I have no idea what you are talking about.  The security model is based on the user explicitly granting a particular component the role of serving as the IME.  That is why an application can't force another IME to be used, because the user needs to approve this due to the danger of what it can do.  (For example, we don't want an app while it is running to silently switch to an IME that is designed to look like the built-in IME, so when the user leaves the app and enters a password in another application that the first application's IME can capture the password.)
 
4. Secure APIs are missing for users, Apps, And IMs, to controll IM related
   controlls.

Besides your demand for an application to directly change the IME (which again, is not going to happen), what are these?

Fwiw, if an application wants its own custom input facility, it can just do this in its own UI.  It is running the UI, there is no need for it to rely on the standard IME if it really needs something specialized to itself.

Reply all
Reply to author
Forward
0 new messages