Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Android 5.0

I/chromium( 6890): [INFO:CONSOLE(37)] "AddJavascriptInterface: top[Android]: com.WebAppInterface@3847a08c - 
error: Access to java.lang.Object.getClass is blocked", source: http://[REDACTED].com/ (37)

For applications targeting Android >= 5.0, you can enumerate the methods available from inside javascript. "Enumeration of methods will be enabled for applications targeting API levels newer than KitKat (to preserve compatibility with older apps)."

Our Java bridge object:

    @JavascriptInterface
    public void showToast(String toast) {
        Toast.makeText(mContext, toast, Toast.LENGTH_LONG).show();
    }

    @JavascriptInterface
    public void exposedFunction(){
    }

    public void nonExposedFunction(){}

Our javascript:

try {
  var x  =  Object.keys(Android).toString();
  log(x);
} catch(e){
  log(e.message);
}

Now we can see the enumeration of the annotated objects being logged:

I/chromium( 9833): [INFO:CONSOLE(37)] 
"AddJavascriptInterface: exposedFunction,showToast", source: http://[REDACTED].com/ (37)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.