From aba5a16a97b43f95659e0f79f76549b1fe2e9d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Parm=C3=A9nides=20GV?= Date: Thu, 29 May 2014 10:05:47 +0200 Subject: No AIDL nor api, logfragment related xml files api folder and aidl files aren't needed for us. They are used for external apps that want to use ics-openvpn as an already installed package, while what we want is to avoid the installation of ics-openvpn including it (refactored) in bitmask android. --- app/build.gradle | 5 +- .../java/de/blinkt/openvpn/api/APIVpnProfile.java | 51 ---- .../aidl/de/blinkt/openvpn/api/APIVpnProfile.aidl | 3 - .../de/blinkt/openvpn/api/IOpenVPNAPIService.aidl | 50 ---- .../blinkt/openvpn/api/IOpenVPNStatusCallback.aidl | 13 - app/src/main/java/de/blinkt/openvpn/LaunchVPN.java | 19 +- .../java/de/blinkt/openvpn/api/APIVpnProfile.java | 51 ---- .../java/de/blinkt/openvpn/api/ConfirmDialog.java | 126 -------- .../de/blinkt/openvpn/api/ExternalAppDatabase.java | 57 ---- .../blinkt/openvpn/api/ExternalOpenVPNService.java | 317 --------------------- .../openvpn/api/SecurityRemoteException.java | 12 - .../main/res/layout-sw600dp-port/log_fragment.xml | 42 +++ app/src/main/res/layout-sw600dp/log_fragment.xml | 32 +++ app/src/main/res/layout/log_fragment.xml | 29 ++ app/src/main/res/layout/log_silders.xml | 61 ++++ app/src/main/res/layout/vpnstatus.xml | 46 +++ app/src/main/res/values/dimens.xml | 7 + app/src/main/res/values/styles.xml | 37 ++- app/src/main/res/values/untranslatable.xml | 285 ++++++++++++++++++ .../src/main/java/de/blinkt/openvpn/LaunchVPN.java | 19 +- .../java/de/blinkt/openvpn/api/APIVpnProfile.java | 51 ---- .../java/de/blinkt/openvpn/api/ConfirmDialog.java | 126 -------- .../de/blinkt/openvpn/api/ExternalAppDatabase.java | 57 ---- .../blinkt/openvpn/api/ExternalOpenVPNService.java | 317 --------------------- .../openvpn/api/SecurityRemoteException.java | 12 - .../main/src/main/res/layout/log_silders.xml | 61 ++++ .../main/src/main/res/layout/vpnstatus.xml | 46 +++ .../main/src/main/res/values/dimens.xml | 7 + .../main/src/main/res/values/styles.xml | 64 +++++ .../java/de/blinkt/openvpn/api/APIVpnProfile.java | 51 ---- 30 files changed, 728 insertions(+), 1326 deletions(-) delete mode 100644 app/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java delete mode 100644 app/src/main/aidl/de/blinkt/openvpn/api/APIVpnProfile.aidl delete mode 100644 app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl delete mode 100644 app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNStatusCallback.aidl delete mode 100644 app/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java delete mode 100644 app/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java delete mode 100644 app/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java delete mode 100644 app/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java delete mode 100644 app/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java create mode 100644 app/src/main/res/layout-sw600dp-port/log_fragment.xml create mode 100644 app/src/main/res/layout-sw600dp/log_fragment.xml create mode 100644 app/src/main/res/layout/log_fragment.xml create mode 100644 app/src/main/res/layout/log_silders.xml create mode 100644 app/src/main/res/layout/vpnstatus.xml create mode 100644 app/src/main/res/values/dimens.xml delete mode 100644 ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java delete mode 100644 ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java delete mode 100644 ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java delete mode 100644 ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java delete mode 100644 ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java create mode 100644 ics-openvpn-stripped/main/src/main/res/layout/log_silders.xml create mode 100644 ics-openvpn-stripped/main/src/main/res/layout/vpnstatus.xml create mode 100644 ics-openvpn-stripped/main/src/main/res/values/dimens.xml create mode 100644 ics-openvpn-stripped/main/src/main/res/values/styles.xml delete mode 100644 ics-openvpn-stripped/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java diff --git a/app/build.gradle b/app/build.gradle index 062bb7c7..2be30e9c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,7 +69,10 @@ task copyIcsOpenVPNClasses( type: Copy, dependsOn: 'checkoutStrippedIcsOpenVPN' include '**/*.java' include '**/*.aidl' include '**/strings.xml' - include '**/log_window.xml' + include '**/log_*.xml' + include '**/vpnstatus.xml' + include '**/styles.xml' + include '**/dimens.xml' rename 'strings.xml', 'strings-icsopenvpn.xml' filter { diff --git a/app/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java b/app/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java deleted file mode 100644 index a44891ab..00000000 --- a/app/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.blinkt.openvpn.api; - -import android.os.Parcel; -import android.os.Parcelable; - -public class APIVpnProfile implements Parcelable { - - public final String mUUID; - public final String mName; - public final boolean mUserEditable; - - public APIVpnProfile(Parcel in) { - mUUID = in.readString(); - mName = in.readString(); - mUserEditable = in.readInt() != 0; - } - - public APIVpnProfile(String uuidString, String name, boolean userEditable) { - mUUID=uuidString; - mName = name; - mUserEditable=userEditable; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mUUID); - dest.writeString(mName); - if(mUserEditable) - dest.writeInt(0); - else - dest.writeInt(1); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public APIVpnProfile createFromParcel(Parcel in) { - return new APIVpnProfile(in); - } - - public APIVpnProfile[] newArray(int size) { - return new APIVpnProfile[size]; - } - }; - - -} diff --git a/app/src/main/aidl/de/blinkt/openvpn/api/APIVpnProfile.aidl b/app/src/main/aidl/de/blinkt/openvpn/api/APIVpnProfile.aidl deleted file mode 100644 index f6799659..00000000 --- a/app/src/main/aidl/de/blinkt/openvpn/api/APIVpnProfile.aidl +++ /dev/null @@ -1,3 +0,0 @@ -package de.blinkt.openvpn.api; - -parcelable APIVpnProfile; diff --git a/app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl b/app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl deleted file mode 100644 index 2e947d8b..00000000 --- a/app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNAPIService.aidl +++ /dev/null @@ -1,50 +0,0 @@ -// IOpenVPNAPIService.aidl -package de.blinkt.openvpn.api; - -import de.blinkt.openvpn.api.APIVpnProfile; -import de.blinkt.openvpn.api.IOpenVPNStatusCallback; - -import android.content.Intent; -import android.os.ParcelFileDescriptor; - -interface IOpenVPNAPIService { - List getProfiles(); - - void startProfile (String profileUUID); - - /** Use a profile with all certificates etc. embedded */ - boolean addVPNProfile (String name, String config); - - /** start a profile using an config */ - void startVPN (String inlineconfig); - - /** This permission framework is used to avoid confused deputy style attack to the VPN - * calling this will give null if the app is allowed to use the external API and an Intent - * that can be launched to request permissions otherwise */ - Intent prepare (String packagename); - - /** Used to trigger to the Android VPN permission dialog (VPNService.prepare()) in advance, - * if this return null OpenVPN for ANdroid already has the permissions otherwise you can start the returned Intent - * to let OpenVPN for Android request the permission */ - Intent prepareVPNService (); - - /* Disconnect the VPN */ - void disconnect(); - - /* Pause the VPN (same as using the pause feature in the notifcation bar) */ - void pause(); - - /* Resume the VPN (same as using the pause feature in the notifcation bar) */ - void resume(); - - /** - * Registers to receive OpenVPN Status Updates - */ - void registerStatusCallback(IOpenVPNStatusCallback cb); - - /** - * Remove a previously registered callback interface. - */ - void unregisterStatusCallback(IOpenVPNStatusCallback cb); - -} \ No newline at end of file diff --git a/app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNStatusCallback.aidl b/app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNStatusCallback.aidl deleted file mode 100644 index 7de84f56..00000000 --- a/app/src/main/aidl/de/blinkt/openvpn/api/IOpenVPNStatusCallback.aidl +++ /dev/null @@ -1,13 +0,0 @@ -package de.blinkt.openvpn.api; - -/** - * Example of a callback interface used by IRemoteService to send - * synchronous notifications back to its clients. Note that this is a - * one-way interface so the server does not block waiting for the client. - */ -oneway interface IOpenVPNStatusCallback { - /** - * Called when the service has a new status for you. - */ - void newStatus(String uuid, String state, String message, String level); -} diff --git a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java index 6b4addb3..f8487891 100644 --- a/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java +++ b/app/src/main/java/de/blinkt/openvpn/LaunchVPN.java @@ -117,19 +117,12 @@ public class LaunchVPN extends Activity { if(requestCode==START_VPN_PROFILE) { if(resultCode == Activity.RESULT_OK) { - int needpw = mSelectedProfile.needUserPWInput(); - if(needpw !=0) { - VpnStatus.updateStateString("USER_VPN_PASSWORD", "", R.string.state_user_vpn_password, - ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT); - askForPW(needpw); - } else { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - boolean showlogwindow = prefs.getBoolean("showlogwindow", true); - - if(!mhideLog && showlogwindow) - showLogWindow(); - new startOpenVpnThread().start(); - } + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + boolean showlogwindow = prefs.getBoolean("showlogwindow", true); + + if(!mhideLog && showlogwindow) + showLogWindow(); + new startOpenVpnThread().start(); } else if (resultCode == Activity.RESULT_CANCELED) { // User does not want us to start, so we just vanish VpnStatus.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled, diff --git a/app/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java b/app/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java deleted file mode 100644 index a44891ab..00000000 --- a/app/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.blinkt.openvpn.api; - -import android.os.Parcel; -import android.os.Parcelable; - -public class APIVpnProfile implements Parcelable { - - public final String mUUID; - public final String mName; - public final boolean mUserEditable; - - public APIVpnProfile(Parcel in) { - mUUID = in.readString(); - mName = in.readString(); - mUserEditable = in.readInt() != 0; - } - - public APIVpnProfile(String uuidString, String name, boolean userEditable) { - mUUID=uuidString; - mName = name; - mUserEditable=userEditable; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mUUID); - dest.writeString(mName); - if(mUserEditable) - dest.writeInt(0); - else - dest.writeInt(1); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public APIVpnProfile createFromParcel(Parcel in) { - return new APIVpnProfile(in); - } - - public APIVpnProfile[] newArray(int size) { - return new APIVpnProfile[size]; - } - }; - - -} diff --git a/app/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java b/app/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java deleted file mode 100644 index 3856a181..00000000 --- a/app/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.blinkt.openvpn.api; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.DialogInterface; -import android.content.DialogInterface.OnShowListener; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.CompoundButton; -import android.widget.ImageView; -import android.widget.TextView; -import se.leap.bitmaskclient.R; - - -public class ConfirmDialog extends Activity implements -CompoundButton.OnCheckedChangeListener, DialogInterface.OnClickListener { - private static final String TAG = "OpenVPNVpnConfirm"; - - private String mPackage; - - private Button mButton; - - private AlertDialog mAlert; - - @Override - protected void onResume() { - super.onResume(); - try { - mPackage = getCallingPackage(); - if (mPackage==null) { - finish(); - return; - } - - - PackageManager pm = getPackageManager(); - ApplicationInfo app = pm.getApplicationInfo(mPackage, 0); - - View view = View.inflate(this, R.layout.api_confirm, null); - ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.loadIcon(pm)); - ((TextView) view.findViewById(R.id.prompt)).setText( - getString(R.string.prompt, app.loadLabel(pm), getString(R.string.app))); - ((CompoundButton) view.findViewById(R.id.check)).setOnCheckedChangeListener(this); - - - Builder builder = new AlertDialog.Builder(this); - - builder.setView(view); - - builder.setIconAttribute(android.R.attr.alertDialogIcon); - builder.setTitle(android.R.string.dialog_alert_title); - builder.setPositiveButton(android.R.string.ok,this); - builder.setNegativeButton(android.R.string.cancel,this); - - mAlert = builder.create(); - mAlert.setCanceledOnTouchOutside(false); - - mAlert.setOnShowListener (new OnShowListener() { - - @Override - public void onShow(DialogInterface dialog) { - mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); - mButton.setEnabled(false); - - } - }); - - //setCloseOnTouchOutside(false); - - mAlert.show(); - - } catch (Exception e) { - Log.e(TAG, "onResume", e); - finish(); - } - } - - @Override - public void onBackPressed() { - setResult(RESULT_CANCELED); - finish(); - } - - @Override - public void onCheckedChanged(CompoundButton button, boolean checked) { - mButton.setEnabled(checked); - } - - @Override - public void onClick(DialogInterface dialog, int which) { - - if (which == DialogInterface.BUTTON_POSITIVE) { - ExternalAppDatabase extapps = new ExternalAppDatabase(this); - extapps.addApp(mPackage); - setResult(RESULT_OK); - finish(); - } - - if (which == DialogInterface.BUTTON_NEGATIVE) { - setResult(RESULT_CANCELED); - finish(); - } - } - -} - diff --git a/app/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java b/app/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java deleted file mode 100644 index 02c369b1..00000000 --- a/app/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.blinkt.openvpn.api; - -import java.util.HashSet; -import java.util.Set; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.preference.PreferenceManager; - -public class ExternalAppDatabase { - - Context mContext; - - public ExternalAppDatabase(Context c) { - mContext =c; - } - - private final String PREFERENCES_KEY = "PREFERENCES_KEY"; - - boolean isAllowed(String packagename) { - Set allowedapps = getExtAppList(); - - return allowedapps.contains(packagename); - - } - - public Set getExtAppList() { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - return prefs.getStringSet(PREFERENCES_KEY, new HashSet()); - } - - void addApp(String packagename) - { - Set allowedapps = getExtAppList(); - allowedapps.add(packagename); - saveExtAppList(allowedapps); - } - - private void saveExtAppList( Set allowedapps) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - Editor prefedit = prefs.edit(); - prefedit.putStringSet(PREFERENCES_KEY, allowedapps); - prefedit.apply(); - } - - public void clearAllApiApps() { - saveExtAppList(new HashSet()); - } - - public void removeApp(String packagename) { - Set allowedapps = getExtAppList(); - allowedapps.remove(packagename); - saveExtAppList(allowedapps); - } - -} diff --git a/app/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/app/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java deleted file mode 100644 index 784ec72a..00000000 --- a/app/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ /dev/null @@ -1,317 +0,0 @@ -package de.blinkt.openvpn.api; - -import java.io.IOException; -import java.io.StringReader; -import java.lang.ref.WeakReference; -import java.util.LinkedList; -import java.util.List; - -import android.annotation.TargetApi; -import android.app.Service; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.net.VpnService; -import android.os.*; -import se.leap.bitmaskclient.R; -import de.blinkt.openvpn.VpnProfile; -import de.blinkt.openvpn.core.ConfigParser; -import de.blinkt.openvpn.core.ConfigParser.ConfigParseError; -import de.blinkt.openvpn.core.VpnStatus; -import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus; -import de.blinkt.openvpn.core.VpnStatus.StateListener; -import de.blinkt.openvpn.core.OpenVpnService; -import de.blinkt.openvpn.core.OpenVpnService.LocalBinder; -import de.blinkt.openvpn.core.ProfileManager; -import de.blinkt.openvpn.core.VPNLaunchHelper; - -@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) -public class ExternalOpenVPNService extends Service implements StateListener { - - private static final int SEND_TOALL = 0; - - final RemoteCallbackList mCallbacks = - new RemoteCallbackList(); - - private OpenVpnService mService; - private ExternalAppDatabase mExtAppDb; - - - private ServiceConnection mConnection = new ServiceConnection() { - - - @Override - public void onServiceConnected(ComponentName className, - IBinder service) { - // We've bound to LocalService, cast the IBinder and get LocalService instance - LocalBinder binder = (LocalBinder) service; - mService = binder.getService(); - } - - @Override - public void onServiceDisconnected(ComponentName arg0) { - mService = null; - } - - }; - - @Override - public void onCreate() { - super.onCreate(); - VpnStatus.addStateListener(this); - mExtAppDb = new ExternalAppDatabase(this); - - Intent intent = new Intent(getBaseContext(), OpenVpnService.class); - intent.setAction(OpenVpnService.START_SERVICE); - - bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - mHandler.setService(this); - } - - private final IOpenVPNAPIService.Stub mBinder = new IOpenVPNAPIService.Stub() { - - private void checkOpenVPNPermission() throws SecurityRemoteException { - PackageManager pm = getPackageManager(); - - for (String apppackage : mExtAppDb.getExtAppList()) { - ApplicationInfo app; - try { - app = pm.getApplicationInfo(apppackage, 0); - if (Binder.getCallingUid() == app.uid) { - return; - } - } catch (NameNotFoundException e) { - // App not found. Remove it from the list - mExtAppDb.removeApp(apppackage); - } - - } - throw new SecurityException("Unauthorized OpenVPN API Caller"); - } - - @Override - public List getProfiles() throws RemoteException { - checkOpenVPNPermission(); - - ProfileManager pm = ProfileManager.getInstance(getBaseContext()); - - List profiles = new LinkedList(); - - for (VpnProfile vp : pm.getProfiles()) - profiles.add(new APIVpnProfile(vp.getUUIDString(), vp.mName, vp.mUserEditable)); - - return profiles; - } - - @Override - public void startProfile(String profileUUID) throws RemoteException { - checkOpenVPNPermission(); - - Intent shortVPNIntent = new Intent(Intent.ACTION_MAIN); - shortVPNIntent.setClass(getBaseContext(), de.blinkt.openvpn.LaunchVPN.class); - shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_KEY, profileUUID); - shortVPNIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(shortVPNIntent); - } - - public void startVPN(String inlineconfig) throws RemoteException { - checkOpenVPNPermission(); - - ConfigParser cp = new ConfigParser(); - try { - cp.parseConfig(new StringReader(inlineconfig)); - VpnProfile vp = cp.convertProfile(); - if (vp.checkProfile(getApplicationContext()) != R.string.no_error_found) - throw new RemoteException(getString(vp.checkProfile(getApplicationContext()))); - - - ProfileManager.setTemporaryProfile(vp); - VPNLaunchHelper.startOpenVpn(vp, getBaseContext()); - - - } catch (IOException e) { - throw new RemoteException(e.getMessage()); - } catch (ConfigParseError e) { - throw new RemoteException(e.getMessage()); - } - } - - @Override - public boolean addVPNProfile(String name, String config) throws RemoteException { - checkOpenVPNPermission(); - - ConfigParser cp = new ConfigParser(); - try { - cp.parseConfig(new StringReader(config)); - VpnProfile vp = cp.convertProfile(); - vp.mName = name; - ProfileManager pm = ProfileManager.getInstance(getBaseContext()); - pm.addProfile(vp); - } catch (IOException e) { - VpnStatus.logException(e); - return false; - } catch (ConfigParseError e) { - VpnStatus.logException(e); - return false; - } - - return true; - } - - - @Override - public Intent prepare(String packagename) { - if (new ExternalAppDatabase(ExternalOpenVPNService.this).isAllowed(packagename)) - return null; - - Intent intent = new Intent(); - intent.setClass(ExternalOpenVPNService.this, ConfirmDialog.class); - return intent; - } - - @Override - public Intent prepareVPNService() throws RemoteException { - checkOpenVPNPermission(); - - if (VpnService.prepare(ExternalOpenVPNService.this) == null) - return null; - else - return new Intent(getBaseContext(), GrantPermissionsActivity.class); - } - - - @Override - public void registerStatusCallback(IOpenVPNStatusCallback cb) - throws RemoteException { - checkOpenVPNPermission(); - - if (cb != null) { - cb.newStatus(mMostRecentState.vpnUUID, mMostRecentState.state, - mMostRecentState.logmessage, mMostRecentState.level.name()); - mCallbacks.register(cb); - } - - - } - - @Override - public void unregisterStatusCallback(IOpenVPNStatusCallback cb) - throws RemoteException { - checkOpenVPNPermission(); - - if (cb != null) - mCallbacks.unregister(cb); - } - - @Override - public void disconnect() throws RemoteException { - checkOpenVPNPermission(); - if (mService != null && mService.getManagement() != null) - mService.getManagement().stopVPN(); - } - - @Override - public void pause() throws RemoteException { - checkOpenVPNPermission(); - if (mService != null) - mService.userPause(true); - } - - @Override - public void resume() throws RemoteException { - checkOpenVPNPermission(); - if (mService != null) - mService.userPause(false); - - } - }; - - - private UpdateMessage mMostRecentState; - - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mCallbacks.kill(); - unbindService(mConnection); - VpnStatus.removeStateListener(this); - } - - class UpdateMessage { - public String state; - public String logmessage; - public ConnectionStatus level; - public String vpnUUID; - - public UpdateMessage(String state, String logmessage, ConnectionStatus level) { - this.state = state; - this.logmessage = logmessage; - this.level = level; - } - } - - @Override - public void updateState(String state, String logmessage, int resid, ConnectionStatus level) { - mMostRecentState = new UpdateMessage(state, logmessage, level); - if (ProfileManager.getLastConnectedVpn() != null) - mMostRecentState.vpnUUID = ProfileManager.getLastConnectedVpn().getUUIDString(); - - Message msg = mHandler.obtainMessage(SEND_TOALL, mMostRecentState); - msg.sendToTarget(); - - } - - private static final OpenVPNServiceHandler mHandler = new OpenVPNServiceHandler(); - - - static class OpenVPNServiceHandler extends Handler { - WeakReference service = null; - - private void setService(ExternalOpenVPNService eos) { - service = new WeakReference(eos); - } - - @Override - public void handleMessage(Message msg) { - - RemoteCallbackList callbacks; - switch (msg.what) { - case SEND_TOALL: - if (service == null || service.get() == null) - return; - - callbacks = service.get().mCallbacks; - - - // Broadcast to all clients the new value. - final int N = callbacks.beginBroadcast(); - for (int i = 0; i < N; i++) { - try { - sendUpdate(callbacks.getBroadcastItem(i), (UpdateMessage) msg.obj); - } catch (RemoteException e) { - // The RemoteCallbackList will take care of removing - // the dead object for us. - } - } - callbacks.finishBroadcast(); - break; - } - } - - private void sendUpdate(IOpenVPNStatusCallback broadcastItem, - UpdateMessage um) throws RemoteException { - broadcastItem.newStatus(um.vpnUUID, um.state, um.logmessage, um.level.name()); - } - } - - -} \ No newline at end of file diff --git a/app/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java b/app/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java deleted file mode 100644 index 08d90e3b..00000000 --- a/app/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.blinkt.openvpn.api; - -import android.os.RemoteException; - -public class SecurityRemoteException extends RemoteException { - - /** - * - */ - private static final long serialVersionUID = 1L; - -} diff --git a/app/src/main/res/layout-sw600dp-port/log_fragment.xml b/app/src/main/res/layout-sw600dp-port/log_fragment.xml new file mode 100644 index 00000000..ddf0506b --- /dev/null +++ b/app/src/main/res/layout-sw600dp-port/log_fragment.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout-sw600dp/log_fragment.xml b/app/src/main/res/layout-sw600dp/log_fragment.xml new file mode 100644 index 00000000..c4e1355c --- /dev/null +++ b/app/src/main/res/layout-sw600dp/log_fragment.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/log_fragment.xml b/app/src/main/res/layout/log_fragment.xml new file mode 100644 index 00000000..0b428070 --- /dev/null +++ b/app/src/main/res/layout/log_fragment.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/log_silders.xml b/app/src/main/res/layout/log_silders.xml new file mode 100644 index 00000000..0ecb5daa --- /dev/null +++ b/app/src/main/res/layout/log_silders.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/vpnstatus.xml b/app/src/main/res/layout/vpnstatus.xml new file mode 100644 index 00000000..eb7c53ee --- /dev/null +++ b/app/src/main/res/layout/vpnstatus.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 00000000..4f325078 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + 20dp + 8dp + false + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 1c20cbcd..95e709b3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,4 +1,21 @@ + + - + - - + - + + - + \ No newline at end of file diff --git a/app/src/main/res/values/untranslatable.xml b/app/src/main/res/values/untranslatable.xml index 4c652f20..c73ccb05 100644 --- a/app/src/main/res/values/untranslatable.xml +++ b/app/src/main/res/values/untranslatable.xml @@ -55,4 +55,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java index c563899d..eead600c 100644 --- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java +++ b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/LaunchVPN.java @@ -115,19 +115,12 @@ public class LaunchVPN extends Activity { if(requestCode==START_VPN_PROFILE) { if(resultCode == Activity.RESULT_OK) { - int needpw = mSelectedProfile.needUserPWInput(); - if(needpw !=0) { - VpnStatus.updateStateString("USER_VPN_PASSWORD", "", R.string.state_user_vpn_password, - ConnectionStatus.LEVEL_WAITING_FOR_USER_INPUT); - askForPW(needpw); - } else { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - boolean showlogwindow = prefs.getBoolean("showlogwindow", true); - - if(!mhideLog && showlogwindow) - showLogWindow(); - new startOpenVpnThread().start(); - } + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + boolean showlogwindow = prefs.getBoolean("showlogwindow", true); + + if(!mhideLog && showlogwindow) + showLogWindow(); + new startOpenVpnThread().start(); } else if (resultCode == Activity.RESULT_CANCELED) { // User does not want us to start, so we just vanish VpnStatus.updateStateString("USER_VPN_PERMISSION_CANCELLED", "", R.string.state_user_vpn_permission_cancelled, diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java deleted file mode 100644 index a44891ab..00000000 --- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.blinkt.openvpn.api; - -import android.os.Parcel; -import android.os.Parcelable; - -public class APIVpnProfile implements Parcelable { - - public final String mUUID; - public final String mName; - public final boolean mUserEditable; - - public APIVpnProfile(Parcel in) { - mUUID = in.readString(); - mName = in.readString(); - mUserEditable = in.readInt() != 0; - } - - public APIVpnProfile(String uuidString, String name, boolean userEditable) { - mUUID=uuidString; - mName = name; - mUserEditable=userEditable; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mUUID); - dest.writeString(mName); - if(mUserEditable) - dest.writeInt(0); - else - dest.writeInt(1); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public APIVpnProfile createFromParcel(Parcel in) { - return new APIVpnProfile(in); - } - - public APIVpnProfile[] newArray(int size) { - return new APIVpnProfile[size]; - } - }; - - -} diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java deleted file mode 100644 index 3856a181..00000000 --- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ConfirmDialog.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.blinkt.openvpn.api; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.AlertDialog.Builder; -import android.content.DialogInterface; -import android.content.DialogInterface.OnShowListener; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.util.Log; -import android.view.View; -import android.widget.Button; -import android.widget.CompoundButton; -import android.widget.ImageView; -import android.widget.TextView; -import se.leap.bitmaskclient.R; - - -public class ConfirmDialog extends Activity implements -CompoundButton.OnCheckedChangeListener, DialogInterface.OnClickListener { - private static final String TAG = "OpenVPNVpnConfirm"; - - private String mPackage; - - private Button mButton; - - private AlertDialog mAlert; - - @Override - protected void onResume() { - super.onResume(); - try { - mPackage = getCallingPackage(); - if (mPackage==null) { - finish(); - return; - } - - - PackageManager pm = getPackageManager(); - ApplicationInfo app = pm.getApplicationInfo(mPackage, 0); - - View view = View.inflate(this, R.layout.api_confirm, null); - ((ImageView) view.findViewById(R.id.icon)).setImageDrawable(app.loadIcon(pm)); - ((TextView) view.findViewById(R.id.prompt)).setText( - getString(R.string.prompt, app.loadLabel(pm), getString(R.string.app))); - ((CompoundButton) view.findViewById(R.id.check)).setOnCheckedChangeListener(this); - - - Builder builder = new AlertDialog.Builder(this); - - builder.setView(view); - - builder.setIconAttribute(android.R.attr.alertDialogIcon); - builder.setTitle(android.R.string.dialog_alert_title); - builder.setPositiveButton(android.R.string.ok,this); - builder.setNegativeButton(android.R.string.cancel,this); - - mAlert = builder.create(); - mAlert.setCanceledOnTouchOutside(false); - - mAlert.setOnShowListener (new OnShowListener() { - - @Override - public void onShow(DialogInterface dialog) { - mButton = mAlert.getButton(DialogInterface.BUTTON_POSITIVE); - mButton.setEnabled(false); - - } - }); - - //setCloseOnTouchOutside(false); - - mAlert.show(); - - } catch (Exception e) { - Log.e(TAG, "onResume", e); - finish(); - } - } - - @Override - public void onBackPressed() { - setResult(RESULT_CANCELED); - finish(); - } - - @Override - public void onCheckedChanged(CompoundButton button, boolean checked) { - mButton.setEnabled(checked); - } - - @Override - public void onClick(DialogInterface dialog, int which) { - - if (which == DialogInterface.BUTTON_POSITIVE) { - ExternalAppDatabase extapps = new ExternalAppDatabase(this); - extapps.addApp(mPackage); - setResult(RESULT_OK); - finish(); - } - - if (which == DialogInterface.BUTTON_NEGATIVE) { - setResult(RESULT_CANCELED); - finish(); - } - } - -} - diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java deleted file mode 100644 index 02c369b1..00000000 --- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalAppDatabase.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.blinkt.openvpn.api; - -import java.util.HashSet; -import java.util.Set; - -import android.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.preference.PreferenceManager; - -public class ExternalAppDatabase { - - Context mContext; - - public ExternalAppDatabase(Context c) { - mContext =c; - } - - private final String PREFERENCES_KEY = "PREFERENCES_KEY"; - - boolean isAllowed(String packagename) { - Set allowedapps = getExtAppList(); - - return allowedapps.contains(packagename); - - } - - public Set getExtAppList() { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - return prefs.getStringSet(PREFERENCES_KEY, new HashSet()); - } - - void addApp(String packagename) - { - Set allowedapps = getExtAppList(); - allowedapps.add(packagename); - saveExtAppList(allowedapps); - } - - private void saveExtAppList( Set allowedapps) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); - Editor prefedit = prefs.edit(); - prefedit.putStringSet(PREFERENCES_KEY, allowedapps); - prefedit.apply(); - } - - public void clearAllApiApps() { - saveExtAppList(new HashSet()); - } - - public void removeApp(String packagename) { - Set allowedapps = getExtAppList(); - allowedapps.remove(packagename); - saveExtAppList(allowedapps); - } - -} diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java deleted file mode 100644 index 784ec72a..00000000 --- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/ExternalOpenVPNService.java +++ /dev/null @@ -1,317 +0,0 @@ -package de.blinkt.openvpn.api; - -import java.io.IOException; -import java.io.StringReader; -import java.lang.ref.WeakReference; -import java.util.LinkedList; -import java.util.List; - -import android.annotation.TargetApi; -import android.app.Service; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.net.VpnService; -import android.os.*; -import se.leap.bitmaskclient.R; -import de.blinkt.openvpn.VpnProfile; -import de.blinkt.openvpn.core.ConfigParser; -import de.blinkt.openvpn.core.ConfigParser.ConfigParseError; -import de.blinkt.openvpn.core.VpnStatus; -import de.blinkt.openvpn.core.VpnStatus.ConnectionStatus; -import de.blinkt.openvpn.core.VpnStatus.StateListener; -import de.blinkt.openvpn.core.OpenVpnService; -import de.blinkt.openvpn.core.OpenVpnService.LocalBinder; -import de.blinkt.openvpn.core.ProfileManager; -import de.blinkt.openvpn.core.VPNLaunchHelper; - -@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) -public class ExternalOpenVPNService extends Service implements StateListener { - - private static final int SEND_TOALL = 0; - - final RemoteCallbackList mCallbacks = - new RemoteCallbackList(); - - private OpenVpnService mService; - private ExternalAppDatabase mExtAppDb; - - - private ServiceConnection mConnection = new ServiceConnection() { - - - @Override - public void onServiceConnected(ComponentName className, - IBinder service) { - // We've bound to LocalService, cast the IBinder and get LocalService instance - LocalBinder binder = (LocalBinder) service; - mService = binder.getService(); - } - - @Override - public void onServiceDisconnected(ComponentName arg0) { - mService = null; - } - - }; - - @Override - public void onCreate() { - super.onCreate(); - VpnStatus.addStateListener(this); - mExtAppDb = new ExternalAppDatabase(this); - - Intent intent = new Intent(getBaseContext(), OpenVpnService.class); - intent.setAction(OpenVpnService.START_SERVICE); - - bindService(intent, mConnection, Context.BIND_AUTO_CREATE); - mHandler.setService(this); - } - - private final IOpenVPNAPIService.Stub mBinder = new IOpenVPNAPIService.Stub() { - - private void checkOpenVPNPermission() throws SecurityRemoteException { - PackageManager pm = getPackageManager(); - - for (String apppackage : mExtAppDb.getExtAppList()) { - ApplicationInfo app; - try { - app = pm.getApplicationInfo(apppackage, 0); - if (Binder.getCallingUid() == app.uid) { - return; - } - } catch (NameNotFoundException e) { - // App not found. Remove it from the list - mExtAppDb.removeApp(apppackage); - } - - } - throw new SecurityException("Unauthorized OpenVPN API Caller"); - } - - @Override - public List getProfiles() throws RemoteException { - checkOpenVPNPermission(); - - ProfileManager pm = ProfileManager.getInstance(getBaseContext()); - - List profiles = new LinkedList(); - - for (VpnProfile vp : pm.getProfiles()) - profiles.add(new APIVpnProfile(vp.getUUIDString(), vp.mName, vp.mUserEditable)); - - return profiles; - } - - @Override - public void startProfile(String profileUUID) throws RemoteException { - checkOpenVPNPermission(); - - Intent shortVPNIntent = new Intent(Intent.ACTION_MAIN); - shortVPNIntent.setClass(getBaseContext(), de.blinkt.openvpn.LaunchVPN.class); - shortVPNIntent.putExtra(de.blinkt.openvpn.LaunchVPN.EXTRA_KEY, profileUUID); - shortVPNIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(shortVPNIntent); - } - - public void startVPN(String inlineconfig) throws RemoteException { - checkOpenVPNPermission(); - - ConfigParser cp = new ConfigParser(); - try { - cp.parseConfig(new StringReader(inlineconfig)); - VpnProfile vp = cp.convertProfile(); - if (vp.checkProfile(getApplicationContext()) != R.string.no_error_found) - throw new RemoteException(getString(vp.checkProfile(getApplicationContext()))); - - - ProfileManager.setTemporaryProfile(vp); - VPNLaunchHelper.startOpenVpn(vp, getBaseContext()); - - - } catch (IOException e) { - throw new RemoteException(e.getMessage()); - } catch (ConfigParseError e) { - throw new RemoteException(e.getMessage()); - } - } - - @Override - public boolean addVPNProfile(String name, String config) throws RemoteException { - checkOpenVPNPermission(); - - ConfigParser cp = new ConfigParser(); - try { - cp.parseConfig(new StringReader(config)); - VpnProfile vp = cp.convertProfile(); - vp.mName = name; - ProfileManager pm = ProfileManager.getInstance(getBaseContext()); - pm.addProfile(vp); - } catch (IOException e) { - VpnStatus.logException(e); - return false; - } catch (ConfigParseError e) { - VpnStatus.logException(e); - return false; - } - - return true; - } - - - @Override - public Intent prepare(String packagename) { - if (new ExternalAppDatabase(ExternalOpenVPNService.this).isAllowed(packagename)) - return null; - - Intent intent = new Intent(); - intent.setClass(ExternalOpenVPNService.this, ConfirmDialog.class); - return intent; - } - - @Override - public Intent prepareVPNService() throws RemoteException { - checkOpenVPNPermission(); - - if (VpnService.prepare(ExternalOpenVPNService.this) == null) - return null; - else - return new Intent(getBaseContext(), GrantPermissionsActivity.class); - } - - - @Override - public void registerStatusCallback(IOpenVPNStatusCallback cb) - throws RemoteException { - checkOpenVPNPermission(); - - if (cb != null) { - cb.newStatus(mMostRecentState.vpnUUID, mMostRecentState.state, - mMostRecentState.logmessage, mMostRecentState.level.name()); - mCallbacks.register(cb); - } - - - } - - @Override - public void unregisterStatusCallback(IOpenVPNStatusCallback cb) - throws RemoteException { - checkOpenVPNPermission(); - - if (cb != null) - mCallbacks.unregister(cb); - } - - @Override - public void disconnect() throws RemoteException { - checkOpenVPNPermission(); - if (mService != null && mService.getManagement() != null) - mService.getManagement().stopVPN(); - } - - @Override - public void pause() throws RemoteException { - checkOpenVPNPermission(); - if (mService != null) - mService.userPause(true); - } - - @Override - public void resume() throws RemoteException { - checkOpenVPNPermission(); - if (mService != null) - mService.userPause(false); - - } - }; - - - private UpdateMessage mMostRecentState; - - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - - @Override - public void onDestroy() { - super.onDestroy(); - mCallbacks.kill(); - unbindService(mConnection); - VpnStatus.removeStateListener(this); - } - - class UpdateMessage { - public String state; - public String logmessage; - public ConnectionStatus level; - public String vpnUUID; - - public UpdateMessage(String state, String logmessage, ConnectionStatus level) { - this.state = state; - this.logmessage = logmessage; - this.level = level; - } - } - - @Override - public void updateState(String state, String logmessage, int resid, ConnectionStatus level) { - mMostRecentState = new UpdateMessage(state, logmessage, level); - if (ProfileManager.getLastConnectedVpn() != null) - mMostRecentState.vpnUUID = ProfileManager.getLastConnectedVpn().getUUIDString(); - - Message msg = mHandler.obtainMessage(SEND_TOALL, mMostRecentState); - msg.sendToTarget(); - - } - - private static final OpenVPNServiceHandler mHandler = new OpenVPNServiceHandler(); - - - static class OpenVPNServiceHandler extends Handler { - WeakReference service = null; - - private void setService(ExternalOpenVPNService eos) { - service = new WeakReference(eos); - } - - @Override - public void handleMessage(Message msg) { - - RemoteCallbackList callbacks; - switch (msg.what) { - case SEND_TOALL: - if (service == null || service.get() == null) - return; - - callbacks = service.get().mCallbacks; - - - // Broadcast to all clients the new value. - final int N = callbacks.beginBroadcast(); - for (int i = 0; i < N; i++) { - try { - sendUpdate(callbacks.getBroadcastItem(i), (UpdateMessage) msg.obj); - } catch (RemoteException e) { - // The RemoteCallbackList will take care of removing - // the dead object for us. - } - } - callbacks.finishBroadcast(); - break; - } - } - - private void sendUpdate(IOpenVPNStatusCallback broadcastItem, - UpdateMessage um) throws RemoteException { - broadcastItem.newStatus(um.vpnUUID, um.state, um.logmessage, um.level.name()); - } - } - - -} \ No newline at end of file diff --git a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java b/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java deleted file mode 100644 index 08d90e3b..00000000 --- a/ics-openvpn-stripped/main/src/main/java/de/blinkt/openvpn/api/SecurityRemoteException.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.blinkt.openvpn.api; - -import android.os.RemoteException; - -public class SecurityRemoteException extends RemoteException { - - /** - * - */ - private static final long serialVersionUID = 1L; - -} diff --git a/ics-openvpn-stripped/main/src/main/res/layout/log_silders.xml b/ics-openvpn-stripped/main/src/main/res/layout/log_silders.xml new file mode 100644 index 00000000..0ecb5daa --- /dev/null +++ b/ics-openvpn-stripped/main/src/main/res/layout/log_silders.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ics-openvpn-stripped/main/src/main/res/layout/vpnstatus.xml b/ics-openvpn-stripped/main/src/main/res/layout/vpnstatus.xml new file mode 100644 index 00000000..eb7c53ee --- /dev/null +++ b/ics-openvpn-stripped/main/src/main/res/layout/vpnstatus.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ics-openvpn-stripped/main/src/main/res/values/dimens.xml b/ics-openvpn-stripped/main/src/main/res/values/dimens.xml new file mode 100644 index 00000000..4f325078 --- /dev/null +++ b/ics-openvpn-stripped/main/src/main/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + 20dp + 8dp + false + + \ No newline at end of file diff --git a/ics-openvpn-stripped/main/src/main/res/values/styles.xml b/ics-openvpn-stripped/main/src/main/res/values/styles.xml new file mode 100644 index 00000000..95e709b3 --- /dev/null +++ b/ics-openvpn-stripped/main/src/main/res/values/styles.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ics-openvpn-stripped/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java b/ics-openvpn-stripped/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java deleted file mode 100644 index a44891ab..00000000 --- a/ics-openvpn-stripped/remoteExample/src/main/java/de/blinkt/openvpn/api/APIVpnProfile.java +++ /dev/null @@ -1,51 +0,0 @@ -package de.blinkt.openvpn.api; - -import android.os.Parcel; -import android.os.Parcelable; - -public class APIVpnProfile implements Parcelable { - - public final String mUUID; - public final String mName; - public final boolean mUserEditable; - - public APIVpnProfile(Parcel in) { - mUUID = in.readString(); - mName = in.readString(); - mUserEditable = in.readInt() != 0; - } - - public APIVpnProfile(String uuidString, String name, boolean userEditable) { - mUUID=uuidString; - mName = name; - mUserEditable=userEditable; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeString(mUUID); - dest.writeString(mName); - if(mUserEditable) - dest.writeInt(0); - else - dest.writeInt(1); - } - - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public APIVpnProfile createFromParcel(Parcel in) { - return new APIVpnProfile(in); - } - - public APIVpnProfile[] newArray(int size) { - return new APIVpnProfile[size]; - } - }; - - -} -- cgit v1.2.3