android: Remove unnecessary API checks
The minSdkVersion is 21, remove unnecessary checks and code that target older API versions.
This commit is contained in:
committed by
Tobias Brunner
parent
5d192246e8
commit
a3e895b4d8
+11
-14
@@ -101,11 +101,12 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
private volatile boolean mTerminate;
|
private volatile boolean mTerminate;
|
||||||
private volatile boolean mIsDisconnecting;
|
private volatile boolean mIsDisconnecting;
|
||||||
private volatile boolean mShowNotification;
|
private volatile boolean mShowNotification;
|
||||||
private BuilderAdapter mBuilderAdapter = new BuilderAdapter();
|
private final BuilderAdapter mBuilderAdapter = new BuilderAdapter();
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private VpnStateService mService;
|
private VpnStateService mService;
|
||||||
private final Object mServiceLock = new Object();
|
private final Object mServiceLock = new Object();
|
||||||
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
private final ServiceConnection mServiceConnection = new ServiceConnection()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name)
|
public void onServiceDisconnected(ComponentName name)
|
||||||
{ /* since the service is local this is theoretically only called when the process is terminated */
|
{ /* since the service is local this is theoretically only called when the process is terminated */
|
||||||
@@ -346,7 +347,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
{
|
{
|
||||||
synchronized (this)
|
synchronized (this)
|
||||||
{
|
{
|
||||||
if (mNextProfile != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
if (mNextProfile != null)
|
||||||
{
|
{
|
||||||
mBuilderAdapter.setProfile(mNextProfile);
|
mBuilderAdapter.setProfile(mNextProfile);
|
||||||
mBuilderAdapter.establishBlocking();
|
mBuilderAdapter.establishBlocking();
|
||||||
@@ -527,7 +528,8 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged() {
|
public void stateChanged()
|
||||||
|
{
|
||||||
if (mShowNotification)
|
if (mShowNotification)
|
||||||
{
|
{
|
||||||
NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
@@ -813,7 +815,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
private VpnService.Builder mBuilder;
|
private VpnService.Builder mBuilder;
|
||||||
private BuilderCache mCache;
|
private BuilderCache mCache;
|
||||||
private BuilderCache mEstablishedCache;
|
private BuilderCache mEstablishedCache;
|
||||||
private PacketDropper mDropper = new PacketDropper();
|
private final PacketDropper mDropper = new PacketDropper();
|
||||||
|
|
||||||
public synchronized void setProfile(VpnProfile profile)
|
public synchronized void setProfile(VpnProfile profile)
|
||||||
{
|
{
|
||||||
@@ -1277,7 +1279,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
else
|
||||||
{ /* allow traffic that would otherwise be blocked to bypass the VPN */
|
{ /* allow traffic that would otherwise be blocked to bypass the VPN */
|
||||||
builder.allowFamily(OsConstants.AF_INET);
|
builder.allowFamily(OsConstants.AF_INET);
|
||||||
}
|
}
|
||||||
@@ -1317,7 +1319,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
else
|
||||||
{
|
{
|
||||||
builder.allowFamily(OsConstants.AF_INET6);
|
builder.allowFamily(OsConstants.AF_INET6);
|
||||||
}
|
}
|
||||||
@@ -1327,8 +1329,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
builder.addRoute("::", 0);
|
builder.addRoute("::", 0);
|
||||||
}
|
}
|
||||||
/* apply selected applications */
|
/* apply selected applications */
|
||||||
if (mSelectedApps.size() > 0 &&
|
if (mSelectedApps.size() > 0)
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
|
||||||
{
|
{
|
||||||
switch (mAppHandling)
|
switch (mAppHandling)
|
||||||
{
|
{
|
||||||
@@ -1372,11 +1373,7 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (addr instanceof Inet6Address)
|
return addr instanceof Inet6Address;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-25
@@ -16,20 +16,18 @@
|
|||||||
|
|
||||||
package org.strongswan.android.logic;
|
package org.strongswan.android.logic;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import org.strongswan.android.security.LocalCertificateKeyStoreProvider;
|
||||||
|
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import org.strongswan.android.security.LocalCertificateKeyStoreProvider;
|
|
||||||
import org.strongswan.android.ui.MainActivity;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
|
|
||||||
import androidx.core.os.HandlerCompat;
|
import androidx.core.os.HandlerCompat;
|
||||||
|
|
||||||
public class StrongSwanApplication extends Application
|
public class StrongSwanApplication extends Application
|
||||||
@@ -38,7 +36,8 @@ public class StrongSwanApplication extends Application
|
|||||||
private final ExecutorService mExecutorService = Executors.newFixedThreadPool(4);
|
private final ExecutorService mExecutorService = Executors.newFixedThreadPool(4);
|
||||||
private final Handler mMainHandler = HandlerCompat.createAsync(Looper.getMainLooper());
|
private final Handler mMainHandler = HandlerCompat.createAsync(Looper.getMainLooper());
|
||||||
|
|
||||||
static {
|
static
|
||||||
|
{
|
||||||
Security.addProvider(new LocalCertificateKeyStoreProvider());
|
Security.addProvider(new LocalCertificateKeyStoreProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +50,7 @@ public class StrongSwanApplication extends Application
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current application context
|
* Returns the current application context
|
||||||
|
*
|
||||||
* @return context
|
* @return context
|
||||||
*/
|
*/
|
||||||
public static Context getContext()
|
public static Context getContext()
|
||||||
@@ -60,6 +60,7 @@ public class StrongSwanApplication extends Application
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a thread pool to run tasks in separate threads
|
* Returns a thread pool to run tasks in separate threads
|
||||||
|
*
|
||||||
* @return thread pool
|
* @return thread pool
|
||||||
*/
|
*/
|
||||||
public Executor getExecutor()
|
public Executor getExecutor()
|
||||||
@@ -69,6 +70,7 @@ public class StrongSwanApplication extends Application
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a handler to execute stuff by the main thread.
|
* Returns a handler to execute stuff by the main thread.
|
||||||
|
*
|
||||||
* @return handler
|
* @return handler
|
||||||
*/
|
*/
|
||||||
public Handler getHandler()
|
public Handler getHandler()
|
||||||
@@ -82,21 +84,6 @@ public class StrongSwanApplication extends Application
|
|||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
|
|
||||||
{
|
|
||||||
System.loadLibrary("strongswan");
|
|
||||||
|
|
||||||
if (MainActivity.USE_BYOD)
|
|
||||||
{
|
|
||||||
System.loadLibrary("tpmtss");
|
|
||||||
System.loadLibrary("tncif");
|
|
||||||
System.loadLibrary("tnccs");
|
|
||||||
System.loadLibrary("imcv");
|
|
||||||
}
|
|
||||||
|
|
||||||
System.loadLibrary("charon");
|
|
||||||
System.loadLibrary("ipsec");
|
|
||||||
}
|
|
||||||
System.loadLibrary("androidbridge");
|
System.loadLibrary("androidbridge");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ package org.strongswan.android.ui;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.format.Formatter;
|
import android.text.format.Formatter;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -82,16 +81,6 @@ public class MainActivity extends AppCompatActivity implements OnVpnProfileSelec
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareOptionsMenu(Menu menu)
|
|
||||||
{
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|
|
||||||
{
|
|
||||||
menu.removeItem(R.id.menu_import_profile);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item)
|
public boolean onOptionsItemSelected(MenuItem item)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-2
@@ -78,7 +78,7 @@ public class TrustedCertificateImportActivity extends AppCompatActivity
|
|||||||
{
|
{
|
||||||
importCertificate(intent.getData());
|
importCertificate(intent.getData());
|
||||||
}
|
}
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
else
|
||||||
{
|
{
|
||||||
Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
openIntent.setType("*/*");
|
openIntent.setType("*/*");
|
||||||
@@ -89,7 +89,6 @@ public class TrustedCertificateImportActivity extends AppCompatActivity
|
|||||||
catch (ActivityNotFoundException e)
|
catch (ActivityNotFoundException e)
|
||||||
{ /* some devices are unable to browse for files */
|
{ /* some devices are unable to browse for files */
|
||||||
finish();
|
finish();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-14
@@ -17,7 +17,6 @@
|
|||||||
package org.strongswan.android.ui;
|
package org.strongswan.android.ui;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@@ -73,10 +72,10 @@ public class TrustedCertificatesActivity extends AppCompatActivity implements Tr
|
|||||||
|
|
||||||
mAdapter = new TrustedCertificatesPagerAdapter(this);
|
mAdapter = new TrustedCertificatesPagerAdapter(this);
|
||||||
|
|
||||||
mPager = (ViewPager2)findViewById(R.id.viewpager);
|
mPager = findViewById(R.id.viewpager);
|
||||||
mPager.setAdapter(mAdapter);
|
mPager.setAdapter(mAdapter);
|
||||||
|
|
||||||
TabLayout tabs = (TabLayout)findViewById(R.id.tabs);
|
TabLayout tabs = findViewById(R.id.tabs);
|
||||||
new TabLayoutMediator(tabs, mPager, (tab, position) -> {
|
new TabLayoutMediator(tabs, mPager, (tab, position) -> {
|
||||||
tab.setText(mAdapter.getTitle(position));
|
tab.setText(mAdapter.getTitle(position));
|
||||||
}).attach();
|
}).attach();
|
||||||
@@ -91,16 +90,6 @@ public class TrustedCertificatesActivity extends AppCompatActivity implements Tr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPrepareOptionsMenu(Menu menu)
|
|
||||||
{
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
|
|
||||||
{
|
|
||||||
menu.removeItem(R.id.menu_import_certificate);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item)
|
public boolean onOptionsItemSelected(MenuItem item)
|
||||||
{
|
{
|
||||||
@@ -164,7 +153,7 @@ public class TrustedCertificatesActivity extends AppCompatActivity implements Tr
|
|||||||
|
|
||||||
public static class TrustedCertificatesPagerAdapter extends FragmentStateAdapter
|
public static class TrustedCertificatesPagerAdapter extends FragmentStateAdapter
|
||||||
{
|
{
|
||||||
private TrustedCertificatesTab mTabs[];
|
private final TrustedCertificatesTab[] mTabs;
|
||||||
|
|
||||||
public TrustedCertificatesPagerAdapter(@NonNull FragmentActivity fragmentActivity)
|
public TrustedCertificatesPagerAdapter(@NonNull FragmentActivity fragmentActivity)
|
||||||
{
|
{
|
||||||
|
|||||||
+63
-59
@@ -22,7 +22,6 @@ import android.app.Dialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.security.KeyChain;
|
import android.security.KeyChain;
|
||||||
@@ -44,7 +43,6 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.AdapterView.OnItemSelectedListener;
|
import android.widget.AdapterView.OnItemSelectedListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
@@ -195,64 +193,64 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
|
|
||||||
setContentView(R.layout.profile_detail_view);
|
setContentView(R.layout.profile_detail_view);
|
||||||
|
|
||||||
mName = (MultiAutoCompleteTextView)findViewById(R.id.name);
|
mName = findViewById(R.id.name);
|
||||||
mNameWrap = (TextInputLayoutHelper)findViewById(R.id.name_wrap);
|
mNameWrap = findViewById(R.id.name_wrap);
|
||||||
mGateway = (EditText)findViewById(R.id.gateway);
|
mGateway = findViewById(R.id.gateway);
|
||||||
mGatewayWrap = (TextInputLayoutHelper) findViewById(R.id.gateway_wrap);
|
mGatewayWrap = findViewById(R.id.gateway_wrap);
|
||||||
mSelectVpnType = (Spinner)findViewById(R.id.vpn_type);
|
mSelectVpnType = findViewById(R.id.vpn_type);
|
||||||
mTncNotice = (RelativeLayout)findViewById(R.id.tnc_notice);
|
mTncNotice = findViewById(R.id.tnc_notice);
|
||||||
|
|
||||||
mUsernamePassword = (ViewGroup)findViewById(R.id.username_password_group);
|
mUsernamePassword = findViewById(R.id.username_password_group);
|
||||||
mUsername = (EditText)findViewById(R.id.username);
|
mUsername = findViewById(R.id.username);
|
||||||
mUsernameWrap = (TextInputLayoutHelper) findViewById(R.id.username_wrap);
|
mUsernameWrap = findViewById(R.id.username_wrap);
|
||||||
mPassword = (EditText)findViewById(R.id.password);
|
mPassword = findViewById(R.id.password);
|
||||||
|
|
||||||
mUserCertificate = (ViewGroup)findViewById(R.id.user_certificate_group);
|
mUserCertificate = findViewById(R.id.user_certificate_group);
|
||||||
mSelectUserCert = (RelativeLayout)findViewById(R.id.select_user_certificate);
|
mSelectUserCert = findViewById(R.id.select_user_certificate);
|
||||||
|
|
||||||
mCheckAuto = (CheckBox)findViewById(R.id.ca_auto);
|
mCheckAuto = findViewById(R.id.ca_auto);
|
||||||
mSelectCert = (RelativeLayout)findViewById(R.id.select_certificate);
|
mSelectCert = findViewById(R.id.select_certificate);
|
||||||
|
|
||||||
mShowAdvanced = (CheckBox)findViewById(R.id.show_advanced);
|
mShowAdvanced = findViewById(R.id.show_advanced);
|
||||||
mAdvancedSettings = (ViewGroup)findViewById(R.id.advanced_settings);
|
mAdvancedSettings = findViewById(R.id.advanced_settings);
|
||||||
|
|
||||||
mRemoteId = (MultiAutoCompleteTextView)findViewById(R.id.remote_id);
|
mRemoteId = findViewById(R.id.remote_id);
|
||||||
mRemoteIdWrap = (TextInputLayoutHelper) findViewById(R.id.remote_id_wrap);
|
mRemoteIdWrap = findViewById(R.id.remote_id_wrap);
|
||||||
mLocalId = findViewById(R.id.local_id);
|
mLocalId = findViewById(R.id.local_id);
|
||||||
mLocalIdWrap = findViewById(R.id.local_id_wrap);
|
mLocalIdWrap = findViewById(R.id.local_id_wrap);
|
||||||
mDnsServers = findViewById(R.id.dns_servers);
|
mDnsServers = findViewById(R.id.dns_servers);
|
||||||
mDnsServersWrap = findViewById(R.id.dns_servers_wrap);
|
mDnsServersWrap = findViewById(R.id.dns_servers_wrap);
|
||||||
mMTU = (EditText)findViewById(R.id.mtu);
|
mMTU = findViewById(R.id.mtu);
|
||||||
mMTUWrap = (TextInputLayoutHelper) findViewById(R.id.mtu_wrap);
|
mMTUWrap = findViewById(R.id.mtu_wrap);
|
||||||
mPort = (EditText)findViewById(R.id.port);
|
mPort = findViewById(R.id.port);
|
||||||
mPortWrap = (TextInputLayoutHelper) findViewById(R.id.port_wrap);
|
mPortWrap = findViewById(R.id.port_wrap);
|
||||||
mNATKeepalive = (EditText)findViewById(R.id.nat_keepalive);
|
mNATKeepalive = findViewById(R.id.nat_keepalive);
|
||||||
mNATKeepaliveWrap = (TextInputLayoutHelper) findViewById(R.id.nat_keepalive_wrap);
|
mNATKeepaliveWrap = findViewById(R.id.nat_keepalive_wrap);
|
||||||
mCertReq = findViewById(R.id.cert_req);
|
mCertReq = findViewById(R.id.cert_req);
|
||||||
mUseCrl = findViewById(R.id.use_crl);
|
mUseCrl = findViewById(R.id.use_crl);
|
||||||
mUseOcsp = findViewById(R.id.use_ocsp);
|
mUseOcsp = findViewById(R.id.use_ocsp);
|
||||||
mStrictRevocation = findViewById(R.id.strict_revocation);
|
mStrictRevocation = findViewById(R.id.strict_revocation);
|
||||||
mRsaPss = findViewById(R.id.rsa_pss);
|
mRsaPss = findViewById(R.id.rsa_pss);
|
||||||
mIPv6Transport = findViewById(R.id.ipv6_transport);
|
mIPv6Transport = findViewById(R.id.ipv6_transport);
|
||||||
mIncludedSubnets = (EditText)findViewById(R.id.included_subnets);
|
mIncludedSubnets = findViewById(R.id.included_subnets);
|
||||||
mIncludedSubnetsWrap = (TextInputLayoutHelper)findViewById(R.id.included_subnets_wrap);
|
mIncludedSubnetsWrap = findViewById(R.id.included_subnets_wrap);
|
||||||
mExcludedSubnets = (EditText)findViewById(R.id.excluded_subnets);
|
mExcludedSubnets = findViewById(R.id.excluded_subnets);
|
||||||
mExcludedSubnetsWrap = (TextInputLayoutHelper)findViewById(R.id.excluded_subnets_wrap);
|
mExcludedSubnetsWrap = findViewById(R.id.excluded_subnets_wrap);
|
||||||
mBlockIPv4 = (CheckBox)findViewById(R.id.split_tunneling_v4);
|
mBlockIPv4 = findViewById(R.id.split_tunneling_v4);
|
||||||
mBlockIPv6 = (CheckBox)findViewById(R.id.split_tunneling_v6);
|
mBlockIPv6 = findViewById(R.id.split_tunneling_v6);
|
||||||
|
|
||||||
mSelectSelectedAppsHandling = (Spinner)findViewById(R.id.apps_handling);
|
mSelectSelectedAppsHandling = findViewById(R.id.apps_handling);
|
||||||
mSelectApps = (RelativeLayout)findViewById(R.id.select_applications);
|
mSelectApps = findViewById(R.id.select_applications);
|
||||||
|
|
||||||
mIkeProposal = (EditText)findViewById(R.id.ike_proposal);
|
mIkeProposal = findViewById(R.id.ike_proposal);
|
||||||
mIkeProposalWrap = (TextInputLayoutHelper)findViewById(R.id.ike_proposal_wrap);
|
mIkeProposalWrap = findViewById(R.id.ike_proposal_wrap);
|
||||||
mEspProposal = (EditText)findViewById(R.id.esp_proposal);
|
mEspProposal = findViewById(R.id.esp_proposal);
|
||||||
mEspProposalWrap = (TextInputLayoutHelper)findViewById(R.id.esp_proposal_wrap);
|
mEspProposalWrap = findViewById(R.id.esp_proposal_wrap);
|
||||||
/* make the link clickable */
|
/* make the link clickable */
|
||||||
((TextView)findViewById(R.id.proposal_intro)).setMovementMethod(LinkMovementMethod.getInstance());
|
((TextView)findViewById(R.id.proposal_intro)).setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
|
||||||
mProfileIdLabel = (TextView)findViewById(R.id.profile_id_label);
|
mProfileIdLabel = findViewById(R.id.profile_id_label);
|
||||||
mProfileId = (TextView)findViewById(R.id.profile_id);
|
mProfileId = findViewById(R.id.profile_id);
|
||||||
|
|
||||||
final SpaceTokenizer spaceTokenizer = new SpaceTokenizer();
|
final SpaceTokenizer spaceTokenizer = new SpaceTokenizer();
|
||||||
mName.setTokenizer(spaceTokenizer);
|
mName.setTokenizer(spaceTokenizer);
|
||||||
@@ -262,14 +260,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
mName.setAdapter(gatewayAdapter);
|
mName.setAdapter(gatewayAdapter);
|
||||||
mRemoteId.setAdapter(gatewayAdapter);
|
mRemoteId.setAdapter(gatewayAdapter);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
mGateway.addTextChangedListener(new TextWatcher()
|
||||||
{
|
{
|
||||||
findViewById(R.id.apps).setVisibility(View.GONE);
|
|
||||||
mSelectSelectedAppsHandling.setVisibility(View.GONE);
|
|
||||||
mSelectApps.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
mGateway.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
|
||||||
@@ -294,7 +286,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener() {
|
mSelectVpnType.setOnItemSelectedListener(new OnItemSelectedListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
@@ -312,7 +305,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
|
|
||||||
((TextView)mTncNotice.findViewById(android.R.id.text1)).setText(R.string.tnc_notice_title);
|
((TextView)mTncNotice.findViewById(android.R.id.text1)).setText(R.string.tnc_notice_title);
|
||||||
((TextView)mTncNotice.findViewById(android.R.id.text2)).setText(R.string.tnc_notice_subtitle);
|
((TextView)mTncNotice.findViewById(android.R.id.text2)).setText(R.string.tnc_notice_subtitle);
|
||||||
mTncNotice.setOnClickListener(new OnClickListener() {
|
mTncNotice.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
@@ -321,14 +315,15 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
});
|
});
|
||||||
|
|
||||||
mSelectUserCert.setOnClickListener(new SelectUserCertOnClickListener());
|
mSelectUserCert.setOnClickListener(new SelectUserCertOnClickListener());
|
||||||
((Button)findViewById(R.id.install_user_certificate)).setOnClickListener(v -> {
|
findViewById(R.id.install_user_certificate).setOnClickListener(v -> {
|
||||||
Intent intent = KeyChain.createInstallIntent();
|
Intent intent = KeyChain.createInstallIntent();
|
||||||
mInstallPKCS12.launch(intent);
|
mInstallPKCS12.launch(intent);
|
||||||
});
|
});
|
||||||
mSelectUserIdAdapter = new CertificateIdentitiesAdapter(this);
|
mSelectUserIdAdapter = new CertificateIdentitiesAdapter(this);
|
||||||
mLocalId.setAdapter(mSelectUserIdAdapter);
|
mLocalId.setAdapter(mSelectUserIdAdapter);
|
||||||
|
|
||||||
mCheckAuto.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mCheckAuto.setOnCheckedChangeListener(new OnCheckedChangeListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||||
{
|
{
|
||||||
@@ -336,7 +331,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mSelectCert.setOnClickListener(new OnClickListener() {
|
mSelectCert.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
@@ -346,7 +342,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mShowAdvanced.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
mShowAdvanced.setOnCheckedChangeListener(new OnCheckedChangeListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||||
{
|
{
|
||||||
@@ -354,7 +351,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mSelectSelectedAppsHandling.setOnItemSelectedListener(new OnItemSelectedListener() {
|
mSelectSelectedAppsHandling.setOnItemSelectedListener(new OnItemSelectedListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
@@ -370,7 +368,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mSelectApps.setOnClickListener(new OnClickListener() {
|
mSelectApps.setOnClickListener(new OnClickListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
@@ -489,7 +488,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
AlertDialog.Builder adb = new AlertDialog.Builder(VpnProfileDetailActivity.this);
|
AlertDialog.Builder adb = new AlertDialog.Builder(VpnProfileDetailActivity.this);
|
||||||
adb.setTitle(R.string.alert_text_nocertfound_title);
|
adb.setTitle(R.string.alert_text_nocertfound_title);
|
||||||
adb.setMessage(R.string.alert_text_nocertfound);
|
adb.setMessage(R.string.alert_text_nocertfound);
|
||||||
adb.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
adb.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id)
|
public void onClick(DialogInterface dialog, int id)
|
||||||
{
|
{
|
||||||
@@ -624,6 +624,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the user input and display error messages.
|
* Verify the user input and display error messages.
|
||||||
|
*
|
||||||
* @return true if the input is valid
|
* @return true if the input is valid
|
||||||
*/
|
*/
|
||||||
private boolean verifyInput()
|
private boolean verifyInput()
|
||||||
@@ -969,7 +970,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
{
|
{
|
||||||
final X509Certificate[] chain = KeyChain.getCertificateChain(VpnProfileDetailActivity.this, alias);
|
final X509Certificate[] chain = KeyChain.getCertificateChain(VpnProfileDetailActivity.this, alias);
|
||||||
/* alias() is not called from our main thread */
|
/* alias() is not called from our main thread */
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
@@ -992,7 +994,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
/**
|
/**
|
||||||
* Callback interface for the user certificate loader.
|
* Callback interface for the user certificate loader.
|
||||||
*/
|
*/
|
||||||
private interface UserCertificateLoaderCallback {
|
private interface UserCertificateLoaderCallback
|
||||||
|
{
|
||||||
void onComplete(X509Certificate result);
|
void onComplete(X509Certificate result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1050,7 +1053,8 @@ public class VpnProfileDetailActivity extends AppCompatActivity
|
|||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
.setTitle(R.string.tnc_notice_title)
|
.setTitle(R.string.tnc_notice_title)
|
||||||
.setMessage(HtmlCompat.fromHtml(getString(R.string.tnc_notice_details), HtmlCompat.FROM_HTML_MODE_LEGACY))
|
.setMessage(HtmlCompat.fromHtml(getString(R.string.tnc_notice_details), HtmlCompat.FROM_HTML_MODE_LEGACY))
|
||||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id)
|
public void onClick(DialogInterface dialog, int id)
|
||||||
{
|
{
|
||||||
|
|||||||
+25
-23
@@ -21,7 +21,6 @@ import android.content.ContentResolver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.security.KeyChain;
|
import android.security.KeyChain;
|
||||||
import android.security.KeyChainAliasCallback;
|
import android.security.KeyChainAliasCallback;
|
||||||
@@ -135,12 +134,12 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
private LoaderManager.LoaderCallbacks<ProfileLoadResult> mProfileLoaderCallbacks = new LoaderManager.LoaderCallbacks<ProfileLoadResult>()
|
private final LoaderManager.LoaderCallbacks<ProfileLoadResult> mProfileLoaderCallbacks = new LoaderManager.LoaderCallbacks<ProfileLoadResult>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Loader<ProfileLoadResult> onCreateLoader(int id, Bundle args)
|
public Loader<ProfileLoadResult> onCreateLoader(int id, Bundle args)
|
||||||
{
|
{
|
||||||
return new ProfileLoader(VpnProfileImportActivity.this, (Uri)args.getParcelable(PROFILE_URI));
|
return new ProfileLoader(VpnProfileImportActivity.this, args.getParcelable(PROFILE_URI));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -156,7 +155,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private LoaderManager.LoaderCallbacks<TrustedCertificateEntry> mUserCertificateLoaderCallbacks = new LoaderManager.LoaderCallbacks<TrustedCertificateEntry>()
|
private final LoaderManager.LoaderCallbacks<TrustedCertificateEntry> mUserCertificateLoaderCallbacks = new LoaderManager.LoaderCallbacks<TrustedCertificateEntry>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Loader<TrustedCertificateEntry> onCreateLoader(int id, Bundle args)
|
public Loader<TrustedCertificateEntry> onCreateLoader(int id, Bundle args)
|
||||||
@@ -191,23 +190,23 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
setContentView(R.layout.profile_import_view);
|
setContentView(R.layout.profile_import_view);
|
||||||
|
|
||||||
mProgressBar = findViewById(R.id.progress_bar);
|
mProgressBar = findViewById(R.id.progress_bar);
|
||||||
mExistsWarning = (TextView)findViewById(R.id.exists_warning);
|
mExistsWarning = findViewById(R.id.exists_warning);
|
||||||
mBasicDataGroup = (ViewGroup)findViewById(R.id.basic_data_group);
|
mBasicDataGroup = findViewById(R.id.basic_data_group);
|
||||||
mName = (TextView)findViewById(R.id.name);
|
mName = findViewById(R.id.name);
|
||||||
mGateway = (TextView)findViewById(R.id.gateway);
|
mGateway = findViewById(R.id.gateway);
|
||||||
mSelectVpnType = (TextView)findViewById(R.id.vpn_type);
|
mSelectVpnType = findViewById(R.id.vpn_type);
|
||||||
|
|
||||||
mUsernamePassword = (ViewGroup)findViewById(R.id.username_password_group);
|
mUsernamePassword = findViewById(R.id.username_password_group);
|
||||||
mUsername = (EditText)findViewById(R.id.username);
|
mUsername = findViewById(R.id.username);
|
||||||
mUsernameWrap = (TextInputLayoutHelper) findViewById(R.id.username_wrap);
|
mUsernameWrap = findViewById(R.id.username_wrap);
|
||||||
mPassword = (EditText)findViewById(R.id.password);
|
mPassword = findViewById(R.id.password);
|
||||||
|
|
||||||
mUserCertificate = (ViewGroup)findViewById(R.id.user_certificate_group);
|
mUserCertificate = findViewById(R.id.user_certificate_group);
|
||||||
mSelectUserCert = (RelativeLayout)findViewById(R.id.select_user_certificate);
|
mSelectUserCert = findViewById(R.id.select_user_certificate);
|
||||||
mImportUserCert = (Button)findViewById(R.id.import_user_certificate);
|
mImportUserCert = findViewById(R.id.import_user_certificate);
|
||||||
|
|
||||||
mRemoteCertificate = (ViewGroup)findViewById(R.id.remote_certificate_group);
|
mRemoteCertificate = findViewById(R.id.remote_certificate_group);
|
||||||
mRemoteCert = (RelativeLayout)findViewById(R.id.remote_certificate);
|
mRemoteCert = findViewById(R.id.remote_certificate);
|
||||||
|
|
||||||
mExistsWarning.setVisibility(View.GONE);
|
mExistsWarning.setVisibility(View.GONE);
|
||||||
mBasicDataGroup.setVisibility(View.GONE);
|
mBasicDataGroup.setVisibility(View.GONE);
|
||||||
@@ -216,7 +215,8 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
mRemoteCertificate.setVisibility(View.GONE);
|
mRemoteCertificate.setVisibility(View.GONE);
|
||||||
|
|
||||||
mSelectUserCert.setOnClickListener(new SelectUserCertOnClickListener());
|
mSelectUserCert.setOnClickListener(new SelectUserCertOnClickListener());
|
||||||
mImportUserCert.setOnClickListener(new View.OnClickListener() {
|
mImportUserCert.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
@@ -233,7 +233,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
{
|
{
|
||||||
loadProfile(getIntent().getData());
|
loadProfile(getIntent().getData());
|
||||||
}
|
}
|
||||||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
else
|
||||||
{
|
{
|
||||||
Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
openIntent.setType("*/*");
|
openIntent.setType("*/*");
|
||||||
@@ -535,9 +535,9 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
if (split != null)
|
if (split != null)
|
||||||
{
|
{
|
||||||
String included = getSubnets(split, "subnets");
|
String included = getSubnets(split, "subnets");
|
||||||
profile.setIncludedSubnets(included != null ? included : null);
|
profile.setIncludedSubnets(included);
|
||||||
String excluded = getSubnets(split, "excluded");
|
String excluded = getSubnets(split, "excluded");
|
||||||
profile.setExcludedSubnets(excluded != null ? excluded : null);
|
profile.setExcludedSubnets(excluded);
|
||||||
int st = 0;
|
int st = 0;
|
||||||
st |= split.optBoolean("block-ipv4") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4 : 0;
|
st |= split.optBoolean("block-ipv4") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV4 : 0;
|
||||||
st |= split.optBoolean("block-ipv6") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6 : 0;
|
st |= split.optBoolean("block-ipv6") ? VpnProfile.SPLIT_TUNNELING_BLOCK_IPV6 : 0;
|
||||||
@@ -710,6 +710,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify the user input and display error messages.
|
* Verify the user input and display error messages.
|
||||||
|
*
|
||||||
* @return true if the input is valid
|
* @return true if the input is valid
|
||||||
*/
|
*/
|
||||||
private boolean verifyInput()
|
private boolean verifyInput()
|
||||||
@@ -899,7 +900,8 @@ public class VpnProfileImportActivity extends AppCompatActivity
|
|||||||
public void alias(final String alias)
|
public void alias(final String alias)
|
||||||
{
|
{
|
||||||
/* alias() is not called from our main thread */
|
/* alias() is not called from our main thread */
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable()
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user