Bug 1512274 - [geckoview] Don't change value of method arguments. r=geckoview-reviewers,snorp

Differential Revision: https://phabricator.services.mozilla.com/D23682

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Agi Sferro 2019-03-15 21:20:20 +00:00
Родитель c92d430c9e
Коммит 789b04a378
19 изменённых файлов: 134 добавлений и 111 удалений

Просмотреть файл

@ -56,11 +56,11 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
* @param exc An exception * @param exc An exception
* @return The root exception * @return The root exception
*/ */
public static Throwable getRootException(Throwable exc) { public static Throwable getRootException(final Throwable exc) {
for (Throwable cause = exc; cause != null; cause = cause.getCause()) { Throwable cause;
exc = cause; for (cause = exc; cause != null; cause = cause.getCause()) {}
}
return exc; return cause;
} }
/** /**
@ -453,20 +453,22 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
return; return;
} }
if (thread == null) { Thread resolvedThread = thread;
if (resolvedThread == null) {
// Gecko may pass in null for thread to denote the current thread. // Gecko may pass in null for thread to denote the current thread.
thread = Thread.currentThread(); resolvedThread = Thread.currentThread();
} }
try { try {
Throwable rootException = exc;
if (!this.unregistered) { if (!this.unregistered) {
// Only process crash ourselves if we have not been unregistered. // Only process crash ourselves if we have not been unregistered.
this.crashing = true; this.crashing = true;
exc = getRootException(exc); rootException = getRootException(exc);
logException(thread, exc); logException(resolvedThread, rootException);
if (reportException(thread, exc)) { if (reportException(resolvedThread, rootException)) {
// Reporting succeeded; we can terminate our process now. // Reporting succeeded; we can terminate our process now.
return; return;
} }
@ -474,7 +476,7 @@ public class CrashHandler implements Thread.UncaughtExceptionHandler {
if (systemUncaughtHandler != null) { if (systemUncaughtHandler != null) {
// Follow the chain of uncaught handlers. // Follow the chain of uncaught handlers.
systemUncaughtHandler.uncaughtException(thread, exc); systemUncaughtHandler.uncaughtException(resolvedThread, rootException);
} }
} finally { } finally {
terminateProcess(); terminateProcess();

Просмотреть файл

@ -1421,24 +1421,28 @@ public class GeckoAppShell
@WrapForJNI(calledFrom = "gecko") @WrapForJNI(calledFrom = "gecko")
private static byte[] getIconForExtension(String aExt, int iconSize) { private static byte[] getIconForExtension(String aExt, int iconSize) {
try { try {
if (iconSize <= 0) int resolvedIconSize = iconSize;
iconSize = 16; if (iconSize <= 0) {
resolvedIconSize = 16;
}
if (aExt != null && aExt.length() > 1 && aExt.charAt(0) == '.') String resolvedExt = aExt;
aExt = aExt.substring(1); if (aExt != null && aExt.length() > 1 && aExt.charAt(0) == '.') {
resolvedExt = aExt.substring(1);
}
PackageManager pm = getApplicationContext().getPackageManager(); PackageManager pm = getApplicationContext().getPackageManager();
Drawable icon = getDrawableForExtension(pm, aExt); Drawable icon = getDrawableForExtension(pm, resolvedExt);
if (icon == null) { if (icon == null) {
// Use a generic icon // Use a generic icon
icon = pm.getDefaultActivityIcon(); icon = pm.getDefaultActivityIcon();
} }
Bitmap bitmap = ((BitmapDrawable)icon).getBitmap(); Bitmap bitmap = ((BitmapDrawable)icon).getBitmap();
if (bitmap.getWidth() != iconSize || bitmap.getHeight() != iconSize) if (bitmap.getWidth() != resolvedIconSize || bitmap.getHeight() != resolvedIconSize)
bitmap = Bitmap.createScaledBitmap(bitmap, iconSize, iconSize, true); bitmap = Bitmap.createScaledBitmap(bitmap, resolvedIconSize, resolvedIconSize, true);
ByteBuffer buf = ByteBuffer.allocate(iconSize * iconSize * 4); ByteBuffer buf = ByteBuffer.allocate(resolvedIconSize * resolvedIconSize * 4);
bitmap.copyPixelsToBuffer(buf); bitmap.copyPixelsToBuffer(buf);
return buf.array(); return buf.array();

Просмотреть файл

@ -218,6 +218,7 @@ public final class GeckoProfile {
// ------------------------------------------ // ------------------------------------------
// Yes | Yes | Active profile or default profile // Yes | Yes | Active profile or default profile
String resolvedProfileName = profileName;
if (TextUtils.isEmpty(profileName) && profileDir == null) { if (TextUtils.isEmpty(profileName) && profileDir == null) {
// If no profile info was passed in, look for the active profile or a default profile. // If no profile info was passed in, look for the active profile or a default profile.
final GeckoProfile profile = GeckoThread.getActiveProfile(); final GeckoProfile profile = GeckoThread.getActiveProfile();
@ -230,25 +231,25 @@ public final class GeckoProfile {
return GeckoProfile.initFromArgs(context, sIntentArgs); return GeckoProfile.initFromArgs(context, sIntentArgs);
} else if (profileName == null) { } else if (profileName == null) {
// If only profile dir was passed in, use custom (anonymous) profile. // If only profile dir was passed in, use custom (anonymous) profile.
profileName = CUSTOM_PROFILE; resolvedProfileName = CUSTOM_PROFILE;
} }
// We require the profile dir to exist if specified, so create it here if needed. // We require the profile dir to exist if specified, so create it here if needed.
final boolean init = profileDir != null && profileDir.mkdirs(); final boolean init = profileDir != null && profileDir.mkdirs();
// Actually try to look up the profile. // Actually try to look up the profile.
GeckoProfile profile = sProfileCache.get(profileName); GeckoProfile profile = sProfileCache.get(resolvedProfileName);
GeckoProfile newProfile = null; GeckoProfile newProfile = null;
if (profile == null) { if (profile == null) {
try { try {
newProfile = new GeckoProfile(context, profileName, profileDir); newProfile = new GeckoProfile(context, resolvedProfileName, profileDir);
} catch (NoMozillaDirectoryException e) { } catch (NoMozillaDirectoryException e) {
// We're unable to do anything sane here. // We're unable to do anything sane here.
throw new RuntimeException(e); throw new RuntimeException(e);
} }
profile = sProfileCache.putIfAbsent(profileName, newProfile); profile = sProfileCache.putIfAbsent(resolvedProfileName, newProfile);
} }
if (profile == null) { if (profile == null) {

Просмотреть файл

@ -164,21 +164,22 @@ public class GeckoScreenOrientation {
if (mShouldNotify) { if (mShouldNotify) {
// Gecko expects a definite screen orientation, so we default to the // Gecko expects a definite screen orientation, so we default to the
// primary orientations. // primary orientations.
ScreenOrientation primaryOrientation = aScreenOrientation;
if (aScreenOrientation == ScreenOrientation.PORTRAIT) { if (aScreenOrientation == ScreenOrientation.PORTRAIT) {
aScreenOrientation = ScreenOrientation.PORTRAIT_PRIMARY; primaryOrientation = ScreenOrientation.PORTRAIT_PRIMARY;
} else if (aScreenOrientation == ScreenOrientation.LANDSCAPE) { } else if (aScreenOrientation == ScreenOrientation.LANDSCAPE) {
aScreenOrientation = ScreenOrientation.LANDSCAPE_PRIMARY; primaryOrientation = ScreenOrientation.LANDSCAPE_PRIMARY;
} else if (aScreenOrientation == ScreenOrientation.DEFAULT) { } else if (aScreenOrientation == ScreenOrientation.DEFAULT) {
aScreenOrientation = ScreenOrientation.PORTRAIT_PRIMARY; primaryOrientation = ScreenOrientation.PORTRAIT_PRIMARY;
} else if (aScreenOrientation == ScreenOrientation.NONE) { } else if (aScreenOrientation == ScreenOrientation.NONE) {
return false; return false;
} }
if (GeckoThread.isRunning()) { if (GeckoThread.isRunning()) {
onOrientationChange(aScreenOrientation.value, getAngle()); onOrientationChange(primaryOrientation.value, getAngle());
} else { } else {
GeckoThread.queueNativeCall(GeckoScreenOrientation.class, "onOrientationChange", GeckoThread.queueNativeCall(GeckoScreenOrientation.class, "onOrientationChange",
aScreenOrientation.value, getAngle()); primaryOrientation.value, getAngle());
} }
} }
ScreenManagerHelper.refreshScreenInfo(); ScreenManagerHelper.refreshScreenInfo();

Просмотреть файл

@ -209,13 +209,18 @@ public final class PrefsHelper {
} }
@WrapForJNI(calledFrom = "gecko") @WrapForJNI(calledFrom = "gecko")
private static void callPrefHandler(final PrefHandler handler, int type, final String pref, private static void callPrefHandler(final PrefHandler handler, final int originalType,
boolean boolVal, int intVal, String strVal) { final String pref, final boolean originalBoolVal,
final int intVal, final String originalStrVal) {
// Some Gecko preferences use integers or strings to reference state instead of // Some Gecko preferences use integers or strings to reference state instead of
// directly representing the value. Since the Java UI uses the type to determine // directly representing the value. Since the Java UI uses the type to determine
// which ui elements to show and how to handle them, we need to normalize these // which ui elements to show and how to handle them, we need to normalize these
// preferences to the correct type. // preferences to the correct type.
int type = originalType;
String strVal = originalStrVal;
boolean boolVal = originalBoolVal;
if (INT_TO_STRING_PREFS.contains(pref)) { if (INT_TO_STRING_PREFS.contains(pref)) {
type = PREF_STRING; type = PREF_STRING;
strVal = String.valueOf(intVal); strVal = String.valueOf(intVal);

Просмотреть файл

@ -109,17 +109,16 @@ public final class SysInfo {
return 0; return 0;
} }
while (offset < length && buffer[offset] != '\n') { int i = offset;
if (buffer[offset] >= '0' && buffer[offset] <= '9') { while (i < length && buffer[i] != '\n') {
int start = offset++; if (buffer[i] >= '0' && buffer[i] <= '9') {
while (offset < length && int start = i++;
buffer[offset] >= '0' && while (i < length && buffer[i] >= '0' && buffer[i] <= '9') {
buffer[offset] <= '9') { ++i;
++offset;
} }
return Integer.parseInt(new String(buffer, start, offset - start), 10); return Integer.parseInt(new String(buffer, start, i - start), 10);
} }
++offset; ++i;
} }
return 0; return 0;
} }

Просмотреть файл

@ -261,24 +261,25 @@ import org.mozilla.gecko.mozglue.JNIObject;
return null; return null;
} }
if (handle == 0) { int resolvedHandle = handle;
if (resolvedHandle == 0) {
// Generate new handle value when none specified. // Generate new handle value when none specified.
handle = sNextHandle++; resolvedHandle = sNextHandle++;
} }
final GeckoSurfaceTexture gst; final GeckoSurfaceTexture gst;
if (isSingleBufferSupported()) { if (isSingleBufferSupported()) {
gst = new GeckoSurfaceTexture(handle, singleBufferMode); gst = new GeckoSurfaceTexture(resolvedHandle, singleBufferMode);
} else { } else {
gst = new GeckoSurfaceTexture(handle); gst = new GeckoSurfaceTexture(resolvedHandle);
} }
if (sSurfaceTextures.containsKey(handle)) { if (sSurfaceTextures.containsKey(resolvedHandle)) {
gst.release(); gst.release();
throw new IllegalArgumentException("Already have a GeckoSurfaceTexture with that handle"); throw new IllegalArgumentException("Already have a GeckoSurfaceTexture with that handle");
} }
sSurfaceTextures.put(handle, gst); sSurfaceTextures.put(resolvedHandle, gst);
return gst; return gst;
} }
} }

Просмотреть файл

@ -124,17 +124,17 @@ import org.mozilla.gecko.annotation.WrapForJNI;
mScrollerX.setFinalPosition(x); mScrollerX.setFinalPosition(x);
} }
private static float viscousFluid(float x) { private static float viscousFluid(final float x) {
x *= sViscousFluidScale; float y = x * sViscousFluidScale;
if (x < 1.0f) { if (y < 1.0f) {
x -= (1.0f - (float) Math.exp(-x)); y -= (1.0f - (float) Math.exp(-y));
} else { } else {
float start = 0.36787944117f; // 1/e == exp(-1) float start = 0.36787944117f; // 1/e == exp(-1)
x = 1.0f - (float) Math.exp(1.0f - x); y = 1.0f - (float) Math.exp(1.0f - y);
x = start + x * (1.0f - start); y = start + y * (1.0f - start);
} }
x *= sViscousFluidNormalize; y *= sViscousFluidNormalize;
return x; return y;
} }
/** /**
@ -255,27 +255,31 @@ import org.mozilla.gecko.annotation.WrapForJNI;
* @param overY Overfling range. If > 0, vertical overfling in either * @param overY Overfling range. If > 0, vertical overfling in either
* direction will be possible. * direction will be possible.
*/ */
public void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, public void fling(final int startX, final int startY, final int velocityX, final int velocityY,
int minY, int maxY, int overX, int overY, long time) { final int minX, final int maxX, final int minY, final int maxY,
final int overX, final int overY, final long time) {
int newVelocityX = velocityX;
int newVelocityY = velocityY;
// Continue a scroll or fling in progress // Continue a scroll or fling in progress
if (mFlywheel && !isFinished()) { if (mFlywheel && !isFinished()) {
float oldVelocityX = mScrollerX.mCurrVelocity; float oldVelocityX = mScrollerX.mCurrVelocity;
float oldVelocityY = mScrollerY.mCurrVelocity; float oldVelocityY = mScrollerY.mCurrVelocity;
boolean sameXDirection = (velocityX == 0) || (oldVelocityX == 0) || boolean sameXDirection = (newVelocityX == 0) || (oldVelocityX == 0) ||
((velocityX < 0) == (oldVelocityX < 0)); ((newVelocityX < 0) == (oldVelocityX < 0));
boolean sameYDirection = (velocityY == 0) || (oldVelocityY == 0) || boolean sameYDirection = (newVelocityY == 0) || (oldVelocityY == 0) ||
((velocityY < 0) == (oldVelocityY < 0)); ((newVelocityY < 0) == (oldVelocityY < 0));
if (sameXDirection) { if (sameXDirection) {
velocityX += oldVelocityX; newVelocityX += + oldVelocityX;
} }
if (sameYDirection) { if (sameYDirection) {
velocityY += oldVelocityY; newVelocityY += oldVelocityY;
} }
} }
mMode = FLING_MODE; mMode = FLING_MODE;
mScrollerX.fling(startX, velocityX, minX, maxX, overX, time); mScrollerX.fling(startX, newVelocityX, minX, maxX, overX, time);
mScrollerY.fling(startY, velocityY, minY, maxY, overY, time); mScrollerY.fling(startY, newVelocityY, minY, maxY, overY, time);
} }
/** /**

Просмотреть файл

@ -45,8 +45,8 @@ class ByteBufferInputStream extends InputStream {
return -1; return -1;
} }
length = Math.min(length, mBuf.remaining()); int remainingLength = Math.min(length, mBuf.remaining());
mBuf.get(buffer, offset, length); mBuf.get(buffer, offset, remainingLength);
return length; return length;
} }
@ -56,9 +56,9 @@ class ByteBufferInputStream extends InputStream {
return 0; return 0;
} }
byteCount = Math.min(byteCount, mBuf.remaining()); long remainingByteCount = Math.min(byteCount, mBuf.remaining());
mBuf.position(mBuf.position() + (int)byteCount); mBuf.position(mBuf.position() + (int) remainingByteCount);
return byteCount; return remainingByteCount;
} }
} }

Просмотреть файл

@ -60,11 +60,12 @@ public class MatrixBlobCursor extends AbstractCursor {
this.columnNames = columnNames; this.columnNames = columnNames;
this.columnCount = columnNames.length; this.columnCount = columnNames.length;
if (initialCapacity < 1) { int capacity = initialCapacity;
initialCapacity = 1; if (capacity < 1) {
capacity = 1;
} }
this.data = new Object[columnCount * initialCapacity]; this.data = new Object[columnCount * capacity];
this.allocationStack = new Throwable("allocationStack"); this.allocationStack = new Throwable("allocationStack");
} }

Просмотреть файл

@ -73,7 +73,6 @@ public class ActivityUtils {
if (context instanceof Activity) { if (context instanceof Activity) {
return (Activity) context; return (Activity) context;
} }
context = ((ContextWrapper) context).getBaseContext();
} }
return null; return null;
} }

Просмотреть файл

@ -286,14 +286,15 @@ public class FileUtils {
if (prefix.length() < 3) { if (prefix.length() < 3) {
throw new IllegalArgumentException("prefix must be at least 3 characters"); throw new IllegalArgumentException("prefix must be at least 3 characters");
} }
if (directory == null) { File tempDirectory = directory;
if (tempDirectory == null) {
String tmpDir = System.getProperty("java.io.tmpdir", "."); String tmpDir = System.getProperty("java.io.tmpdir", ".");
directory = new File(tmpDir); tempDirectory = new File(tmpDir);
} }
File result; File result;
Random random = new Random(); Random random = new Random();
do { do {
result = new File(directory, prefix + random.nextInt()); result = new File(tempDirectory, prefix + random.nextInt());
} while (!result.mkdirs()); } while (!result.mkdirs());
return result; return result;
} }

Просмотреть файл

@ -88,22 +88,25 @@ public final class GamepadUtils {
// determine if they are swapped so the proper key codes can be mapped to the keys // determine if they are swapped so the proper key codes can be mapped to the keys
boolean areKeysSwapped = areSonyXperiaGamepadKeysSwapped(); boolean areKeysSwapped = areSonyXperiaGamepadKeysSwapped();
int translatedKeyCode = keyCode;
// If a Sony Xperia, remap the cross and circle buttons to buttons // If a Sony Xperia, remap the cross and circle buttons to buttons
// A and B for the gamepad API // A and B for the gamepad API
switch (keyCode) { switch (keyCode) {
case KeyEvent.KEYCODE_BACK: case KeyEvent.KEYCODE_BACK:
keyCode = (areKeysSwapped ? KeyEvent.KEYCODE_BUTTON_A : KeyEvent.KEYCODE_BUTTON_B); translatedKeyCode = (areKeysSwapped ? KeyEvent.KEYCODE_BUTTON_A
: KeyEvent.KEYCODE_BUTTON_B);
break; break;
case KeyEvent.KEYCODE_DPAD_CENTER: case KeyEvent.KEYCODE_DPAD_CENTER:
keyCode = (areKeysSwapped ? KeyEvent.KEYCODE_BUTTON_B : KeyEvent.KEYCODE_BUTTON_A); translatedKeyCode = (areKeysSwapped ? KeyEvent.KEYCODE_BUTTON_B
: KeyEvent.KEYCODE_BUTTON_A);
break; break;
default: default:
return event; return event;
} }
return new KeyEvent(event.getAction(), keyCode); return new KeyEvent(event.getAction(), translatedKeyCode);
} }
public static boolean isSonyXperiaGamepadKeyEvent(KeyEvent event) { public static boolean isSonyXperiaGamepadKeyEvent(KeyEvent event) {

Просмотреть файл

@ -187,6 +187,7 @@ public final class GeckoJarReader {
private static InputStream getStream(NativeZip zip, Stack<String> jarUrls, String origUrl) { private static InputStream getStream(NativeZip zip, Stack<String> jarUrls, String origUrl) {
InputStream inputStream = null; InputStream inputStream = null;
NativeZip currentZip = zip;
// loop through children jar files until we reach the innermost one // loop through children jar files until we reach the innermost one
while (!jarUrls.empty()) { while (!jarUrls.empty()) {
String fileName = jarUrls.pop(); String fileName = jarUrls.pop();
@ -194,7 +195,7 @@ public final class GeckoJarReader {
if (inputStream != null) { if (inputStream != null) {
// intermediate NativeZips and InputStreams will be garbage collected. // intermediate NativeZips and InputStreams will be garbage collected.
try { try {
zip = new NativeZip(inputStream); currentZip = new NativeZip(inputStream);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
String description = "!!! BUG 849589 !!! origUrl=" + origUrl; String description = "!!! BUG 849589 !!! origUrl=" + origUrl;
Log.e(LOGTAG, description, e); Log.e(LOGTAG, description, e);
@ -202,7 +203,7 @@ public final class GeckoJarReader {
} }
} }
inputStream = zip.getInputStream(fileName); inputStream = currentZip.getInputStream(fileName);
if (inputStream == null) { if (inputStream == null) {
Log.d(LOGTAG, "No Entry for " + fileName); Log.d(LOGTAG, "No Entry for " + fileName);
return null; return null;
@ -221,15 +222,11 @@ public final class GeckoJarReader {
* omni.ja * omni.ja
* chrome/chrome/content/branding/favicon32.png * chrome/chrome/content/branding/favicon32.png
*/ */
private static Stack<String> parseUrl(String url) { private static Stack<String> parseUrl(final String url) {
return parseUrl(url, null); return parseUrl(url, new Stack<>());
}
private static Stack<String> parseUrl(String url, Stack<String> results) {
if (results == null) {
results = new Stack<String>();
} }
private static Stack<String> parseUrl(final String url, final Stack<String> results) {
if (url.startsWith("jar:")) { if (url.startsWith("jar:")) {
int jarEnd = url.lastIndexOf("!"); int jarEnd = url.lastIndexOf("!");
String subStr = url.substring(4, jarEnd); String subStr = url.substring(4, jarEnd);

Просмотреть файл

@ -77,8 +77,8 @@ public class IOUtils {
// If buffer has overflowed, double its size and carry on. // If buffer has overflowed, double its size and carry on.
if (bPointer == buffer.length) { if (bPointer == buffer.length) {
bufferSize *= 2; int newBufferSize = bufferSize * 2;
byte[] newBuffer = new byte[bufferSize]; byte[] newBuffer = new byte[newBufferSize];
// Copy the contents of the old buffer into the new buffer. // Copy the contents of the old buffer into the new buffer.
System.arraycopy(buffer, 0, newBuffer, 0, buffer.length); System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);

Просмотреть файл

@ -50,13 +50,13 @@ public class StringUtils {
*/ */
public static boolean isSearchQuery(String text, boolean wasSearchQuery) { public static boolean isSearchQuery(String text, boolean wasSearchQuery) {
// We remove leading and trailing white spaces when decoding URLs // We remove leading and trailing white spaces when decoding URLs
text = text.trim(); String trimmedText = text.trim();
if (text.length() == 0) { if (trimmedText.length() == 0) {
return wasSearchQuery; return wasSearchQuery;
} }
int colon = text.indexOf(':'); int colon = trimmedText.indexOf(':');
int dot = text.indexOf('.'); int dot = trimmedText.indexOf('.');
int space = text.indexOf(' '); int space = trimmedText.indexOf(' ');
// If a space is found in a trimmed string, we assume this is a search query(Bug 1278245) // If a space is found in a trimmed string, we assume this is a search query(Bug 1278245)
if (space > -1) { if (space > -1) {

Просмотреть файл

@ -897,26 +897,26 @@ import android.view.inputmethod.EditorInfo;
public void sendKeyEvent(final @Nullable View view, final int action, @NonNull KeyEvent event) { public void sendKeyEvent(final @Nullable View view, final int action, @NonNull KeyEvent event) {
final Editable editable = mProxy; final Editable editable = mProxy;
final KeyListener keyListener = TextKeyListener.getInstance(); final KeyListener keyListener = TextKeyListener.getInstance();
event = translateKey(event.getKeyCode(), event); KeyEvent translatedEvent = translateKey(event.getKeyCode(), event);
// We only let TextKeyListener do UI things on the UI thread. // We only let TextKeyListener do UI things on the UI thread.
final View v = ThreadUtils.isOnUiThread() ? view : null; final View v = ThreadUtils.isOnUiThread() ? view : null;
final int keyCode = event.getKeyCode(); final int keyCode = translatedEvent.getKeyCode();
final boolean handled; final boolean handled;
if (shouldSkipKeyListener(keyCode, event)) { if (shouldSkipKeyListener(keyCode, translatedEvent)) {
handled = false; handled = false;
} else if (action == KeyEvent.ACTION_DOWN) { } else if (action == KeyEvent.ACTION_DOWN) {
setSuppressKeyUp(true); setSuppressKeyUp(true);
handled = keyListener.onKeyDown(v, editable, keyCode, event); handled = keyListener.onKeyDown(v, editable, keyCode, translatedEvent);
} else if (action == KeyEvent.ACTION_UP) { } else if (action == KeyEvent.ACTION_UP) {
handled = keyListener.onKeyUp(v, editable, keyCode, event); handled = keyListener.onKeyUp(v, editable, keyCode, translatedEvent);
} else { } else {
handled = keyListener.onKeyOther(v, editable, event); handled = keyListener.onKeyOther(v, editable, translatedEvent);
} }
if (!handled) { if (!handled) {
sendKeyEvent(event, action, TextKeyListener.getMetaState(editable)); sendKeyEvent(translatedEvent, action, TextKeyListener.getMetaState(editable));
} }
if (action == KeyEvent.ACTION_DOWN) { if (action == KeyEvent.ACTION_DOWN) {
@ -1384,7 +1384,7 @@ import android.view.inputmethod.EditorInfo;
}); });
} }
/* package */ void icNotifyIMEContext(int state, final String typeHint, /* package */ void icNotifyIMEContext(final int originalState, final String typeHint,
final String modeHint, final String actionHint, final String modeHint, final String actionHint,
final int flags) { final int flags) {
if (DEBUG) { if (DEBUG) {
@ -1394,12 +1394,15 @@ import android.view.inputmethod.EditorInfo;
// For some input type we will use a widget to display the ui, for those we must not // For some input type we will use a widget to display the ui, for those we must not
// display the ime. We can display a widget for date and time types and, if the sdk version // display the ime. We can display a widget for date and time types and, if the sdk version
// is 11 or greater, for datetime/month/week as well. // is 11 or greater, for datetime/month/week as well.
int state;
if (typeHint != null && (typeHint.equalsIgnoreCase("date") || if (typeHint != null && (typeHint.equalsIgnoreCase("date") ||
typeHint.equalsIgnoreCase("time") || typeHint.equalsIgnoreCase("time") ||
typeHint.equalsIgnoreCase("month") || typeHint.equalsIgnoreCase("month") ||
typeHint.equalsIgnoreCase("week") || typeHint.equalsIgnoreCase("week") ||
typeHint.equalsIgnoreCase("datetime-local"))) { typeHint.equalsIgnoreCase("datetime-local"))) {
state = SessionTextInput.EditableListener.IME_STATE_DISABLED; state = SessionTextInput.EditableListener.IME_STATE_DISABLED;
} else {
state = originalState;
} }
final int oldState = mIMEState; final int oldState = mIMEState;
@ -2090,12 +2093,13 @@ import android.view.inputmethod.EditorInfo;
return true; return true;
} }
while ((repeatCount--) > 0) { for (int i = 0; i < repeatCount; i++) {
if (!processKey(view, KeyEvent.ACTION_DOWN, keyCode, event) || if (!processKey(view, KeyEvent.ACTION_DOWN, keyCode, event) ||
!processKey(view, KeyEvent.ACTION_UP, keyCode, event)) { !processKey(view, KeyEvent.ACTION_UP, keyCode, event)) {
return false; return false;
} }
} }
return true; return true;
} }

Просмотреть файл

@ -591,9 +591,9 @@ import java.lang.reflect.Proxy;
} }
@Override @Override
public boolean sendKeyEvent(@NonNull KeyEvent event) { public boolean sendKeyEvent(final @NonNull KeyEvent event) {
event = translateKey(event.getKeyCode(), event); KeyEvent translatedEvent = translateKey(event.getKeyCode(), event);
mEditableClient.sendKeyEvent(getView(), event.getAction(), event); mEditableClient.sendKeyEvent(getView(), event.getAction(), translatedEvent);
return false; // seems to always return false return false; // seems to always return false
} }

Просмотреть файл

@ -428,10 +428,10 @@ public class PanZoomController extends JNIObject {
} }
} }
private void synthesizeNativePointer(int source, int pointerId, int eventType, private void synthesizeNativePointer(final int source, final int pointerId,
int clientX, int clientY, double pressure, final int originalEventType,
int orientation) final int clientX, final int clientY,
{ final double pressure, final int orientation) {
if (mPointerState == null) { if (mPointerState == null) {
mPointerState = new SynthesizedEventState(); mPointerState = new SynthesizedEventState();
} }
@ -440,7 +440,8 @@ public class PanZoomController extends JNIObject {
int pointerIndex = mPointerState.getPointerIndex(pointerId); int pointerIndex = mPointerState.getPointerIndex(pointerId);
// Event-specific handling // Event-specific handling
switch (eventType) { int eventType = originalEventType;
switch (originalEventType) {
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
if (pointerIndex < 0) { if (pointerIndex < 0) {
Log.w(LOGTAG, "Pointer-up for invalid pointer"); Log.w(LOGTAG, "Pointer-up for invalid pointer");