Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Fix potential null pointer error issue. #143

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open

Fix potential null pointer error issue. #143

wants to merge 90 commits into from

Conversation

agamemnus
Copy link

See: apache/cordova-android#126.

I am writing a Google Play APK expansion library.

All the libraries I have seen so far store version data inside the content provider's tag as meta-data, and again inside a separate .xml file. This is wrong, but they are forced to do this because it is very difficult to figure out the code to source all data from one xml file. I have done this, but it does require telling Cordova not to extract the zip file before the plugin file is ready.

To do that, I return a null value from APEZProvider (extends ContentProvider for APKs) if the APK expansion plugin class instance didn't run yet. That of course causes Cordova to crash because it doesn't have the null test I am proposing.

infil00p and others added 30 commits May 6, 2014 15:51
The plain Cordova app is able to run.

TODO:
1. Plugin
2. Unit testing
This fixes the issue that Geolocation plugin does not work.
In XWalk, the thread which ExposedJsApi.exec() runs in does not contain
a message loop. As android.location.LocationManager need a loop to
process message, we have to prepare a Looper manually.
The root cause is the File Transfer API implementation leverages the android.webkit.CookieManager.
But trying to getinstance() of CookieManager before the webview isn't instantiated would cause crash.
In the cordova with xwalk backend solution, there doesn't exist webview.

According to android official document:
http://developer.android.com/reference/android/webkit/CookieManager.html#getInstance%28%29
We need to call "CookieSyncManager.createInstance(Context)" first.

Known issue:
This only fix crash issue, the cookie support is faking.
Still need to bridge xwalk cookie manager with default android.webkit.CookieManager.

BUG=https://github.com/otcshare/cordova-xwalk-android/issues/13
It needs to hook activity life-cycle events (resume, pause, destory and
on activityresult) to XWalkView handlers. Otherwise, it causes black screen
when pause-resume cycles for apps.

BUG=https://github.com/otcshare/cordova-xwalk-android/issues/55
Enable them since XWalkView has the APIs.
Changes in this patch:
 1. Implement XWalkRuntimeViewProvider interface for CordovaWebView.
 2. Add a public class CordovaXWalkCoreExtensionBridge to provide the
    functionalities of friendly class XWalkCoreExtensionBridge.
Otherwise, buildbot will not pack it into tarball.
Otherwise, build is blocked for abstract function not implemented.
It is introduced in XWalkRuntimeViewProvider to destroy the native
resources occupied by extension.
This is a refactor to remove unnecessary interfaces exposed by
XWalkRuntimeViewProvider. Reusing XWalkExtensionManager is enough to
integrate the extension system into cordova container.
XWalk adds the onGeolocationPermissionsShowPrompt support. Change the
CordovaWebView's implemenation to that.
XWalk adds the copyBackForwardList/saveState/restoreState API support,
and also adds WebBackForwardList and WebHistoryItem class.
Change the CordovaWebView's implemenation to that.
It includes:
1. update the project wiki URL.
2. add the python 2.6 into the requires.
Now the "create" script will not compile a cordova.jar,
insteadly, it will setup dependency for newly created
project.

Currently, the script will assume xwalk_core_library is
placed aside of cordova-xwalk-android.

TODO:
1. if core library not found, the "create" script should
download it.
2. Enable create.bat script on Windows.

Usage:
Assumpt the working folder is at /home/me/cordova
1. mkdir /home/me/cordova
2. cd /home/me/cordova
3. git clone ssh://[email protected]/otcshare/cordova-xwalk-android.git
4. download xwalk_core_library.tar.gz from xwalk release and extract it at
   /home/me/cordova/xwalk_core_library.
   (If the build you pick doesn't include
    crosswalk-project/crosswalk#847, you need to
    manually update the build.xml in xwalk_core_library to work)
5. cd cordova-xwalk-android
6. ./bin/create ../hello your.package.name YourAppName
7. cd ../hello
8. ant release/debug
   (you probably need to create you keystore first for release)

BUG=https://github.com/otcshare/cordova-xwalk-android/issues/19
Android library project doesn't handle assets according to
http://developer.android.com/tools/projects/index.html.

BUG=Input tag crashes cordova app
It aims to optimize the CLI workflow. It requires the buildbot copies the
xwalk_core_library into framework when producing cordova.tar.gz.

