├── .gitignore ├── README.md ├── app ├── .gitignore ├── build.gradle ├── libs │ └── microlog4android-1.0.0.jar ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── assets │ └── microlog.properties │ ├── java │ ├── com │ │ └── xinli │ │ │ └── portalclient │ │ │ ├── BaseActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── MySurfaceView.java │ │ │ ├── SetAccountActivity.java │ │ │ ├── SucessActivity.java │ │ │ ├── WELCOMEActivity.java │ │ │ ├── WifiManagerUtil.java │ │ │ ├── model │ │ │ ├── RequestModel.java │ │ │ ├── ReturnMessage.java │ │ │ ├── TouchPoint.java │ │ │ └── UpdataInfo.java │ │ │ ├── service │ │ │ └── OnlineHeartService.java │ │ │ └── util │ │ │ ├── AESByKey.java │ │ │ ├── BitmapUtils.java │ │ │ ├── Config.java │ │ │ ├── HttpUtils.java │ │ │ ├── MD5Builder.java │ │ │ ├── MessageContext.java │ │ │ ├── PrefUtils.java │ │ │ ├── Sim_NetKeeperClient.java │ │ │ ├── SocketClientUDP.java │ │ │ ├── ThreeDes.java │ │ │ └── WifiUtil.java │ └── edu │ │ └── util │ │ └── Secret.java │ └── res │ ├── drawable-hdpi │ ├── account_setting.png │ ├── android.png │ ├── face.jpg │ ├── gesture_default.png │ ├── ic_launcher_title.png │ ├── input_bg.xml │ ├── input_normal.png │ ├── input_over.png │ ├── loginok.png │ ├── titlebar_style.xml │ ├── tk.jpg │ ├── usertitle.png │ ├── verify_button.png │ ├── verify_sel_button.png │ ├── welcomepic.png │ └── xicon.png │ ├── drawable-ldpi │ ├── account_del.png │ └── account_edit.png │ ├── drawable-mdpi │ ├── account_add.png │ ├── account_add_down.png │ ├── back.png │ ├── button2.png │ ├── button2_down.png │ ├── button2_over.png │ ├── default_bg.png │ ├── exit.png │ ├── exit_down.png │ ├── login_back.9.png │ ├── login_input.9.png │ ├── loginok.png │ ├── logo.png │ ├── logout.png │ ├── logout_down.png │ ├── more_select.xml │ ├── qq_edit_login.xml │ ├── refresh.png │ ├── refresh_down.png │ ├── returnbutton.png │ ├── returnbutton_down.png │ ├── time.png │ ├── titlelogo.png │ ├── user_select.png │ ├── userbk.png │ ├── usermbk.png │ ├── usermbk_down.png │ └── usertitle.png │ ├── drawable-xhdpi │ ├── account.png │ ├── loginok.png │ ├── loginoktop.png │ ├── logo.png │ ├── starting.png │ └── usertitle.png │ ├── drawable │ ├── btn_bg_style.xml │ └── shape.xml │ ├── layout │ ├── activity_main.xml │ ├── add_account.xml │ ├── dialoglayout.xml │ ├── dropdown_item.xml │ ├── setting_account.xml │ ├── success.xml │ ├── success_gansu.xml │ ├── test.xml │ └── welcome.xml │ ├── menu │ └── main.xml │ ├── values-sw720dp-land │ └── dimens.xml │ ├── values-v11 │ └── styles.xml │ ├── values-v14 │ └── styles.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── drawables.xml │ ├── ids.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── build └── intermediates │ └── model_data.bin ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Eclipse project files 19 | .classpath 20 | .project 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Intellij project files 26 | *.iml 27 | *.ipr 28 | *.iws 29 | .idea/ 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-netkeeper 2 | android-netkeeper 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 21 10 | versionCode 1 11 | //DO NOT change the verison! 12 | versionName "1.0.7" 13 | } 14 | 15 | compileOptions { 16 | sourceCompatibility JavaVersion.VERSION_1_7 17 | targetCompatibility JavaVersion.VERSION_1_7 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | } 27 | 28 | dependencies { 29 | compile fileTree(dir: 'libs', include: ['*.jar']) 30 | compile 'com.android.support:appcompat-v7:21.0.3' 31 | compile 'dom4j:dom4j:20040902.021138' 32 | } 33 | -------------------------------------------------------------------------------- /app/libs/microlog4android-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/libs/microlog4android-1.0.0.jar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/vrancdi/Documents/APPS/android-sdk-bundle/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 | 26 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/assets/microlog.properties: -------------------------------------------------------------------------------- 1 | microlog.level=DEBUG 2 | microlog.appender=FileAppender;LogCatAppender 3 | microlog.appender.FileAppender.File=portalClient.txt 4 | microlog.formatter=PatternFormatter 5 | microlog.formatter.PatternFormatter.pattern=[%d{YYYY/MM/DD HH:mm:ss,SSS}] [%P] %m %c(%T) -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient; 2 | 3 | import android.app.Activity; 4 | import android.content.pm.PackageInfo; 5 | import android.content.pm.PackageManager; 6 | import android.net.wifi.WifiManager; 7 | import android.os.Bundle; 8 | import android.util.Log; 9 | import com.google.code.microlog4android.Logger; 10 | import com.google.code.microlog4android.LoggerFactory; 11 | import com.google.code.microlog4android.config.PropertyConfigurator; 12 | import java.util.ArrayList; 13 | 14 | public class BaseActivity extends Activity { 15 | public static final String TAG = BaseActivity.class.getSimpleName(); 16 | protected static ArrayList activityList; 17 | protected final transient Logger logger; 18 | WifiManager wifiManager; 19 | 20 | public BaseActivity() { 21 | this.logger = LoggerFactory.getLogger(getClass()); 22 | } 23 | 24 | static { 25 | activityList = new ArrayList(); 26 | } 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | this.wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); 32 | PropertyConfigurator.getConfigurator(this).configure(); 33 | activityList.add(this); 34 | Log.i(TAG,"activityList count = " + activityList.size() ); 35 | } 36 | 37 | @Override 38 | protected void onDestroy() { 39 | super.onDestroy(); 40 | activityList.remove(this); 41 | } 42 | 43 | @Override 44 | public void finish() { 45 | super.finish(); 46 | if (activityList.contains(this)) { 47 | activityList.remove(this); 48 | } 49 | } 50 | 51 | public String getVersionName() { 52 | 53 | try { 54 | PackageManager packageManager = getPackageManager(); 55 | PackageInfo packInfo = packageManager.getPackageInfo(getPackageName(), 0); 56 | return packInfo.versionName; 57 | } catch (Exception e) { 58 | e.printStackTrace(); 59 | return "unknown"; 60 | } 61 | } 62 | 63 | public int getLocalIpAddress() { 64 | 65 | int ipAddress = this.wifiManager.getConnectionInfo().getIpAddress(); 66 | Log.d(TAG, "getLocalIpAddress " + intToIp(ipAddress)); 67 | return ipAddress; 68 | } 69 | 70 | public String intToIp(int i) { 71 | return new StringBuilder(String.valueOf(i & 255)).append(".") 72 | .append((i >> 8) & 255) 73 | .append(".") 74 | .append((i >> 16) & 255) 75 | .append(".") 76 | .append((i >> 24) & 255) 77 | .toString(); 78 | } 79 | 80 | public static int ntol(int n) { 81 | return ((((n & 255) << 24) | (((n >> 8) & 255) << 16)) | (((n >> 16) & 255) << 8)) | ((n >> 24) 82 | & 255); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.AlertDialog; 5 | import android.app.AlertDialog.Builder; 6 | import android.app.ProgressDialog; 7 | import android.content.BroadcastReceiver; 8 | import android.content.Context; 9 | import android.content.DialogInterface; 10 | import android.content.DialogInterface.OnClickListener; 11 | import android.content.Intent; 12 | import android.content.IntentFilter; 13 | import android.content.SharedPreferences; 14 | import android.content.SharedPreferences.Editor; 15 | import android.net.ConnectivityManager; 16 | import android.net.NetworkInfo; 17 | import android.net.NetworkInfo.State; 18 | import android.net.Uri; 19 | import android.net.wifi.WifiInfo; 20 | import android.net.wifi.WifiManager; 21 | import android.os.Build.VERSION; 22 | import android.os.Bundle; 23 | import android.os.Environment; 24 | import android.os.Handler; 25 | import android.os.Message; 26 | import android.os.Process; 27 | import android.os.StrictMode; 28 | import android.os.StrictMode.ThreadPolicy; 29 | import android.util.DisplayMetrics; 30 | import android.util.Log; 31 | import android.util.Xml; 32 | import android.view.LayoutInflater; 33 | import android.view.MotionEvent; 34 | import android.view.View; 35 | import android.view.View.OnTouchListener; 36 | import android.view.ViewGroup; 37 | import android.widget.ArrayAdapter; 38 | import android.widget.CheckBox; 39 | import android.widget.EditText; 40 | import android.widget.ImageView; 41 | import android.widget.LinearLayout; 42 | import android.widget.LinearLayout.LayoutParams; 43 | import android.widget.ListView; 44 | import android.widget.PopupWindow; 45 | import android.widget.SimpleAdapter; 46 | import android.widget.TextView; 47 | import android.widget.Toast; 48 | import com.google.code.microlog4android.format.SimpleFormatter; 49 | import com.xinli.portalclient.model.RequestModel; 50 | import com.xinli.portalclient.model.ReturnMessage; 51 | import com.xinli.portalclient.model.UpdataInfo; 52 | import com.xinli.portalclient.util.BitmapUtils; 53 | import com.xinli.portalclient.util.Config; 54 | import com.xinli.portalclient.util.HttpUtils; 55 | import com.xinli.portalclient.util.MessageContext; 56 | import com.xinli.portalclient.util.PrefUtils; 57 | import java.io.BufferedInputStream; 58 | import java.io.File; 59 | import java.io.FileOutputStream; 60 | import java.io.InputStream; 61 | import java.io.UnsupportedEncodingException; 62 | import java.net.HttpURLConnection; 63 | import java.net.URL; 64 | import java.util.ArrayList; 65 | import java.util.HashMap; 66 | import java.util.List; 67 | import org.apache.http.NameValuePair; 68 | import org.apache.http.message.BasicNameValuePair; 69 | import org.xmlpull.v1.XmlPullParser; 70 | 71 | /* 72 | * 73 | * Draw a bitmap 74 | * * */ 75 | @SuppressLint({ "NewApi" }) 76 | public class MainActivity extends BaseActivity { 77 | public static final int CHECK_DISCONNECT = 2; 78 | public static final int DISCOVER = 1; 79 | protected static final int DOWN_ERROR = 2; 80 | private static final int GET_UNDATAINFO_ERROR = Toast.LENGTH_LONG; 81 | public static final int INIT_RESET_WIFI = 3; 82 | protected static final String TAG = "MainActivity"; 83 | private static final int UPDATA_CLIENT = Toast.LENGTH_SHORT; 84 | private static final int UPDATA_CLIENT_FORCE = 4; 85 | ArrayAdapter _Adapter; 86 | Handler authHandler; 87 | private SharedPreferences defaultAccFile; 88 | private MyAdapter dropDownAdapter; 89 | ImageView errView; 90 | LinearLayout gestureLayout; 91 | static Handler handler; 92 | Handler handlerUpdate; 93 | private MySurfaceView imageView; 94 | private UpdataInfo info; 95 | private String ipConfig; 96 | private String keyvalue; 97 | private List list1; 98 | private List list2; 99 | private SharedPreferences loginFile; 100 | private int mConnMethod; 101 | private ProgressDialog mDialog; 102 | private String mPassword; 103 | private String mSsid; 104 | private WifiInfo mWifiInfo; 105 | private WifiManager mWifiManager; 106 | private WifiManagerUtil mWifiUtil; 107 | private ImageView moreSelect; 108 | public String password; 109 | private int picHeight; 110 | private int picWidth; 111 | private PopupWindow popView; 112 | BroadcastReceiver receiver; 113 | RequestModel reqResource; 114 | String[] resultArray; 115 | CheckBox savePasswordCB; 116 | private int screenHeight; 117 | private int screenWidth; 118 | private String sessionId; 119 | private SharedPreferences sp; 120 | public EditText username; 121 | private String usernametext; 122 | 123 | /* 124 | * Check for update 125 | * */ 126 | class AnonymousClass_14 extends Thread { 127 | private final /* synthetic */ ProgressDialog val$pd; 128 | 129 | AnonymousClass_14(ProgressDialog progressDialog) { 130 | this.val$pd = progressDialog; 131 | } 132 | 133 | public void run() { 134 | try { 135 | 136 | File file = MainActivity.getFileFromServer(info.getUrl(), this.val$pd); 137 | sleep(3000); 138 | installApk(file); 139 | this.val$pd.dismiss(); 140 | } catch (Exception e) { 141 | 142 | Message msg = new Message(); 143 | msg.what = 2; 144 | handlerUpdate.sendMessage(msg); 145 | e.printStackTrace(); 146 | this.val$pd.cancel(); 147 | } 148 | } 149 | } 150 | 151 | //disconnect network 152 | class AnonymousClass_5 implements OnClickListener { 153 | private final /* synthetic */ EditText val$edtInput; 154 | 155 | AnonymousClass_5(EditText editText) { 156 | this.val$edtInput = editText; 157 | } 158 | 159 | public void onClick(DialogInterface dialog, int whichButton) { 160 | mPassword = this.val$edtInput.getText().toString().trim(); 161 | mWifiManager.disableNetwork(mWifiInfo.getNetworkId()); 162 | mWifiManager.disconnect(); 163 | handler.sendEmptyMessage(DOWN_ERROR); 164 | dialog.dismiss(); 165 | } 166 | } 167 | 168 | //clear editText 169 | class AnonymousClass_6 implements OnClickListener { 170 | private final /* synthetic */ EditText val$edtInput; 171 | 172 | AnonymousClass_6(EditText editText) { 173 | this.val$edtInput = editText; 174 | } 175 | 176 | public void onClick(DialogInterface dialog, int whichButton) { 177 | this.val$edtInput.setText(""); 178 | } 179 | } 180 | 181 | //check for update apk 182 | // Config.realUrl + /app/version.xml 183 | public class CheckVersionTask implements Runnable { 184 | boolean force; 185 | 186 | public CheckVersionTask(boolean force) { 187 | this.force = false; 188 | this.force = force; 189 | } 190 | 191 | public void run() { 192 | Message msg; 193 | try { 194 | URL url = new URL( 195 | new StringBuilder(String.valueOf(Config.realUrl)).append("/apps/version.xml") 196 | .toString()); 197 | 198 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 199 | conn.setConnectTimeout(BitmapUtils.REQUEST_TIMEOUT); 200 | info = MainActivity.getUpdataInfo(conn.getInputStream()); 201 | //no need to update 202 | if (info.getVersion().equals(getVersionName())) { 203 | Log.d(TAG, "版本号相同无需升级"); 204 | return; 205 | } 206 | } catch (Exception e) { 207 | msg = new Message(); 208 | msg.what = 1; 209 | handlerUpdate.sendMessage(msg); 210 | e.printStackTrace(); 211 | } 212 | } 213 | } 214 | 215 | class LoginThread implements Runnable { 216 | 217 | //private int picWidth; 218 | //private int picHeight; 219 | //private String keyvalue; 220 | //private List list1; 221 | //private List list2; 222 | //private String usernametext; 223 | //private String password; 224 | //private String ipaddr; 225 | 226 | private String endpoint; 227 | private String session; 228 | List postparas; 229 | 230 | LoginThread(String endpoint, String session, List postparas) { 231 | this.endpoint = endpoint; 232 | this.session = session; 233 | this.postparas = postparas; 234 | } 235 | 236 | @Override 237 | public void run() { 238 | Log.d(TAG, "LoginThread run"); 239 | if (usernametext.isEmpty() || password.isEmpty()) { 240 | Log.e(TAG, "passwd or username is empty"); 241 | return; 242 | } 243 | Message msg = handler.obtainMessage(); 244 | Bundle bundle = new Bundle(); 245 | 246 | String result = HttpUtils.sendContentByHttpPost( 247 | //host address 248 | endpoint + "/wf.do?code=8", 249 | //sessionId 250 | sessionId, 251 | //List paras 252 | postparas); 253 | 254 | resultArray = result.split("#"); 255 | list1.clear(); 256 | list2.clear(); 257 | Log.v(TAG, "result = " + resultArray[0].toString()); 258 | if (ReturnMessage.AUTH_TRUE.equals(resultArray[0])) { 259 | msg.what = 0; 260 | PrefUtils prefUtils = new PrefUtils(MainActivity.this); 261 | if (resultArray.length < 6) { 262 | prefUtils.setVerifyURL(""); 263 | } else if (resultArray[5].split("=").length > 1) { 264 | prefUtils.setVerifyURL(resultArray[5].split("=")[1]); 265 | } 266 | Log.i(TAG, 267 | new StringBuilder("LoginThread=======verifyURL==").append(prefUtils.getVerifyURL()) 268 | .toString()); 269 | msg.setData(bundle); 270 | authHandler.sendMessage(msg); 271 | } 272 | if (ReturnMessage.AUTH_FALSE.equals(resultArray[0])) { 273 | msg.what = 1; 274 | bundle.putString("resultDesc", resultArray[1]); 275 | } else if (ReturnMessage.KEY_FALSE.equals(resultArray[0])) { 276 | msg.what = 2; 277 | bundle.putString("resultDesc", 278 | "\u624b\u52bf\u5df2\u8fc7\u671f\uff0c\u8bf7\u91cd\u65b0\u64cd\u4f5c"); 279 | } else if (ReturnMessage.PIC_FALSE.equals(resultArray[0])) { 280 | bundle.putString("resultDesc", "\u624b\u52bf\u9a8c\u8bc1\u5931\u8d25"); 281 | msg.what = 3; 282 | } else { 283 | bundle.putString("resultDesc", "\u8ba4\u8bc1\u7ed3\u679c\u7801\u5f02\u5e38"); 284 | msg.what = 100; 285 | } 286 | msg.setData(bundle); 287 | authHandler.sendMessage(msg); 288 | } 289 | } 290 | 291 | class MyAdapter extends SimpleAdapter { 292 | private List> data; 293 | 294 | class AnonymousClass_1 implements View.OnClickListener { 295 | private final /* synthetic */ int val$position; 296 | 297 | AnonymousClass_1(int i) { 298 | this.val$position = i; 299 | } 300 | 301 | public void onClick(View v) { 302 | 303 | Log.d("点击下拉框", this.val$position + ""); 304 | //mock password 305 | usernametext = "123_MyAdapter"; 306 | password = "passwd_MyAdapter"; 307 | username.setText(usernametext); 308 | SharedPreferences.Editor editor = sp.edit(); 309 | editor.putString(usernametext, password); 310 | editor.apply(); 311 | 312 | Log.d("username=", usernametext); 313 | popView.dismiss(); 314 | } 315 | } 316 | 317 | public MyAdapter(Context context, List> data, int resource, 318 | String[] from, int[] to) { 319 | super(context, data, resource, from, to); 320 | this.data = data; 321 | } 322 | 323 | public int getCount() { 324 | return this.data.size(); 325 | } 326 | 327 | public Object getItem(int position) { 328 | return position; 329 | } 330 | 331 | public long getItemId(int position) { 332 | return (long) position; 333 | } 334 | 335 | public View getView(int position, View convertView, ViewGroup parent) { 336 | ViewHolder holder; 337 | if (convertView == null) { 338 | holder = new ViewHolder(); 339 | convertView = LayoutInflater.from(MainActivity.this).inflate(R.layout.dropdown_item, null); 340 | holder.tv = (TextView) convertView.findViewById(R.id.textview); 341 | convertView.setTag(holder); 342 | } else { 343 | holder = (ViewHolder) convertView.getTag(); 344 | } 345 | holder.tv.setText(((HashMap) this.data.get(position)).get("name").toString()); 346 | holder.tv.setOnClickListener(new AnonymousClass_1(position)); 347 | return convertView; 348 | } 349 | } 350 | 351 | class ViewHolder { 352 | private TextView tv; 353 | 354 | ViewHolder() { 355 | } 356 | } 357 | 358 | public MainActivity() { 359 | this.handler = new Handler() { 360 | @Override 361 | public void handleMessage(Message msg) { 362 | Log.d(TAG, "handler:msg.what = " + msg.what); 363 | switch (msg.what) { 364 | //called when last surfaceview touch left 365 | case UPDATA_CLIENT: 366 | list1 = msg.getData().getParcelableArrayList("list1"); 367 | list2 = msg.getData().getParcelableArrayList("list2"); 368 | picWidth = msg.getData().getInt("picwidth"); 369 | picHeight = msg.getData().getInt("picheight"); 370 | mDialog = new ProgressDialog(MainActivity.this); 371 | mDialog.setTitle("\u767b\u5f55"); 372 | mDialog.setMessage("正在登录服务器,请稍后..."); 373 | mDialog.show(); 374 | List postparas = 375 | MessageContext.paramStrReturn(picWidth, picHeight, list1, list2, keyvalue, 376 | usernametext, password, intToIp(getLocalIpAddress())); 377 | 378 | new Thread(new LoginThread(Config.realUrl, sessionId, postparas)).start(); 379 | break; 380 | case GET_UNDATAINFO_ERROR: 381 | sendDiscover(); 382 | break; 383 | case DOWN_ERROR: 384 | if (wifiConnectState()) { 385 | handler.sendEmptyMessageDelayed(DOWN_ERROR, 1000); 386 | return; 387 | } 388 | handler.removeMessages(DOWN_ERROR); 389 | mDialog = new ProgressDialog(MainActivity.this); 390 | mDialog.setTitle("\u767b\u5f55\u5237\u65b0"); 391 | mDialog.setMessage("正在连接服务器,请稍后..."); 392 | mDialog.show(); 393 | mWifiUtil.connectToTargetWifi(mSsid, mPassword, mConnMethod); 394 | handler.sendEmptyMessage(GET_UNDATAINFO_ERROR); 395 | break; 396 | case INIT_RESET_WIFI: 397 | showDialog(); 398 | break; 399 | default: 400 | break; 401 | } 402 | } 403 | }; 404 | 405 | this.authHandler = new Handler() { 406 | public void handleMessage(Message msg) { 407 | String resultText = msg.getData().getString("resultDesc"); 408 | Log.d(TAG, "authHandler:msg.what = " + msg.what); 409 | switch (msg.what) { 410 | case UPDATA_CLIENT: 411 | mDialog.cancel(); 412 | SucessActivity.userInfo = new RequestModel(usernametext, sessionId); 413 | Editor editor = loginFile.edit(); 414 | editor.putString(Config.USERNAME, usernametext); 415 | editor.putString(Config.SESSIONID, sessionId); 416 | if (!(Config.realUrl == null 417 | || Config.realUrl.isEmpty() 418 | || Config.firstRreqUrl.equalsIgnoreCase(Config.realUrl))) { 419 | 420 | editor.putString(Config.REDIRECTINFO, Config.realUrl); 421 | editor.commit(); 422 | } 423 | 424 | //start SucessActivity 425 | //Intent intent = 426 | // new Intent(getApplicationContext(), SucessActivity.class); 427 | //intent.putExtra("loginTime", System.currentTimeMillis()); 428 | //intent.putExtra("authFlag", true); 429 | //startActivity(intent); 430 | break; 431 | 432 | case GET_UNDATAINFO_ERROR: 433 | mDialog.cancel(); 434 | Toast.makeText(getApplicationContext(), resultText, UPDATA_CLIENT).show(); 435 | break; 436 | 437 | //error == 2 438 | case DOWN_ERROR: 439 | Log.d(TAG, "挑战码过期,重新获取图片和key"); 440 | try { 441 | if (isPrivateIpAdress()) { 442 | Log.e(TAG, "isPrivateIpAdress"); 443 | return; 444 | } 445 | RequestModel reset = 446 | BitmapUtils.getKey(getVersionName(), intToIp(getLocalIpAddress())); 447 | if (ReturnMessage.NATCHECK.equals(reset.getMessage())) { 448 | mDialog.cancel(); 449 | Toast.makeText(getApplicationContext(), 450 | "\u7f51\u7edc\u5f02\u5e38\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\uff01", 451 | UPDATA_CLIENT).show(); 452 | exceptionView(); 453 | } else if (ReturnMessage.VERSIONCHECK.equals(reset.getMessage())) { 454 | Toast.makeText(getApplicationContext(), 455 | "\u60a8\u7684\u7248\u672c\u8fc7\u4f4e\uff0c\u8bf7\u6309\u63d0\u793a\u8fdb\u884c\u66f4\u65b0\uff01", 456 | GET_UNDATAINFO_ERROR).show(); 457 | new Thread(new CheckVersionTask(true)).start(); 458 | mDialog.cancel(); 459 | } else { 460 | imageView.setSessionId(reset.getSessionId()); 461 | imageView.setKeyvalue(reset.getKeyvalue()); 462 | sessionId = reset.getSessionId(); 463 | keyvalue = reset.getKeyvalue(); 464 | imageView.bitmap = 465 | BitmapUtils.getPicture(reset.getSessionId(), screenWidth, screenHeight) 466 | .getBitmap(); 467 | 468 | reqResource.setSessionId(imageView.getSessionId()); 469 | reqResource.setKeyvalue(imageView.getKeyvalue()); 470 | reqResource.setBitmap(imageView.bitmap); 471 | mDialog.cancel(); 472 | Toast.makeText(getApplicationContext(), resultText, UPDATA_CLIENT).show(); 473 | } 474 | } catch (Exception e) { 475 | 476 | mDialog.cancel(); 477 | Toast.makeText(getApplicationContext(), 478 | "\u83b7\u53d6\u624b\u52bf\u5931\u8d25\uff0c\u8bf7\u70b9\u51fb\u6309\u94ae\u91cd\u65b0\u8bf7\u6c42\u624b\u52bf", 479 | UPDATA_CLIENT).show(); 480 | } 481 | break; 482 | case INIT_RESET_WIFI: 483 | mDialog.cancel(); 484 | Toast.makeText(getApplicationContext(), resultText, UPDATA_CLIENT).show(); 485 | break; 486 | case UPDATA_CLIENT_FORCE: 487 | mDialog.cancel(); 488 | exceptionView(); 489 | Toast.makeText(getApplicationContext(), resultText, UPDATA_CLIENT).show(); 490 | break; 491 | case 100: 492 | mDialog.cancel(); 493 | Toast.makeText(getApplicationContext(), resultText, UPDATA_CLIENT).show(); 494 | break; 495 | default: 496 | break; 497 | } 498 | } 499 | }; 500 | 501 | this.receiver = new BroadcastReceiver() { 502 | public void onReceive(Context context, Intent intent) { 503 | Log.d(TAG, "intent.getAction().equals(\"mysurface\")"); 504 | if (intent.getAction().equals("mysurface")) { 505 | //Intent mainIntent = new Intent(context, SucessActivity.class); 506 | //intent.putExtra("authFlag", true); 507 | //context.startActivity(mainIntent); 508 | //finish(); 509 | } 510 | } 511 | }; 512 | 513 | this.handlerUpdate = new Handler() { 514 | public void handleMessage(Message msg) { 515 | super.handleMessage(msg); 516 | switch (msg.what) { 517 | case UPDATA_CLIENT: 518 | showUpdataDialog(false); 519 | case DOWN_ERROR: 520 | Toast.makeText(getApplicationContext(), "\u4e0b\u8f7d\u65b0\u7248\u672c\u5931\u8d25", 521 | GET_UNDATAINFO_ERROR).show(); 522 | case UPDATA_CLIENT_FORCE: 523 | showUpdataDialog(true); 524 | default: 525 | break; 526 | } 527 | } 528 | }; 529 | } 530 | 531 | private void showDialog() { 532 | Log.v(TAG, "showDialog"); 533 | this.mWifiUtil = new WifiManagerUtil(this, this.logger); 534 | this.mWifiUtil.getWifiInfo(); 535 | this.mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); 536 | this.mWifiInfo = this.mWifiManager.getConnectionInfo(); 537 | this.mSsid = this.mWifiInfo.getSSID().trim(); 538 | this.mSsid = trim(this.mSsid); 539 | this.mConnMethod = 1; 540 | View textEntryView = LayoutInflater.from(this).inflate(R.layout.dialoglayout, null); 541 | EditText edtInput = (EditText) textEntryView.findViewById(R.id.edtInput); 542 | Builder builder = new Builder(this); 543 | builder.setCancelable(false); 544 | builder.setTitle("\u8f93\u5165WIFI\u5bc6\u7801"); 545 | builder.setMessage(this.mSsid); 546 | builder.setView(textEntryView); 547 | builder.setPositiveButton("\u786e\u5b9a", new AnonymousClass_5(edtInput)); 548 | builder.setNeutralButton("\u53d6\u6d88", new AnonymousClass_6(edtInput)); 549 | builder.show(); 550 | 551 | } 552 | 553 | private String getWifiMacAddress() { 554 | try { 555 | WifiInfo info = ((WifiManager) getSystemService(WIFI_SERVICE)).getConnectionInfo(); 556 | String mac = ""; 557 | if (info == null) { 558 | return mac; 559 | } 560 | mac = info.getMacAddress().replaceAll(":", SimpleFormatter.DEFAULT_DELIMITER); 561 | 562 | return mac; 563 | } catch (Exception e) { 564 | e.printStackTrace(); 565 | return ""; 566 | } 567 | } 568 | 569 | private void sendDiscover() { 570 | Log.d(TAG, "sendDiscover"); 571 | if (!wifiConnectState()) { 572 | handler.sendEmptyMessageDelayed(1, 1000L); 573 | return; 574 | } 575 | ArrayList localArrayList = new ArrayList(); 576 | localArrayList.add(new BasicNameValuePair("username", usernametext)); 577 | try { 578 | String str = HttpUtils.sendContentByHttpPost(Config.realUrl + "/wf.do?code=9", sessionId, 579 | localArrayList); 580 | 581 | if ("discover00".equals(str)) { 582 | SucessActivity.userInfo = new RequestModel(usernametext, sessionId); 583 | SharedPreferences.Editor localEditor = loginFile.edit(); 584 | localEditor.putString("username", usernametext); 585 | localEditor.putString("sessionId", sessionId); 586 | if ((Config.realUrl != null) 587 | && (!Config.realUrl.isEmpty()) 588 | && (!Config.firstRreqUrl.equalsIgnoreCase(Config.realUrl))) { 589 | localEditor.putString(Config.REDIRECTINFO, Config.realUrl); 590 | localEditor.commit(); 591 | } 592 | //Intent localIntent = new Intent(getApplicationContext(), SucessActivity.class); 593 | //localIntent.putExtra("loginTime", System.currentTimeMillis()); 594 | //localIntent.putExtra("authFlag", true); 595 | //startActivity(localIntent); 596 | return; 597 | } 598 | } catch (Exception localException) { 599 | 600 | return; 601 | } 602 | handler.sendEmptyMessageDelayed(1, 1000L); 603 | } 604 | 605 | private boolean wifiConnectState() { 606 | NetworkInfo wifiInfo = 607 | ((ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE)).getNetworkInfo( 608 | GET_UNDATAINFO_ERROR); 609 | if (wifiInfo == null || !wifiInfo.isConnected() || wifiInfo.getState() != State.CONNECTED) { 610 | return false; 611 | } 612 | return true; 613 | } 614 | 615 | public String trim(String str) { 616 | int len = str.length(); 617 | int st = UPDATA_CLIENT; 618 | char[] val = str.toCharArray(); 619 | while (st < len && val[0 + st] <= '\"') { 620 | st++; 621 | } 622 | while (st < len && val[(0 + len) - 1] <= '\"') { 623 | len--; 624 | } 625 | return (st > 0 || len < str.length()) ? str.substring(st, len) : str; 626 | } 627 | 628 | @Override 629 | protected void onCreate(Bundle savedInstanceState) { 630 | 631 | IntentFilter filter = new IntentFilter(); 632 | filter.addAction("mysurface"); 633 | registerReceiver(this.receiver, filter); 634 | if (((double) Float.valueOf(VERSION.RELEASE.substring(UPDATA_CLIENT, INIT_RESET_WIFI).trim()) 635 | .floatValue()) > 2.3d) { 636 | StrictMode.setThreadPolicy(new ThreadPolicy.Builder().detectDiskReads() 637 | .detectDiskWrites() 638 | .detectNetwork() 639 | .permitNetwork() 640 | .penaltyLog() 641 | .build()); 642 | } 643 | requestWindowFeature(GET_UNDATAINFO_ERROR); 644 | super.onCreate(savedInstanceState); 645 | 646 | if (activityList.size() > 1) { 647 | 648 | Log.d(TAG, "activityList.size>1"); 649 | //Intent intent = new Intent(); 650 | //intent.setClass(this, SucessActivity.class); 651 | //intent.putExtra("authFlag", true); 652 | //startActivity(intent); 653 | //finish(); 654 | return; 655 | } 656 | setContentView(R.layout.activity_main); 657 | this.gestureLayout = (LinearLayout) findViewById(R.id.auth_pic_layout); 658 | DisplayMetrics displayMetrics = new DisplayMetrics(); 659 | displayMetrics = getResources().getDisplayMetrics(); 660 | this.screenWidth = displayMetrics.widthPixels; 661 | this.screenHeight = displayMetrics.heightPixels; 662 | this.username = (EditText) findViewById(R.id.username); 663 | this.defaultAccFile = getSharedPreferences(SetAccountActivity.DEFAULT_ACCOUNT, UPDATA_CLIENT); 664 | this.sp = getSharedPreferences("passwordFile", UPDATA_CLIENT); 665 | this.loginFile = getSharedPreferences(Config.LOGININFOFILE, UPDATA_CLIENT); 666 | initLoginUserName(); 667 | ImageView accountSeting = (ImageView) findViewById(R.id.account_setting); 668 | accountSeting.setBackgroundResource(R.drawable.usermbk); 669 | accountSeting.setOnTouchListener(new OnTouchListener() { 670 | public boolean onTouch(View arg0, MotionEvent arg1) { 671 | if (arg1.getAction() == 0) { 672 | arg0.setBackgroundResource(R.drawable.usermbk_down); 673 | } else if (arg1.getAction() == 1) { 674 | arg0.setBackgroundResource(R.drawable.usermbk); 675 | } 676 | return false; 677 | } 678 | }); 679 | accountSeting.setOnClickListener(new View.OnClickListener() { 680 | public void onClick(View v) { 681 | Intent intent = new Intent(); 682 | intent.setClass(MainActivity.this, SetAccountActivity.class); 683 | startActivity(intent); 684 | finish(); 685 | } 686 | }); 687 | ((ImageView) findViewById(R.id.moreSelect)).setOnClickListener(new View.OnClickListener() { 688 | public void onClick(View v) { 689 | switch (v.getId()) { 690 | case R.id.moreSelect: 691 | if (popView == null) { 692 | String[] mItems = (String[]) sp.getAll().keySet().toArray(new String[0]); 693 | if (mItems.length > 0) { 694 | initPopView(mItems); 695 | if (popView.isShowing()) { 696 | popView.dismiss(); 697 | return; 698 | } else { 699 | popView.showAsDropDown(username); 700 | return; 701 | } 702 | } 703 | Intent intent = new Intent(); 704 | intent.setClass(MainActivity.this, SetAccountActivity.class); 705 | startActivity(intent); 706 | finish(); 707 | Toast.makeText(getApplicationContext(), "\u8bf7\u5148\u6dfb\u52a0\u5e10\u53f7", 708 | UPDATA_CLIENT).show(); 709 | } else if (popView.isShowing()) { 710 | popView.dismiss(); 711 | } else { 712 | popView.showAsDropDown(username); 713 | } 714 | default: 715 | break; 716 | } 717 | } 718 | }); 719 | ImageView refreshText = (ImageView) findViewById(R.id.refresh_pic); 720 | refreshText.setBackgroundResource(R.drawable.refresh); 721 | refreshText.setOnTouchListener(new OnTouchListener() { 722 | public boolean onTouch(View arg0, MotionEvent arg1) { 723 | if (arg1.getAction() == 0) { 724 | arg0.setBackgroundResource(R.drawable.refresh_down); 725 | } else if (arg1.getAction() == 1) { 726 | arg0.setBackgroundResource(R.drawable.refresh); 727 | } 728 | return false; 729 | } 730 | }); 731 | refreshText.setOnClickListener(new View.OnClickListener() { 732 | public void onClick(View v) { 733 | 734 | if (!CheckNetworkState()) { 735 | shoWifiUnavaialableDialog(); 736 | return; 737 | } 738 | 739 | if (isPrivateIpAdress()) { 740 | Log.e(TAG, "isPrivateIpAdress"); 741 | return; 742 | } 743 | 744 | if (imageView == null) { 745 | Log.e(TAG, "imageView == null"); 746 | Log.d(TAG, "refresh image and key"); 747 | reqResource = getAuthPicAndKey(); 748 | keyvalue = reqResource.getKeyvalue(); 749 | Log.d(TAG, "refresh image and key done"); 750 | return; 751 | } else { 752 | Log.d(TAG, "imageView != null"); 753 | Log.d(TAG, "refresh image only!"); 754 | imageView.bitmap = 755 | BitmapUtils.getPicture(reqResource.getSessionId(), screenWidth, screenHeight) 756 | .getBitmap(); 757 | Log.d(TAG, "refresh image done"); 758 | return; 759 | } 760 | } 761 | }); 762 | 763 | if (!CheckNetworkState()) { 764 | exceptionView(); 765 | shoWifiUnavaialableDialog(); 766 | } else if (isPrivateIpAdress()) { 767 | exceptionView(); 768 | Toast.makeText(getApplicationContext(), "网络异常,请检查网络!", UPDATA_CLIENT).show(); 769 | } else { 770 | //start http 771 | try { 772 | if (!BitmapUtils.isHaveinitRealAddress(Config.firstRreqUrl)) { 773 | Log.d(TAG, "!BitmapUtils.isHaveinitRealAddress(Config.firstRreqUrl))"); 774 | 775 | //Intent intent = new Intent(); 776 | //intent.setClass(this, SucessActivity.class); 777 | //intent.putExtra("authFlag", true); 778 | //startActivity(intent); 779 | //finish(); 780 | return; 781 | } 782 | 783 | this.reqResource = getAuthPicAndKey(); 784 | 785 | if (!this.reqResource.isForceUpdated()) { 786 | new Thread(new CheckVersionTask(false)).start(); 787 | } 788 | } catch (Exception e) { 789 | exceptionView(); 790 | Toast.makeText(getApplicationContext(), 791 | "\u7f51\u7edc\u5f02\u5e38\uff0c\u8bf7\u7a0d\u5019\u518d\u8bd5", UPDATA_CLIENT).show(); 792 | 793 | } 794 | } 795 | } 796 | 797 | //parse update.xml 798 | public static UpdataInfo getUpdataInfo(InputStream is) throws Exception { 799 | XmlPullParser parser = Xml.newPullParser(); 800 | parser.setInput(is, "utf-8"); 801 | UpdataInfo info = new UpdataInfo(); 802 | for (int type = parser.getEventType(); type != 1; type = parser.next()) { 803 | switch (type) { 804 | case DOWN_ERROR: 805 | if ("version".equals(parser.getName())) { 806 | info.setVersion(parser.nextText()); 807 | } else if ("url".equals(parser.getName())) { 808 | info.setUrl(parser.nextText()); 809 | } else if ("description".equals(parser.getName())) { 810 | info.setDescription(parser.nextText()); 811 | } 812 | default: 813 | break; 814 | } 815 | } 816 | return info; 817 | } 818 | 819 | //update apk from server 820 | 821 | public static File getFileFromServer(String path, ProgressDialog pd) throws Exception { 822 | if (!Environment.getExternalStorageState().equals("mounted")) { 823 | return null; 824 | } 825 | HttpURLConnection conn = (HttpURLConnection) new URL(path).openConnection(); 826 | conn.setConnectTimeout(BitmapUtils.REQUEST_TIMEOUT); 827 | pd.setMax(conn.getContentLength()); 828 | InputStream is = conn.getInputStream(); 829 | File file = new File(Environment.getExternalStorageDirectory(), "portal_client_update.apk"); 830 | FileOutputStream fos = new FileOutputStream(file); 831 | BufferedInputStream bis = new BufferedInputStream(is); 832 | byte[] buffer = new byte[1024]; 833 | int total = UPDATA_CLIENT; 834 | while (true) { 835 | int len = bis.read(buffer); 836 | if (len == -1) { 837 | fos.close(); 838 | bis.close(); 839 | is.close(); 840 | return file; 841 | } 842 | fos.write(buffer, UPDATA_CLIENT, len); 843 | total += len; 844 | pd.setProgress(total); 845 | } 846 | } 847 | 848 | protected void showUpdataDialog(boolean force) { 849 | Builder builer = new Builder(this); 850 | builer.setTitle("\u7248\u672c\u5347\u7ea7"); 851 | try { 852 | builer.setMessage(new String(this.info.getDescription().getBytes(), "UTF-8")); 853 | builer.setPositiveButton("\u786e\u5b9a", new OnClickListener() { 854 | public void onClick(DialogInterface dialog, int which) { 855 | 856 | downLoadApk(); 857 | } 858 | }); 859 | 860 | if (!force) { 861 | 862 | builer.setNegativeButton("\u53d6\u6d88", new OnClickListener() { 863 | public void onClick(DialogInterface dialog, int which) { 864 | Process.killProcess(Process.myPid()); 865 | } 866 | }); 867 | } 868 | AlertDialog dialog = builer.create(); 869 | dialog.setCanceledOnTouchOutside(false); 870 | dialog.show(); 871 | } catch (UnsupportedEncodingException e) { 872 | 873 | } 874 | } 875 | 876 | protected void downLoadApk() { 877 | ProgressDialog pd = new ProgressDialog(this); 878 | pd.setProgressStyle(GET_UNDATAINFO_ERROR); 879 | pd.setMessage("\u6b63\u5728\u4e0b\u8f7d\u66f4\u65b0"); 880 | pd.show(); 881 | new AnonymousClass_14(pd).start(); 882 | } 883 | 884 | protected void installApk(File file) { 885 | Intent intent = new Intent(); 886 | intent.addFlags(268435456); 887 | intent.setAction("android.intent.action.VIEW"); 888 | intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); 889 | startActivity(intent); 890 | } 891 | 892 | private void initLoginUserName() { 893 | Log.d(TAG, "initLoginUserName"); 894 | this.usernametext = "usernametext"; 895 | this.password = "usernamepassword"; 896 | } 897 | 898 | private void initPopView(String[] usernames) { 899 | List> list = new ArrayList(); 900 | for (int i = UPDATA_CLIENT; i < usernames.length; i++) { 901 | HashMap map = new HashMap(); 902 | map.put("name", usernames[i]); 903 | list.add(map); 904 | } 905 | this.dropDownAdapter = 906 | new MyAdapter(this, list, 2130903043, new String[] { "name" }, new int[] { 2131296269 }); 907 | ListView listView = new ListView(this); 908 | listView.setAdapter(this.dropDownAdapter); 909 | this.popView = new PopupWindow(listView, this.username.getWidth(), -2, false); 910 | this.popView.setBackgroundDrawable(getResources().getDrawable(R.drawable.white)); 911 | } 912 | 913 | private RequestModel getAuthPicAndKey() { 914 | 915 | Log.v(TAG, "getAuthPicAndKey"); 916 | if (isPrivateIpAdress()) { 917 | 918 | exceptionView(); 919 | Log.e(TAG, "isPrivateIpAdress"); 920 | return null; 921 | } 922 | 923 | this.gestureLayout.removeView(this.errView); 924 | try { 925 | RequestModel requestResult = 926 | BitmapUtils.requestBeforeLogin(Config.firstRreqUrl, this.screenWidth, this.screenHeight, 927 | getVersionName(), intToIp(getLocalIpAddress())); 928 | 929 | if (ReturnMessage.NATCHECK.equals(requestResult.getMessage())) { 930 | exceptionView(); 931 | } else if (ReturnMessage.VERSIONCHECK.equals(requestResult.getMessage())) { 932 | Toast.makeText(getApplicationContext(), "update available!", GET_UNDATAINFO_ERROR).show(); 933 | new Thread(new CheckVersionTask(true)).start(); 934 | requestResult.setForceUpdated(true); 935 | } else { 936 | this.imageView = new MySurfaceView(this, requestResult.getBitmap(), this.sp, this.handler); 937 | LayoutParams params = new LayoutParams(-2, -2); 938 | this.imageView.setSessionId(requestResult.getSessionId()); 939 | this.imageView.setFocusableInTouchMode(true); 940 | this.imageView.setKeyvalue(requestResult.getKeyvalue()); 941 | this.gestureLayout.addView(this.imageView, params); 942 | this.sessionId = requestResult.getSessionId(); 943 | this.keyvalue = requestResult.getKeyvalue(); 944 | Log.d(TAG, 945 | "requestResult " + requestResult.getKeyvalue() + "/" + requestResult.getSessionId()); 946 | } 947 | return requestResult; 948 | } catch (Exception e) { 949 | exceptionView(); 950 | 951 | Toast.makeText(getApplicationContext(), 952 | "\u83b7\u53d6\u624b\u52bf\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u6216\u7a0d\u5019\u518d\u8bd5", 953 | UPDATA_CLIENT).show(); 954 | return null; 955 | } 956 | } 957 | 958 | private void exceptionView() { 959 | try { 960 | if (this.imageView != null) { 961 | this.gestureLayout.removeView(this.imageView); 962 | } 963 | this.errView = new ImageView(this); 964 | LayoutParams params = new LayoutParams(-2, -2); 965 | this.errView.setBackgroundResource(R.drawable.gesture_default); 966 | this.gestureLayout.addView(this.errView, params); 967 | } catch (Exception e) { 968 | } 969 | } 970 | 971 | public boolean CheckNetworkState() { 972 | State wifi = ((ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE)).getNetworkInfo( 973 | GET_UNDATAINFO_ERROR).getState(); 974 | return wifi == State.CONNECTED || wifi == State.CONNECTING; 975 | } 976 | 977 | private void shoWifiUnavaialableDialog() { 978 | AlertDialog.Builder localBuilder = new AlertDialog.Builder(this); 979 | localBuilder.setIcon(17301543); 980 | localBuilder.setTitle("没有可用Wifi网络"); 981 | localBuilder.setMessage("当前Wifi网络不可用,是否设置Wifi网络?"); 982 | localBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() { 983 | public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { 984 | startActivity(new Intent("android.settings.WIFI_SETTINGS")); 985 | } 986 | }); 987 | localBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() { 988 | public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) { 989 | paramAnonymousDialogInterface.cancel(); 990 | finish(); 991 | } 992 | }); 993 | localBuilder.create(); 994 | localBuilder.show(); 995 | } 996 | 997 | @Override 998 | protected void onDestroy() { 999 | super.onDestroy(); 1000 | unregisterReceiver(this.receiver); 1001 | } 1002 | 1003 | private boolean isPrivateIpAdress() { 1004 | boolean result; 1005 | int netaddr = ntol(getLocalIpAddress()); 1006 | if (netaddr >= -1062731776 && netaddr <= -1062666241) { 1007 | result = true; 1008 | } else if (netaddr >= 167772160 && netaddr <= 184549375) { 1009 | result = true; 1010 | } else if (netaddr < -1408237568 || netaddr > -1400635393) { 1011 | result = false; 1012 | } else { 1013 | result = true; 1014 | } 1015 | //mock 1016 | //return result; 1017 | return false; 1018 | } 1019 | } 1020 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/MySurfaceView.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient; 2 | 3 | import android.app.AlertDialog.Builder; 4 | import android.app.ProgressDialog; 5 | import android.content.Context; 6 | import android.content.SharedPreferences; 7 | import android.graphics.Bitmap; 8 | import android.graphics.Canvas; 9 | import android.graphics.Matrix; 10 | import android.graphics.Paint; 11 | import android.graphics.Paint.Cap; 12 | import android.graphics.Paint.Style; 13 | import android.graphics.Path; 14 | import android.os.Bundle; 15 | import android.os.Handler; 16 | import android.os.Message; 17 | import android.util.Log; 18 | import android.view.MotionEvent; 19 | import android.view.SurfaceHolder; 20 | import android.view.SurfaceHolder.Callback; 21 | import android.view.SurfaceView; 22 | import android.widget.Toast; 23 | import com.xinli.portalclient.model.TouchPoint; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | import org.dom4j.swing.XMLTableColumnDefinition; 27 | 28 | public class MySurfaceView extends SurfaceView implements Callback, Runnable { 29 | private static final int MAX_TOUCHPOINTS = Toast.LENGTH_LONG; 30 | protected static final String TAG = MySurfaceView.class.getSimpleName(); 31 | public static final int TIME_IN_FRAME = 50; 32 | Canvas bakmCanvas; 33 | Bitmap bitmap; 34 | private int[] colors; 35 | private String keyvalue; 36 | final List list1; 37 | final List list2; 38 | Canvas mCanvas; 39 | private ProgressDialog mDialog; 40 | boolean mIsRunning; 41 | Paint mPaint; 42 | private Path[] mPath; 43 | boolean mRunning; 44 | SurfaceHolder mSurfaceHolder; 45 | private Handler mainHandler; 46 | MySurfaceView me; 47 | private float[] mposX; 48 | private float[] mposY; 49 | private boolean rememberPasswd; 50 | final List> resultList; 51 | private String sessionId; 52 | private SharedPreferences sp; 53 | private Paint[] touchPaints; 54 | 55 | public String getSessionId() { 56 | return this.sessionId; 57 | } 58 | 59 | public void setSessionId(String sessionId) { 60 | this.sessionId = sessionId; 61 | } 62 | 63 | public String getKeyvalue() { 64 | return this.keyvalue; 65 | } 66 | 67 | public void setKeyvalue(String keyvalue) { 68 | this.keyvalue = keyvalue; 69 | } 70 | 71 | public MySurfaceView(Context context) { 72 | super(context); 73 | this.mPaint = null; 74 | this.touchPaints = new Paint[10]; 75 | this.colors = new int[10]; 76 | this.mPath = new Path[10]; 77 | this.mposX = new float[10]; 78 | this.mposY = new float[10]; 79 | this.mSurfaceHolder = null; 80 | this.mRunning = false; 81 | this.mCanvas = null; 82 | this.bakmCanvas = null; 83 | this.mIsRunning = false; 84 | this.list1 = new ArrayList<>(); 85 | this.list2 = new ArrayList<>(); 86 | this.resultList = new ArrayList<>(); 87 | this.me = this; 88 | } 89 | 90 | public MySurfaceView(Context context, Bitmap bitMap, SharedPreferences sp, Handler mainHandler) { 91 | super(context); 92 | this.mPaint = null; 93 | this.touchPaints = new Paint[10]; 94 | this.colors = new int[10]; 95 | this.mPath = new Path[10]; 96 | this.mposX = new float[10]; 97 | this.mposY = new float[10]; 98 | this.mSurfaceHolder = null; 99 | this.mRunning = false; 100 | this.mCanvas = null; 101 | this.bakmCanvas = null; 102 | this.mIsRunning = false; 103 | this.list1 = new ArrayList<>(); 104 | this.list2 = new ArrayList<>(); 105 | this.resultList = new ArrayList<>(); 106 | this.me = this; 107 | setFocusable(true); 108 | setFocusableInTouchMode(true); 109 | this.mSurfaceHolder = getHolder(); 110 | this.mSurfaceHolder.addCallback(this); 111 | this.mCanvas = new Canvas(); 112 | this.mPaint = new Paint(); 113 | this.mPaint.setColor(-16777216); 114 | this.bitmap = bitMap; 115 | init(); 116 | this.sp = sp; 117 | this.mainHandler = mainHandler; 118 | } 119 | 120 | private void init() { 121 | this.colors[0] = -256; 122 | this.colors[1] = -256; 123 | this.colors[2] = -16711936; 124 | this.colors[3] = -256; 125 | this.colors[4] = -16711681; 126 | this.colors[5] = -65281; 127 | this.colors[6] = -12303292; 128 | this.colors[7] = -1; 129 | this.colors[8] = -3355444; 130 | this.colors[9] = -7829368; 131 | for (int i = 0; i < 10; i++) { 132 | this.touchPaints[i] = new Paint(); 133 | this.touchPaints[i].setColor(this.colors[i]); 134 | this.touchPaints[i].setAntiAlias(true); 135 | this.touchPaints[i].setStyle(Style.STROKE); 136 | this.touchPaints[i].setStrokeCap(Cap.ROUND); 137 | this.touchPaints[i].setStrokeWidth(25.0f); 138 | this.touchPaints[i].setDither(true); 139 | this.touchPaints[i].setShadowLayer(5.0f, 8.0f, 8.0f, this.colors[i]); 140 | this.mPath[i] = new Path(); 141 | } 142 | } 143 | 144 | public boolean onTouchEvent(MotionEvent event) { 145 | String username = ((MainActivity) getContext()).username.getText().toString(); 146 | String password = this.sp.getString(username, ""); 147 | this.rememberPasswd = false; 148 | Log.v(TAG, username); 149 | Log.v(TAG, password); 150 | if ("".equals(username) || username == null || "".equals(password) || password == null) { 151 | Toast.makeText(getContext(), "请先选择帐号", MAX_TOUCHPOINTS).show(); 152 | return false; 153 | } 154 | int pointCount = event.getPointerCount(); 155 | int i; 156 | int y; 157 | switch (event.getAction() & 255) { 158 | case XMLTableColumnDefinition.OBJECT_TYPE: 159 | Log.v(TAG, "第一个点按下触摸屏"); 160 | for (i = 0; i < pointCount; i++) { 161 | y = (int) event.getY(i); 162 | Log.v(TAG, new StringBuilder("point(").append(i + 1) 163 | .append(") action_down:(") 164 | .append((int) event.getX(i)) 165 | .append(",") 166 | .append(y) 167 | .append(")") 168 | .toString()); 169 | } 170 | this.mPath[event.getPointerId(event.getPointerCount() - 1)].moveTo(event.getX(), 171 | event.getY()); 172 | this.mposX[event.getPointerId(event.getPointerCount() - 1)] = event.getX(); 173 | this.mposY[event.getPointerId(event.getPointerCount() - 1)] = event.getY(); 174 | break; 175 | case XMLTableColumnDefinition.STRING_TYPE: 176 | Log.v(TAG, "最后一个点离开触摸屏"); 177 | for (i = 0; i < pointCount; i++) { 178 | y = (int) event.getY(i); 179 | Log.v(TAG, new StringBuilder("point(").append(i + 1) 180 | .append(") ACTION_UP:(") 181 | .append((int) event.getX(i)) 182 | .append(",") 183 | .append(y) 184 | .append(")") 185 | .toString()); 186 | } 187 | Log.w(TAG,"画图完毕==="+new StringBuilder(String.valueOf(getWidth())).append("\u00d7") 188 | .append(getHeight()) 189 | .toString()); 190 | Message msg = this.mainHandler.obtainMessage(); 191 | if (this.list1.size() == 0 && this.list2.size() == 0) { 192 | this.me.setFocusableInTouchMode(false); 193 | Builder builder = new Builder(getContext()); 194 | builder.setTitle("消息提示"); 195 | builder.setMessage("消息提示"); 196 | builder.create().show(); 197 | } else { 198 | Log.w("画图完毕=2==", new StringBuilder(String.valueOf(getWidth())).append("×") 199 | .append(getHeight()) 200 | .toString()); 201 | msg.what = 0; 202 | Bundle bundle = new Bundle(); 203 | bundle.putParcelableArrayList("list1", 204 | (ArrayList) this.list1); 205 | bundle.putParcelableArrayList("list2", 206 | (ArrayList) this.list2); 207 | bundle.putInt("picwidth", getWidth()); 208 | bundle.putInt("picheight", getHeight()); 209 | Log.d(TAG,"画图完毕=3==" + new StringBuilder(String.valueOf(getWidth())).append("×") 210 | .append(getHeight()) 211 | .toString()); 212 | msg.setData(bundle); 213 | this.mainHandler.sendMessage(msg); 214 | } 215 | for (i = 0; i < 10; i++) { 216 | this.mPath[i].reset(); 217 | } 218 | break; 219 | case XMLTableColumnDefinition.NUMBER_TYPE: 220 | Log.v(TAG, new StringBuilder("有").append(pointCount).append("个点同时移动").toString()); 221 | for (i = 0; i < pointCount; i++) { 222 | int x = (int) event.getX(i); 223 | y = (int) event.getY(i); 224 | TouchPoint tp = new TouchPoint(); 225 | tp.setX(x); 226 | tp.setY(y); 227 | tp.setEventTime(event.getEventTime()); 228 | TouchPoint touchPoint = new TouchPoint(); 229 | 230 | if (i == 0) { 231 | if (this.list1.size() != 0) { 232 | touchPoint = this.list1.get(this.list1.size() - 1); 233 | if (((tp.getX() - touchPoint.getX()) * (tp.getX() - touchPoint.getX())) + ((tp.getY() 234 | - touchPoint.getY()) * (tp.getY() - touchPoint.getY())) > 16) { 235 | this.list1.add(tp); 236 | Log.v(TAG, "------------移动距离超过预设距离,加入list1"); 237 | } 238 | } else { 239 | this.list1.add(tp); 240 | } 241 | } else if (i == 1) { 242 | if (this.list2.size() != 0) { 243 | touchPoint = this.list2.get(this.list2.size() - 1); 244 | if (((tp.getX() - touchPoint.getX()) * (tp.getX() - touchPoint.getX())) + ((tp.getY() 245 | - touchPoint.getY()) * (tp.getY() - touchPoint.getY())) > 16) { 246 | this.list2.add(tp); 247 | Log.v(TAG, "------------移动距离超过预设距离,加入list2"); 248 | } 249 | } else { 250 | this.list2.add(tp); 251 | } 252 | } 253 | Log.v(TAG, new StringBuilder("point(").append(i + 1) 254 | .append(") ACTION_MOVE:(") 255 | .append(x) 256 | .append(",") 257 | .append(y) 258 | .append("),") 259 | .append(event.getPointerId(i)) 260 | .toString()); 261 | } 262 | for (i = 0; i < pointCount; i++) { 263 | this.mPath[event.getPointerId(i)].quadTo(this.mposX[event.getPointerId(i)], 264 | this.mposY[event.getPointerId(i)], event.getX(i), event.getY(i)); 265 | this.mposX[event.getPointerId(i)] = event.getX(i); 266 | this.mposY[event.getPointerId(i)] = event.getY(i); 267 | } 268 | break; 269 | case SucessActivity.COUNT_DOWN_LOGOUT: 270 | Log.v(TAG, new StringBuilder("有1个点按下触摸屏.count:").append(event.getPointerCount()) 271 | .append(",") 272 | .append(event.getPointerId(event.getPointerCount() - 1)) 273 | .toString()); 274 | this.mPath[event.getPointerId(event.getPointerCount() - 1)].moveTo( 275 | event.getX(event.getPointerId(event.getPointerCount() - 1)), 276 | event.getY(event.getPointerId(event.getPointerCount() - 1))); 277 | this.mposX[event.getPointerId(event.getPointerCount() - 1)] = 278 | event.getX(event.getPointerId(event.getPointerCount() - 1)); 279 | this.mposY[event.getPointerId(event.getPointerCount() - 1)] = 280 | event.getY(event.getPointerId(event.getPointerCount() - 1)); 281 | break; 282 | case SucessActivity.GET_VERIFYCODE_SUCCESS: 283 | Log.v(TAG, "有1个点离开触摸屏"); 284 | break; 285 | } 286 | Log.w(TAG, "一次绘制结束"); 287 | return true; 288 | } 289 | 290 | public void run() { 291 | while (this.mIsRunning) { 292 | long startTime = System.currentTimeMillis(); 293 | synchronized (this.mSurfaceHolder) { 294 | this.mCanvas = this.mSurfaceHolder.lockCanvas(); 295 | Matrix matrix = new Matrix(); 296 | matrix.setScale(((float) getWidth()) / ((float) this.bitmap.getWidth()), 297 | ((float) getHeight()) / ((float) this.bitmap.getHeight())); 298 | matrix.postTranslate(0.0f, 0.0f); 299 | if (this.mCanvas != null) { 300 | this.mCanvas.drawBitmap(this.bitmap, matrix, this.mPaint); 301 | for (int i = 0; i < 2; i++) { 302 | this.mCanvas.drawPath(this.mPath[i], this.touchPaints[i]); 303 | } 304 | this.mSurfaceHolder.unlockCanvasAndPost(this.mCanvas); 305 | } 306 | } 307 | int diffTime = (int) (System.currentTimeMillis() - startTime); 308 | while (diffTime <= 50) { 309 | diffTime = (int) (System.currentTimeMillis() - startTime); 310 | Thread.yield(); 311 | } 312 | } 313 | } 314 | 315 | public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { 316 | drawBackground(); 317 | } 318 | 319 | public void surfaceCreated(SurfaceHolder holder) { 320 | drawBackground(); 321 | this.mIsRunning = true; 322 | new Thread(this).start(); 323 | } 324 | 325 | public void surfaceDestroyed(SurfaceHolder holder) { 326 | this.mIsRunning = false; 327 | } 328 | 329 | private void drawBackground() { 330 | this.mCanvas = this.mSurfaceHolder.lockCanvas(); 331 | Matrix matrix = new Matrix(); 332 | Log.d(TAG, "清空画布==drawBackground==" + new StringBuilder(String.valueOf(getWidth())).append("×") 333 | .append(getHeight()) 334 | .toString()); 335 | float widthRatio = ((float) getWidth()) / ((float) this.bitmap.getWidth()); 336 | float heightRatio = ((float) getHeight()) / ((float) this.bitmap.getHeight()); 337 | Log.d(TAG, "清空画布drawBackground,clie" + new StringBuilder(String.valueOf(getWidth())).append("×") 338 | .append(getHeight()) 339 | .toString()); 340 | matrix.setScale(widthRatio, heightRatio); 341 | matrix.postTranslate(0.0f, 0.0f); 342 | this.mCanvas.drawBitmap(this.bitmap, matrix, this.mPaint); 343 | this.mSurfaceHolder.unlockCanvasAndPost(this.mCanvas); 344 | } 345 | } 346 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/SetAccountActivity.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog.Builder; 5 | import android.app.Dialog; 6 | import android.content.DialogInterface; 7 | import android.content.DialogInterface.OnClickListener; 8 | import android.content.Intent; 9 | import android.content.SharedPreferences; 10 | import android.content.SharedPreferences.Editor; 11 | import android.os.Bundle; 12 | import android.view.LayoutInflater; 13 | import android.view.MotionEvent; 14 | import android.view.View; 15 | import android.view.View.OnTouchListener; 16 | import android.widget.EditText; 17 | import android.widget.ImageButton; 18 | import android.widget.ImageView; 19 | import android.widget.TableLayout; 20 | import android.widget.TableRow; 21 | import android.widget.TableRow.LayoutParams; 22 | import android.widget.TextView; 23 | import android.widget.Toast; 24 | import com.google.code.microlog4android.Level; 25 | import com.google.code.microlog4android.appender.SyslogMessage; 26 | import java.lang.reflect.Field; 27 | import java.util.Set; 28 | import org.dom4j.swing.XMLTableColumnDefinition; 29 | 30 | public class SetAccountActivity extends Activity { 31 | public static final String DEFAULT_ACCOUNT = "default_account"; 32 | public static final int REFRESH = 0; 33 | private Dialog accountDialog; 34 | private ImageView btnAdd; 35 | private SharedPreferences defaultAccFile; 36 | private int defaultAccountTextId; 37 | private EditText password; 38 | private SharedPreferences sp; 39 | private TableLayout tableLayout; 40 | private EditText username; 41 | 42 | class AnonymousClass_10 implements OnClickListener { 43 | private final /* synthetic */ String val$oldAccount; 44 | private final /* synthetic */ String val$oldPasswd; 45 | private final /* synthetic */ TextView val$tv; 46 | private final /* synthetic */ TextView val$tvValue; 47 | 48 | AnonymousClass_10(String str, String str2, TextView textView, TextView textView2) { 49 | this.val$oldAccount = str; 50 | this.val$oldPasswd = str2; 51 | this.val$tv = textView; 52 | this.val$tvValue = textView2; 53 | } 54 | 55 | public void onClick(DialogInterface dialog, int which) { 56 | if (SetAccountActivity.this.username.getText().toString().isEmpty() || SetAccountActivity.this.password.getText().toString().isEmpty()) { 57 | Toast.makeText(SetAccountActivity.this.getApplicationContext(), "\u5e10\u53f7\u548c\u5bc6\u7801\u5747\u4e0d\u80fd\u4e3a\u7a7a\uff01", 0).show(); 58 | SetAccountActivity.this.username.setText(this.val$oldAccount); 59 | SetAccountActivity.this.password.setText(this.val$oldPasswd); 60 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, false); 61 | } else if (SetAccountActivity.this.username.getText().toString().equals(this.val$oldAccount) || !SetAccountActivity.this.sp.getAll().keySet().contains(SetAccountActivity.this.username.getText().toString())) { 62 | Editor editor = SetAccountActivity.this.sp.edit(); 63 | editor.remove(this.val$oldAccount); 64 | editor.putString(SetAccountActivity.this.username.getText().toString(), SetAccountActivity.this.password.getText().toString()); 65 | editor.commit(); 66 | this.val$tv.setText(SetAccountActivity.this.accountShowOnPage(SetAccountActivity.this.username.getText().toString())); 67 | this.val$tvValue.setText(SetAccountActivity.this.username.getText().toString()); 68 | if (SetAccountActivity.this.defaultAccFile.getString(DEFAULT_ACCOUNT, "").equals(this.val$oldAccount)) { 69 | ((TextView) SetAccountActivity.this.findViewById(R.id.defaultAccount)).setText(SetAccountActivity.this.username.getText().toString()); 70 | Editor defEditor = SetAccountActivity.this.defaultAccFile.edit(); 71 | defEditor.putString(DEFAULT_ACCOUNT, SetAccountActivity.this.username.getText().toString()); 72 | defEditor.commit(); 73 | } 74 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, true); 75 | } else { 76 | Toast.makeText(SetAccountActivity.this.getApplicationContext(), R.string.setAccountActivity_account_exists_error, 0).show(); 77 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, false); 78 | } 79 | } 80 | } 81 | 82 | class AnonymousClass_12 implements OnClickListener { 83 | private final /* synthetic */ TextView val$oldAcc; 84 | private final /* synthetic */ TextView val$oldAccVal; 85 | private final /* synthetic */ View val$view; 86 | 87 | AnonymousClass_12(View view, TextView textView, TextView textView2) { 88 | this.val$view = view; 89 | this.val$oldAccVal = textView; 90 | this.val$oldAcc = textView2; 91 | } 92 | 93 | public void onClick(DialogInterface dialog, int which) { 94 | SetAccountActivity.this.tableLayout.removeView((TableRow) this.val$view.getParent()); 95 | Editor editor = SetAccountActivity.this.sp.edit(); 96 | editor.remove(this.val$oldAccVal.getText().toString()); 97 | editor.commit(); 98 | int delRow = this.val$oldAcc.getId() / 10; 99 | int nextAccountId = this.val$oldAcc.getId() + 10; 100 | for (int start = 0; start < SetAccountActivity.this.sp.getAll().size() - delRow; start++) { 101 | TextView t = (TextView) SetAccountActivity.this.findViewById(nextAccountId); 102 | ImageView editButton = (ImageView) SetAccountActivity.this.findViewById(nextAccountId + 1); 103 | ImageView delButton = (ImageView) SetAccountActivity.this.findViewById(nextAccountId + 2); 104 | TextView defaultText = (TextView) SetAccountActivity.this.findViewById(nextAccountId + 3); 105 | TextView valueText = (TextView) SetAccountActivity.this.findViewById(nextAccountId + 4); 106 | int newaccId = t.getId() - 10; 107 | t.setId(newaccId); 108 | editButton.setId(newaccId + 1); 109 | delButton.setId(newaccId + 2); 110 | defaultText.setId(newaccId + 3); 111 | valueText.setId(newaccId + 4); 112 | nextAccountId += 10; 113 | } 114 | if (this.val$oldAccVal.getText().equals(SetAccountActivity.this.defaultAccFile.getString(DEFAULT_ACCOUNT, ""))) { 115 | ((TextView) SetAccountActivity.this.findViewById(R.id.defaultAccount)).setText(""); 116 | Editor defaulAccount = SetAccountActivity.this.defaultAccFile.edit(); 117 | defaulAccount.remove(DEFAULT_ACCOUNT); 118 | defaulAccount.commit(); 119 | } 120 | } 121 | } 122 | 123 | class AnonymousClass_14 implements OnClickListener { 124 | private final /* synthetic */ TextView val$oldAcc; 125 | private final /* synthetic */ View val$view; 126 | 127 | AnonymousClass_14(View view, TextView textView) { 128 | this.val$view = view; 129 | this.val$oldAcc = textView; 130 | } 131 | 132 | public void onClick(DialogInterface dialog, int which) { 133 | SetAccountActivity.this.setDefaultAccount(this.val$view.getId(), this.val$oldAcc.getText().toString()); 134 | } 135 | } 136 | 137 | protected void onCreate(Bundle savedInstanceState) { 138 | requestWindowFeature(1); 139 | super.onCreate(savedInstanceState); 140 | setContentView(R.layout.setting_account); 141 | ImageButton buttBack = (ImageButton) findViewById(R.id.userbacklogin); 142 | TextView defaultAccount = (TextView) findViewById(R.id.defaultAccount); 143 | this.sp = getSharedPreferences("passwordFile", 0); 144 | this.defaultAccFile = getSharedPreferences(DEFAULT_ACCOUNT, 0); 145 | defaultAccount.setText(this.defaultAccFile.getString(DEFAULT_ACCOUNT, "")); 146 | this.tableLayout = (TableLayout) findViewById(R.id.accountTable); 147 | this.btnAdd = (ImageView) findViewById(R.id.btnAddAccount); 148 | int i = 1; 149 | for (String key : this.sp.getAll().keySet()) { 150 | showAccount(key, i); 151 | i++; 152 | } 153 | this.btnAdd.setBackgroundResource(R.drawable.account_add); 154 | this.btnAdd.setOnTouchListener(new OnTouchListener() { 155 | public boolean onTouch(View arg0, MotionEvent arg1) { 156 | if (arg1.getAction() == 0) { 157 | arg0.setBackgroundResource(R.drawable.account_add_down); 158 | } else if (arg1.getAction() == 1) { 159 | arg0.setBackgroundResource(R.drawable.account_add); 160 | } 161 | return false; 162 | } 163 | }); 164 | this.btnAdd.setOnClickListener(new View.OnClickListener() { 165 | public void onClick(View view) { 166 | SetAccountActivity.this.addAccountDialog(); 167 | } 168 | }); 169 | buttBack.setBackgroundResource(R.drawable.returnbutton); 170 | buttBack.setOnTouchListener(new OnTouchListener() { 171 | public boolean onTouch(View arg0, MotionEvent arg1) { 172 | if (arg1.getAction() == 0) { 173 | arg0.setBackgroundResource(R.drawable.returnbutton_down); 174 | } else if (arg1.getAction() == 1) { 175 | arg0.setBackgroundResource(R.drawable.returnbutton); 176 | } 177 | return false; 178 | } 179 | }); 180 | buttBack.setOnClickListener(new View.OnClickListener() { 181 | public void onClick(View view) { 182 | Intent intent = new Intent(); 183 | intent.setClass(SetAccountActivity.this, MainActivity.class); 184 | SetAccountActivity.this.startActivity(intent); 185 | SetAccountActivity.this.finish(); 186 | } 187 | }); 188 | } 189 | 190 | public void addAccountDialog() { 191 | View longinDialogView = LayoutInflater.from(this).inflate(R.layout.add_account, null); 192 | this.username = (EditText) longinDialogView.findViewById(R.id.edit_usename); 193 | this.password = (EditText) longinDialogView.findViewById(R.id.edit_passwd); 194 | this.accountDialog = new Builder(this).setTitle("\u6dfb\u52a0\u5e10\u53f7").setView(longinDialogView).setPositiveButton("\u786e\u5b9a", new OnClickListener() { 195 | public void onClick(DialogInterface dialog, int which) { 196 | SetAccountActivity.this.addAccount(SetAccountActivity.this.username.getText().toString(), SetAccountActivity.this.password.getText().toString()); 197 | } 198 | }).setNeutralButton("\u53d6\u6d88", new OnClickListener() { 199 | public void onClick(DialogInterface dialog, int which) { 200 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, true); 201 | } 202 | }).create(); 203 | this.accountDialog.show(); 204 | } 205 | 206 | private void addAccount(String account, String passwd) { 207 | if (account.isEmpty() || passwd.isEmpty()) { 208 | Toast.makeText(getApplicationContext(), "\u5e10\u53f7\u6216\u5bc6\u7801\u5747\u4e0d\u80fd\u4e3a\u7a7a\uff01", 0).show(); 209 | setDialogMiss(this.accountDialog, false); 210 | return; 211 | } 212 | Set keys = this.sp.getAll().keySet(); 213 | if (keys.contains(account)) { 214 | Toast.makeText(getApplicationContext(), R.string.setAccountActivity_account_exists_error, 0).show(); 215 | setDialogMiss(this.accountDialog, false); 216 | return; 217 | } 218 | Editor editor = this.sp.edit(); 219 | editor.putString(account, passwd); 220 | editor.commit(); 221 | if (keys.size() == 0) { 222 | Editor defAccountEditor = this.defaultAccFile.edit(); 223 | defAccountEditor.putString(DEFAULT_ACCOUNT, account); 224 | defAccountEditor.commit(); 225 | ((TextView) findViewById(R.id.defaultAccount)).setText(account); 226 | this.defaultAccountTextId = 13; 227 | } 228 | Toast.makeText(getApplicationContext(), "\u5e10\u53f7\u4fdd\u5b58\u6210\u529f\uff01", 0).show(); 229 | setDialogMiss(this.accountDialog, true); 230 | showAccount(account, keys.size() + 1); 231 | } 232 | 233 | private void setDialogMiss(Dialog accountDialog, boolean miss) { 234 | try { 235 | Field field = accountDialog.getClass().getSuperclass().getDeclaredField("mShowing"); 236 | field.setAccessible(true); 237 | field.set(accountDialog, Boolean.valueOf(miss)); 238 | } catch (Exception e) { 239 | e.printStackTrace(); 240 | } 241 | if (miss) { 242 | accountDialog.dismiss(); 243 | } 244 | } 245 | 246 | private void showAccount(String account, int order) { 247 | TextView accountText = new TextView(this); 248 | accountText.setId(Integer.valueOf(new StringBuilder(String.valueOf(order)).append("0").toString()).intValue()); 249 | accountText.setText(accountShowOnPage(account)); 250 | accountText.setGravity(XMLTableColumnDefinition.NODE_TYPE); 251 | accountText.setPadding(25, 25, 0, 25); 252 | accountText.getPaint().setFlags(Level.ERROR_INT); 253 | accountText.setLayoutParams(new LayoutParams(-1, -2)); 254 | TextView accountDefault = new TextView(this); 255 | accountDefault.setId(Integer.valueOf(new StringBuilder(String.valueOf(order)).append("3").toString()).intValue()); 256 | if (this.defaultAccFile.getString(DEFAULT_ACCOUNT, "").equals(account)) { 257 | this.defaultAccountTextId = accountDefault.getId(); 258 | } else { 259 | accountDefault.setText("\u8bbe\u4e3a\u9ed8\u8ba4"); 260 | } 261 | LayoutParams defParams = new LayoutParams(-1, -2); 262 | defParams.rightMargin = 25; 263 | accountDefault.setPadding(0, 25, 0, 25); 264 | accountDefault.setLayoutParams(defParams); 265 | accountDefault.setOnClickListener(new View.OnClickListener() { 266 | public void onClick(View view) { 267 | if (!((TextView) SetAccountActivity.this.findViewById(Integer.valueOf(view.getId()).intValue())).getText().toString().isEmpty()) { 268 | SetAccountActivity.this.defaultAccount(view); 269 | } 270 | } 271 | }); 272 | ImageView ivEdit = new ImageView(this); 273 | ivEdit.setId(Integer.valueOf(new StringBuilder(String.valueOf(order)).append("1").toString()).intValue()); 274 | ivEdit.setBackgroundResource(R.drawable.account_edit); 275 | LayoutParams editParams = new LayoutParams(-1, -2); 276 | editParams.rightMargin = 25; 277 | ivEdit.setLayoutParams(editParams); 278 | ivEdit.setOnClickListener(new View.OnClickListener() { 279 | public void onClick(View view) { 280 | SetAccountActivity.this.editAccount(view); 281 | } 282 | }); 283 | ImageView ivDel = new ImageView(this); 284 | ivDel.setId(Integer.valueOf(new StringBuilder(String.valueOf(order)).append("2").toString()).intValue()); 285 | ivDel.setBackgroundResource(R.drawable.account_del); 286 | LayoutParams delParams = new LayoutParams(-1, -2); 287 | delParams.rightMargin = 25; 288 | ivDel.setLayoutParams(delParams); 289 | ivDel.setOnClickListener(new View.OnClickListener() { 290 | public void onClick(View view) { 291 | SetAccountActivity.this.delAccount(view); 292 | } 293 | }); 294 | TextView accountValueText = new TextView(this); 295 | accountValueText.setId(Integer.valueOf(new StringBuilder(String.valueOf(order)).append("4").toString()).intValue()); 296 | accountValueText.setText(account); 297 | accountValueText.setVisibility(Level.ERROR_INT); 298 | TableRow tableRow = new TableRow(this); 299 | tableRow.setGravity(17); 300 | tableRow.setBackgroundColor(getResources().getColor(R.color.lightbulue)); 301 | tableRow.setLayoutParams(new LayoutParams(-1, -2)); 302 | tableRow.addView(accountText); 303 | tableRow.addView(accountDefault); 304 | tableRow.addView(ivEdit); 305 | tableRow.addView(ivDel); 306 | tableRow.addView(accountValueText); 307 | this.tableLayout.addView(tableRow); 308 | } 309 | 310 | private String accountShowOnPage(String account) { 311 | StringBuilder accountShow = new StringBuilder(); 312 | int accLen = account.length(); 313 | if (accLen > 10) { 314 | accountShow = new StringBuilder(account.substring(0, SyslogMessage.TEN)); 315 | accountShow.append("...").append(account.substring(accLen - 6)); 316 | } else { 317 | accountShow.append(account); 318 | } 319 | return accountShow.toString(); 320 | } 321 | 322 | private void editAccount(View view) { 323 | TextView tv = (TextView) findViewById(Integer.valueOf(view.getId() - 1).intValue()); 324 | TextView tvValue = (TextView) findViewById(Integer.valueOf(view.getId() + 3).intValue()); 325 | String oldAccount = tvValue.getText().toString(); 326 | String oldPasswd = this.sp.getString(oldAccount, ""); 327 | View longinDialogView = LayoutInflater.from(this).inflate(R.layout.add_account, null); 328 | this.username = (EditText) longinDialogView.findViewById(R.id.edit_usename); 329 | this.password = (EditText) longinDialogView.findViewById(R.id.edit_passwd); 330 | this.username.setText(oldAccount); 331 | this.password.setText(oldPasswd); 332 | this.accountDialog = new Builder(this).setTitle("\u7f16\u8f91\u5e10\u53f7").setView(longinDialogView).setPositiveButton("\u786e\u5b9a", new AnonymousClass_10(oldAccount, oldPasswd, tv, tvValue)).setNeutralButton("\u53d6\u6d88", new OnClickListener() { 333 | public void onClick(DialogInterface dialog, int which) { 334 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, true); 335 | } 336 | }).create(); 337 | this.accountDialog.show(); 338 | } 339 | 340 | private void delAccount(View view) { 341 | TextView oldAccVal = (TextView) findViewById(Integer.valueOf(view.getId() + 2).intValue()); 342 | this.accountDialog = new Builder(this).setTitle("\u5220\u9664\u5e10\u53f7").setMessage(new StringBuilder("\u786e\u5b9a\u5220\u9664\u5e10\u53f7").append(oldAccVal.getText()).append("\u5417\uff1f").toString()).setPositiveButton("\u786e\u5b9a", new AnonymousClass_12(view, oldAccVal, (TextView) findViewById(Integer.valueOf(view.getId() - 2).intValue()))).setNeutralButton("\u53d6\u6d88", new OnClickListener() { 343 | public void onClick(DialogInterface dialog, int which) { 344 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, true); 345 | } 346 | }).create(); 347 | this.accountDialog.show(); 348 | } 349 | 350 | private void defaultAccount(View view) { 351 | TextView oldAcc = (TextView) findViewById(Integer.valueOf(view.getId() + 1).intValue()); 352 | this.accountDialog = new Builder(this).setTitle("\u9ed8\u8ba4\u5e10\u53f7").setMessage(new StringBuilder("\u786e\u5b9a\u8bbe\u7f6e\u5e10\u53f7").append(oldAcc.getText()).append("\u4e3a\u9ed8\u8ba4\u5e10\u53f7\u5417\uff1f").toString()).setPositiveButton("\u786e\u5b9a", new AnonymousClass_14(view, oldAcc)).setNeutralButton("\u53d6\u6d88", new OnClickListener() { 353 | public void onClick(DialogInterface dialog, int which) { 354 | SetAccountActivity.this.setDialogMiss(SetAccountActivity.this.accountDialog, true); 355 | } 356 | }).create(); 357 | this.accountDialog.show(); 358 | } 359 | 360 | private void setDefaultAccount(int id, String newAccount) { 361 | ((TextView) findViewById(R.id.defaultAccount)).setText(newAccount); 362 | Editor editor = this.defaultAccFile.edit(); 363 | editor.putString(DEFAULT_ACCOUNT, newAccount); 364 | editor.commit(); 365 | if (this.defaultAccountTextId != 0) { 366 | TextView oldDefTextView = (TextView) findViewById(this.defaultAccountTextId); 367 | if (oldDefTextView != null) { 368 | oldDefTextView.setText("\u8bbe\u4e3a\u9ed8\u8ba4"); 369 | } 370 | } 371 | this.defaultAccountTextId = id; 372 | ((TextView) findViewById(this.defaultAccountTextId)).setText(""); 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/WELCOMEActivity.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; 7 | import android.util.Log; 8 | import android.view.Window; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | public class WELCOMEActivity extends BaseActivity { 13 | private final int SPLASH_DISPLAY_LENGHT; 14 | private ImageView image; 15 | 16 | public WELCOMEActivity() { 17 | this.SPLASH_DISPLAY_LENGHT = 5000; 18 | this.image = null; 19 | } 20 | 21 | public void onCreate(Bundle savedInstanceState) { 22 | requestWindowFeature(Window.FEATURE_NO_TITLE); 23 | getWindow().setFlags(AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT, 24 | AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT); 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.welcome); 27 | String version = null; 28 | this.logger.debug("onCreate ====step1========"); 29 | try { 30 | version = getVersionName(); 31 | } catch (Exception e) { 32 | Log.e("\u6b22\u8fce\u9875\u9762\u83b7\u53d6\u7248\u672c\u53f7\u53d1\u751f\u5f02\u5e38", 33 | e.getMessage()); 34 | this.logger.error(new StringBuilder( 35 | "\u6b22\u8fce\u9875\u9762\u83b7\u53d6\u7248\u672c\u53f7\u53d1\u751f\u5f02\u5e38").append( 36 | e.getMessage()).toString()); 37 | e.printStackTrace(); 38 | } 39 | this.logger.debug("onCreate ==step2=========="); 40 | if (version != null) { 41 | ((TextView) findViewById(R.id.version)).setText( 42 | new StringBuilder("V ").append(version).toString()); 43 | } 44 | //The progressbar is fake!!!! 45 | new Handler().postDelayed(new Runnable() { 46 | public void run() { 47 | WELCOMEActivity.this.startActivity(new Intent(WELCOMEActivity.this, MainActivity.class)); 48 | WELCOMEActivity.this.finish(); 49 | } 50 | }, 5000); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/WifiManagerUtil.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient; 2 | 3 | import android.content.Context; 4 | import android.net.wifi.ScanResult; 5 | import android.net.wifi.WifiConfiguration; 6 | import android.net.wifi.WifiInfo; 7 | import android.net.wifi.WifiManager; 8 | import android.text.format.Formatter; 9 | import com.google.code.microlog4android.Logger; 10 | import java.util.List; 11 | import org.dom4j.swing.XMLTableColumnDefinition; 12 | 13 | public class WifiManagerUtil { 14 | private static final String TAG = Context.WIFI_SERVICE; 15 | Logger logger; 16 | Context mContext; 17 | int mNetworkID; 18 | String mSSID; 19 | WifiConfiguration mTargetWifiCfg; 20 | List mWifiHotSpotLists; 21 | WifiInfo mWifiInfo; 22 | WifiManager mWifiManager; 23 | List mWifiScanResultLists; 24 | 25 | public WifiManagerUtil(Context c, Logger iLogger) { 26 | this.mContext = c; 27 | this.logger = iLogger; 28 | this.logger.debug(" Construct..."); 29 | } 30 | 31 | public void openWifi() { 32 | this.mWifiManager = (WifiManager) this.mContext.getSystemService(TAG); 33 | if (this.mWifiManager.isWifiEnabled()) { 34 | this.logger.debug("before have setWifiEnabled ..."); 35 | } else if (this.mWifiManager.setWifiEnabled(true)) { 36 | this.logger.debug(" setWifiEnabled...success"); 37 | } else { 38 | this.logger.debug(" setWifiEnabled...failure"); 39 | } 40 | } 41 | 42 | public void closeWifi() { 43 | if (!this.mWifiManager.isWifiEnabled()) { 44 | return; 45 | } 46 | if (this.mWifiManager.setWifiEnabled(false)) { 47 | this.logger.debug(" disableWifiEnabled...success"); 48 | } else { 49 | this.logger.debug(" disableWifiEnabled...failure"); 50 | } 51 | } 52 | 53 | public WifiInfo getWifiInfo() { 54 | if (this.mWifiManager == null) { 55 | this.mWifiManager = (WifiManager) this.mContext.getSystemService(TAG); 56 | } 57 | return this.mWifiManager.getConnectionInfo(); 58 | } 59 | 60 | public List getWifiScanResult() { 61 | this.logger.debug(" connectToTargetWifi step2======="); 62 | List wifiScanResultLists = this.mWifiManager.getScanResults(); 63 | this.logger.debug(" connectToTargetWifi step3======="); 64 | return wifiScanResultLists; 65 | } 66 | 67 | public List getWifiAllHotSpot() { 68 | List wifiHotSpotLists = this.mWifiManager.getConfiguredNetworks(); 69 | for (WifiConfiguration wifiConfiguration : wifiHotSpotLists) { 70 | this.logger.debug(new StringBuilder(" wifiConfiguration.SSID(hotSpot):").append(wifiConfiguration.SSID).toString()); 71 | } 72 | return wifiHotSpotLists; 73 | } 74 | 75 | public boolean isConfigHotSpot() { 76 | try { 77 | this.logger.debug(" connectToTargetWifi step4======="); 78 | this.mWifiHotSpotLists = getWifiAllHotSpot(); 79 | for (WifiConfiguration wifiConfiguration : this.mWifiHotSpotLists) { 80 | this.logger.debug(new StringBuilder(" connectToTargetWifi wifiConfiguration.SSID=======").append(wifiConfiguration.SSID).append("==mSSID==").append(this.mSSID).toString()); 81 | if (wifiConfiguration.SSID.equals(new StringBuilder("\"").append(this.mSSID).append("\"").toString())) { 82 | this.logger.debug(new StringBuilder("before have cfg this hotspot:").append(wifiConfiguration.SSID).toString()); 83 | return true; 84 | } 85 | } 86 | return false; 87 | } catch (Exception e) { 88 | e.printStackTrace(); 89 | this.logger.debug(new StringBuilder("isConfigHotSpot Exception:").append(e.toString()).toString()); 90 | return false; 91 | } 92 | } 93 | 94 | public boolean isScanTargetWifi() { 95 | try { 96 | this.logger.debug(" connectToTargetWifi step1======="); 97 | this.mWifiScanResultLists = getWifiScanResult(); 98 | if (this.mWifiScanResultLists == null) { 99 | return false; 100 | } 101 | for (ScanResult wifiScanResultList : this.mWifiScanResultLists) { 102 | this.logger.debug(new StringBuilder(" connectToTargetWifi====wifiScanResultList.SSID:").append(wifiScanResultList.SSID).append("==mSSID==").append(this.mSSID).toString()); 103 | if (wifiScanResultList.SSID.equals(this.mSSID)) { 104 | return true; 105 | } 106 | } 107 | return false; 108 | } catch (Exception e) { 109 | e.printStackTrace(); 110 | this.logger.debug(new StringBuilder("isScanTargetWifi Exception:").append(e.toString()).toString()); 111 | return false; 112 | } 113 | } 114 | 115 | public WifiConfiguration isExistWifiConfiguration(String ssid) { 116 | this.mWifiHotSpotLists = getWifiAllHotSpot(); 117 | for (WifiConfiguration exsitWifiConfiguration : this.mWifiHotSpotLists) { 118 | this.logger.debug(new StringBuilder(" connectToTargetWifi===wifiConfiguration.SSID:").append(exsitWifiConfiguration.SSID).append("==ssid==").append(ssid).toString()); 119 | if (exsitWifiConfiguration.SSID.equals(new StringBuilder("\"").append(ssid).append("\"").toString())) { 120 | return exsitWifiConfiguration; 121 | } 122 | } 123 | return null; 124 | } 125 | 126 | public WifiConfiguration createWifiCfg(String ssid, String password, int method) { 127 | try { 128 | this.logger.debug(" connectToTargetWifi==createWifiCfg.........................."); 129 | WifiConfiguration wifiCfg = new WifiConfiguration(); 130 | wifiCfg.allowedAuthAlgorithms.clear(); 131 | wifiCfg.allowedGroupCiphers.clear(); 132 | wifiCfg.allowedKeyManagement.clear(); 133 | wifiCfg.allowedPairwiseCiphers.clear(); 134 | wifiCfg.allowedProtocols.clear(); 135 | wifiCfg.SSID = new StringBuilder("\"").append(ssid).append("\"").toString(); 136 | switch (method) { 137 | case XMLTableColumnDefinition.OBJECT_TYPE: 138 | this.logger.debug(" createWifiCfg..........................no password "); 139 | wifiCfg.wepKeys[0] = ""; 140 | wifiCfg.allowedKeyManagement.set(0); 141 | wifiCfg.wepTxKeyIndex = 0; 142 | break; 143 | case XMLTableColumnDefinition.STRING_TYPE: 144 | this.logger.debug(" connectToTargetWifi===createWifiCfg..........................have password :WPA"); 145 | wifiCfg.preSharedKey = new StringBuilder("\"").append(password).append("\"").toString(); 146 | wifiCfg.hiddenSSID = true; 147 | wifiCfg.allowedAuthAlgorithms.set(0); 148 | wifiCfg.allowedGroupCiphers.set(XMLTableColumnDefinition.NUMBER_TYPE); 149 | wifiCfg.allowedKeyManagement.set(1); 150 | wifiCfg.allowedPairwiseCiphers.set(1); 151 | wifiCfg.allowedProtocols.set(0); 152 | wifiCfg.status = 2; 153 | break; 154 | case XMLTableColumnDefinition.NUMBER_TYPE: 155 | this.logger.debug(" createWifiCfg..........................have password :WEP"); 156 | wifiCfg.preSharedKey = new StringBuilder("\"").append(password).append("\"").toString(); 157 | wifiCfg.hiddenSSID = true; 158 | wifiCfg.allowedAuthAlgorithms.set(1); 159 | wifiCfg.allowedGroupCiphers.set(XMLTableColumnDefinition.NODE_TYPE); 160 | wifiCfg.allowedGroupCiphers.set(XMLTableColumnDefinition.NUMBER_TYPE); 161 | wifiCfg.allowedGroupCiphers.set(0); 162 | wifiCfg.allowedGroupCiphers.set(1); 163 | wifiCfg.allowedKeyManagement.set(0); 164 | wifiCfg.wepTxKeyIndex = 0; 165 | break; 166 | default: 167 | wifiCfg = null; 168 | break; 169 | } 170 | WifiConfiguration tempWifiCfg = isExistWifiConfiguration(ssid); 171 | if (tempWifiCfg == null) { 172 | return wifiCfg; 173 | } 174 | this.logger.debug("connectToTargetWifi== tempWifiCfg != null:"); 175 | this.mWifiManager.removeNetwork(tempWifiCfg.networkId); 176 | return wifiCfg; 177 | } catch (Exception e) { 178 | e.printStackTrace(); 179 | this.logger.debug(new StringBuilder("createWifiCfg Exception:").append(e.toString()).toString()); 180 | return null; 181 | } 182 | } 183 | 184 | public synchronized void connectToTargetWifi(String ssid, String password, int method) { 185 | try { 186 | this.mSSID = ssid; 187 | if (isScanTargetWifi()) { 188 | this.logger.debug(" connectToTargetWifi success======="); 189 | this.logger.debug(new StringBuilder(" connectToTargetWifi step5=====password==").append(password).append("==ssid==").append(ssid).toString()); 190 | this.mTargetWifiCfg = createWifiCfg(ssid, password, method); 191 | this.logger.debug(" connectToTargetWifi step6====="); 192 | this.mNetworkID = this.mWifiManager.addNetwork(this.mTargetWifiCfg); 193 | this.logger.debug(new StringBuilder("connectToTargetWifi==addNetwork:mTargetWifiCfg->").append(this.mTargetWifiCfg).toString()); 194 | this.logger.debug(new StringBuilder("connectToTargetWifi==addNetwork:mNetworkID->").append(this.mNetworkID).toString()); 195 | this.mWifiManager.enableNetwork(this.mNetworkID, true); 196 | this.logger.debug(" connectToTargetWifi step7====="); 197 | this.mWifiManager.reassociate(); 198 | this.logger.debug(" connectToTargetWifi step8====="); 199 | this.mWifiManager.reconnect(); 200 | this.logger.debug(" connectToTargetWifi step9====="); 201 | this.logger.debug(new StringBuilder(" connectToTargetWifi step9===dhcpinfo.ipAddress==").append(Formatter.formatIpAddress(this.mWifiManager.getDhcpInfo().ipAddress)).toString()); 202 | } else { 203 | this.logger.debug(" connectToTargetWifi fail======="); 204 | } 205 | } catch (Exception e) { 206 | e.printStackTrace(); 207 | this.logger.debug(new StringBuilder("connectToTargetWifi Exception:").append(e.toString()).toString()); 208 | } 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/model/RequestModel.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.model; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | public class RequestModel { 6 | private Bitmap bitmap; 7 | private boolean forceUpdated; 8 | private String keyvalue; 9 | private String message; 10 | private String sessionId; 11 | private String username; 12 | 13 | public RequestModel(String username, String sessionId) { 14 | this.username = username; 15 | this.sessionId = sessionId; 16 | } 17 | 18 | public RequestModel() { 19 | 20 | } 21 | 22 | public boolean isForceUpdated() { 23 | return this.forceUpdated; 24 | } 25 | 26 | public void setForceUpdated(boolean forceUpdated) { 27 | this.forceUpdated = forceUpdated; 28 | } 29 | 30 | public String getMessage() { 31 | return this.message; 32 | } 33 | 34 | public void setMessage(String message) { 35 | this.message = message; 36 | } 37 | 38 | public Bitmap getBitmap() { 39 | return this.bitmap; 40 | } 41 | 42 | public void setBitmap(Bitmap bitmap) { 43 | this.bitmap = bitmap; 44 | } 45 | 46 | public String getKeyvalue() { 47 | return this.keyvalue; 48 | } 49 | 50 | public void setKeyvalue(String keyvalue) { 51 | this.keyvalue = keyvalue; 52 | } 53 | 54 | public String getSessionId() { 55 | return this.sessionId; 56 | } 57 | 58 | public void setSessionId(String sessionId) { 59 | this.sessionId = sessionId; 60 | } 61 | 62 | public String getUsername() { 63 | return this.username; 64 | } 65 | 66 | public void setUsername(String username) { 67 | this.username = username; 68 | } 69 | 70 | public String toString() { 71 | return new StringBuilder("RequestModel [bitmap=").append(this.bitmap).append(", keyvalue=").append(this.keyvalue).append(", sessionId=").append(this.sessionId).append(", username=").append(this.username).append("]").toString(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/model/ReturnMessage.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.model; 2 | 3 | public class ReturnMessage { 4 | public static final String AUTH_EXCEPTION = "auth02"; 5 | public static final String AUTH_FALSE = "auth01"; 6 | public static final String AUTH_NAME_NULL = "auth03"; 7 | public static final String AUTH_PASS_NULL = "auth04"; 8 | public static final String AUTH_TRUE = "auth00"; 9 | public static final String DISCOVER_FALSE = "discover01"; 10 | public static final String DISCOVER_TRUE = "discover00"; 11 | public static final String KEY_EXCEPTION = "key02"; 12 | public static final String KEY_FALSE = "key01"; 13 | public static final String KEY_NULL = "key03"; 14 | public static final String KEY_TRUE = "key00"; 15 | public static final String NATCHECK = "nat01"; 16 | public static final String PIC_EXCEPTION = "pic02"; 17 | public static final String PIC_FALSE = "pic01"; 18 | public static final String PIC_NULL = "pic03"; 19 | public static final String PIC_TRUE = "pic00"; 20 | public static final String SESSION_FALSE = "session01"; 21 | public static final String VERSIONCHECK = "version01"; 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/model/TouchPoint.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.model; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | public class TouchPoint implements Parcelable { 7 | private long eventTime; 8 | private int x; 9 | private int y; 10 | 11 | public long getEventTime() { 12 | return this.eventTime; 13 | } 14 | 15 | public void setEventTime(long eventTime) { 16 | this.eventTime = eventTime; 17 | } 18 | 19 | public int getX() { 20 | return this.x; 21 | } 22 | 23 | public void setX(int x) { 24 | this.x = x; 25 | } 26 | 27 | public int getY() { 28 | return this.y; 29 | } 30 | 31 | public void setY(int y) { 32 | this.y = y; 33 | } 34 | 35 | public String toString() { 36 | return new StringBuilder("TouchPoint [x=").append(this.x).append(", y=").append(this.y).append(", eventTime=").append(this.eventTime).append("]").toString(); 37 | } 38 | 39 | @Override public int describeContents() { 40 | return 0; 41 | } 42 | 43 | @Override public void writeToParcel(Parcel dest, int flags) { 44 | dest.writeLong(this.eventTime); 45 | dest.writeInt(this.x); 46 | dest.writeInt(this.y); 47 | } 48 | 49 | public TouchPoint() { 50 | } 51 | 52 | private TouchPoint(Parcel in) { 53 | this.eventTime = in.readLong(); 54 | this.x = in.readInt(); 55 | this.y = in.readInt(); 56 | } 57 | 58 | public static final Creator CREATOR = new Creator() { 59 | public TouchPoint createFromParcel(Parcel source) { 60 | return new TouchPoint(source); 61 | } 62 | 63 | public TouchPoint[] newArray(int size) { 64 | return new TouchPoint[size]; 65 | } 66 | }; 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/model/UpdataInfo.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.model; 2 | 3 | public class UpdataInfo { 4 | private String description; 5 | private String url; 6 | private String version; 7 | 8 | public String getVersion() { 9 | return this.version; 10 | } 11 | 12 | public void setVersion(String version) { 13 | this.version = version; 14 | } 15 | 16 | public String getUrl() { 17 | return this.url; 18 | } 19 | 20 | public void setUrl(String url) { 21 | this.url = url; 22 | } 23 | 24 | public String getDescription() { 25 | return this.description; 26 | } 27 | 28 | public void setDescription(String description) { 29 | this.description = description; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/service/OnlineHeartService.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.service; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.Binder; 6 | import android.os.Handler; 7 | import android.os.IBinder; 8 | import android.os.Message; 9 | import android.util.Log; 10 | import com.google.code.microlog4android.Logger; 11 | import com.google.code.microlog4android.LoggerFactory; 12 | import com.xinli.portalclient.util.HttpUtils; 13 | import com.xinli.portalclient.util.Sim_NetKeeperClient; 14 | import java.util.ArrayList; 15 | import java.util.Date; 16 | import org.apache.http.message.BasicNameValuePair; 17 | 18 | public class OnlineHeartService extends Service { 19 | 20 | public static final String TAG = "OnlineHeartService"; 21 | private static String clientVersion; 22 | private static final Logger logger = LoggerFactory.getLogger(OnlineHeartService.class); 23 | private static String phoneIp; 24 | private static String sessionId; 25 | private static String url = null; 26 | private static String username; 27 | private Binder binder = new LocalBinder(); 28 | private Handler handler = new Handler() { 29 | public void handleMessage(Message paramAnonymousMessage) { 30 | super.handleMessage(paramAnonymousMessage); 31 | } 32 | }; 33 | 34 | private Handler proxyHandler = new Handler(); 35 | private Runnable proxyRunnable = new Runnable() { 36 | public void run() { 37 | } 38 | }; 39 | private Runnable runable = new Runnable() { 40 | public void run() { 41 | OnlineHeartService.this.sendOnlineHeart(); 42 | handler.postDelayed(runable, 120000L); 43 | } 44 | }; 45 | private boolean sendHeart = true; 46 | 47 | static { 48 | sessionId = null; 49 | phoneIp = null; 50 | clientVersion = null; 51 | username = null; 52 | } 53 | 54 | public OnlineHeartService() { 55 | } 56 | 57 | 58 | private void sendOnlineHeart() { 59 | ArrayList localArrayList = new ArrayList(); 60 | localArrayList.add(new BasicNameValuePair("username", username)); 61 | try { 62 | Log.d(TAG, 63 | "sendOnlineHeart:" + url + "/wf.do?code=7 ,sessionId:" + sessionId + ",time:" + new Date()); 64 | String str = 65 | HttpUtils.sendContentByHttpPost(url + "/wf.do?code=7", sessionId, localArrayList); 66 | logger.info("sendOnlineHeart done:" + str); 67 | return; 68 | } catch (Exception localException) { 69 | onlineHeartBroadcast(); 70 | Log.d(TAG,"sendOnlineHeart error!" + localException.getMessage()); 71 | sendHeart = false; 72 | } 73 | } 74 | 75 | private void sendProxyHeart() { 76 | try { 77 | Log.d(TAG, 78 | "sendProxyHeart: ip:" + phoneIp + ",version:" + clientVersion + "username:" + username); 79 | new Sim_NetKeeperClient().sendHeart(username, phoneIp, "android" + clientVersion); 80 | Log.d(TAG,"sendProxyHeart success!"); 81 | return; 82 | } catch (Exception localException) { 83 | Log.d(TAG,"sendProxyHeart exception!" + localException.getMessage()); 84 | localException.printStackTrace(); 85 | } 86 | } 87 | 88 | @Override 89 | public IBinder onBind(Intent paramIntent) { 90 | Log.i("OnlineHeartService", "onBind"); 91 | url = paramIntent.getStringExtra("url"); 92 | sessionId = paramIntent.getStringExtra("sessionId"); 93 | phoneIp = paramIntent.getStringExtra("phoneIp"); 94 | clientVersion = paramIntent.getStringExtra("clientVersion"); 95 | username = paramIntent.getStringExtra("username"); 96 | return binder; 97 | } 98 | 99 | @Override 100 | public void onCreate() { 101 | super.onCreate(); 102 | Log.i("OnlineHeartService", "onCreate"); 103 | handler.post(runable); 104 | } 105 | 106 | @Override 107 | public void onDestroy() { 108 | super.onDestroy(); 109 | Log.i("OnlineHeartService", "onDestroy"); 110 | } 111 | 112 | @Override 113 | public void onRebind(Intent paramIntent) { 114 | super.onRebind(paramIntent); 115 | Log.i("OnlineHeartService", "onRebind"); 116 | } 117 | 118 | @Override 119 | public boolean onUnbind(Intent paramIntent) { 120 | Log.i("OnlineHeartService", "onUnbind"); 121 | handler.removeCallbacks(runable); 122 | return super.onUnbind(paramIntent); 123 | } 124 | 125 | public void onlineHeartBroadcast() { 126 | Intent localIntent = new Intent(); 127 | localIntent.putExtra("onlineHeart", "Exception"); 128 | localIntent.setAction("android.intent.onlineheart.exception"); 129 | sendBroadcast(localIntent); 130 | } 131 | 132 | public class LocalBinder extends Binder { 133 | public LocalBinder() { 134 | } 135 | 136 | public OnlineHeartService getService() { 137 | return OnlineHeartService.this; 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/AESByKey.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.support.annotation.NonNull; 5 | import com.google.code.microlog4android.Level; 6 | import javax.crypto.Cipher; 7 | import javax.crypto.spec.SecretKeySpec; 8 | import org.dom4j.swing.XMLTableColumnDefinition; 9 | 10 | @SuppressLint({ "DefaultLocale" }) 11 | public class AESByKey { 12 | private static final String AES = "AES"; 13 | 14 | public static byte[] encrypt(byte[] src, @NonNull String key) throws Exception { 15 | Cipher cipher = Cipher.getInstance(AES); 16 | cipher.init(1, new SecretKeySpec(key.getBytes(), AES)); 17 | return cipher.doFinal(src); 18 | } 19 | 20 | public static byte[] decrypt(byte[] src, String key) throws Exception { 21 | Cipher cipher = Cipher.getInstance(AES); 22 | cipher.init(XMLTableColumnDefinition.NUMBER_TYPE, new SecretKeySpec(key.getBytes(), AES)); 23 | return cipher.doFinal(src); 24 | } 25 | 26 | public static String byte2hex(byte[] b) { 27 | String hs = ""; 28 | String str = ""; 29 | for (byte b2 : b) { 30 | str = Integer.toHexString(b2 & 255); 31 | if (str.length() == 1) { 32 | hs = new StringBuilder(String.valueOf(hs)).append("0").append(str).toString(); 33 | } else { 34 | hs = new StringBuilder(String.valueOf(hs)).append(str).toString(); 35 | } 36 | } 37 | return hs.toUpperCase(); 38 | } 39 | 40 | public static byte[] hex2byte(byte[] b) { 41 | if (b.length % 2 != 0) { 42 | throw new IllegalArgumentException("\u957f\u5ea6\u4e0d\u662f\u5076\u6570"); 43 | } 44 | byte[] b2 = new byte[(b.length / 2)]; 45 | for (int n = 0; n < b.length; n += 2) { 46 | b2[n / 2] = (byte) Integer.parseInt(new String(b, n, 2), Level.FATAL_INT); 47 | } 48 | return b2; 49 | } 50 | 51 | public static final String decrypt(String data, String key) { 52 | try { 53 | return new String(decrypt(hex2byte(data.getBytes()), key)); 54 | } catch (Exception e) { 55 | return null; 56 | } 57 | } 58 | 59 | public static final byte[] encrypt(String data, String key) { 60 | try { 61 | return encrypt(data.getBytes(), key); 62 | } catch (Exception e) { 63 | return null; 64 | } 65 | } 66 | 67 | public static final String encryptToString(String data, String key) { 68 | try { 69 | return byte2hex(encrypt(data.getBytes(), key)); 70 | } catch (Exception e) { 71 | return null; 72 | } 73 | } 74 | 75 | public byte[] intToByte(int i) { 76 | return new byte[] { 77 | (byte) (i & 255), (byte) ((65280 & i) >> 8), (byte) ((16711680 & i) >> 16), 78 | (byte) ((-16777216 & i) >> 24) 79 | }; 80 | } 81 | 82 | 83 | public static int bytesToInt(byte[] bytes) { 84 | return (((bytes[0] & 255) | ((bytes[1] << 8) & 65280)) | ((bytes[2] << 16) & 16711680)) | (( 85 | bytes[3] 86 | << 24) & -16777216); 87 | } 88 | 89 | //这个是外包的码农写的吧!!!??? 90 | public static void main(String[] args) { 91 | System.out.println(new StringBuilder("enCode=").append(byte2hex( 92 | encrypt("TEL=15829350859&SEQ=411D23BB-6A71-44C3-B468-123B643ED8BF", "0123456789012345"))) 93 | .toString()); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/BitmapUtils.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.graphics.BitmapFactory; 6 | import android.os.Build; 7 | import android.os.Build.VERSION; 8 | import android.util.Log; 9 | import com.google.code.microlog4android.Logger; 10 | import com.google.code.microlog4android.LoggerFactory; 11 | import com.xinli.portalclient.model.RequestModel; 12 | import com.xinli.portalclient.model.ReturnMessage; 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.io.OutputStream; 16 | import java.net.HttpURLConnection; 17 | import java.net.URL; 18 | import java.net.URLEncoder; 19 | 20 | public class BitmapUtils { 21 | public static final String TAG = BitmapUtils.class.getSimpleName(); 22 | public static final int REQUEST_TIMEOUT = 5000; 23 | public static final int SO_TIMEOUT = 10000; 24 | protected static final Logger logger; 25 | 26 | static { 27 | logger = LoggerFactory.getLogger(BitmapUtils.class); 28 | } 29 | 30 | public static boolean isHaveinitRealAddress(String requestUrl) throws RuntimeException { 31 | InputStream inputStream = null; 32 | HttpURLConnection httpURLConnection = null; 33 | boolean isredirect = true; 34 | try { 35 | Log.i(TAG, "init redirect url:" + requestUrl); 36 | URL myFileUrl = new URL(requestUrl); 37 | try { 38 | httpURLConnection = (HttpURLConnection) myFileUrl.openConnection(); 39 | httpURLConnection.setConnectTimeout(REQUEST_TIMEOUT); 40 | httpURLConnection.setReadTimeout(SO_TIMEOUT); 41 | httpURLConnection.setDoInput(true); 42 | httpURLConnection.connect(); 43 | inputStream = httpURLConnection.getInputStream(); 44 | String realUrl = httpURLConnection.getURL().toString().split("\\?")[0]; 45 | if (requestUrl.equalsIgnoreCase(realUrl)) { 46 | isredirect = false; 47 | Log.v(TAG, "URL no redirected :" + requestUrl); 48 | } else { 49 | Config.realUrl = realUrl; 50 | Log.v(TAG, "URL redirected :" + realUrl); 51 | } 52 | if (httpURLConnection != null) { 53 | httpURLConnection.disconnect(); 54 | } 55 | closeStream(inputStream, null); 56 | return isredirect; 57 | } catch (IOException e) { 58 | Log.e(TAG,"error" + e.getMessage()); 59 | } 60 | } catch (IOException e3) { 61 | throw new RuntimeException(e3.getMessage()); 62 | } finally { 63 | if (httpURLConnection != null) { 64 | httpURLConnection.disconnect(); 65 | } 66 | closeStream(inputStream, null); 67 | return false; 68 | } 69 | } 70 | 71 | public static RequestModel requestBeforeLogin(String requestUrl, int screenWidth, 72 | int screenHeight, String clientVersion, String localIp) throws RuntimeException { 73 | RequestModel requestResult = new RequestModel(); 74 | try { 75 | 76 | if (Config.realUrl == null) { 77 | isHaveinitRealAddress(Config.firstRreqUrl); 78 | } 79 | 80 | Log.i(TAG,"requestBeforeLogin "+ requestUrl); 81 | RequestModel keyResult = getKey(clientVersion, localIp); 82 | if (ReturnMessage.VERSIONCHECK.equals(keyResult.getMessage()) 83 | || ReturnMessage.NATCHECK.equals(keyResult.getMessage())) { 84 | 85 | return keyResult; 86 | } 87 | 88 | requestResult.setKeyvalue(keyResult.getKeyvalue()); 89 | requestResult.setSessionId(keyResult.getSessionId()); 90 | RequestModel picResult = getPicture(keyResult.getSessionId(), screenWidth, screenHeight); 91 | requestResult.setBitmap(picResult.getBitmap()); 92 | 93 | return requestResult; 94 | } catch (Exception e) { 95 | 96 | throw new RuntimeException(e.getMessage()); 97 | } 98 | } 99 | 100 | public static Bitmap getLoacalBitmapByAssets(Context paramContext, String paramString) { 101 | InputStream localInputStream = null; 102 | try { 103 | localInputStream = paramContext.getResources().getAssets().open(paramString); 104 | Bitmap localBitmap = BitmapFactory.decodeStream(localInputStream); 105 | return localBitmap; 106 | } catch (IOException localIOException) { 107 | localIOException.printStackTrace(); 108 | return null; 109 | } finally { 110 | closeStream(localInputStream, null); 111 | } 112 | } 113 | 114 | //download bitmap from realUrl 115 | public static RequestModel getPicture(String sessionId, int screenWidth, int screenHeight) 116 | throws RuntimeException { 117 | Throwable th; 118 | RequestModel requestResult = new RequestModel(); 119 | InputStream in = null; 120 | try { 121 | if (Config.realUrl == null) { 122 | isHaveinitRealAddress(Config.firstRreqUrl); 123 | } 124 | Log.d(TAG, "getPicture/url: " + Config.realUrl + "/wf.do?code=2"); 125 | URL myFileUrl = new URL( 126 | new StringBuilder(String.valueOf(Config.realUrl)).append("/wf.do?code=2&screen=") 127 | .append(URLEncoder.encode(new StringBuilder(String.valueOf(screenWidth)).append("*") 128 | .append(screenHeight) 129 | .toString(), "UTF-8")) 130 | .toString()); 131 | Log.d(TAG, "getPicture/bitmap: " + myFileUrl.toString()); 132 | try { 133 | HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection(); 134 | conn.setConnectTimeout(REQUEST_TIMEOUT); 135 | conn.setReadTimeout(SO_TIMEOUT); 136 | conn.setDoInput(true); 137 | conn.setRequestProperty("Cookie", sessionId); 138 | conn.connect(); 139 | in = conn.getInputStream(); 140 | // save bitmap to requestResult , will use too much memory? 141 | requestResult.setBitmap(BitmapFactory.decodeStream(in)); 142 | } catch (IOException e) { 143 | 144 | Log.e(TAG, "getPicture/exception" + e.getMessage()); 145 | } finally { 146 | closeStream(in, null); 147 | return requestResult; 148 | } 149 | } catch (IOException e2) { 150 | return null; 151 | } 152 | } 153 | 154 | public static RequestModel getKey(String clientVersion, String localIp) throws RuntimeException { 155 | IOException e; 156 | URL url; 157 | Exception e2; 158 | Throwable th; 159 | RequestModel requestResult = new RequestModel(); 160 | InputStream inputStream = null; 161 | String result = ""; 162 | try { 163 | if (Config.realUrl == null) { 164 | //http://www.189.cn 165 | isHaveinitRealAddress(Config.firstRreqUrl); 166 | } 167 | StringBuffer urlStr = new StringBuffer(Config.realUrl).append("/wf.do?code=1&device=") 168 | .append(URLEncoder.encode(new StringBuffer("Phone:").append(Build.MODEL) 169 | .append("\\SDK:") 170 | .append(VERSION.SDK_INT) 171 | .toString(), "UTF-8")) 172 | .append("&version=") 173 | .append(URLEncoder.encode(clientVersion, "UTF-8")) 174 | .append("&clientip=") 175 | .append(URLEncoder.encode(localIp, "UTF-8")); 176 | Log.d(TAG,"getPicture" + urlStr.toString()); 177 | URL myFileUrl = new URL(urlStr.toString()); 178 | HttpURLConnection conn = (HttpURLConnection) myFileUrl.openConnection(); 179 | try { 180 | conn.setConnectTimeout(REQUEST_TIMEOUT); 181 | conn.setReadTimeout(SO_TIMEOUT); 182 | conn.setDoInput(true); 183 | conn.connect(); 184 | inputStream = conn.getInputStream(); 185 | while (true) { 186 | int tempbyte = inputStream.read(); 187 | if (tempbyte == -1) { 188 | break; 189 | } 190 | result = new StringBuilder(String.valueOf(result)).append((char) tempbyte).toString(); 191 | } 192 | Log.d(TAG, "getKey/key = " + result); 193 | requestResult.setMessage(result); 194 | closeStream(inputStream, null); 195 | return requestResult; 196 | } catch (IOException e3) { 197 | e = e3; 198 | url = myFileUrl; 199 | } finally { 200 | closeStream(inputStream, null); 201 | } 202 | 203 | if (!(ReturnMessage.VERSIONCHECK.equals(result) || ReturnMessage.NATCHECK.equals(result))) { 204 | String session_value = conn.getHeaderField("Set-Cookie"); 205 | Log.d(TAG, 206 | "getKey/Client key" + new StringBuilder("pic\u4f1a\u8bddID\uff1a").append(session_value) 207 | .toString()); 208 | String[] session = session_value.split(";"); 209 | RequestModel requestResult2 = new RequestModel(); 210 | requestResult2.setSessionId(session[0]); 211 | requestResult2.setKeyvalue(result); 212 | return requestResult2; 213 | } 214 | } catch (IOException e7) { 215 | e = e7; 216 | Log.d(TAG, new StringBuilder("\u8bf7\u6c42key\u5f02\u5e38").append(e.getMessage()).toString()); 217 | throw new RuntimeException( 218 | new StringBuilder("\u8bf7\u6c42key\u5f02\u5e38\uff1a").append(e.getMessage()).toString()); 219 | } 220 | return requestResult; 221 | } 222 | 223 | public static void closeStream(InputStream paramInputStream, OutputStream paramOutputStream) { 224 | if (paramInputStream != null) { 225 | } 226 | try { 227 | paramInputStream.close(); 228 | if (paramOutputStream != null) { 229 | paramOutputStream.close(); 230 | } 231 | return; 232 | } catch (IOException localIOException) { 233 | localIOException.printStackTrace(); 234 | } 235 | } 236 | 237 | public static void main(String[] args) { 238 | isHaveinitRealAddress("http://192.168.3.198:8888"); 239 | } 240 | } 241 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/Config.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | public class Config { 4 | public static final String KEYVALUE = "keyValue"; 5 | public static final String LOGININFOFILE = "loginInfo"; 6 | public static String REDIRECTINFO = null; 7 | public static final String SESSIONID = "sessionId"; 8 | public static final String USERNAME = "username"; 9 | public static int VERIFYCODE_AUTH_SORT; 10 | public static String VERIFYCODE_AUTH_URL; 11 | public static String VERIFYCODE_SWITCH; 12 | public static String firstRreqUrl; 13 | //this is Http redirect home page 14 | //http://gxprotal.online.cq.cn:8080/ 15 | public static String realUrl = "http://gxprotal.online.cq.cn:8080/"; 16 | 17 | static { 18 | REDIRECTINFO = "redirectInfo"; 19 | firstRreqUrl = "http://gxprotal.online.cq.cn:8080/"; 20 | VERIFYCODE_AUTH_URL = "117.34.65.39"; 21 | VERIFYCODE_AUTH_SORT = 8099; 22 | VERIFYCODE_SWITCH = "OFF"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/HttpUtils.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import android.util.Log; 4 | import com.google.code.microlog4android.Logger; 5 | import com.google.code.microlog4android.LoggerFactory; 6 | import java.io.BufferedReader; 7 | import java.io.IOException; 8 | import java.io.InputStreamReader; 9 | import java.net.HttpURLConnection; 10 | import java.net.URL; 11 | import java.util.List; 12 | import org.apache.http.HttpResponse; 13 | import org.apache.http.client.HttpClient; 14 | import org.apache.http.client.entity.UrlEncodedFormEntity; 15 | import org.apache.http.client.methods.HttpGet; 16 | import org.apache.http.client.methods.HttpPost; 17 | import org.apache.http.impl.client.DefaultHttpClient; 18 | import org.apache.http.util.EntityUtils; 19 | 20 | public class HttpUtils { 21 | 22 | public static final String TAG = HttpUtils.class.getSimpleName(); 23 | private static String USER_AGENT; 24 | private static final Logger logger; 25 | 26 | static { 27 | USER_AGENT = "wifikeeper/0.9.1 ( linux; u: android ; build :cs)"; 28 | logger = LoggerFactory.getLogger(HttpUtils.class); 29 | } 30 | 31 | public static String getContentByHttp(String strUrl) { 32 | String result = ""; 33 | try { 34 | URL url = new URL(strUrl); 35 | HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 36 | InputStreamReader in = new InputStreamReader(conn.getInputStream()); 37 | BufferedReader br = new BufferedReader(in); 38 | while (true) { 39 | String readline = br.readLine(); 40 | if (readline == null) { 41 | break; 42 | } 43 | result = new StringBuilder(String.valueOf(result)).append(readline).toString(); 44 | } 45 | in.close(); 46 | conn.disconnect(); 47 | URL url2 = url; 48 | } catch (Exception e) { 49 | } 50 | return result; 51 | } 52 | 53 | public static String sendContentByHttpPost(String strUrl, String sessionid, List params) { 54 | try { 55 | Log.v(TAG, new StringBuilder("sendContentByHttpPost:").append(strUrl).toString()); 56 | HttpPost httpPost = new HttpPost(strUrl); 57 | httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); 58 | httpPost.setHeader("Cookie", sessionid); 59 | HttpClient httpClient = new DefaultHttpClient(); 60 | httpClient.getParams() 61 | .setParameter("http.connection.timeout", Integer.valueOf(BitmapUtils.REQUEST_TIMEOUT)); 62 | httpClient.getParams() 63 | .setParameter("http.socket.timeout", Integer.valueOf(BitmapUtils.SO_TIMEOUT)); 64 | HttpResponse httpResponse = httpClient.execute(httpPost); 65 | if (httpResponse.getStatusLine().getStatusCode() == 200) { 66 | String result = EntityUtils.toString(httpResponse.getEntity(), "GBK"); 67 | Log.v(TAG, "HttpPost return 200"); 68 | return result; 69 | } 70 | 71 | } catch (IOException e) { 72 | Log.v(TAG, "HttpPost failed"); 73 | return null; 74 | } 75 | return null; 76 | } 77 | 78 | public static String requestHttpGet(String strUrl, String sessionid, String params) { 79 | Log.v("client", new StringBuilder( 80 | "\u6d4b\u8bd5\u8c03\u7528HTTPClient\u5411\u670d\u52a1\u5668\u53d1\u9001\u6570\u636e\uff01").append( 81 | strUrl).toString()); 82 | try { 83 | HttpGet request = 84 | new HttpGet(new StringBuilder(String.valueOf(strUrl)).append(params).toString()); 85 | request.setHeader("Cookie", sessionid); 86 | HttpClient httpClient = new DefaultHttpClient(); 87 | httpClient.getParams() 88 | .setParameter("http.connection.timeout", Integer.valueOf(BitmapUtils.REQUEST_TIMEOUT)); 89 | httpClient.getParams() 90 | .setParameter("http.socket.timeout", Integer.valueOf(BitmapUtils.SO_TIMEOUT)); 91 | HttpResponse httpResponse = httpClient.execute(request); 92 | logger.debug(new StringBuilder("getStatusCode()====").append( 93 | httpResponse.getStatusLine().getStatusCode()).toString()); 94 | if (httpResponse.getStatusLine().getStatusCode() == 200) { 95 | String result = EntityUtils.toString(httpResponse.getEntity(), "GBK"); 96 | logger.info( 97 | new StringBuilder("\u8bf7\u6c42\u8fd4\u56de\u7ed3\u679c\u6210\u529f\uff1a").append( 98 | result).toString()); 99 | Log.v("client", "HttpGet\u65b9\u5f0f\u8bf7\u6c42\u6210\u529f!"); 100 | return result; 101 | } 102 | logger.info("\u8bf7\u6c42\u8fd4\u56de\u7ed3\u679c\u5931\u8d25"); 103 | Log.v("client", "HttpGet\u65b9\u5f0f\u8bf7\u6c42\u5931\u8d25"); 104 | return null; 105 | } catch (Exception e) { 106 | logger.error( 107 | new StringBuilder("\u8bf7\u6c42\u53d1\u751f\u5f02\u5e38\uff1a").append(e).toString()); 108 | e.printStackTrace(); 109 | throw new RuntimeException(e.getMessage()); 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/MD5Builder.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.security.MessageDigest; 5 | import java.security.NoSuchAlgorithmException; 6 | 7 | public class MD5Builder { 8 | static char[] hexDigits; 9 | 10 | static { 11 | hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; 12 | } 13 | 14 | public static String getMD5(String message) throws NoSuchAlgorithmException, UnsupportedEncodingException { 15 | return byteToHexString(MessageDigest.getInstance("MD5").digest(message.getBytes("GBK"))); 16 | } 17 | 18 | private static String byteToHexString(byte[] tmp) { 19 | char[] str = new char[32]; 20 | int i = 0; 21 | for (int i2 = 0; i2 < 16; i2++) { 22 | byte byte0 = tmp[i2]; 23 | int i3 = i + 1; 24 | str[i] = hexDigits[(byte0 >>> 4) & 15]; 25 | i = i3 + 1; 26 | str[i3] = hexDigits[byte0 & 15]; 27 | } 28 | return new String(str); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/MessageContext.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import android.support.annotation.NonNull; 4 | import android.util.Log; 5 | import com.xinli.portalclient.model.TouchPoint; 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | import org.apache.http.NameValuePair; 9 | import org.apache.http.message.BasicNameValuePair; 10 | 11 | public class MessageContext { 12 | public static final String TAG = MessageContext.class.getSimpleName(); 13 | 14 | public static List paramStrReturn(int picWidth, int picHeight, List list1, 15 | List list2, @NonNull String key, String username, String password, 16 | String clientIp) { 17 | StringBuilder outString = new StringBuilder(); 18 | Log.w(TAG, "width=====" + String.valueOf(picWidth)); 19 | Log.w(TAG, "height====" + String.valueOf(picHeight)); 20 | outString.append("{").append(picWidth).append(",").append(picHeight).append("}@"); 21 | for (TouchPoint tp : list1) { 22 | outString.append("{") 23 | .append(tp.getX()) 24 | .append(",") 25 | .append(tp.getY()) 26 | .append(",") 27 | .append(tp.getEventTime()) 28 | .append("}") 29 | .append("#"); 30 | } 31 | outString.append("@"); 32 | for (TouchPoint tp2 : list2) { 33 | outString.append("{") 34 | .append(tp2.getX()) 35 | .append(",") 36 | .append(tp2.getY()) 37 | .append(",") 38 | .append(tp2.getEventTime()) 39 | .append("}") 40 | .append("#"); 41 | } 42 | List params = new ArrayList(); 43 | params.add(new BasicNameValuePair("xypoints", outString.toString())); 44 | Log.v(TAG, key + " jyangzi5@163.com"); 45 | params.add(new BasicNameValuePair("key", AESByKey.encryptToString(key, "jyangzi5@163.com"))); 46 | params.add(new BasicNameValuePair(Config.USERNAME, username)); 47 | params.add( 48 | new BasicNameValuePair("password", AESByKey.encryptToString(password, "pass012345678910"))); 49 | params.add(new BasicNameValuePair("clientip", clientIp)); 50 | params.add(new BasicNameValuePair("clientType", "android")); 51 | Log.v(TAG, AESByKey.encryptToString(key, "jyangzi5@163.com")); 52 | Log.v(TAG, outString.toString()); 53 | return params; 54 | } 55 | 56 | public static List paramStrReturn(int picWidth, int picHeight, List list1, 57 | List list2, String key, String username, String password, String clientIp, 58 | String clientMAC) { 59 | StringBuilder outString = new StringBuilder(); 60 | Log.w(TAG, 61 | "\u8bf7\u6c42\u624b\u52bf\u7ec4\u88c5\u53c2\u6570 width=====" + String.valueOf(picWidth)); 62 | Log.w(TAG, 63 | "\u8bf7\u6c42\u624b\u52bf\u7ec4\u88c5\u53c2\u6570 height====" + String.valueOf(picHeight)); 64 | outString.append("{").append(picWidth).append(",").append(picHeight).append("}@"); 65 | for (TouchPoint tp : list1) { 66 | outString.append("{") 67 | .append(tp.getX()) 68 | .append(",") 69 | .append(tp.getY()) 70 | .append(",") 71 | .append(tp.getEventTime()) 72 | .append("}") 73 | .append("#"); 74 | } 75 | outString.append("@"); 76 | for (TouchPoint tp2 : list2) { 77 | outString.append("{") 78 | .append(tp2.getX()) 79 | .append(",") 80 | .append(tp2.getY()) 81 | .append(",") 82 | .append(tp2.getEventTime()) 83 | .append("}") 84 | .append("#"); 85 | } 86 | List params = new ArrayList(); 87 | params.add(new BasicNameValuePair("xypoints", outString.toString())); 88 | Log.v(TAG, new StringBuilder(String.valueOf(key)).append("jyangzi5@163.com").toString()); 89 | params.add(new BasicNameValuePair("key", AESByKey.encryptToString(key, "jyangzi5@163.com"))); 90 | params.add(new BasicNameValuePair(Config.USERNAME, username)); 91 | params.add( 92 | new BasicNameValuePair("password", AESByKey.encryptToString(password, "pass012345678910"))); 93 | params.add(new BasicNameValuePair("clientip", clientIp)); 94 | params.add(new BasicNameValuePair("clientType", "android")); 95 | params.add(new BasicNameValuePair("clientmac", clientMAC)); 96 | Log.v(TAG, AESByKey.encryptToString(key, "jyangzi5@163.com")); 97 | Log.v(TAG, outString.toString()); 98 | return params; 99 | } 100 | 101 | public static List keyStrReturn(String key, String username, String password) { 102 | List params = new ArrayList(); 103 | try { 104 | Log.v(TAG, new StringBuilder(String.valueOf(key)).append("jyangzi5@163.com").toString()); 105 | params.add(new BasicNameValuePair("key", AESByKey.encryptToString(key, "jyangzi5@163.com"))); 106 | params.add(new BasicNameValuePair(Config.USERNAME, username)); 107 | params.add(new BasicNameValuePair("password", 108 | AESByKey.encryptToString(password, "pass012345678910"))); 109 | Log.v(TAG, AESByKey.encryptToString(key, "jyangzi5@163.com")); 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | } 113 | return params; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/PrefUtils.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.content.SharedPreferences.Editor; 6 | import android.util.Log; 7 | 8 | public class PrefUtils { 9 | private static final String TAG = "ShareUtil"; 10 | Context mContext; 11 | private SharedPreferences sharedVerifyURL; 12 | 13 | public PrefUtils(Context c) { 14 | Log.d(TAG, " ShareUtil..."); 15 | this.mContext = c; 16 | } 17 | 18 | public void setVerifyURL(String verifyURl) { 19 | try { 20 | this.sharedVerifyURL = this.mContext.getSharedPreferences("VERIFY_URL", 1); 21 | Editor edit = this.sharedVerifyURL.edit(); 22 | edit.putString("verifyURl", verifyURl); 23 | edit.commit(); 24 | Log.i(TAG, new StringBuilder("sharedCheckVerifyURL=====verifyURl==").append(verifyURl).toString()); 25 | } catch (Exception e) { 26 | e.printStackTrace(); 27 | } 28 | } 29 | 30 | public String getVerifyURL() { 31 | try { 32 | Log.i(TAG, "sharedCheckVerifyURL======"); 33 | this.sharedVerifyURL = this.mContext.getSharedPreferences("VERIFY_URL", 1); 34 | return this.sharedVerifyURL.getString("verifyURl", ""); 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | return ""; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/Sim_NetKeeperClient.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import com.google.code.microlog4android.Logger; 4 | import com.google.code.microlog4android.LoggerFactory; 5 | import java.net.DatagramPacket; 6 | import java.net.DatagramSocket; 7 | import java.net.InetAddress; 8 | import java.net.UnknownHostException; 9 | import java.nio.ByteBuffer; 10 | 11 | public class Sim_NetKeeperClient { 12 | private static final int TIMEOUT = 3000; 13 | private static final int dataType = 8; 14 | private static String encryKey = null; 15 | private static String key = null; 16 | private static final int localPort = 3311; 17 | private static final String serverHost = "222.177.26.12"; 18 | private static final int serverPort = 443; 19 | private final transient Logger logger; 20 | private DatagramSocket socket; 21 | 22 | static { 23 | key = ""; 24 | encryKey = "XINLIAPSECRET01234567891"; 25 | } 26 | 27 | public Sim_NetKeeperClient() throws Exception { 28 | this.logger = LoggerFactory.getLogger(getClass()); 29 | this.socket = null; 30 | if (this.socket == null) { 31 | this.socket = new DatagramSocket(3311); 32 | } 33 | } 34 | 35 | public final void setSoTimeout(int timeout) throws Exception { 36 | this.socket.setSoTimeout(timeout); 37 | } 38 | 39 | public final int getSoTimeout() throws Exception { 40 | return this.socket.getSoTimeout(); 41 | } 42 | 43 | public final DatagramSocket getSocket() { 44 | return this.socket; 45 | } 46 | 47 | public void sendHeart(String username, String ip, String version) throws Exception { 48 | sendDataPackage(username, ip, version); 49 | acceptHeartResponse(); 50 | try { 51 | this.socket.close(); 52 | } catch (Exception ex) { 53 | ex.printStackTrace(); 54 | } 55 | } 56 | 57 | public void acceptHeartResponse() { 58 | byte[] buffer = new byte[200]; 59 | try { 60 | DatagramPacket dataPackage = new DatagramPacket(buffer, buffer.length); 61 | setSoTimeout(TIMEOUT); 62 | this.logger.info("\u9632\u4ee3\u7406\u5fc3\u8df3\u51c6\u5907\u63a5\u53d7\u8fd4\u56de\u6570\u636e"); 63 | this.socket.receive(dataPackage); 64 | this.logger.info("\u9632\u4ee3\u7406\u5fc3\u8df3\u51c6\u5907\u8fd4\u56de\u6570\u636e\u6210\u529f"); 65 | ByteBuffer b = ByteBuffer.wrap(dataPackage.getData()); 66 | byte[] ver = new byte[4]; 67 | b.get(ver); 68 | byte reportType = b.get(); 69 | byte[] dataByte = new byte[b.getInt()]; 70 | b.get(dataByte); 71 | byte[] decryptData = ThreeDes.decryptMode(dataByte, encryKey); 72 | key = new String(decryptData); 73 | this.logger.warn(new StringBuilder("\u534f\u8bae").append(new String(ver)).append(" \u62a5\u6587\u7c7b\u578b").append(reportType).append(" \u89e3\u5bc6\u8fc7\u540e\u7684\u6570\u636e\u662f:").append(new String(decryptData)).toString()); 74 | } catch (Exception e) { 75 | this.logger.error(new StringBuilder("\u9632\u4ee3\u7406\u5fc3\u8df3\u63a5\u6536\u5f02\u5e38:").append(e.getMessage()).toString()); 76 | if (this.logger.isDebugEnabled()) { 77 | this.logger.info("\u670d\u52a1\u5668\u63a5\u6536\u62a5\u6587\u51fa\u9519"); 78 | } 79 | e.printStackTrace(); 80 | } 81 | } 82 | 83 | public void sendDataPackage(String username, String ip, String version) throws Exception { 84 | StringBuffer respBuffer = new StringBuffer(); 85 | respBuffer.append("TYPE=").append("HEARTBEAT").append("&").append("USER_NAME=").append(username).append("&").append("IP=").append(ip).append("&").append("VERSION_NUMBER=").append(version).append("&").append("KEY=").append(key); 86 | try { 87 | this.socket.send(createPackage(respBuffer.toString(), dataType)); 88 | this.logger.debug("\u62a5\u65878\u53d1\u9001\u6210\u529f"); 89 | } catch (Exception e) { 90 | this.logger.error(new StringBuilder("\u53d1\u9001\u5fc3\u8df3\u5931\u8d25").append(e.getMessage()).toString()); 91 | throw new Exception(e.getMessage()); 92 | } 93 | } 94 | 95 | public DatagramPacket createPackage(String resp, int dataType) { 96 | byte[] enc_a = ThreeDes.encryptMode(resp.getBytes(), encryKey); 97 | ByteBuffer byteBuffer = ByteBuffer.allocate(enc_a.length + 9); 98 | byteBuffer.put("HR10".getBytes()); 99 | byteBuffer.put((byte) dataType); 100 | byteBuffer.putInt(enc_a.length); 101 | byteBuffer.put(enc_a); 102 | byteBuffer.flip(); 103 | byte[] buf = byteBuffer.array(); 104 | InetAddress address = null; 105 | try { 106 | address = InetAddress.getByName(serverHost); 107 | } catch (UnknownHostException e) { 108 | this.logger.error("\u4e0d\u80fd\u8bc6\u522b\u7684\u8fdc\u7a0b\u4e3b\u673a:222.177.26.12"); 109 | } 110 | return new DatagramPacket(buf, buf.length, address, 443); 111 | } 112 | 113 | public final void close() { 114 | try { 115 | this.socket.close(); 116 | } catch (Exception ex) { 117 | ex.printStackTrace(); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/SocketClientUDP.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import java.io.IOException; 4 | import java.net.DatagramPacket; 5 | import java.net.DatagramSocket; 6 | import java.net.InetAddress; 7 | 8 | public class SocketClientUDP { 9 | private byte[] buffer; 10 | private DatagramSocket ds; 11 | 12 | public SocketClientUDP() throws Exception { 13 | this.buffer = new byte[4096]; 14 | this.ds = null; 15 | this.ds = new DatagramSocket(); 16 | } 17 | 18 | public final void setSoTimeout(int timeout) throws Exception { 19 | this.ds.setSoTimeout(timeout); 20 | } 21 | 22 | public final int getSoTimeout() throws Exception { 23 | return this.ds.getSoTimeout(); 24 | } 25 | 26 | public final DatagramSocket getSocket() { 27 | return this.ds; 28 | } 29 | 30 | public final DatagramPacket send(String host, int port, byte[] bytes) throws IOException { 31 | DatagramPacket dp = new DatagramPacket(bytes, bytes.length, InetAddress.getByName(host), port); 32 | this.ds.send(dp); 33 | return dp; 34 | } 35 | 36 | public final String receive(String lhost, int lport) throws Exception { 37 | DatagramPacket dp = new DatagramPacket(this.buffer, this.buffer.length); 38 | this.ds.receive(dp); 39 | return new String(dp.getData(), 0, dp.getLength(), "GBK"); 40 | } 41 | 42 | public final void close() { 43 | try { 44 | this.ds.close(); 45 | } catch (Exception ex) { 46 | ex.printStackTrace(); 47 | } 48 | } 49 | 50 | public static byte[] intToByteArray(int value, int len) { 51 | byte[] b = new byte[len]; 52 | for (int i = 0; i < len; i++) { 53 | b[i] = (byte) ((value >>> (((b.length - 1) - i) * 8)) & 255); 54 | } 55 | return b; 56 | } 57 | 58 | public static byte[] getAuth(int len) { 59 | int i = 0; 60 | byte[] b = new byte[len]; 61 | for (int j = 0; j < len; j++) { 62 | b[i] = (byte) ((int) ((Math.random() * 100.0d) % 255.0d)); 63 | i++; 64 | } 65 | return b; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/ThreeDes.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import javax.crypto.Cipher; 4 | import javax.crypto.SecretKey; 5 | import javax.crypto.SecretKeyFactory; 6 | import javax.crypto.spec.DESedeKeySpec; 7 | import javax.crypto.spec.IvParameterSpec; 8 | import org.dom4j.swing.XMLTableColumnDefinition; 9 | 10 | // http://zhangzhaoaaa.iteye.com/blog/2145750 11 | public class ThreeDes { 12 | private static final String Algorithm = "DESede/CBC/PKCS5Padding"; 13 | static byte[] RADIUS_KEY; 14 | static byte[] XKJS_KEY_20; 15 | static byte[] XKJS_KEY_21; 16 | private static byte[] ivByte; 17 | 18 | static { 19 | ivByte = new byte[] { 20 | (byte) 49, (byte) 50, (byte) 51, (byte) 52, (byte) 53, (byte) 54, (byte) 55, (byte) 56 21 | }; 22 | RADIUS_KEY = "XINLIAPSECRET01234567890".getBytes(); 23 | XKJS_KEY_20 = "XINLIAPSECRET01234567891".getBytes(); 24 | XKJS_KEY_21 = "XINLIAPSECRET01JIANGXI21".getBytes(); 25 | } 26 | 27 | public static byte[] encryptMode(byte[] src, String key) { 28 | try { 29 | DESedeKeySpec dESedeKeySpec; 30 | DESedeKeySpec dks = new DESedeKeySpec(key.getBytes()); 31 | 32 | IvParameterSpec iv = new IvParameterSpec(ivByte); 33 | SecretKey securekey = SecretKeyFactory.getInstance("DESede").generateSecret(dks); 34 | Cipher cipher = Cipher.getInstance(Algorithm); 35 | cipher.init(1, securekey, iv); 36 | dESedeKeySpec = dks; 37 | return cipher.doFinal(src); 38 | } catch (Exception e6) { 39 | 40 | return null; 41 | } 42 | } 43 | 44 | public static byte[] decryptMode(byte[] src, String key) { 45 | try { 46 | DESedeKeySpec dks = new DESedeKeySpec(key.getBytes()); 47 | 48 | IvParameterSpec iv = new IvParameterSpec(ivByte); 49 | SecretKey securekey = SecretKeyFactory.getInstance("DESede").generateSecret(dks); 50 | Cipher cipher = Cipher.getInstance(Algorithm); 51 | cipher.init(XMLTableColumnDefinition.NUMBER_TYPE, securekey, iv); 52 | return cipher.doFinal(src); 53 | } catch (java.security.NoSuchAlgorithmException e1) { 54 | // TODO: handle exception 55 | e1.printStackTrace(); 56 | } catch (javax.crypto.NoSuchPaddingException e2) { 57 | e2.printStackTrace(); 58 | } catch (java.lang.Exception e3) { 59 | e3.printStackTrace(); 60 | } 61 | return null; 62 | } 63 | 64 | public static String byte2hex(byte[] b) { 65 | String hs = ""; 66 | String str = ""; 67 | for (int n = 0; n < b.length; n++) { 68 | str = Integer.toHexString(b[n] & 255); 69 | if (str.length() == 1) { 70 | hs = new StringBuilder(String.valueOf(hs)).append("0").append(str).toString(); 71 | } else { 72 | hs = new StringBuilder(String.valueOf(hs)).append(str).toString(); 73 | } 74 | if (n < b.length - 1) { 75 | hs = new StringBuilder(String.valueOf(hs)).append(":").toString(); 76 | } 77 | } 78 | System.out.println(hs.toUpperCase()); 79 | return hs.toUpperCase(); 80 | } 81 | 82 | public static void main(String[] args) { 83 | System.out.println("加密前的字符串:" 84 | + "Account=0791643455;SessionID=SHL-ME603006098000184f5e27c044211;ClientID=220.177.248.109;IP=59.52.1.131;"); 85 | System.out.println("长度" 86 | + "Account=0791643455;SessionID=SHL-ME603006098000184f5e27c044211;ClientID=220.177.248.109;IP=59.52.1.131;" 87 | .length()); 88 | byte[] arrayOfByte1 = encryptMode( 89 | "Account=0791643455;SessionID=SHL-ME603006098000184f5e27c044211;ClientID=220.177.248.109;IP=59.52.1.131;" 90 | .getBytes(), "RADIUS"); 91 | byte2hex(arrayOfByte1); 92 | System.out.println("加密后的字符串:" + new String(arrayOfByte1)); 93 | System.out.println(arrayOfByte1.length); 94 | byte[] arrayOfByte2 = decryptMode(arrayOfByte1, "RADIUS"); 95 | System.out.println("解密后的字符串:" + new String(arrayOfByte2)); 96 | System.out.println( 97 | "F0DBC06B30D350CC3CBC05ADC29F9FAEE34CCF36BCAFE9660C661AFB45FC0B95AD9CBB5796F00FCC8AFD326B335354C4A17B14AB8970C49E69D89F8A98944442CDFEFBBDB7E188E644C11AA44B6A346445BD13730A3BAF4B86E0248DEB898C16E50CCD116F112D44451F84B7EBD44D23" 98 | .getBytes().length); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /app/src/main/java/com/xinli/portalclient/util/WifiUtil.java: -------------------------------------------------------------------------------- 1 | package com.xinli.portalclient.util; 2 | 3 | import android.content.Context; 4 | import android.net.wifi.ScanResult; 5 | import android.net.wifi.WifiConfiguration; 6 | import android.net.wifi.WifiInfo; 7 | import android.net.wifi.WifiManager; 8 | import android.text.format.Formatter; 9 | import android.util.Log; 10 | import java.util.List; 11 | import org.dom4j.swing.XMLTableColumnDefinition; 12 | 13 | public class WifiUtil { 14 | private static final String TAG = Context.WIFI_SERVICE; 15 | Context mContext; 16 | int mNetworkID; 17 | String mSSID; 18 | WifiConfiguration mTargetWifiCfg; 19 | List mWifiHotSpotLists; 20 | WifiInfo mWifiInfo; 21 | WifiManager mWifiManager; 22 | List mWifiScanResultLists; 23 | 24 | public WifiUtil(Context c) { 25 | Log.d(TAG, " Construct..."); 26 | this.mContext = c; 27 | } 28 | 29 | public void openWifi() { 30 | this.mWifiManager = (WifiManager) this.mContext.getSystemService(TAG); 31 | if (this.mWifiManager.isWifiEnabled()) { 32 | Log.d(TAG, "before have setWifiEnabled ..."); 33 | } else if (this.mWifiManager.setWifiEnabled(true)) { 34 | Log.d(TAG, " setWifiEnabled...success"); 35 | } else { 36 | Log.d(TAG, " setWifiEnabled...failure"); 37 | } 38 | } 39 | 40 | public void closeWifi() { 41 | if (!this.mWifiManager.isWifiEnabled()) { 42 | return; 43 | } 44 | if (this.mWifiManager.setWifiEnabled(false)) { 45 | Log.d(TAG, " disableWifiEnabled...success"); 46 | } else { 47 | Log.d(TAG, " disableWifiEnabled...failure"); 48 | } 49 | } 50 | 51 | public WifiInfo getWifiInfo() { 52 | if (this.mWifiManager == null) { 53 | this.mWifiManager = (WifiManager) this.mContext.getSystemService(TAG); 54 | } 55 | return this.mWifiManager.getConnectionInfo(); 56 | } 57 | 58 | public List getWifiScanResult() { 59 | Log.d(TAG, " connectToTargetWifi step2======="); 60 | List wifiScanResultLists = this.mWifiManager.getScanResults(); 61 | Log.d(TAG, " connectToTargetWifi step3======="); 62 | return wifiScanResultLists; 63 | } 64 | 65 | public List getWifiAllHotSpot() { 66 | List wifiHotSpotLists = this.mWifiManager.getConfiguredNetworks(); 67 | for (WifiConfiguration wifiConfiguration : wifiHotSpotLists) { 68 | Log.d(TAG, new StringBuilder(" wifiConfiguration.SSID(hotSpot):").append(wifiConfiguration.SSID).toString()); 69 | } 70 | return wifiHotSpotLists; 71 | } 72 | 73 | public boolean isConfigHotSpot() { 74 | try { 75 | Log.d(TAG, " connectToTargetWifi step4======="); 76 | this.mWifiHotSpotLists = getWifiAllHotSpot(); 77 | for (WifiConfiguration wifiConfiguration : this.mWifiHotSpotLists) { 78 | Log.d(TAG, new StringBuilder(" connectToTargetWifi wifiConfiguration.SSID=======").append(wifiConfiguration.SSID).append("==mSSID==").append(this.mSSID).toString()); 79 | if (wifiConfiguration.SSID.equals(new StringBuilder("\"").append(this.mSSID).append("\"").toString())) { 80 | Log.d(TAG, new StringBuilder("before have cfg this hotspot:").append(wifiConfiguration.SSID).toString()); 81 | return true; 82 | } 83 | } 84 | return false; 85 | } catch (Exception e) { 86 | e.printStackTrace(); 87 | Log.d(TAG, new StringBuilder("isConfigHotSpot Exception:").append(e.toString()).toString()); 88 | return false; 89 | } 90 | } 91 | 92 | public boolean isScanTargetWifi() { 93 | try { 94 | Log.d(TAG, " connectToTargetWifi step1======="); 95 | this.mWifiScanResultLists = getWifiScanResult(); 96 | if (this.mWifiScanResultLists == null) { 97 | return false; 98 | } 99 | for (ScanResult wifiScanResultList : this.mWifiScanResultLists) { 100 | Log.d(TAG, new StringBuilder(" connectToTargetWifi====wifiScanResultList.SSID:").append(wifiScanResultList.SSID).append("==mSSID==").append(this.mSSID).toString()); 101 | if (wifiScanResultList.SSID.equals(this.mSSID)) { 102 | return true; 103 | } 104 | } 105 | return false; 106 | } catch (Exception e) { 107 | e.printStackTrace(); 108 | Log.d(TAG, new StringBuilder("isScanTargetWifi Exception:").append(e.toString()).toString()); 109 | return false; 110 | } 111 | } 112 | 113 | public WifiConfiguration isExistWifiConfiguration(String ssid) { 114 | this.mWifiHotSpotLists = getWifiAllHotSpot(); 115 | for (WifiConfiguration exsitWifiConfiguration : this.mWifiHotSpotLists) { 116 | Log.d(TAG, new StringBuilder(" connectToTargetWifi===wifiConfiguration.SSID:").append(exsitWifiConfiguration.SSID).append("==ssid==").append(ssid).toString()); 117 | if (exsitWifiConfiguration.SSID.equals(new StringBuilder("\"").append(ssid).append("\"").toString())) { 118 | return exsitWifiConfiguration; 119 | } 120 | } 121 | return null; 122 | } 123 | 124 | public WifiConfiguration createWifiCfg(String ssid, String password, int method) { 125 | try { 126 | Log.d(TAG, " connectToTargetWifi==createWifiCfg.........................."); 127 | WifiConfiguration wifiCfg = new WifiConfiguration(); 128 | wifiCfg.allowedAuthAlgorithms.clear(); 129 | wifiCfg.allowedGroupCiphers.clear(); 130 | wifiCfg.allowedKeyManagement.clear(); 131 | wifiCfg.allowedPairwiseCiphers.clear(); 132 | wifiCfg.allowedProtocols.clear(); 133 | wifiCfg.SSID = new StringBuilder("\"").append(ssid).append("\"").toString(); 134 | switch (method) { 135 | case XMLTableColumnDefinition.OBJECT_TYPE: 136 | Log.d(TAG, " createWifiCfg..........................no password "); 137 | wifiCfg.wepKeys[0] = ""; 138 | wifiCfg.allowedKeyManagement.set(0); 139 | wifiCfg.wepTxKeyIndex = 0; 140 | break; 141 | case XMLTableColumnDefinition.STRING_TYPE: 142 | Log.d(TAG, " connectToTargetWifi===createWifiCfg..........................have password :WPA"); 143 | wifiCfg.preSharedKey = new StringBuilder("\"").append(password).append("\"").toString(); 144 | wifiCfg.hiddenSSID = true; 145 | wifiCfg.allowedAuthAlgorithms.set(0); 146 | wifiCfg.allowedGroupCiphers.set(XMLTableColumnDefinition.NUMBER_TYPE); 147 | wifiCfg.allowedKeyManagement.set(1); 148 | wifiCfg.allowedPairwiseCiphers.set(1); 149 | wifiCfg.allowedProtocols.set(0); 150 | wifiCfg.status = 2; 151 | break; 152 | case XMLTableColumnDefinition.NUMBER_TYPE: 153 | Log.d(TAG, " createWifiCfg..........................have password :WEP"); 154 | wifiCfg.preSharedKey = new StringBuilder("\"").append(password).append("\"").toString(); 155 | wifiCfg.hiddenSSID = true; 156 | wifiCfg.allowedAuthAlgorithms.set(1); 157 | wifiCfg.allowedGroupCiphers.set(XMLTableColumnDefinition.NODE_TYPE); 158 | wifiCfg.allowedGroupCiphers.set(XMLTableColumnDefinition.NUMBER_TYPE); 159 | wifiCfg.allowedGroupCiphers.set(0); 160 | wifiCfg.allowedGroupCiphers.set(1); 161 | wifiCfg.allowedKeyManagement.set(0); 162 | wifiCfg.wepTxKeyIndex = 0; 163 | break; 164 | default: 165 | wifiCfg = null; 166 | break; 167 | } 168 | WifiConfiguration tempWifiCfg = isExistWifiConfiguration(ssid); 169 | if (tempWifiCfg == null) { 170 | return wifiCfg; 171 | } 172 | Log.d(TAG, "connectToTargetWifi== tempWifiCfg != null:"); 173 | this.mWifiManager.removeNetwork(tempWifiCfg.networkId); 174 | return wifiCfg; 175 | } catch (Exception e) { 176 | e.printStackTrace(); 177 | Log.d(TAG, new StringBuilder("createWifiCfg Exception:").append(e.toString()).toString()); 178 | return null; 179 | } 180 | } 181 | 182 | public synchronized void connectToTargetWifi(String ssid, String password, int method) { 183 | try { 184 | this.mSSID = ssid; 185 | if (isScanTargetWifi()) { 186 | Log.d(TAG, " connectToTargetWifi success======="); 187 | Log.d(TAG, new StringBuilder(" connectToTargetWifi step5=====password==").append(password).append("==ssid==").append(ssid).toString()); 188 | this.mTargetWifiCfg = createWifiCfg(ssid, password, method); 189 | Log.d(TAG, " connectToTargetWifi step6====="); 190 | this.mNetworkID = this.mWifiManager.addNetwork(this.mTargetWifiCfg); 191 | Log.d(TAG, new StringBuilder("connectToTargetWifi==addNetwork:mTargetWifiCfg->").append(this.mTargetWifiCfg).toString()); 192 | Log.d(TAG, new StringBuilder("connectToTargetWifi==addNetwork:mNetworkID->").append(this.mNetworkID).toString()); 193 | this.mWifiManager.enableNetwork(this.mNetworkID, true); 194 | Log.d(TAG, " connectToTargetWifi step7====="); 195 | this.mWifiManager.reassociate(); 196 | Log.d(TAG, " connectToTargetWifi step8====="); 197 | this.mWifiManager.reconnect(); 198 | Log.d(TAG, " connectToTargetWifi step9====="); 199 | Log.d(TAG, new StringBuilder(" connectToTargetWifi step9===dhcpinfo.ipAddress==").append(Formatter.formatIpAddress(this.mWifiManager.getDhcpInfo().ipAddress)).toString()); 200 | } else { 201 | Log.d(TAG, " connectToTargetWifi fail======="); 202 | } 203 | } catch (Exception e) { 204 | e.printStackTrace(); 205 | Log.d(TAG, new StringBuilder("connectToTargetWifi Exception:").append(e.toString()).toString()); 206 | } 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /app/src/main/java/edu/util/Secret.java: -------------------------------------------------------------------------------- 1 | package edu.util; 2 | 3 | import java.security.SecureRandom; 4 | import javax.crypto.Cipher; 5 | import javax.crypto.SecretKey; 6 | import javax.crypto.SecretKeyFactory; 7 | import javax.crypto.spec.DESKeySpec; 8 | 9 | public class Secret 10 | { 11 | private static final String DES = "DES"; 12 | private static final String PASSWORD_CRYPT_KEY = "__jDlog_"; 13 | 14 | public Secret() {} 15 | 16 | public static String byte2hex(byte[] paramArrayOfByte) 17 | { 18 | String str1 = new String(); 19 | for (int i = 0; ; i++) 20 | { 21 | if (i >= paramArrayOfByte.length) 22 | return str1.toString(); 23 | String str2 = Integer.toHexString(0xFF & paramArrayOfByte[i]).toLowerCase(); 24 | if (str2.length() == 1) 25 | str2 = '0' + str2; 26 | str1 = str1 + str2; 27 | } 28 | } 29 | 30 | public static final String decrypt(String paramString) 31 | { 32 | try 33 | { 34 | String str = new String(decrypt(hex2byte(paramString.getBytes()), "__jDlog_".getBytes())); 35 | return str; 36 | } 37 | catch (Exception localException) {} 38 | return null; 39 | } 40 | 41 | public static byte[] decrypt(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2) 42 | throws Exception 43 | { 44 | SecureRandom localSecureRandom = new SecureRandom(); 45 | DESKeySpec localDESKeySpec = new DESKeySpec(paramArrayOfByte2); 46 | SecretKey localSecretKey = SecretKeyFactory.getInstance("DES").generateSecret(localDESKeySpec); 47 | Cipher localCipher = Cipher.getInstance("DES"); 48 | localCipher.init(2, localSecretKey, localSecureRandom); 49 | return localCipher.doFinal(paramArrayOfByte1); 50 | } 51 | 52 | public static final String encrypt(String paramString) 53 | { 54 | try 55 | { 56 | String str = byte2hex(encrypt(paramString.getBytes(), "__jDlog_".getBytes())); 57 | return str; 58 | } 59 | catch (Exception localException) {} 60 | return null; 61 | } 62 | 63 | public static byte[] encrypt(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2) 64 | throws Exception 65 | { 66 | SecureRandom localSecureRandom = new SecureRandom(); 67 | DESKeySpec localDESKeySpec = new DESKeySpec(paramArrayOfByte2); 68 | SecretKey localSecretKey = SecretKeyFactory.getInstance("DES").generateSecret(localDESKeySpec); 69 | Cipher localCipher = Cipher.getInstance("DES"); 70 | localCipher.init(1, localSecretKey, localSecureRandom); 71 | return localCipher.doFinal(paramArrayOfByte1); 72 | } 73 | 74 | public static byte[] hex2byte(byte[] paramArrayOfByte) 75 | { 76 | if (paramArrayOfByte.length % 2 != 0) { 77 | throw new IllegalArgumentException("长度不是偶数"); 78 | } 79 | byte[] arrayOfByte = new byte[paramArrayOfByte.length / 2]; 80 | for (int i = 0;; i += 2) 81 | { 82 | if (i >= paramArrayOfByte.length) { 83 | return arrayOfByte; 84 | } 85 | String str = new String(paramArrayOfByte, i, 2); 86 | arrayOfByte[(i / 2)] = ((byte)Integer.parseInt(str, 16)); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/account_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/account_setting.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/face.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/face.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/gesture_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/gesture_default.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/ic_launcher_title.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/input_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/input_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/input_normal.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/input_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/input_over.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/loginok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/loginok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/titlebar_style.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/tk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/tk.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/usertitle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/usertitle.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/verify_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/verify_button.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/verify_sel_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/verify_sel_button.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/welcomepic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/welcomepic.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/xicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-hdpi/xicon.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/account_del.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-ldpi/account_del.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldpi/account_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-ldpi/account_edit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/account_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/account_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/account_add_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/account_add_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/back.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/button2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/button2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/button2_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/button2_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/button2_over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/button2_over.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/default_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/default_bg.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/exit.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/exit_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/exit_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/login_back.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/login_back.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/login_input.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/login_input.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/loginok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/loginok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/logout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/logout.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/logout_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/logout_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/more_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/qq_edit_login.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/refresh.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/refresh_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/refresh_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/returnbutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/returnbutton.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/returnbutton_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/returnbutton_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/time.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/titlelogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/titlelogo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/user_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/user_select.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/userbk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/userbk.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/usermbk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/usermbk.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/usermbk_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/usermbk_down.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/usertitle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-mdpi/usertitle.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/account.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-xhdpi/account.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/loginok.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-xhdpi/loginok.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/loginoktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-xhdpi/loginoktop.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-xhdpi/logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/starting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-xhdpi/starting.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/usertitle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miao1007/android-netkeeper/2611cda2fb37768d55cb04aa3c3d43fdd17b3a91/app/src/main/res/drawable-xhdpi/usertitle.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/btn_bg_style.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/add_account.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialoglayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dropdown_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/layout/setting_account.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/success.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 25 |