3737import android .content .pm .PackageManager ;
3838import android .content .pm .ResolveInfo ;
3939import android .content .pm .PackageManager .NameNotFoundException ;
40- import android .content .res .Configuration ;
4140import android .content .res .Resources ;
4241import android .content .res .Resources .NotFoundException ;
4342import android .content .res .TypedArray ;
@@ -597,8 +596,8 @@ public KeyboardLayout[] getKeyboardLayouts() {
597596 visitAllKeyboardLayouts (new KeyboardLayoutVisitor () {
598597 @ Override
599598 public void visitKeyboardLayout (Resources resources ,
600- String descriptor , String label , int keyboardLayoutResId ) {
601- list .add (new KeyboardLayout (descriptor , label ));
599+ String descriptor , String label , String collection , int keyboardLayoutResId ) {
600+ list .add (new KeyboardLayout (descriptor , label , collection ));
602601 }
603602 });
604603 return list .toArray (new KeyboardLayout [list .size ()]);
@@ -614,8 +613,8 @@ public KeyboardLayout getKeyboardLayout(String keyboardLayoutDescriptor) {
614613 visitKeyboardLayout (keyboardLayoutDescriptor , new KeyboardLayoutVisitor () {
615614 @ Override
616615 public void visitKeyboardLayout (Resources resources ,
617- String descriptor , String label , int keyboardLayoutResId ) {
618- result [0 ] = new KeyboardLayout (descriptor , label );
616+ String descriptor , String label , String collection , int keyboardLayoutResId ) {
617+ result [0 ] = new KeyboardLayout (descriptor , label , collection );
619618 }
620619 });
621620 if (result [0 ] == null ) {
@@ -663,6 +662,9 @@ private void visitKeyboardLayoutsInPackage(PackageManager pm, ActivityInfo recei
663662 return ;
664663 }
665664
665+ CharSequence receiverLabel = receiver .loadLabel (pm );
666+ String collection = receiverLabel != null ? receiverLabel .toString () : "" ;
667+
666668 try {
667669 Resources resources = pm .getResourcesForApplication (receiver .applicationInfo );
668670 XmlResourceParser parser = resources .getXml (configResId );
@@ -696,7 +698,7 @@ private void visitKeyboardLayoutsInPackage(PackageManager pm, ActivityInfo recei
696698 receiver .packageName , receiver .name , name );
697699 if (keyboardName == null || name .equals (keyboardName )) {
698700 visitor .visitKeyboardLayout (resources , descriptor ,
699- label , keyboardLayoutResId );
701+ label , collection , keyboardLayoutResId );
700702 }
701703 }
702704 } finally {
@@ -1139,7 +1141,7 @@ private String[] getKeyboardLayoutOverlay(String inputDeviceDescriptor) {
11391141 visitKeyboardLayout (keyboardLayoutDescriptor , new KeyboardLayoutVisitor () {
11401142 @ Override
11411143 public void visitKeyboardLayout (Resources resources ,
1142- String descriptor , String label , int keyboardLayoutResId ) {
1144+ String descriptor , String label , String collection , int keyboardLayoutResId ) {
11431145 try {
11441146 result [0 ] = descriptor ;
11451147 result [1 ] = Streams .readFully (new InputStreamReader (
@@ -1262,7 +1264,7 @@ public static KeyboardLayoutDescriptor parse(String descriptor) {
12621264
12631265 private interface KeyboardLayoutVisitor {
12641266 void visitKeyboardLayout (Resources resources ,
1265- String descriptor , String label , int keyboardLayoutResId );
1267+ String descriptor , String label , String collection , int keyboardLayoutResId );
12661268 }
12671269
12681270 private final class InputDevicesChangedListenerRecord implements DeathRecipient {
0 commit comments