Supports VirtualDisplay for the input window mappings.
- Uses the regular expression to match the display unique id. - Changes the config separator from comma to slash, since comma is used in virtual display unique id. - Adds the example config for ActivityView. Bug: 136039906 Test: manually with the example configs. Change-Id: I51917d39c5cb11666dcb4fea69545f3075a024a7
This commit is contained in:
@@ -21,15 +21,21 @@
|
||||
<!--
|
||||
The MultiClientInputMethod will use the same display for the IME window by default.
|
||||
But, if you want to use the separate display for the IME window, consider to define item of
|
||||
'config_inputDisplayToImeDisplay'. The each item is a comma-separated pair of the uniqueId of
|
||||
the displays. The first is the uniqueId of the display where the input happens and the second
|
||||
'config_inputDisplayToImeDisplay'. The each item is a slash-separated (/) pair of the display
|
||||
the uniqueIds. The first is the uniqueId of the display where the input happens and the second
|
||||
is the unqiueId of the display where the IME window will be shown.
|
||||
FYI, you can find the uniqueId of displays in "dumpsys display".
|
||||
|
||||
E.g. If you have two displays 19261083906282752, local:19260422155234049 and you want to use
|
||||
local:19260422155234049 as the IME window for the input at the display local:19261083906282752,
|
||||
then the config item will be:
|
||||
<item>local:19261083906282752,local:19260422155234049</item>
|
||||
<item>local:19261083906282752/local:19260422155234049</item>
|
||||
|
||||
E.g. The display of ActivityView has the unique id of the form of
|
||||
'virtual:' + package_name + ',' + ownerUid + ',' + 'ActivityViewVirtualDisplay@'
|
||||
+ hashCode + ',' + displayIndex.
|
||||
We can use the following regular expression to match it:
|
||||
<item>virtual:com.android.car.carlauncher,\\d+,ActivityViewVirtualDisplay@\\d+,\\d+/local:19260422155234049</item>
|
||||
-->
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -90,6 +90,7 @@ public final class MultiClientInputMethod extends Service implements DisplayList
|
||||
|
||||
@Override
|
||||
public void onDisplayAdded(int displayId) {
|
||||
mInputDisplayToImeDisplay = buildInputDisplayToImeDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,7 +133,6 @@ public final class MultiClientInputMethod extends Service implements DisplayList
|
||||
|
||||
@NonNull
|
||||
private SparseIntArray buildInputDisplayToImeDisplay() {
|
||||
// TODO: Support the virtual display after b/137375833 is fixed.
|
||||
Context context = getApplicationContext();
|
||||
String config[] = context.getResources().getStringArray(
|
||||
R.array.config_inputDisplayToImeDisplay);
|
||||
@@ -140,7 +140,7 @@ public final class MultiClientInputMethod extends Service implements DisplayList
|
||||
SparseIntArray inputDisplayToImeDisplay = new SparseIntArray();
|
||||
Display[] displays = context.getSystemService(DisplayManager.class).getDisplays();
|
||||
for (String item: config) {
|
||||
String[] pair = item.split(",");
|
||||
String[] pair = item.split("/");
|
||||
if (pair.length != 2) {
|
||||
Log.w(TAG, "Skip illegal config: " + item);
|
||||
continue;
|
||||
@@ -154,13 +154,17 @@ public final class MultiClientInputMethod extends Service implements DisplayList
|
||||
return inputDisplayToImeDisplay;
|
||||
}
|
||||
|
||||
private static int findDisplayId(Display displays[], String uniqueId) {
|
||||
private static int findDisplayId(Display displays[], String regexp) {
|
||||
for (Display display: displays) {
|
||||
if (uniqueId.equals(display.getUniqueId())) {
|
||||
return display.getDisplayId();
|
||||
if (display.getUniqueId().matches(regexp)) {
|
||||
int displayId = display.getDisplayId();
|
||||
if (DEBUG) {
|
||||
Log.v(TAG, regexp + " matches displayId=" + displayId);
|
||||
}
|
||||
return displayId;
|
||||
}
|
||||
}
|
||||
Log.w(TAG, "Can't find the display of " + uniqueId);
|
||||
Log.w(TAG, "Can't find the display of " + regexp);
|
||||
return Display.INVALID_DISPLAY;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user