Java tutorial
/* * Copyright (c) 2012-2016 Arne Schwabe * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt */ package be.blinkt.openvpn.activities; import android.annotation.TargetApi; import android.app.ActionBar; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.RestrictionsManager; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.PowerManager; import android.preference.ListPreference; import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.provider.Settings; import android.support.v4n.view.ViewPager; import android.util.Base64; import android.view.Menu; import android.view.MenuItem; import java.io.Reader; import java.io.StringReader; import java.util.HashSet; import java.util.Set; import be.blinkt.openvpn.R; import be.blinkt.openvpn.VpnProfile; import be.blinkt.openvpn.core.AppConfiguration; import be.blinkt.openvpn.core.ConfigParser; import be.blinkt.openvpn.core.ProfileManager; import be.blinkt.openvpn.fragments.AboutFragment; import be.blinkt.openvpn.fragments.FaqFragment; import be.blinkt.openvpn.fragments.GeneralSettings; import be.blinkt.openvpn.fragments.LogFragment; import be.blinkt.openvpn.fragments.SendDumpFragment; import be.blinkt.openvpn.fragments.VPNProfileList; import be.blinkt.openvpn.views.ScreenSlidePagerAdapter; import be.blinkt.openvpn.views.SlidingTabLayout; import be.blinkt.openvpn.views.TabBarView; public class MainActivity extends BaseActivity { private ViewPager mPager; private ScreenSlidePagerAdapter mPagerAdapter; private SlidingTabLayout mSlidingTabLayout; protected void onCreate(android.os.Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); // Instantiate a ViewPager and a PagerAdapter. mPager = (ViewPager) findViewById(R.id.pager); mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager(), this); /* Toolbar and slider should have the same elevation */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { disableToolbarElevation(); } mPagerAdapter.addTab(R.string.vpn_list_title, VPNProfileList.class); mPagerAdapter.addTab(R.string.generalsettings, GeneralSettings.class); mPagerAdapter.addTab(R.string.faq, FaqFragment.class); if (SendDumpFragment.getLastestDump(this) != null) { mPagerAdapter.addTab(R.string.crashdump, SendDumpFragment.class); } if (isDirectToTV()) mPagerAdapter.addTab(R.string.openvpn_log, LogFragment.class); mPagerAdapter.addTab(R.string.about, AboutFragment.class); mPager.setAdapter(mPagerAdapter); TabBarView tabs = (TabBarView) findViewById(R.id.sliding_tabs); tabs.setViewPager(mPager); // requestDozeDisable(); } private AppConfiguration getManagedConfiguration() { AppConfiguration appConf = new AppConfiguration(); RestrictionsManager myRestrictionsMgr = (RestrictionsManager) this .getSystemService(Context.RESTRICTIONS_SERVICE); Bundle appRestrictions = myRestrictionsMgr.getApplicationRestrictions(); String commonVPNConfiguration = null, userVPNConfiguration = null, allowedApps = null; if (appRestrictions.containsKey("CommonVPNConfiguration")) { commonVPNConfiguration = appRestrictions.getString("CommonVPNConfiguration"); System.out.println("CommonVPNConfiguration: " + commonVPNConfiguration); } if (appRestrictions.containsKey("UserVPNConfiguration")) { userVPNConfiguration = appRestrictions.getString("UserVPNConfiguration"); System.out.println("UserVPNConfiguration: " + userVPNConfiguration); } if (appRestrictions.containsKey("AllowedApps")) { allowedApps = appRestrictions.getString("AllowedApps"); System.out.println("AllowedApps: " + allowedApps); } if (commonVPNConfiguration != null && userVPNConfiguration != null && allowedApps != null) { appConf.setAllowedApps(allowedApps); appConf.setCommonConfiguration(commonVPNConfiguration); appConf.setUserConfiguration(userVPNConfiguration); return appConf; } else return null; } //String profileString64 = "cGVyc2lzdC10dW4KcGVyc2lzdC1rZXkKY2lwaGVyIEFFUy0yNTYtQ0JDCmF1dGggU0hBMQp0bHMtY2xpZW50CmNsaWVudApyZW1vdGUgMTkyLjE2OC4xLjEwMCAxMTk0IHVkcApscG9ydCAwCnZlcmlmeS14NTA5LW5hbWUgIm9wZW52cG4tY2EiIG5hbWUKYXV0aC11c2VyLXBhc3MKbnMtY2VydC10eXBlIHNlcnZlcgoKPGNhPgotLS0tLUJFR0lOIENFU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2ODdiNjM3ZjgxNQpiMWI3MWQxZTRkMDM0MTgyNzliNGQ2Mzk1Y2JiMGFiYwo2MzVhNDFlNWRhMjNhZTdiMTkyMDhmZGQ3MzhjN2JlYwpmZWFkODgyYmI1ZjcwOWUzYzk3NWE2MDJlN2Q4MzNlYQpiNGRiMDdlZjhlODFhN2NiOTIzMmJmMDNjZWU0OTE1YwplMjMxZTg2MTQ1YjJkZGVjNDg2MzNhODFmZDcyMzI0MAo2Yzc2OTU4YzU4MTQwZDk3MjZiMmQ4ODQ5ZWZmOTY4MgphN2EyZTE1Yjc4YTVlZmU4OWI4MWJjYjY4MWI5MzQwMAoxMjE3NzRkODRiZDU3Y2NlYTk1YWQxYTkzMWI0NmNkZQowOTMwMjg4OTE3YzQ2Njc4ODNhOGY0NzNiY2Y3ZGYzOQpjNzAwYTBiNjRhMWRmY2UzNTExYTAwNTE2Mjg0MmU5MAotLS0tLUVORCBPcGVuVlBOIFN0YXRpYyBrZXkgVjEtLS0tLQo8L3Rscy1hdXRoPgoga2V5LWRpcmVjdGlvbiAxCg=="; //String profileString = new String(Base64.decode(profileString64, Base64.DEFAULT)); //Reader reader = new StringReader(profileString); // VpnProfile profile = pm.getProfileByName("afw_vpn"); // // if(profile != null ) { // profile.mAllowedAppsVpnAreDisallowed = false; // profile.mAllowedAppsVpn.add("ua.com.streamsoft.pingtools"); // profile.writeConfigFile(this); // }else{ // System.out.println("Profile doesn't exists, cant update settings"); // // } public void onResume() { super.onResume(); try { AppConfiguration appConf = getManagedConfiguration(); if (appConf != null) { String commonConfStr = new String(Base64.decode(appConf.getCommonConfiguration(), Base64.DEFAULT)); String userConfStr = new String(Base64.decode(appConf.getUserConfiguration(), Base64.DEFAULT)); Reader reader = new StringReader((commonConfStr + userConfStr)); ProfileManager pm = ProfileManager.getInstance(this); if (pm.getProfileByName("afw_vpn") == null) { ConfigParser confParser = new ConfigParser(); confParser.parseConfig(reader); VpnProfile profile = confParser.convertProfile(); //profile.mUsername = "jan"; //profile.mPassword = "jan"; profile.mName = "afw_vpn"; pm.addProfile(profile); profile.mAllowedAppsVpnAreDisallowed = false; String allowedApps = appConf.getAllowedApps(); String[] allowedAppsArray = allowedApps.split(","); for (String allowedApp : allowedAppsArray) profile.mAllowedAppsVpn.add(allowedApp); profile.writeConfigFile(this); } else { System.out.println("Profile already exists, not creating new"); } } else { System.out.println("EMPTY CONF"); } } catch (Exception e) { System.out.println("Exception managed profile: " + e); } } private void editPreferences() { try { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = prefs.edit(); //Set<String> s = new HashSet<String>(); //s.add(profile.getName()); //editor.putString("alwaysOnVpn", "afw_vpn"); // editor.putStringSet("alwaysOnVpn", s); editor.putBoolean("restartvpnonboot", true); editor.apply(); } catch (Exception e) { System.out.println("Exception managed profile, edit prefs: " + e); } } @TargetApi(Build.VERSION_CODES.M) private void requestDozeDisable() { Intent intent = new Intent(); String packageName = getPackageName(); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); else { intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); } startActivity(intent); } private static final String FEATURE_TELEVISION = "android.hardware.type.television"; private static final String FEATURE_LEANBACK = "android.software.leanback"; private boolean isDirectToTV() { return (getPackageManager().hasSystemFeature(FEATURE_TELEVISION) || getPackageManager().hasSystemFeature(FEATURE_LEANBACK)); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void disableToolbarElevation() { ActionBar toolbar = getActionBar(); toolbar.setElevation(0); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_menu, menu); return super.onCreateOptionsMenu(menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.show_log) { Intent showLog = new Intent(this, LogWindow.class); startActivity(showLog); } return super.onOptionsItemSelected(item); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); System.out.println(data); } }