use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class ContentViewCore method onSelectionBoundsChanged.
@SuppressWarnings("unused")
@CalledByNative
private void onSelectionBoundsChanged(Rect anchorRectDip, int anchorDir, Rect focusRectDip, int focusDir, boolean isAnchorFirst) {
// All coordinates are in DIP.
int x1 = anchorRectDip.left;
int y1 = anchorRectDip.bottom;
int x2 = focusRectDip.left;
int y2 = focusRectDip.bottom;
if (x1 != x2 || y1 != y2 || (mSelectionHandleController != null && mSelectionHandleController.isDragging())) {
if (mInsertionHandleController != null) {
mInsertionHandleController.hide();
}
if (isAnchorFirst) {
mStartHandlePoint.setLocalDip(x1, y1);
mEndHandlePoint.setLocalDip(x2, y2);
} else {
mStartHandlePoint.setLocalDip(x2, y2);
mEndHandlePoint.setLocalDip(x1, y1);
}
getSelectionHandleController().onSelectionChanged(anchorDir, focusDir);
updateHandleScreenPositions();
mHasSelection = true;
} else {
mUnselectAllOnActionModeDismiss = false;
hideSelectActionBar();
if (x1 != 0 && y1 != 0 && mSelectionEditable) {
// Selection is a caret, and a text field is focused.
if (mSelectionHandleController != null) {
mSelectionHandleController.hide();
}
mInsertionHandlePoint.setLocalDip(x1, y1);
getInsertionHandleController().onCursorPositionChanged();
updateHandleScreenPositions();
InputMethodManager manager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (manager.isWatchingCursor(mContainerView)) {
final int xPix = (int) mInsertionHandlePoint.getXPix();
final int yPix = (int) mInsertionHandlePoint.getYPix();
manager.updateCursor(mContainerView, xPix, yPix, xPix, yPix);
}
} else {
// Deselection
if (mSelectionHandleController != null) {
mSelectionHandleController.hideAndDisallowAutomaticShowing();
}
if (mInsertionHandleController != null) {
mInsertionHandleController.hideAndDisallowAutomaticShowing();
}
}
mHasSelection = false;
}
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class BuildInfo method getPackageVersionCode.
@CalledByNative
public static String getPackageVersionCode(Context context) {
String msg = "versionCode not available.";
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
msg = "" + pi.versionCode;
} catch (NameNotFoundException e) {
Log.d(TAG, msg);
}
return msg;
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class BuildInfo method getPackageVersionName.
@CalledByNative
public static String getPackageVersionName(Context context) {
String msg = "versionName not available";
try {
PackageManager pm = context.getPackageManager();
PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
msg = pi.versionName;
} catch (NameNotFoundException e) {
Log.d(TAG, msg);
}
return msg;
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class AudioManagerAndroid method registerHeadsetReceiver.
@CalledByNative
public void registerHeadsetReceiver() {
if (mReceiver != null) {
return;
}
mOriginalSpeakerStatus = mAudioManager.isSpeakerphoneOn();
IntentFilter filter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_HEADSET_PLUG.equals(intent.getAction())) {
try {
mAudioManager.setSpeakerphoneOn(intent.getIntExtra("state", 0) == 0);
} catch (SecurityException e) {
Log.e(TAG, "setMode exception: " + e.getMessage());
logDeviceInfo();
}
}
}
};
mContext.registerReceiver(mReceiver, filter);
}
use of org.chromium.base.CalledByNative in project chromeview by pwnall.
the class AndroidKeyStore method getOpenSSLHandleForPrivateKey.
/**
* Return the system EVP_PKEY handle corresponding to a given PrivateKey
* object, obtained through reflection.
*
* This shall only be used when the "NONEwithRSA" signature is not
* available, as described in rawSignDigestWithPrivateKey(). I.e.
* never use this on Android 4.2 or higher.
*
* This can only work in Android 4.0.4 and higher, for older versions
* of the platform (e.g. 4.0.3), there is no system OpenSSL EVP_PKEY,
* but the private key contents can be retrieved directly with
* the getEncoded() method.
*
* This assumes that the target device uses a vanilla AOSP
* implementation of its java.security classes, which is also
* based on OpenSSL (fortunately, no OEM has apperently changed to
* a different implementation, according to the Android team).
*
* Note that the object returned was created with the platform version
* of OpenSSL, and _not_ the one that comes with Chromium. Whether the
* object can be used safely with the Chromium OpenSSL library depends
* on differences between their actual ABI / implementation details.
*
* To better understand what's going on below, please refer to the
* following source files in the Android 4.0.4 and 4.1 source trees:
* libcore/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLRSAPrivateKey.java
* libcore/luni/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp
*
* @param privateKey The PrivateKey handle.
* @return The EVP_PKEY handle, as a 32-bit integer (0 if not available)
*/
@CalledByNative
public static int getOpenSSLHandleForPrivateKey(PrivateKey privateKey) {
// Sanity checks
if (privateKey == null) {
Log.e(TAG, "privateKey == null");
return 0;
}
if (!(privateKey instanceof RSAPrivateKey)) {
Log.e(TAG, "does not implement RSAPrivateKey");
return 0;
}
// First, check that this is a proper instance of OpenSSLRSAPrivateKey
// or one of its sub-classes.
Class<?> superClass;
try {
superClass = Class.forName("org.apache.harmony.xnet.provider.jsse.OpenSSLRSAPrivateKey");
} catch (Exception e) {
// This may happen if the target device has a completely different
// implementation of the java.security APIs, compared to vanilla
// Android. Highly unlikely, but still possible.
Log.e(TAG, "Cannot find system OpenSSLRSAPrivateKey class: " + e);
return 0;
}
if (!superClass.isInstance(privateKey)) {
// This may happen if the PrivateKey was not created by the "AndroidOpenSSL"
// provider, which should be the default. That could happen if an OEM decided
// to implement a different default provider. Also highly unlikely.
Log.e(TAG, "Private key is not an OpenSSLRSAPrivateKey instance, its class name is:" + privateKey.getClass().getCanonicalName());
return 0;
}
try {
// Use reflection to invoke the 'getOpenSSLKey()' method on
// the private key. This returns another Java object that wraps
// a native EVP_PKEY. Note that the method is final, so calling
// the superclass implementation is ok.
Method getKey = superClass.getDeclaredMethod("getOpenSSLKey");
getKey.setAccessible(true);
Object opensslKey = null;
try {
opensslKey = getKey.invoke(privateKey);
} finally {
getKey.setAccessible(false);
}
if (opensslKey == null) {
// Bail when detecting OEM "enhancement".
Log.e(TAG, "getOpenSSLKey() returned null");
return 0;
}
// Use reflection to invoke the 'getPkeyContext' method on the
// result of the getOpenSSLKey(). This is an 32-bit integer
// which is the address of an EVP_PKEY object.
Method getPkeyContext;
try {
getPkeyContext = opensslKey.getClass().getDeclaredMethod("getPkeyContext");
} catch (Exception e) {
// Bail here too, something really not working as expected.
Log.e(TAG, "No getPkeyContext() method on OpenSSLKey member:" + e);
return 0;
}
getPkeyContext.setAccessible(true);
int evp_pkey = 0;
try {
evp_pkey = (Integer) getPkeyContext.invoke(opensslKey);
} finally {
getPkeyContext.setAccessible(false);
}
if (evp_pkey == 0) {
// The PrivateKey is probably rotten for some reason.
Log.e(TAG, "getPkeyContext() returned null");
}
return evp_pkey;
} catch (Exception e) {
Log.e(TAG, "Exception while trying to retrieve system EVP_PKEY handle: " + e);
return 0;
}
}
Aggregations