With these changes, CLI users will not download xwalk_core_library separately.
Shiliu Wang and others added 23 commits July 7, 2014 15:12
XWalkSettings is not a public class in XWalk Embedding API.
Use XWalkPreferences instead.
Remove crosswalk internal dependency after Crosswalk Embedding API v2
Ignore eclipse files and remove them from repo.
TODO: Recover these tests once the missed functions were implemented.

BUG=https://crosswalk-project.org/jira/browse/XWALK-1688
Add override prop to allow changes to framework/assets/www/cordova.js
can override to test/assets/www/cordova.js
XWalk already convert the error code from
chromium's error code to android ones.
No need to convert again in cordova.

BUG=https://crosswalk-project.org/jira/browse/XWALK-2139
Do not convert xwalk's error code again
After Kikkat, the immersive fullscreen mode is supported, we need support it.

BUG=XWALK-2142
As Crosswalk enable multiple windows to implement opening url with system
default browser, the navigation by clicking <a target="_blank"> in Cordova
was blocked, so disable multiple windows with XWalkPreferences.

To open urls in system default browser, the InAppBrowser plugin should be
used.

BUG=https://crosswalk-project.org/jira/browse/XWALK-2157
Disable multiple windows to align navigation behavior with upstream.
Add immersive fullscreen mode support
Fix crash for instrumentation test
onShow() and onHide() will be called by XWalkView internally, depends on activity lifecycle change.
Avoid calling these two methods directly, otherwise there will be a white screen displayed.

BUG=XWALK-1956
The tag is <input type="file" accept="image/*;capture=camera">.
Chromium has already implemented a better file chooser for android,
so bypass that implemented by Cordova.

BUG=https://crosswalk-project.org/jira/browse/XWALK-2148
Fix issue of failing to launch camera when tapping input tag.
In the activity onResume() method, the view enters fullscreen mode
without checking the Fullscreen property. An if condition was added
to fix the issue.

BUG=https://crosswalk-project.org/jira/browse/XWALK-2187
Fix the layout issue happens when app was switched back from background.
Fix white screen issue when application paused
Beacuse the JavaScripte timer was paused, the pause event can't send by
setTimeOut function.
Apply a patch from https://github.com/clelland/cordova-crosswalk-engine/
commit/e25e506cf815845480ae6e7a42be6cd0cd94f6bb

BUG=XWALK-2417
Don't pause timers when app is backgrounded
Adjust the onDestory() invoking in CordovaActivity.java to avoid
the null object reference.

BUG=https://crosswalk-project.org/jira/browse/XWALK-2493
Fix issue that app crashs when exit with back key.
@sqliu
Copy link

sqliu commented Oct 9, 2014

lgtm. @agamemnus could please also refine the commit log as apache/cordova-android#126 thanks!

@rakuco
Copy link

rakuco commented Oct 9, 2014

Since that's been sent upstream (thank you so much for doing that), it would be better to cherry-pick it from there once it's merged.

@agamemnus
Copy link
Author

sqliu, "refine the commit log"? I don't understand what that means, sorry. :-(

@baleboy
Copy link

baleboy commented Oct 9, 2014

I think he is asking to repeat what the commit does as described in the cordova commit (as opposed to just putting a link)

@agamemnus
Copy link
Author

All right. I got a response there, and seems that throw new FileNotFoundException (); will work instead of modifying CordovaResourceApi.java, but I wonder if it is the most correct thing to do, since it is not really that the file isn't found, but that openAssetFile won't even try open the file (as intended, due to my changes).

So in other words:

 @Override public AssetFileDescriptor openAssetFile (Uri uri, String mode) throws FileNotFoundException {
  if (initIfNecessary () == false) throw new FileNotFoundException (); // or return null?
  String path = uri.getEncodedPath ();
  if (path.startsWith("/")) path = path.substring (1);
  return mAPKExtensionFile.getAssetFileDescriptor (path);  
 }

Can you give some input on this?

@rakuco
Copy link

rakuco commented Oct 10, 2014

I'd discuss this in the upstream PR and tend to follow whatever suggestions are made there, since the people reviewing the code are normally the maintainers and the people who wrote it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.