jeudi 7 mai 2015

I am getting error "Implicit intents with startService are not safe"

I am deploying a vpn app.Which can connect to my vpn service which is duck vpn.It a simple app.But i am not able to connect to vpn service due to Implicit intents error.

This is my vpn connect function

private void connect(final VpnProfile profile, final String username, final String password) {

    mVpnManager.startVpnService();


    ServiceConnection c = new ServiceConnection() {
        public void onServiceConnected(ComponentName className,
                IBinder service) {
            try {

                boolean success = IVpnService.Stub.asInterface(service)
                        .connect(profile, username, password);
                if (!success) {
                    Log.d(TAG, "~~~~~~ connect() failed!");
                } else {
                    Log.d(TAG, "~~~~~~ connect() succeeded!");
                }
            } catch (Throwable e) {
                Log.e(TAG, "connect()", e);
                broadcastConnectivity(VpnState.IDLE,
                        VpnManager.VPN_ERROR_CONNECTION_FAILED);
            } finally {
                MainActivity.this.unbindService(this);
            }
        }

        public void onServiceDisconnected(ComponentName className) {
            checkStatus();
        }
    };
    if (!bindService(c)) {
        broadcastConnectivity(VpnState.IDLE,
                VpnManager.VPN_ERROR_CONNECTION_FAILED);
    }

}

At this line

ServiceConnection c = new ServiceConnection() 

My log cat shows this

05-08 08:22:35.613    505-25270/system_process I/ActivityManager﹕ Killing 21162:com.android.defcontainer/u0a5 (adj 15): empty #17
05-08 08:22:37.423  21251-21251/name.chakimar.vpnconnection W/ContextImpl﹕ Implicit intents with startService are not safe: Intent { act=android.net.vpn.SERVICE } android.content.ContextWrapper.bindService:517 android.net.vpn.VpnManager.bindVpnService:155 name.chakimar.vpnconnection.MainActivity.bindService:108
05-08 08:22:37.423  21251-21251/name.chakimar.vpnconnection W/VpnManager﹕ failed to connect to VPN service
05-08 08:22:37.423      505-915/system_process W/ActivityManager﹕ Unable to start service Intent { act=android.net.vpn.SERVICE } U=0: not found
05-08 08:22:37.583   1051-21410/com.google.android.gms V/ConfigFetchTask﹕ ConfigFetchTask getDeviceDataVersionInfo(): ABFEt1VPhtO-54w5i2ZVE_jYd4Mb53Q36OPUdLJf_0gggOdZooMNPQqjJ5dfs1BDMUsBMV0BgAOSV4ZmHaesE-EGHzu1Lfd8PF6--xo2nUYzjSX45K883je4i87V7sg1aeLd9KKSQ-Bo8GJdk3zmAjSF0mEMcbNb8auVjHMtT3gZ1USV8PTbwMR8mdDh-x7C-k5W_viQqNCJDT5aprA1vN8ghAOp1qnlRT20ovWJsVFqwu04Ily10UH1NPs-X5RB5fNumKfI8Iu9th0qCMZPlt_n6SodsiQxtoVmozVf_Ix-W9OuHnE7pCM
05-08 08:22:37.603   1051-21410/com.google.android.gms I/GoogleURLConnFactory﹕ Using platform SSLCertificateSocketFactory
05-08 08:22:38.063      505-519/system_process I/ActivityManager﹕ Displayed name.chakimar.vpnconnection/.MainActivity: +18s189ms
05-08 08:22:38.063      505-519/system_process I/Timeline﹕ Timeline: Activity_windows_visible id: ActivityRecord{41b0e100 u0 name.chakimar.vpnconnection/.MainActivity t158} time:52991914
05-08 08:22:38.103  17841-17841/org.mozilla.firefox D/GeckoMemoryMonitor﹕ onTrimMemory() notification received with level 20
05-08 08:22:38.113  21251-21251/name.chakimar.vpnconnection I/Timeline﹕ Timeline: Activity_idle id: android.os.BinderProxy@41ae9108 time:52991969
05-08 08:22:38.743    1051-1051/com.google.android.gms I/ConfigFetchService﹕ fetch service done; releasing wakelock
05-08 08:22:38.753    1051-1051/com.google.android.gms I/ConfigFetchService﹕ stopping self
05-08 08:22:38.753      505-917/system_process I/ActivityManager﹕ Killing 20123:com.google.android.youtube/u0a74 (adj 15): empty #17

And moves to this catch block

catch (Throwable e) {
                Log.e(TAG, "connect()", e);
                broadcastConnectivity(VpnState.IDLE,
                        VpnManager.VPN_ERROR_CONNECTION_FAILED);
            } 

And i am not able to create vpn connection due to implicit intent error.How to solve this intent issue?Thanks in advance :)

Aucun commentaire:

Enregistrer un commentaire