New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VpnService.prepare crashes due to XPosed module #1084

Closed
ameshkov opened this Issue Mar 3, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@ameshkov
Member

ameshkov commented Mar 3, 2017

We should handle this issue.

Thread: Thread[main,5,main]; Uncaught exception:

java.lang.RuntimeException: Unable to start receiver com.adguard.android.receivers.NetworkStateReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.connectivity.Vpn.prepare(java.lang.String, java.lang.String)' on a null object reference
	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2680) ~[na:0.0]
	at android.app.ActivityThread.access$1700(ActivityThread.java:156) ~[na:0.0]
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1428) ~[na:0.0]
	at android.os.Handler.dispatchMessage(Handler.java:102) ~[na:0.0]
	at android.os.Looper.loop(Looper.java:211) ~[na:0.0]
	at android.app.ActivityThread.main(ActivityThread.java:5389) ~[na:0.0]
	at java.lang.reflect.Method.invoke(Native Method) ~[na:0.0]
	at java.lang.reflect.Method.invoke(Method.java:372) ~[na:0.0]
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) ~[na:0.0]
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) ~[na:0.0]
	at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) ~[na:na]
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.android.server.connectivity.Vpn.prepare(java.lang.String, java.lang.String)' on a null object reference
	at android.os.Parcel.readException(Parcel.java:1562) ~[na:0.0]
	at android.os.Parcel.readException(Parcel.java:1505) ~[na:0.0]
	at android.net.IConnectivityManager$Stub$Proxy.prepareVpn(IConnectivityManager.java:1716) ~[na:0.0]
	at android.net.VpnService.prepare(VpnService.java:159) ~[na:0.0]
	at com.adguard.android.receivers.BaseReceiver.a(Unknown Source) ~[na:0.0]
	at com.adguard.android.receivers.NetworkStateReceiver.onReceive(Unknown Source) ~[na:0.0]
	at android.app.ActivityThread.handleReceiver(ActivityThread.java:2673) ~[na:0.0]
	... 10 common frames omitted

@ameshkov ameshkov added the Bug label Mar 3, 2017

@ameshkov ameshkov added this to the 2.9 milestone Mar 3, 2017

@ameshkov ameshkov self-assigned this Mar 3, 2017

@ameshkov

This comment has been minimized.

Show comment
Hide comment
@ameshkov

ameshkov Mar 3, 2017

Member

Fix: android/bug/1084

Member

ameshkov commented Mar 3, 2017

Fix: android/bug/1084

@ameshkov ameshkov closed this Mar 3, 2017

@jbir789

This comment has been minimized.

Show comment
Hide comment
@jbir789

jbir789 Sep 19, 2017

Probably not the right place to ask, but I am having the same issue with my app. Could you briefly explain what was the issue with your app, please?

jbir789 commented Sep 19, 2017

Probably not the right place to ask, but I am having the same issue with my app. Could you briefly explain what was the issue with your app, please?

@ameshkov

This comment has been minimized.

Show comment
Hide comment
@ameshkov

ameshkov Sep 19, 2017

Member

As I recall, the only thing we could do is to wrap all the VpnService.prepare calls in try-catch blocks to prevent the app crashes. The check was not crucial (it was inside of a receiver).

Member

ameshkov commented Sep 19, 2017

As I recall, the only thing we could do is to wrap all the VpnService.prepare calls in try-catch blocks to prevent the app crashes. The check was not crucial (it was inside of a receiver).

@ameshkov

This comment has been minimized.

Show comment
Hide comment
@ameshkov

ameshkov Sep 19, 2017

Member
    /**
     * Checks VpnService.prepare result in a safe manner
     *
     * @param context Application context
     * @return true if VpnService.prepare returns null
     */
    public boolean isVpnServicePrepared(Context context) {
        try {
            return VpnService.prepare(context.getApplicationContext()) == null;
        } catch (Exception ex) {
            LOG.warn("Error preparing vpn service\n", ex);
        }

        return false;
    }
Member

ameshkov commented Sep 19, 2017

    /**
     * Checks VpnService.prepare result in a safe manner
     *
     * @param context Application context
     * @return true if VpnService.prepare returns null
     */
    public boolean isVpnServicePrepared(Context context) {
        try {
            return VpnService.prepare(context.getApplicationContext()) == null;
        } catch (Exception ex) {
            LOG.warn("Error preparing vpn service\n", ex);
        }

        return false;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment