Methods Summary |
---|
public boolean | addKeyboardLayout(java.lang.String inputDeviceDescriptor, java.lang.String keyboardLayoutDescriptor)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, true);
if (state.addKeyboardLayout(keyboardLayoutDescriptor)) {
setDirty();
return true;
}
return false;
|
private void | clearState()
mInputDevices.clear();
|
public java.lang.String | getCurrentKeyboardLayout(java.lang.String inputDeviceDescriptor)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, false);
return state != null ? state.getCurrentKeyboardLayout() : null;
|
private com.android.server.input.PersistentDataStore$InputDeviceState | getInputDeviceState(java.lang.String inputDeviceDescriptor, boolean createIfAbsent)
loadIfNeeded();
InputDeviceState state = mInputDevices.get(inputDeviceDescriptor);
if (state == null && createIfAbsent) {
state = new InputDeviceState();
mInputDevices.put(inputDeviceDescriptor, state);
setDirty();
}
return state;
|
public java.lang.String[] | getKeyboardLayouts(java.lang.String inputDeviceDescriptor)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, false);
if (state == null) {
return (String[])ArrayUtils.emptyArray(String.class);
}
return state.getKeyboardLayouts();
|
public android.hardware.input.TouchCalibration | getTouchCalibration(java.lang.String inputDeviceDescriptor, int surfaceRotation)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, false);
if (state == null) {
return TouchCalibration.IDENTITY;
}
TouchCalibration cal = state.getTouchCalibration(surfaceRotation);
if (cal == null) {
return TouchCalibration.IDENTITY;
}
return cal;
|
private void | load()
clearState();
final InputStream is;
try {
is = mAtomicFile.openRead();
} catch (FileNotFoundException ex) {
return;
}
XmlPullParser parser;
try {
parser = Xml.newPullParser();
parser.setInput(new BufferedInputStream(is), null);
loadFromXml(parser);
} catch (IOException ex) {
Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex);
clearState();
} catch (XmlPullParserException ex) {
Slog.w(InputManagerService.TAG, "Failed to load input manager persistent store data.", ex);
clearState();
} finally {
IoUtils.closeQuietly(is);
}
|
private void | loadFromXml(org.xmlpull.v1.XmlPullParser parser)
XmlUtils.beginDocument(parser, "input-manager-state");
final int outerDepth = parser.getDepth();
while (XmlUtils.nextElementWithin(parser, outerDepth)) {
if (parser.getName().equals("input-devices")) {
loadInputDevicesFromXml(parser);
}
}
|
private void | loadIfNeeded()
if (!mLoaded) {
load();
mLoaded = true;
}
|
private void | loadInputDevicesFromXml(org.xmlpull.v1.XmlPullParser parser)
final int outerDepth = parser.getDepth();
while (XmlUtils.nextElementWithin(parser, outerDepth)) {
if (parser.getName().equals("input-device")) {
String descriptor = parser.getAttributeValue(null, "descriptor");
if (descriptor == null) {
throw new XmlPullParserException(
"Missing descriptor attribute on input-device.");
}
if (mInputDevices.containsKey(descriptor)) {
throw new XmlPullParserException("Found duplicate input device.");
}
InputDeviceState state = new InputDeviceState();
state.loadFromXml(parser);
mInputDevices.put(descriptor, state);
}
}
|
public boolean | removeKeyboardLayout(java.lang.String inputDeviceDescriptor, java.lang.String keyboardLayoutDescriptor)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, true);
if (state.removeKeyboardLayout(keyboardLayoutDescriptor)) {
setDirty();
return true;
}
return false;
|
public boolean | removeUninstalledKeyboardLayouts(java.util.Set availableKeyboardLayouts)
boolean changed = false;
for (InputDeviceState state : mInputDevices.values()) {
if (state.removeUninstalledKeyboardLayouts(availableKeyboardLayouts)) {
changed = true;
}
}
if (changed) {
setDirty();
return true;
}
return false;
|
private void | save()
final FileOutputStream os;
try {
os = mAtomicFile.startWrite();
boolean success = false;
try {
XmlSerializer serializer = new FastXmlSerializer();
serializer.setOutput(new BufferedOutputStream(os), "utf-8");
saveToXml(serializer);
serializer.flush();
success = true;
} finally {
if (success) {
mAtomicFile.finishWrite(os);
} else {
mAtomicFile.failWrite(os);
}
}
} catch (IOException ex) {
Slog.w(InputManagerService.TAG, "Failed to save input manager persistent store data.", ex);
}
|
public void | saveIfNeeded()
if (mDirty) {
save();
mDirty = false;
}
|
private void | saveToXml(org.xmlpull.v1.XmlSerializer serializer)
serializer.startDocument(null, true);
serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
serializer.startTag(null, "input-manager-state");
serializer.startTag(null, "input-devices");
for (Map.Entry<String, InputDeviceState> entry : mInputDevices.entrySet()) {
final String descriptor = entry.getKey();
final InputDeviceState state = entry.getValue();
serializer.startTag(null, "input-device");
serializer.attribute(null, "descriptor", descriptor);
state.saveToXml(serializer);
serializer.endTag(null, "input-device");
}
serializer.endTag(null, "input-devices");
serializer.endTag(null, "input-manager-state");
serializer.endDocument();
|
public boolean | setCurrentKeyboardLayout(java.lang.String inputDeviceDescriptor, java.lang.String keyboardLayoutDescriptor)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, true);
if (state.setCurrentKeyboardLayout(keyboardLayoutDescriptor)) {
setDirty();
return true;
}
return false;
|
private void | setDirty()
mDirty = true;
|
public boolean | setTouchCalibration(java.lang.String inputDeviceDescriptor, int surfaceRotation, android.hardware.input.TouchCalibration calibration)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, true);
if (state.setTouchCalibration(surfaceRotation, calibration)) {
setDirty();
return true;
}
return false;
|
public boolean | switchKeyboardLayout(java.lang.String inputDeviceDescriptor, int direction)
InputDeviceState state = getInputDeviceState(inputDeviceDescriptor, false);
if (state != null && state.switchKeyboardLayout(direction)) {
setDirty();
return true;
}
return false;
|