rtlduino rtl8710af gcc base version
45
tools/simple_config_wizard/Android/ChangeLog
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
ChangeLog
|
||||
----------------------------------------------------------------
|
||||
2016/06/13
|
||||
- Refined PacketSendTimeIntervalMs
|
||||
|
||||
2016/02/16
|
||||
- Refined wifi connection for Android 6
|
||||
|
||||
2015/12/29
|
||||
- Fixed ssid is empty when ap is hidden SSID
|
||||
|
||||
2015/11/18
|
||||
- Refined simple config Lib about other charset issue
|
||||
|
||||
2015/11/09
|
||||
- refined connection and refined sending packet method
|
||||
|
||||
2015/07/23
|
||||
- device type : 0xff00~0xffff for customer
|
||||
|
||||
2015/04/22
|
||||
- Show one AP of the same SSID multiple APs on AP List by site survey
|
||||
|
||||
2015/02/11
|
||||
- Bug fixed: Reconnection WiFi AP issue.
|
||||
- Bug fixed: Type transformation for Encryption WiFi profile.
|
||||
- Re-fine time interval(ms) between sending two packets
|
||||
|
||||
2014/10/20
|
||||
- Re-fine configure flow when DUT receives first UDP packet.
|
||||
|
||||
2014/10/01
|
||||
- Refined if the profile length>127, configure will fail issue.
|
||||
|
||||
2014/08/13
|
||||
- Add Hidden SSID Support
|
||||
|
||||
2014/08/04
|
||||
- Re-fine configure flow
|
||||
- Re-fine control flow
|
||||
- Re-fine discovery flow
|
||||
- Add descriptions of the delay about sending packet
|
||||
|
||||
2014/06/19
|
||||
- Initial Release
|
||||
BIN
tools/simple_config_wizard/Android/SimpleConfigWizard_v115.apk
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>SimpleConfigWizard</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.rtk.simpleconfig_wizard"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.1.5.20160613"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="18" />
|
||||
|
||||
|
||||
<!-- wifi usage -->
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
|
||||
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
|
||||
|
||||
<!-- Camera usage -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
||||
<!-- file and SD Card usage -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
|
||||
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
|
||||
<activity
|
||||
android:name="com.rtk.simpleconfig_wizard.MainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/app_name" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.wifi.connection.MainActivity"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:launchMode="singleInstance"
|
||||
android:excludeFromRecents="true"
|
||||
android:noHistory="true">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.INFO" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.wifi.connection.CONNECT_OR_EDIT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.zxing.activity.CaptureActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" >
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.rtk.simpleconfig_wizard"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.1.5.20160613"
|
||||
android:installLocation="auto">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="18" />
|
||||
|
||||
|
||||
<!-- wifi usage -->
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
|
||||
<uses-permission android:name="android.permission.READ_SMS"></uses-permission>
|
||||
|
||||
<!-- Camera usage -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
|
||||
<!-- file and SD Card usage -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
|
||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission>
|
||||
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
|
||||
<activity
|
||||
android:name="com.rtk.simpleconfig_wizard.MainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||
android:label="@string/app_name" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.wifi.connection.MainActivity"
|
||||
android:theme="@android:style/Theme.Dialog"
|
||||
android:launchMode="singleInstance"
|
||||
android:excludeFromRecents="true"
|
||||
android:noHistory="true">
|
||||
<intent-filter>
|
||||
<category android:name="android.intent.category.INFO" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="com.wifi.connection.CONNECT_OR_EDIT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name="com.zxing.activity.CaptureActivity"
|
||||
android:configChanges="orientation|keyboardHidden"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:windowSoftInputMode="stateAlwaysHidden" >
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 3 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 560 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
|
@ -0,0 +1,6 @@
|
|||
/** Automatically generated file. DO NOT MODIFY */
|
||||
package com.rtk.simpleconfig_wizard;
|
||||
|
||||
public final class BuildConfig {
|
||||
public final static boolean DEBUG = true;
|
||||
}
|
||||
|
|
@ -0,0 +1,283 @@
|
|||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.rtk.simpleconfig_wizard;
|
||||
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class color {
|
||||
public static final int bg_color=0x7f050002;
|
||||
public static final int buttons_view_bk=0x7f050000;
|
||||
public static final int content_bk=0x7f050001;
|
||||
public static final int contents_text=0x7f050003;
|
||||
public static final int encode_view=0x7f050004;
|
||||
public static final int grgray=0x7f05001c;
|
||||
public static final int header=0x7f05001b;
|
||||
public static final int help_button_view=0x7f050005;
|
||||
public static final int help_view=0x7f050006;
|
||||
public static final int possible_result_points=0x7f050007;
|
||||
public static final int result_image_border=0x7f050008;
|
||||
public static final int result_minor_text=0x7f050009;
|
||||
public static final int result_points=0x7f05000a;
|
||||
public static final int result_text=0x7f05000b;
|
||||
public static final int result_view=0x7f05000c;
|
||||
public static final int sbc_header_text=0x7f05000d;
|
||||
public static final int sbc_header_view=0x7f05000e;
|
||||
public static final int sbc_layout_view=0x7f050010;
|
||||
public static final int sbc_list_item=0x7f05000f;
|
||||
public static final int sbc_page_number_text=0x7f050011;
|
||||
public static final int sbc_snippet_text=0x7f050012;
|
||||
public static final int share_text=0x7f050013;
|
||||
public static final int share_view=0x7f050014;
|
||||
public static final int status_text=0x7f050016;
|
||||
public static final int status_view=0x7f050015;
|
||||
public static final int transparent=0x7f050017;
|
||||
public static final int viewfinder_frame=0x7f050018;
|
||||
public static final int viewfinder_laser=0x7f050019;
|
||||
public static final int viewfinder_mask=0x7f05001a;
|
||||
}
|
||||
public static final class dimen {
|
||||
/** Default screen margins, per the Android Design guidelines.
|
||||
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
|
||||
*/
|
||||
public static final int activity_horizontal_margin=0x7f060000;
|
||||
public static final int activity_vertical_margin=0x7f060001;
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int add_icon=0x7f020000;
|
||||
public static final int ic_dialog_icon=0x7f020001;
|
||||
public static final int ic_launcher=0x7f020002;
|
||||
public static final int icon=0x7f020003;
|
||||
public static final int navbar=0x7f020004;
|
||||
public static final int qrcode_img=0x7f020005;
|
||||
public static final int refresh=0x7f020006;
|
||||
public static final int settings=0x7f020007;
|
||||
public static final int settings_icon=0x7f020008;
|
||||
public static final int signal1=0x7f020009;
|
||||
public static final int signal2=0x7f02000a;
|
||||
public static final int signal3=0x7f02000b;
|
||||
public static final int signal4=0x7f02000c;
|
||||
public static final int signal5=0x7f02000d;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int IPAddress=0x7f070021;
|
||||
public static final int IPAddress_TextView=0x7f070022;
|
||||
public static final int LinkSpeed_TextView=0x7f07001e;
|
||||
public static final int Password=0x7f070023;
|
||||
public static final int Password_EditText=0x7f070025;
|
||||
public static final int Password_TextView=0x7f070024;
|
||||
public static final int Security_TextView=0x7f070020;
|
||||
public static final int ShowPassword_CheckBox=0x7f070026;
|
||||
public static final int SignalStrength_TextView=0x7f07001f;
|
||||
public static final int Speed=0x7f07001d;
|
||||
public static final int Status=0x7f07001b;
|
||||
public static final int Status_TextView=0x7f07001c;
|
||||
public static final int action_settings=0x7f07003e;
|
||||
public static final int addNewNetworkBtn=0x7f070030;
|
||||
public static final int add_network_dialog=0x7f070016;
|
||||
/** Messages IDs
|
||||
*/
|
||||
public static final int auto_focus=0x7f070000;
|
||||
public static final int btn_cancel_scan=0x7f070039;
|
||||
public static final int btn_configNewDevice=0x7f070015;
|
||||
public static final int btn_scan=0x7f07002c;
|
||||
public static final int btn_scanDevices=0x7f07000f;
|
||||
public static final int button1=0x7f070034;
|
||||
public static final int button2=0x7f070035;
|
||||
public static final int button3=0x7f070036;
|
||||
public static final int buttons_view=0x7f070033;
|
||||
public static final int checkBox_password=0x7f07001a;
|
||||
public static final int content=0x7f070032;
|
||||
public static final int customtitlebar=0x7f07002f;
|
||||
public static final int decode=0x7f070001;
|
||||
public static final int decode_failed=0x7f070002;
|
||||
public static final int decode_succeeded=0x7f070003;
|
||||
public static final int encode_failed=0x7f070004;
|
||||
public static final int encode_succeeded=0x7f070005;
|
||||
public static final int encrypt_type=0x7f070018;
|
||||
public static final int icon=0x7f07002d;
|
||||
public static final int icon_sub=0x7f07002e;
|
||||
public static final int id_ap_password=0x7f070019;
|
||||
public static final int id_device_name=0x7f070031;
|
||||
public static final int img=0x7f070028;
|
||||
public static final int info=0x7f07002b;
|
||||
public static final int info_aplist=0x7f07003c;
|
||||
public static final int launch_product_query=0x7f070006;
|
||||
public static final int layer1_linear1=0x7f07000d;
|
||||
public static final int layer1_linear2=0x7f070010;
|
||||
public static final int layer1_linear3=0x7f070013;
|
||||
public static final int layer2_linear1=0x7f070011;
|
||||
public static final int layer2_linear2=0x7f070014;
|
||||
public static final int linearLayout1=0x7f070029;
|
||||
public static final int linearLayout2=0x7f070027;
|
||||
public static final int listView1=0x7f070012;
|
||||
public static final int mainlayout=0x7f07000c;
|
||||
public static final int network_name_edit=0x7f070017;
|
||||
public static final int preview_view=0x7f070037;
|
||||
public static final int quit=0x7f070007;
|
||||
public static final int radioButton1=0x7f07003d;
|
||||
public static final int restart_preview=0x7f070008;
|
||||
public static final int return_scan_result=0x7f070009;
|
||||
public static final int search_book_contents_failed=0x7f07000a;
|
||||
public static final int search_book_contents_succeeded=0x7f07000b;
|
||||
public static final int signalImg=0x7f07003a;
|
||||
public static final int textDeviceTitle=0x7f07000e;
|
||||
public static final int title=0x7f07002a;
|
||||
public static final int title_aplist=0x7f07003b;
|
||||
public static final int viewfinder_view=0x7f070038;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int activity_main=0x7f030000;
|
||||
public static final int add_network_content=0x7f030001;
|
||||
public static final int base_content=0x7f030002;
|
||||
public static final int buttons_view_divider=0x7f030003;
|
||||
public static final int confirm_list=0x7f030004;
|
||||
public static final int confirm_pincode_entry=0x7f030005;
|
||||
public static final int customtitlebar=0x7f030006;
|
||||
public static final int device_list=0x7f030007;
|
||||
public static final int device_rename=0x7f030008;
|
||||
public static final int floating=0x7f030009;
|
||||
public static final int qrcode_scanner=0x7f03000a;
|
||||
public static final int title_view=0x7f03000b;
|
||||
public static final int wifi_password_entry=0x7f03000c;
|
||||
public static final int wifiap_list=0x7f03000d;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int main=0x7f0a0000;
|
||||
}
|
||||
public static final class raw {
|
||||
public static final int beep=0x7f040000;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int action_settings=0x7f080001;
|
||||
public static final int adhoc_not_supported_yet=0x7f08002c;
|
||||
public static final int ap_connected=0x7f080003;
|
||||
public static final int ap_unconnected=0x7f080004;
|
||||
public static final int app_name=0x7f080000;
|
||||
public static final int buttonOp=0x7f080006;
|
||||
public static final int button_change_password=0x7f080029;
|
||||
public static final int cancel=0x7f080012;
|
||||
/** Button label to connect to a wifi network
|
||||
*/
|
||||
public static final int connect=0x7f080011;
|
||||
public static final int del_prof=0x7f080010;
|
||||
/** For Simple Control Layout Interface
|
||||
*/
|
||||
public static final int dev_discovery=0x7f08000e;
|
||||
public static final int dummy_content_description=0x7f08002d;
|
||||
/** Button caption to forget a wifi network
|
||||
*/
|
||||
public static final int forget_network=0x7f080016;
|
||||
public static final int hello_world=0x7f080002;
|
||||
/** Wi-Fi IP address label
|
||||
*/
|
||||
public static final int ip_address=0x7f080014;
|
||||
public static final int pin_text=0x7f080008;
|
||||
public static final int please_type_passphrase=0x7f080026;
|
||||
public static final int qrcode_cancel=0x7f08000b;
|
||||
public static final int qrcode_desc=0x7f080009;
|
||||
public static final int qrcode_title=0x7f08000a;
|
||||
public static final int rename_dev=0x7f08000f;
|
||||
/** Label for the security of a wifi network
|
||||
*/
|
||||
public static final int security=0x7f08001f;
|
||||
/** Label for the signal strength
|
||||
*/
|
||||
public static final int signal=0x7f080015;
|
||||
public static final int start_config=0x7f08000c;
|
||||
/** Wi-Fi settings screen, summary text for network when connected
|
||||
*/
|
||||
public static final int status_connected=0x7f080018;
|
||||
public static final int status_connecting=0x7f080019;
|
||||
public static final int stop_config=0x7f08000d;
|
||||
public static final int toastFailed=0x7f080005;
|
||||
public static final int wifi_change_password=0x7f080028;
|
||||
/** !!!!!!!! vpn_connect_toTitle of VPN connect dialog
|
||||
*/
|
||||
public static final int wifi_connect_to=0x7f080013;
|
||||
/** Label for link speed (wifi)
|
||||
*/
|
||||
public static final int wifi_link_speed=0x7f08001a;
|
||||
/** An edit field's grayed out value when it has not been modified
|
||||
*/
|
||||
public static final int wifi_password_unchanged=0x7f08002a;
|
||||
/** Button caption to save a configuration wifi
|
||||
*/
|
||||
public static final int wifi_save_config=0x7f08002b;
|
||||
/** For Simple Config Layout Interface
|
||||
*/
|
||||
public static final int wifi_scan=0x7f080007;
|
||||
/** Value for the wifi security
|
||||
*/
|
||||
public static final int wifi_security_ieee8021x=0x7f080025;
|
||||
/** Value for the wifi security. This means no encryption.
|
||||
*/
|
||||
public static final int wifi_security_open=0x7f080020;
|
||||
/** Value for the wifi security
|
||||
*/
|
||||
public static final int wifi_security_wep=0x7f080021;
|
||||
/** Value for the wifi security
|
||||
*/
|
||||
public static final int wifi_security_wpa=0x7f080022;
|
||||
/** Value for the wifi security
|
||||
*/
|
||||
public static final int wifi_security_wpa2=0x7f080023;
|
||||
/** Value for the wifi security
|
||||
*/
|
||||
public static final int wifi_security_wpa_eap=0x7f080024;
|
||||
public static final int wifi_show_password=0x7f080027;
|
||||
/** Verbose wifi signal strength. This is the worst out of 4 levels.
|
||||
*/
|
||||
public static final int wifi_signal_0=0x7f08001e;
|
||||
/** Verbose wifi signal strength. This is the 3rd best out of 4 levels.
|
||||
*/
|
||||
public static final int wifi_signal_1=0x7f08001d;
|
||||
/** Verbose wifi signal strength. This is the 2nd best out of 4 levels.
|
||||
*/
|
||||
public static final int wifi_signal_2=0x7f08001c;
|
||||
/** Verbose wifi signal strength. This is the best out of 4 levels.
|
||||
*/
|
||||
public static final int wifi_signal_3=0x7f08001b;
|
||||
/** Label for status of connection
|
||||
*/
|
||||
public static final int wifi_status=0x7f080017;
|
||||
}
|
||||
public static final class style {
|
||||
/**
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
|
||||
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
|
||||
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
|
||||
API 11 theme customizations can go here.
|
||||
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
|
||||
API 14 theme customizations can go here.
|
||||
*/
|
||||
public static final int AppBaseTheme=0x7f090000;
|
||||
/** Application theme.
|
||||
All customizations that are NOT specific to a particular API-level can go here.
|
||||
*/
|
||||
public static final int AppTheme=0x7f090001;
|
||||
public static final int PlatformDialog=0x7f090002;
|
||||
public static final int textAppearanceBaseContent=0x7f090003;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 50 KiB |
|
|
@ -0,0 +1,20 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-19
|
||||
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 3 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 2 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
android:id="@+id/mainlayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layer1_linear1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="#CACACA"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textDeviceTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:layout_weight="5"
|
||||
android:text="Configured Device"
|
||||
android:textSize="25dip"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_scanDevices"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
android:scaleType="fitCenter"
|
||||
android:text="Scan Configured Devices"
|
||||
android:src="@drawable/refresh"
|
||||
android:adjustViewBounds="true"
|
||||
android:padding="15dp"
|
||||
android:onClick="ScanDevices_OnClick"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/layer1_linear2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="10">
|
||||
<LinearLayout
|
||||
android:id="@+id/layer2_linear1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<ListView android:id="@+id/listView1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
</ListView>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layer1_linear3"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:background="#737373"
|
||||
android:layout_weight="1">
|
||||
<LinearLayout
|
||||
android:id="@+id/layer2_linear2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="4">
|
||||
<Button
|
||||
android:id="@+id/btn_configNewDevice"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="Configure New Device"
|
||||
android:onClick="configNewDevice_OnClick"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="5sp"
|
||||
android:id="@+id/add_network_dialog"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="SSID Name: "
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10sp"
|
||||
/>
|
||||
|
||||
<EditText android:id="@+id/network_name_edit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="Encryption: "
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10sp"
|
||||
/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/encrypt_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="Password: "
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10sp"/>
|
||||
<EditText
|
||||
android:id="@+id/id_ap_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:drawable/editbox_background_normal"
|
||||
android:padding="5dip"
|
||||
android:singleLine="true"
|
||||
android:textColor="#999999"
|
||||
android:inputType="textPassword"
|
||||
android:textSize="20dp"/>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
<CheckBox
|
||||
android:id="@+id/checkBox_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Show Password" />
|
||||
<!-- CheckBox android:id="@+id/is_hidden_ssid"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="Is Hidden SSID"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/-->
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,178 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
/*
|
||||
* Wifi Connector
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:padding="5sp"
|
||||
>
|
||||
|
||||
<LinearLayout android:id="@+id/Status"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/wifi_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/Status_TextView"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/status_connected"
|
||||
android:paddingLeft = "5sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/Speed"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/wifi_link_speed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/LinkSpeed_TextView"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="54Mbps"
|
||||
android:paddingLeft = "5sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/signal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/SignalStrength_TextView"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="Poor"
|
||||
android:paddingLeft = "5sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/security"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/Security_TextView"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="WEP"
|
||||
android:paddingLeft = "5sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/IPAddress"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/ip_address"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<TextView android:id="@+id/IPAddress_TextView"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="192.168.0.1"
|
||||
android:paddingLeft = "5sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:id="@+id/Password"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView android:id="@+id/Password_TextView"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/please_type_passphrase"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="10sp"
|
||||
/>
|
||||
|
||||
<com.wifi.connection.ChangingAwareEditText android:id="@+id/Password_EditText"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="text|textPassword"/>
|
||||
|
||||
<CheckBox android:id="@+id/ShowPassword_CheckBox"
|
||||
style="@style/textAppearanceBaseContent"
|
||||
android:text="@string/wifi_show_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@android:drawable/divider_horizontal_dark"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="@string/dummy_content_description"
|
||||
android:scaleType="fitXY"/>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView android:src="@drawable/ic_dialog_icon"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:padding="3dp"
|
||||
android:id="@+id/img">
|
||||
</ImageView>
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="9">
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:textSize = "25dp"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="2"></TextView>
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="1">
|
||||
<TextView android:id="@+id/info"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize = "15dp"
|
||||
android:textColor="#3333ff"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="1"></TextView>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_scan"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1"
|
||||
android:src="@drawable/qrcode_img"
|
||||
android:onClick="qrcode_onclick"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/id_ap_password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="5"
|
||||
android:background="@android:drawable/editbox_background_normal"
|
||||
android:padding="5dip"
|
||||
android:singleLine="true"
|
||||
android:textColor="#999999"
|
||||
android:textSize="20dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="#525f67">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_weight="4"
|
||||
android:orientation="vertical"
|
||||
android:background="#525f67">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon_sub"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:padding="2dp"
|
||||
android:src="@drawable/settings_icon"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true" >
|
||||
</ImageView>
|
||||
<TextView
|
||||
android:id="@+id/customtitlebar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:textColor="#ffffff"
|
||||
android:text="Connect to home AP"
|
||||
android:padding="3px"
|
||||
android:textStyle="bold"
|
||||
android:layout_toRightOf="@id/icon_sub"
|
||||
android:layout_alignParentTop="true"
|
||||
android:gravity="center_vertical"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/addNewNetworkBtn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
|
||||
android:background="@null"
|
||||
android:contentDescription="@string/app_name"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:padding="2dp"
|
||||
android:onClick="addNewNetwork_OnClick"
|
||||
android:src="@drawable/add_icon"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="#ff0000"
|
||||
android:layout_below="@id/icon"><!-- This is line below the title -->
|
||||
</ImageView>
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView android:src="@drawable/ic_dialog_icon"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_height="35dp"
|
||||
android:layout_width="35dp"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:padding="3dp"
|
||||
android:id="@+id/img">
|
||||
</ImageView>
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:orientation="vertical"
|
||||
android:layout_weight="9">
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:textSize = "25dp"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="2"></TextView>
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout1"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="1">
|
||||
<TextView android:id="@+id/info"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize = "15dp"
|
||||
android:textColor="#3333ff"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="1"></TextView>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/id_device_name"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:drawable/editbox_background_normal"
|
||||
android:padding="5dp"
|
||||
android:singleLine="true"
|
||||
android:textColor="#999999"
|
||||
android:textSize="14dip"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Wifi Connector
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<include
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/title_view" />
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/content_bk" >
|
||||
</ScrollView>
|
||||
|
||||
<include layout="@layout/buttons_view_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/buttons_view_bk"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:padding="5sp" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
|
||||
<SurfaceView
|
||||
android:id="@+id/preview_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<com.zxing.view.ViewfinderView
|
||||
android:id="@+id/viewfinder_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/navbar"
|
||||
android:gravity="center"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/qrcode_title" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_cancel_scan"
|
||||
android:layout_width="248dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginBottom="75dp"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/qrcode_cancel" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@drawable/ic_dialog_icon"
|
||||
android:drawablePadding="5dp"
|
||||
android:gravity="center_vertical"
|
||||
android:textColor="@android:color/primary_text_dark"
|
||||
android:textSize="20sp"
|
||||
android:padding="10dp" />
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<EditText
|
||||
android:id="@+id/id_ap_password"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:drawable/editbox_background_normal"
|
||||
android:padding="5dip"
|
||||
android:singleLine="true"
|
||||
android:textColor="#999999"
|
||||
android:inputType="textPassword"
|
||||
android:textSize="20dp"/>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkBox_password"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Show Password" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout2"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_height="35dp"
|
||||
android:layout_width="35dp"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:padding="3dp"
|
||||
android:id="@+id/signalImg">
|
||||
</ImageView>
|
||||
|
||||
<LinearLayout android:id="@+id/linearLayout1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="9">
|
||||
<TextView android:id="@+id/title_aplist"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize = "20dp"
|
||||
android:layout_gravity="center_vertical|left"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="6"></TextView>
|
||||
|
||||
<TextView android:id="@+id/info_aplist"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize = "15dp"
|
||||
android:textColor="#3333ff"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
android:gravity="center_vertical|left"
|
||||
android:layout_weight="1"></TextView>
|
||||
<RadioGroup
|
||||
android:id="@+id/radioButton1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical|right"
|
||||
android:gravity="center_vertical|left"
|
||||
android:text="" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/action_settings"/>
|
||||
|
||||
</menu>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw600dp devices (e.g. 7" tablets) here.
|
||||
-->
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Customize dimensions originally defined in res/values/dimens.xml (such as
|
||||
screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
|
||||
-->
|
||||
<dimen name="activity_horizontal_margin">128dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
|
||||
<!-- API 11 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
|
||||
<!-- API 14 theme customizations can go here. -->
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<resources>
|
||||
|
||||
<color name="buttons_view_bk">@android:color/darker_gray</color>
|
||||
<color name="content_bk">@android:color/background_light</color>
|
||||
|
||||
<color name="bg_color">#EDEDED</color>
|
||||
<color name="contents_text">#ff000000</color>
|
||||
<color name="encode_view">#ffffffff</color>
|
||||
<color name="help_button_view">#ffcccccc</color>
|
||||
<color name="help_view">#ff404040</color>
|
||||
<color name="possible_result_points">#c0ffff00</color>
|
||||
<color name="result_image_border">#ffffffff</color>
|
||||
<color name="result_minor_text">#ffc0c0c0</color>
|
||||
<color name="result_points">#c000ff00</color>
|
||||
<color name="result_text">#ffffffff</color>
|
||||
<color name="result_view">#b0000000</color>
|
||||
<color name="sbc_header_text">#ff808080</color>
|
||||
<color name="sbc_header_view">#ffffffff</color>
|
||||
<color name="sbc_list_item">#fffff0e0</color>
|
||||
<color name="sbc_layout_view">#ffffffff</color>
|
||||
<color name="sbc_page_number_text">#ff000000</color>
|
||||
<color name="sbc_snippet_text">#ff4b4b4b</color>
|
||||
<color name="share_text">#ff000000</color>
|
||||
<color name="share_view">#ffffffff</color>
|
||||
<color name="status_view">#50000000</color>
|
||||
<color name="status_text">#ffffffff</color>
|
||||
<color name="transparent">#00000000</color>
|
||||
<color name="viewfinder_frame">#ff000000</color>
|
||||
<color name="viewfinder_laser">#ffff0000</color>
|
||||
<color name="viewfinder_mask">#60000000</color>
|
||||
<color name="header">#58567D</color>
|
||||
<color name="grgray">#686868</color>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<resources>
|
||||
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2008 ZXing authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<resources>
|
||||
<!-- Messages IDs -->
|
||||
<item type="id" name="auto_focus"/>
|
||||
<item type="id" name="decode"/>
|
||||
<item type="id" name="decode_failed"/>
|
||||
<item type="id" name="decode_succeeded"/>
|
||||
<item type="id" name="encode_failed"/>
|
||||
<item type="id" name="encode_succeeded"/>
|
||||
<item type="id" name="launch_product_query"/>
|
||||
<item type="id" name="quit"/>
|
||||
<item type="id" name="restart_preview"/>
|
||||
<item type="id" name="return_scan_result"/>
|
||||
<item type="id" name="search_book_contents_failed"/>
|
||||
<item type="id" name="search_book_contents_succeeded"/>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Simple Config Wizard</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="hello_world">Hello world!</string>
|
||||
|
||||
<string name="ap_connected">connected</string>
|
||||
<string name="ap_unconnected"></string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<resources>
|
||||
|
||||
<!--
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
-->
|
||||
<style name="AppBaseTheme" parent="android:Theme.Light">
|
||||
<!--
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
-->
|
||||
</style>
|
||||
|
||||
<!-- Application theme. -->
|
||||
<style name="AppTheme" parent="AppBaseTheme">
|
||||
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
|
||||
</style>
|
||||
|
||||
|
||||
<string name="toastFailed">Failed!</string>
|
||||
<string name="buttonOp">More…</string>
|
||||
|
||||
<!-- For Simple Config Layout Interface -->
|
||||
<string name="wifi_scan">Wi-Fi Network</string>
|
||||
<string name="pin_text">PIN</string>
|
||||
<string name="qrcode_desc">QRCode</string>
|
||||
<string name="qrcode_title">QRCode Scan</string>
|
||||
<string name="qrcode_cancel">Cancel</string>
|
||||
<string name="start_config">Start</string>
|
||||
<string name="stop_config">Press to Stop</string>
|
||||
|
||||
<!-- For Simple Control Layout Interface -->
|
||||
<string name="dev_discovery">Connected Device</string>
|
||||
<string name="rename_dev">Rename Device</string>
|
||||
<string name="del_prof">Remove Device</string>
|
||||
|
||||
<!-- Button label to connect to a wifi network-->
|
||||
<string name="connect">Connect</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<!-- !!!!!!!! vpn_connect_toTitle of VPN connect dialog -->
|
||||
<string name="wifi_connect_to">Connect to %s</string>
|
||||
<!-- Wi-Fi IP address label -->
|
||||
<string name="ip_address">IP address</string>
|
||||
<!-- Label for the signal strength -->
|
||||
<string name="signal">Signal strength</string>
|
||||
|
||||
<!-- Button caption to forget a wifi network -->
|
||||
<string name="forget_network">Forget</string>
|
||||
<!-- Label for status of connection -->
|
||||
<string name="wifi_status">Status</string>
|
||||
<!--Wi-Fi settings screen, summary text for network when connected -->
|
||||
<string name="status_connected">Connected</string>
|
||||
<string name="status_connecting">Connecting…</string>
|
||||
<!-- Label for link speed (wifi) -->
|
||||
<string name="wifi_link_speed">Speed</string>
|
||||
<!-- Verbose wifi signal strength. This is the best out of 4 levels. -->
|
||||
<string name="wifi_signal_3">Excellent</string>
|
||||
<!-- Verbose wifi signal strength. This is the 2nd best out of 4 levels. -->
|
||||
<string name="wifi_signal_2">Good</string>
|
||||
<!-- Verbose wifi signal strength. This is the 3rd best out of 4 levels. -->
|
||||
<string name="wifi_signal_1">Fair</string>
|
||||
<!-- Verbose wifi signal strength. This is the worst out of 4 levels. -->
|
||||
<string name="wifi_signal_0">Poor</string>
|
||||
<!-- Label for the security of a wifi network -->
|
||||
<string name="security">Security</string>
|
||||
<!-- Value for the wifi security. This means no encryption. -->
|
||||
<string name="wifi_security_open">Open</string>
|
||||
<!-- Value for the wifi security -->
|
||||
<string name="wifi_security_wep">WEP</string>
|
||||
<!-- Value for the wifi security -->
|
||||
<string name="wifi_security_wpa">WPA</string>
|
||||
<!-- Value for the wifi security -->
|
||||
<string name="wifi_security_wpa2">WPA2</string>
|
||||
<!-- Value for the wifi security -->
|
||||
<string name="wifi_security_wpa_eap">WPA-EAP</string>
|
||||
<!-- Value for the wifi security -->
|
||||
<string name="wifi_security_ieee8021x">IEEE8021X</string>
|
||||
|
||||
|
||||
<string name="please_type_passphrase">Wireless password</string>
|
||||
<string name="wifi_show_password">Show password.</string>
|
||||
|
||||
<string name="wifi_change_password">Change password</string>
|
||||
<string name="button_change_password">Modify</string>
|
||||
<!-- An edit field's grayed out value when it has not been modified -->
|
||||
<string name="wifi_password_unchanged">(unchanged)</string>
|
||||
<!-- Button caption to save a configuration wifi -->
|
||||
<string name="wifi_save_config">Save</string>
|
||||
|
||||
<string name="adhoc_not_supported_yet">AdHoc is not supported by Android platform yet!</string>
|
||||
|
||||
<string name="dummy_content_description">""</string>
|
||||
|
||||
<style name="PlatformDialog" parent="android:Theme.Dialog"/>
|
||||
<style name="textAppearanceBaseContent" parent="@android:style/TextAppearance.Small.Inverse" />
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.rtk.simpleconfig_wizard;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
public class AESCrypt {
|
||||
// private static final String TAG = "AESCrypt";
|
||||
|
||||
public static String encrypt(String key, String cleartext) throws Exception {
|
||||
byte[] md5Key = MD5(key.getBytes());
|
||||
byte[] result = encrypt(md5Key, cleartext.getBytes());
|
||||
return toHex(result);
|
||||
}
|
||||
|
||||
public static String decrypt(String key, String encrypted) throws Exception {
|
||||
byte[] md5Key = MD5(key.getBytes());
|
||||
byte[] result = decrypt(md5Key, toByte(encrypted));
|
||||
return new String(result);
|
||||
}
|
||||
|
||||
public static byte[] MD5(byte[] key) throws Exception {
|
||||
byte[] md5_digest = new byte[16];
|
||||
MessageDigest mDigest;
|
||||
|
||||
mDigest = MessageDigest.getInstance("MD5");
|
||||
mDigest.update(key, 0, key.length);
|
||||
md5_digest = mDigest.digest();
|
||||
// System.out.printf("MD5: ");
|
||||
// for(int i=0; i<16; i++) {
|
||||
// System.out.printf("%02x ", md5_digest[i]);
|
||||
// }
|
||||
// System.out.printf("\n");
|
||||
|
||||
return md5_digest;
|
||||
}
|
||||
|
||||
public static byte[] encrypt(byte[] raw, byte[] clear) throws Exception {
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES/ECB/PKCS5Padding");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
|
||||
byte[] encrypted = cipher.doFinal(clear);
|
||||
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
public static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception {
|
||||
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES/ECB/PKCS5Padding");
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
|
||||
byte[] decrypted = cipher.doFinal(encrypted);
|
||||
return decrypted;
|
||||
}
|
||||
|
||||
public static byte[] toByte(String hexString) {
|
||||
int len = hexString.length()/2;
|
||||
byte[] result = new byte[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
result[i] = Integer.valueOf(hexString.substring(2*i, 2*i+2), 16).byteValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String toHex(byte[] buf) {
|
||||
if (buf == null)
|
||||
return "";
|
||||
StringBuffer result = new StringBuffer(2*buf.length);
|
||||
for (int i = 0; i < buf.length; i++) {
|
||||
appendHex(result, buf[i]);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private final static String HEX = "0123456789ABCDEF";
|
||||
private static void appendHex(StringBuffer sb, byte b) {
|
||||
sb.append(HEX.charAt((b>>4)&0x0f)).append(HEX.charAt(b&0x0f));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
package com.rtk.simpleconfig_wizard;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public class ConfigurationDevice {
|
||||
|
||||
public static class DeviceInfo
|
||||
{
|
||||
private int aliveFlag;
|
||||
private String name;
|
||||
private String IP;
|
||||
private String macAdrress;
|
||||
private int securityType;
|
||||
private Drawable img;
|
||||
private boolean connectedflag;
|
||||
|
||||
public int getaliveFlag()
|
||||
{
|
||||
return this.aliveFlag;
|
||||
}
|
||||
public void setaliveFlag(int aliveFlag)
|
||||
{
|
||||
this.aliveFlag = aliveFlag;
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name= name;
|
||||
}
|
||||
public String getIP()
|
||||
{
|
||||
return this.IP;
|
||||
}
|
||||
public void setIP(String IP)
|
||||
{
|
||||
this.IP= IP;
|
||||
}
|
||||
public String getmacAdrress()
|
||||
{
|
||||
return this.macAdrress;
|
||||
}
|
||||
public void setmacAdrress(String macAdrress)
|
||||
{
|
||||
this.macAdrress= macAdrress;
|
||||
}
|
||||
|
||||
public int getsecurityType()
|
||||
{
|
||||
return this.securityType;
|
||||
}
|
||||
public void setsecurityType(int securityType)
|
||||
{
|
||||
this.securityType= securityType;
|
||||
}
|
||||
|
||||
public Drawable getimg()
|
||||
{
|
||||
return this.img;
|
||||
}
|
||||
public void setimg(Drawable img)
|
||||
{
|
||||
this.img= img;
|
||||
}
|
||||
public boolean getconnectedflag()
|
||||
{
|
||||
return this.connectedflag;
|
||||
}
|
||||
public void setconnectedflag(boolean connectedflag)
|
||||
{
|
||||
this.connectedflag= connectedflag;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,472 @@
|
|||
package com.rtk.simpleconfig_wizard;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
|
||||
public class FileOps {
|
||||
private static final String TAG = "FileOps";
|
||||
|
||||
private String SDPATH = Environment.getExternalStorageDirectory()+"/";
|
||||
//private String SDPATH = "/data/data/com.realtek.simpleconfig_wizard/files/";
|
||||
private String CFGFOLDER = "rtk_sc_wizard/";
|
||||
public static String SsidPasswdFile = "wizard1";
|
||||
public static String CfgPinFile = "wizard2";
|
||||
public static String CtlPinFile = "wizard3";
|
||||
public static String PASSWD;
|
||||
|
||||
private boolean checkFileExists(String path) {
|
||||
File file = new File(path);
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
private boolean createDir(String dir) {
|
||||
File dfile = new File(dir);
|
||||
if(dfile.exists())
|
||||
return true;
|
||||
// Log.d(TAG, "createDir: " + dfile);
|
||||
return dfile.mkdir();
|
||||
}
|
||||
|
||||
private boolean createFile(String file) throws Exception
|
||||
{
|
||||
File ffile = new File(file);
|
||||
// Log.d(TAG, "createFile: " + ffile);
|
||||
return ffile.createNewFile();
|
||||
}
|
||||
|
||||
// private boolean deleteFile(String file) throws Exception
|
||||
// {
|
||||
// File ffile = new File(file);
|
||||
// Log.d(TAG, "createFile: " + ffile);
|
||||
// return ffile.delete();
|
||||
// }
|
||||
|
||||
public void SetKey(String key)
|
||||
{
|
||||
PASSWD = key;
|
||||
// Log.d(TAG, "PASSWD: " + PASSWD);
|
||||
}
|
||||
|
||||
|
||||
public RandomAccessFile openFile(String filename) throws Exception
|
||||
{
|
||||
RandomAccessFile rf = null;
|
||||
String dir = SDPATH + CFGFOLDER;
|
||||
String file = dir + filename;
|
||||
// Log.d(TAG, "openFile: " + file);
|
||||
|
||||
if(!checkFileExists(file)) {
|
||||
if(!createDir(dir)) {
|
||||
//Log.e(TAG, "Create Dir Error");
|
||||
return null;
|
||||
}
|
||||
if(!createFile(file)) {
|
||||
Log.e(TAG, "Create File Error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
rf = new RandomAccessFile(file, "rw");
|
||||
|
||||
return rf;
|
||||
}
|
||||
|
||||
public void writeFile(RandomAccessFile rf, String str) throws Exception
|
||||
{
|
||||
if(rf==null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String estr = AESCrypt.encrypt(PASSWD, str);
|
||||
// Log.d(TAG, "estr: " + estr);
|
||||
rf.writeBytes(estr);
|
||||
}
|
||||
|
||||
public String readFile(RandomAccessFile rf) throws Exception
|
||||
{
|
||||
String str = null;
|
||||
byte[] strbuf = null;
|
||||
int len = 0 ;
|
||||
|
||||
if(rf==null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
len = (int)rf.length();
|
||||
if(len==0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
strbuf = new byte[len];
|
||||
rf.read(strbuf, 0, len);
|
||||
// for(int i=0; i<strbuf.length; i++)
|
||||
// Log.d(TAG, "" + strbuf[i]);
|
||||
str = new String(strbuf);
|
||||
// Log.d(TAG, "read str: " + str);
|
||||
|
||||
String dstr = AESCrypt.decrypt(PASSWD, str);
|
||||
// Log.d(TAG, "decrypt str: " + dstr);
|
||||
|
||||
return dstr;
|
||||
}
|
||||
|
||||
public void closeFile(RandomAccessFile rf) throws Exception
|
||||
{
|
||||
if(rf==null)
|
||||
return;
|
||||
|
||||
rf.close();
|
||||
}
|
||||
|
||||
|
||||
public void ParseSsidPasswdFile(String ssid)
|
||||
{
|
||||
RandomAccessFile rf = null;
|
||||
String str = null;
|
||||
|
||||
try {
|
||||
rf = openFile(FileOps.SsidPasswdFile);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Open File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
str = readFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Read File Error");
|
||||
try {
|
||||
rf.setLength(0);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Set Length Error");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Log.d(TAG, "Read: " + str);
|
||||
|
||||
SCCtlOps.StoredPasswd = new String();
|
||||
if(str==null) {
|
||||
//Log.e(TAG, "Null File");
|
||||
} else {
|
||||
String[] items = str.split("\\|");
|
||||
for(int i=0; i<items.length; i++) {
|
||||
// System.out.printf("items[%d]: %s\n", i, items[i]);
|
||||
String[] subitems = items[i].split("\\:");
|
||||
// for(int j=0; j<subitems.length; j++) {
|
||||
// Log.d(TAG, String.format("subitems[%d]: %s\n", j, subitems[j]));
|
||||
// }
|
||||
// Log.d(TAG, String.format("Selected SSID: %s\n", ssid));
|
||||
if(ssid.equals(subitems[0]) && !subitems[1].equals("null")) {
|
||||
SCCtlOps.StoredPasswd += subitems[1];
|
||||
// Log.d(TAG, "Find already existed SSID");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
closeFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Close File Error");
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSsidPasswdFile(boolean isOpenNetwork)
|
||||
{
|
||||
RandomAccessFile rf;
|
||||
try {
|
||||
rf = openFile(FileOps.SsidPasswdFile);
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
Log.e(TAG, "Open File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
long len=0;
|
||||
boolean isOld = false;
|
||||
String getstr = new String();
|
||||
String setstr = new String();
|
||||
try {
|
||||
len = rf.length();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Get Length Error");
|
||||
return;
|
||||
}
|
||||
if(len>0) {
|
||||
try {
|
||||
getstr = readFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Read File Error");
|
||||
return;
|
||||
}
|
||||
// Log.d(TAG, "getstr: " + getstr);
|
||||
|
||||
String[] items = getstr.split("\\|");
|
||||
for(int i=0; i<items.length; i++) {
|
||||
// System.out.printf("items[%d]: %s\n", i, items[i]);
|
||||
String[] subitems = items[i].split("\\:");
|
||||
// for(int j=0; j<subitems.length; j++) {
|
||||
// System.out.printf("subitems[%d]: %s\n", j, subitems[j]);
|
||||
// }
|
||||
if(SCCtlOps.ConnectedSSID.equals(subitems[0])) {
|
||||
isOld = true;
|
||||
// Log.d(TAG, "Refresh old");
|
||||
if(isOpenNetwork)
|
||||
setstr += SCCtlOps.ConnectedSSID + ":null|";
|
||||
else
|
||||
setstr += SCCtlOps.ConnectedSSID + ":" + SCCtlOps.ConnectedPasswd + "|";
|
||||
} else {
|
||||
// Log.d(TAG, "Re-Add existed");
|
||||
setstr += subitems[0] + ":" + subitems[1] + "|";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isOld) {
|
||||
// Log.d(TAG, "Add new");
|
||||
if(isOpenNetwork)
|
||||
setstr += SCCtlOps.ConnectedSSID + ":null|";
|
||||
else
|
||||
setstr += SCCtlOps.ConnectedSSID + ":" + SCCtlOps.ConnectedPasswd + "|";
|
||||
}
|
||||
|
||||
// Log.d(TAG, "setstr: " + setstr);
|
||||
try {
|
||||
rf.seek(0); //re-write all info
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Re-Seek Error");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
writeFile(rf, setstr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Write File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
closeFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Close File Error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public String ParseCfgPinFile()
|
||||
{
|
||||
RandomAccessFile rf = null;
|
||||
String getstr = null;
|
||||
|
||||
try {
|
||||
rf = openFile(FileOps.CfgPinFile);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Open File Error");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
getstr = readFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Read File Error");
|
||||
try {
|
||||
rf.setLength(0);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Set Length Error");
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Log.d(TAG, "Read: " + getstr);
|
||||
|
||||
try {
|
||||
closeFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Close File Error");
|
||||
}
|
||||
|
||||
return getstr;
|
||||
}
|
||||
|
||||
public void UpdateCfgPinFile(String pin)
|
||||
{
|
||||
RandomAccessFile rf;
|
||||
try {
|
||||
rf = openFile(FileOps.CfgPinFile);
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
Log.e(TAG, "Open File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
writeFile(rf, pin);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Write File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
closeFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Close File Error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public String ParseCtlPinFile(String mac)
|
||||
{
|
||||
RandomAccessFile rf = null;
|
||||
String getstr = null;
|
||||
String pin = null;
|
||||
|
||||
try {
|
||||
rf = openFile(FileOps.CtlPinFile);
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Open File Error");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
getstr = readFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Read File Error");
|
||||
try {
|
||||
rf.setLength(0);
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Set Length Error");
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// Log.d(TAG, "Read: " + getstr);
|
||||
|
||||
if(getstr==null) {
|
||||
//Log.e(TAG, "Null File");
|
||||
} else {
|
||||
String[] items = getstr.split("\\;");
|
||||
for(int i=0; i<items.length; i++) {
|
||||
// System.out.printf("items[%d]: %s\n", i, items[i]);
|
||||
String[] subitems = items[i].split("\\|");
|
||||
// for(int j=0; j<subitems.length; j++) {
|
||||
// Log.d(TAG, String.format("subitems[%d]: %s\n", j, subitems[j]));
|
||||
// }
|
||||
// Log.d(TAG, String.format("Selected MAC: %s\n", mac));
|
||||
if(mac.equals(subitems[0]) && !subitems[1].equals("null")) {
|
||||
pin = subitems[1];
|
||||
// Log.d(TAG, "Find PIN");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
closeFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Close File Error");
|
||||
}
|
||||
|
||||
return pin;
|
||||
}
|
||||
|
||||
public void UpdateCtlPinFile(String mac, String pin)
|
||||
{
|
||||
RandomAccessFile rf;
|
||||
try {
|
||||
rf = openFile(FileOps.CtlPinFile);
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
Log.e(TAG, "Open File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
long len=0;
|
||||
boolean isOld = false;
|
||||
String getstr = new String();
|
||||
String setstr = new String();
|
||||
try {
|
||||
len = rf.length();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
Log.e(TAG, "Get Length Error");
|
||||
return;
|
||||
}
|
||||
if(len>0) {
|
||||
try {
|
||||
getstr = readFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Read File Error");
|
||||
return;
|
||||
}
|
||||
// Log.d(TAG, "getstr: " + getstr);
|
||||
|
||||
String[] items = getstr.split("\\;");
|
||||
for(int i=0; i<items.length; i++) {
|
||||
// System.out.printf("items[%d]: %s\n", i, items[i]);
|
||||
String[] subitems = items[i].split("\\|");
|
||||
// for(int j=0; j<subitems.length; j++) {
|
||||
// System.out.printf("subitems[%d]: %s\n", j, subitems[j]);
|
||||
// }
|
||||
if(mac.equals(subitems[0])) {
|
||||
isOld = true;
|
||||
// Log.d(TAG, "Refresh old");
|
||||
setstr += subitems[0] + "|" + pin + ";";
|
||||
} else {
|
||||
// Log.d(TAG, "Re-Add existed");
|
||||
setstr += subitems[0] + "|" + subitems[1] + ";";
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!isOld) {
|
||||
// Log.d(TAG, "Add new");
|
||||
setstr += mac + "|" + pin + ";";
|
||||
}
|
||||
|
||||
// Log.d(TAG, "setstr: " + setstr);
|
||||
try {
|
||||
rf.seek(0); //re-write all info
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Re-Seek Error");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
writeFile(rf, setstr);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Write File Error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
closeFile(rf);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, "Close File Error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,494 @@
|
|||
package com.rtk.simpleconfig_wizard;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.util.Log;
|
||||
|
||||
public class SCCtlOps {
|
||||
private static final String TAG = "SCCtlOps";
|
||||
|
||||
public static boolean IsOpenNetwork = false; // Default has password, not open network
|
||||
public static String ConnectedSSID; // Connected WIFI's SSID
|
||||
public static String ConnectedPasswd; // Connected WIFI's Password
|
||||
public static String StoredPasswd;
|
||||
|
||||
public static boolean isHiddenSSID;
|
||||
public static boolean addNewNetwork;
|
||||
public static ScanResult reBuiltScanResult;
|
||||
|
||||
public static final int MAX_CLIENTS_NUM = 32;
|
||||
public static boolean DiscoveredNew;
|
||||
public static boolean SetAble = true;
|
||||
|
||||
/** For UDP Data Receive */
|
||||
// public static byte[] RecvBuf = new byte[512];
|
||||
|
||||
/** UDP Payload Format Flag */
|
||||
public static class Flag{
|
||||
|
||||
private Flag(){
|
||||
}
|
||||
|
||||
/** Flag */
|
||||
public static final int Version = (0x00<<6); // 2 bits
|
||||
public static final int RequestFlag = (0<<5); // 1 bit
|
||||
public static final int ResponseFlag = (1<<5);
|
||||
/** Request */
|
||||
public static final int Discover = 0x00; // 5 bits
|
||||
public static final int SaveProf = 0x01;
|
||||
public static final int DelProf = 0x02;
|
||||
public static final int RenameDev = 0x03;
|
||||
public static final int ReturnACK = 0x04;
|
||||
/** Response */
|
||||
public static final int CfgSuccessACK = 0x00; // 5 bits
|
||||
public static final int DiscoverACK = 0x01;
|
||||
public static final int SaveProfACK = 0x02;
|
||||
public static final int DelProfACK = 0x03;
|
||||
public static final int RenameDevACK = 0x04;
|
||||
public static final int CfgSuccessACKSendBack = 0x05;
|
||||
}
|
||||
|
||||
/** UDP Payload Format ACK to Scan */
|
||||
public static class ScanACK{
|
||||
|
||||
private ScanACK(){
|
||||
}
|
||||
|
||||
/** MAC */
|
||||
public static int MaxDevNum = 0;
|
||||
public static byte[][] Mac = new byte[MAX_CLIENTS_NUM][6]; // Record the connected STA
|
||||
/** Status */
|
||||
public static byte[] Status = new byte[MAX_CLIENTS_NUM];
|
||||
/** Device Type */
|
||||
public static byte[][] Type = new byte[MAX_CLIENTS_NUM][2];
|
||||
/** Device IP */
|
||||
public static byte[][] IPBuf = new byte[MAX_CLIENTS_NUM][4];
|
||||
public static String[] IP = new String[MAX_CLIENTS_NUM];
|
||||
/** Device Name */
|
||||
public static byte[][] NameBuf = new byte[MAX_CLIENTS_NUM][64];
|
||||
public static String[] Name = new String[MAX_CLIENTS_NUM];
|
||||
}
|
||||
|
||||
public static byte[] rtk_sc_gen_digest(byte[] inputData)
|
||||
{
|
||||
try {
|
||||
return AESCrypt.MD5(inputData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void rtk_sc_control_reset()
|
||||
{
|
||||
ScanACK.MaxDevNum = 0;
|
||||
Arrays.fill(ScanACK.Status, (byte)0);
|
||||
for(int i=0; i<MAX_CLIENTS_NUM; i++) {
|
||||
Arrays.fill(ScanACK.Mac[i], (byte)0);
|
||||
Arrays.fill(ScanACK.Type[i], (byte)0);
|
||||
Arrays.fill(ScanACK.IPBuf[i], (byte)0);
|
||||
Arrays.fill(ScanACK.NameBuf[i], (byte)0);
|
||||
}
|
||||
ScanACK.IP = new String[MAX_CLIENTS_NUM];
|
||||
ScanACK.Name = new String[MAX_CLIENTS_NUM];
|
||||
}
|
||||
|
||||
public static byte[] rtk_sc_gen_discover_packet(String defaultPIN)
|
||||
{
|
||||
byte[] CmdBuf = new byte[92];
|
||||
short PayloadLen = 0;
|
||||
|
||||
Arrays.fill(CmdBuf, (byte)0);
|
||||
/** Flag */
|
||||
CmdBuf[0] += Flag.Version;
|
||||
CmdBuf[0] += Flag.RequestFlag;
|
||||
CmdBuf[0] += Flag.Discover;
|
||||
|
||||
/** Encrypt Flag */
|
||||
CmdBuf[3] = 0x01;
|
||||
PayloadLen += 1;
|
||||
|
||||
/** Nonce */
|
||||
if(CmdBuf[3] == 0x01) {
|
||||
for(int i=0; i<64; i++) {
|
||||
Random r = new Random();
|
||||
CmdBuf[4+i] = (byte) (r.nextInt(256) + 1);
|
||||
}
|
||||
}
|
||||
PayloadLen += 64;
|
||||
|
||||
/** Default PIN Digest */
|
||||
byte[] inputData = new byte[64 + defaultPIN.length()];
|
||||
System.arraycopy(CmdBuf, 4, inputData, 0, 64);
|
||||
System.arraycopy(defaultPIN.getBytes(), 0, inputData, 64, defaultPIN.length());
|
||||
byte[] digest = rtk_sc_gen_digest(inputData);
|
||||
System.arraycopy(digest, 0, CmdBuf, PayloadLen+3, 16);
|
||||
PayloadLen += 16;
|
||||
|
||||
/** MAC Address */
|
||||
PayloadLen += 6;
|
||||
|
||||
/** Device Type */
|
||||
PayloadLen += 2;
|
||||
|
||||
/** Length */
|
||||
byte[] buf = new byte[2];
|
||||
buf[0] = (byte)((PayloadLen >> 8) & 0xff);
|
||||
buf[1] = (byte)(PayloadLen & 0xff);
|
||||
System.arraycopy(buf, 0, CmdBuf, 1, 2);
|
||||
|
||||
/*String dbgStr = new String();
|
||||
for(int i=0; i<92; i++)
|
||||
dbgStr += String.format("%02x ", CmdBuf[i]);
|
||||
Log.d(TAG, "Client Discover Packet: " + dbgStr);*/
|
||||
|
||||
return CmdBuf;
|
||||
}
|
||||
|
||||
public static byte[] rtk_sc_gen_control_packet(int flag, String defaultPIN, String inputPIN, String nameStr)
|
||||
{
|
||||
byte[] CmdBuf;
|
||||
short PayloadLen = 0;
|
||||
byte[] digest;
|
||||
byte[] inputData;
|
||||
byte[] nameBuf = null;
|
||||
|
||||
if(flag == Flag.RenameDev) {
|
||||
// Log.d(TAG, "nameStr: " + nameStr);
|
||||
try {
|
||||
nameBuf = nameStr.getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(TAG, "Get name bytes error");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
CmdBuf = new byte[100+nameBuf.length];
|
||||
} else {
|
||||
CmdBuf = new byte[100];
|
||||
}
|
||||
|
||||
Arrays.fill(CmdBuf, (byte)0);
|
||||
/** Flag */
|
||||
CmdBuf[0] += Flag.Version;
|
||||
CmdBuf[0] += Flag.RequestFlag;
|
||||
CmdBuf[0] += flag;
|
||||
|
||||
/** Encrypt Flag */
|
||||
CmdBuf[3] = 0x01;
|
||||
PayloadLen += 1;
|
||||
|
||||
/** Nonce */
|
||||
if(CmdBuf[3] == 0x01) {
|
||||
for(int i=0; i<64; i++) {
|
||||
Random r = new Random();
|
||||
CmdBuf[4+i] = (byte) (r.nextInt(256) + 1);
|
||||
}
|
||||
}
|
||||
PayloadLen += 64;
|
||||
|
||||
/** Default PIN Digest */
|
||||
// Log.d(TAG, "defaultPIN: " + defaultPIN);
|
||||
inputData = new byte[64 + defaultPIN.length()];
|
||||
System.arraycopy(CmdBuf, 4, inputData, 0, 64);
|
||||
System.arraycopy(defaultPIN.getBytes(), 0, inputData, 64, defaultPIN.length());
|
||||
digest = rtk_sc_gen_digest(inputData);
|
||||
System.arraycopy(digest, 0, CmdBuf, PayloadLen+3, 16);
|
||||
PayloadLen += 16;
|
||||
|
||||
/** User Input PIN Digest */
|
||||
// Log.d(TAG, "inputPIN: " + inputPIN);
|
||||
inputData = new byte[64 + inputPIN.length()];
|
||||
System.arraycopy(CmdBuf, 4, inputData, 0, 64);
|
||||
System.arraycopy(inputPIN.getBytes(), 0, inputData, 64, inputPIN.length());
|
||||
digest = rtk_sc_gen_digest(inputData);
|
||||
System.arraycopy(digest, 0, CmdBuf, PayloadLen+3, 16);
|
||||
PayloadLen += 16;
|
||||
|
||||
/** Device Name */
|
||||
if(flag == Flag.RenameDev) {
|
||||
// String tmp = new String();
|
||||
// for(int i=0; i<nameBuf.length; i++) {
|
||||
// tmp += String.format("%02x ", nameBuf[i]);
|
||||
// }
|
||||
// Log.d(TAG, "nameBuf: " + tmp);
|
||||
|
||||
System.arraycopy(nameBuf, 0, CmdBuf, PayloadLen+3, nameBuf.length);
|
||||
PayloadLen += nameBuf.length;
|
||||
}
|
||||
|
||||
/** Length */
|
||||
byte[] buf = new byte[2];
|
||||
buf[0] = (byte)((PayloadLen >> 8) & 0xff);
|
||||
buf[1] = (byte)(PayloadLen & 0xff);
|
||||
System.arraycopy(buf, 0, CmdBuf, 1, 2);
|
||||
|
||||
return CmdBuf;
|
||||
}
|
||||
|
||||
public static byte[] rtk_sc_gen_control_confirm_packet(int flag, String defaultPIN, String inputPIN)
|
||||
{
|
||||
byte[] CmdBuf;
|
||||
short PayloadLen = 0;
|
||||
byte[] digest;
|
||||
byte[] inputData;
|
||||
|
||||
CmdBuf = new byte[101];
|
||||
Arrays.fill(CmdBuf, (byte)0);
|
||||
/** Flag */
|
||||
CmdBuf[0] += Flag.Version;
|
||||
CmdBuf[0] += Flag.RequestFlag;
|
||||
CmdBuf[0] += Flag.ReturnACK;
|
||||
|
||||
/** Encrypt Flag */
|
||||
CmdBuf[3] = 0x01;
|
||||
PayloadLen += 1;
|
||||
|
||||
/** Nonce */
|
||||
if(CmdBuf[3] == 0x01) {
|
||||
for(int i=0; i<64; i++) {
|
||||
Random r = new Random();
|
||||
CmdBuf[4+i] = (byte) (r.nextInt(256) + 1);
|
||||
}
|
||||
}
|
||||
PayloadLen += 64;
|
||||
|
||||
/** Default PIN Digest */
|
||||
// Log.d(TAG, "defaultPIN: " + defaultPIN);
|
||||
inputData = new byte[64 + defaultPIN.length()];
|
||||
System.arraycopy(CmdBuf, 4, inputData, 0, 64);
|
||||
System.arraycopy(defaultPIN.getBytes(), 0, inputData, 64, defaultPIN.length());
|
||||
digest = rtk_sc_gen_digest(inputData);
|
||||
System.arraycopy(digest, 0, CmdBuf, PayloadLen+3, 16);
|
||||
PayloadLen += 16;
|
||||
|
||||
/** User Input PIN Digest */
|
||||
// Log.d(TAG, "inputPIN: " + inputPIN);
|
||||
inputData = new byte[64 + inputPIN.length()];
|
||||
System.arraycopy(CmdBuf, 4, inputData, 0, 64);
|
||||
System.arraycopy(inputPIN.getBytes(), 0, inputData, 64, inputPIN.length());
|
||||
digest = rtk_sc_gen_digest(inputData);
|
||||
System.arraycopy(digest, 0, CmdBuf, PayloadLen+3, 16);
|
||||
PayloadLen += 16;
|
||||
|
||||
/** Encrypt Flag */
|
||||
CmdBuf[PayloadLen+3] += flag;
|
||||
PayloadLen += 1;
|
||||
|
||||
/** Length */
|
||||
byte[] buf = new byte[2];
|
||||
buf[0] = (byte)((PayloadLen >> 8) & 0xff);
|
||||
buf[1] = (byte)(PayloadLen & 0xff);
|
||||
System.arraycopy(buf, 0, CmdBuf, 1, 2);
|
||||
|
||||
return CmdBuf;
|
||||
}
|
||||
|
||||
|
||||
public static int handle_discover_ack(byte[] recv_buf)
|
||||
{
|
||||
int length, equalCnt=0;
|
||||
String dbgStr;
|
||||
|
||||
if(SetAble==false)
|
||||
return -1;
|
||||
|
||||
DiscoveredNew = false;
|
||||
// System.arraycopy(recv_buf, 0, RecvBuf, 0, recv_buf.length);
|
||||
|
||||
length = (recv_buf[1]<<8)&0xFF00 | (recv_buf[2])&0xFF;
|
||||
// Log.d(TAG, String.format("length: 0x%02x", length));
|
||||
if(length < 6) {
|
||||
Log.e(TAG, "At least a mac\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ScanACK.MaxDevNum > MAX_CLIENTS_NUM) {
|
||||
Log.e(TAG, "The receive buf is full\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Judge if it is the same MAC */
|
||||
// Log.d(TAG, "Max Device Number: " + ScanACK.MaxDevNum);
|
||||
if(ScanACK.MaxDevNum > 0) {/* Not the first time */
|
||||
for(int j=0; j<ScanACK.MaxDevNum; j++) {
|
||||
for(int i=0; i<6; i++) {
|
||||
if(recv_buf[3+i] == ScanACK.Mac[j][i])
|
||||
equalCnt++;
|
||||
}
|
||||
if(equalCnt == 6)
|
||||
return -1; //find the same MAC
|
||||
equalCnt = 0; //for the second judge(if has)
|
||||
}
|
||||
}
|
||||
|
||||
/** Not the same MAC */
|
||||
System.arraycopy(recv_buf, 3, ScanACK.Mac[ScanACK.MaxDevNum], 0, 6);
|
||||
dbgStr = new String();
|
||||
for(int i=0; i<6; i++) {
|
||||
dbgStr += String.format("%02x", ScanACK.Mac[ScanACK.MaxDevNum][i]);
|
||||
if(i<5)
|
||||
dbgStr += ":";
|
||||
}
|
||||
Log.i(TAG, "Discovered MAC: " + dbgStr);
|
||||
|
||||
/** Status */
|
||||
if(length > 7) {
|
||||
ScanACK.Status[ScanACK.MaxDevNum] = recv_buf[9];
|
||||
// Log.d(TAG, String.format("Status: %02x", ScanACK.Status[ScanACK.MaxDevNum]));
|
||||
}
|
||||
|
||||
/** Device Type */
|
||||
if(length > 9) {
|
||||
System.arraycopy(recv_buf, 10, ScanACK.Type[ScanACK.MaxDevNum], 0, 2);
|
||||
// Log.d(TAG, String.format("Device Type: %02x %02x", ScanACK.DevType[ScanACK.MaxDevNum][0],
|
||||
// ScanACK.DevType[ScanACK.MaxDevNum][1]));
|
||||
}
|
||||
|
||||
/** Device IP */
|
||||
if(length > 13) {
|
||||
System.arraycopy(recv_buf, 12, ScanACK.IPBuf[ScanACK.MaxDevNum], 0, 4);
|
||||
ScanACK.IP[ScanACK.MaxDevNum] = String.format("%d.%d.%d.%d",
|
||||
ScanACK.IPBuf[ScanACK.MaxDevNum][0]&0xff,
|
||||
ScanACK.IPBuf[ScanACK.MaxDevNum][1]&0xff,
|
||||
ScanACK.IPBuf[ScanACK.MaxDevNum][2]&0xff,
|
||||
ScanACK.IPBuf[ScanACK.MaxDevNum][3]&0xff);
|
||||
Log.i(TAG, "Device IP: " + ScanACK.IP[ScanACK.MaxDevNum]);
|
||||
}
|
||||
|
||||
/** Device Name */
|
||||
if(length > 14) {
|
||||
System.arraycopy(recv_buf, 16, ScanACK.NameBuf[ScanACK.MaxDevNum], 0, 64);
|
||||
String name = null;
|
||||
try {
|
||||
name = new String(ScanACK.NameBuf[ScanACK.MaxDevNum], "UTF-8").trim();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(TAG, "Get device name error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(name.length()>0)
|
||||
ScanACK.Name[ScanACK.MaxDevNum] = name;
|
||||
else
|
||||
ScanACK.Name[ScanACK.MaxDevNum] = null;
|
||||
Log.i(TAG, "Device Name: " + ScanACK.Name[ScanACK.MaxDevNum]);
|
||||
}
|
||||
|
||||
ScanACK.MaxDevNum++;
|
||||
DiscoveredNew = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int rtk_sc_get_discovered_dev_num()
|
||||
{
|
||||
return ScanACK.MaxDevNum;
|
||||
}
|
||||
|
||||
// public static void rtk_get_connected_dev_test1()
|
||||
// {
|
||||
// /** For test */
|
||||
// byte[] tmp = {0x21,
|
||||
// 00,0x2c,
|
||||
// 00,0x18,(byte)0x95,0x61,(byte)0x89,0x75,
|
||||
// 0x01,
|
||||
// 00,0x01,
|
||||
// (byte)0xc0,(byte)0xa8,0x01,(byte)0xdd,00,
|
||||
// (byte)0xe7,(byte)0xa9,(byte)0xba,(byte)0xe8,(byte)0xb0,
|
||||
// (byte)0x83,00,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00};
|
||||
// System.arraycopy(tmp, 0, RecvBuf, 0, tmp.length);
|
||||
// handle_discover_ack();
|
||||
// }
|
||||
//
|
||||
// public static void rtk_get_connected_dev_test2()
|
||||
// {
|
||||
// byte[] tmp = {0x21,
|
||||
// 00,0x2c,
|
||||
// 00,0x44,0x46,0x66,0x66,0x76,
|
||||
// 0x02,
|
||||
// 00,0x02,
|
||||
// (byte)0xc0,(byte)0xa8,0x01,(byte)0xde,00,
|
||||
// 0x54,0x56,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00,00,00,00,
|
||||
// 00,00};
|
||||
// System.arraycopy(tmp, 0, RecvBuf, 0, tmp.length);
|
||||
// handle_discover_ack();
|
||||
// }
|
||||
|
||||
public static int rtk_sc_get_discovered_dev_info(List<HashMap<String, Object>> DevInfo)
|
||||
{
|
||||
int i;
|
||||
String buf;
|
||||
HashMap<String, Object> hmap;
|
||||
|
||||
SetAble = false;
|
||||
// Log.d(TAG, "ScanACK.MaxDevNum: " + ScanACK.MaxDevNum);
|
||||
for(int index=0; index<ScanACK.MaxDevNum; index++) {
|
||||
buf = new String();
|
||||
hmap = new HashMap<String, Object>();
|
||||
for(i=0; i<6; i++) {
|
||||
buf += String.format("%02x", ScanACK.Mac[index][i]);
|
||||
if(i<5)
|
||||
buf += ":";
|
||||
}
|
||||
// Log.d(TAG, "Mac: " + buf);
|
||||
hmap.put("MAC", buf);
|
||||
|
||||
buf = new String();
|
||||
switch(ScanACK.Status[index]) {
|
||||
case 0x01:
|
||||
buf = "Connected";
|
||||
break;
|
||||
case 0x02:
|
||||
buf = "Profile saved";
|
||||
break;
|
||||
default:
|
||||
buf = "Unkown status";
|
||||
break;
|
||||
}
|
||||
// Log.d(TAG, "Status: " + buf);
|
||||
hmap.put("Status", buf);
|
||||
|
||||
buf = new String();
|
||||
short type = (short)((ScanACK.Type[index][0]&0xff<<8) + (ScanACK.Type[index][1]&0xff) );
|
||||
switch(type) {
|
||||
case 0x0000:
|
||||
buf = "Any type";
|
||||
break;
|
||||
case 0x0001:
|
||||
buf = "TV";
|
||||
break;
|
||||
case 0x0002:
|
||||
buf = "Air conditioner";
|
||||
break;
|
||||
default:
|
||||
buf = "Unkown type";
|
||||
break;
|
||||
}
|
||||
// Log.d(TAG, "DevType: " + buf);
|
||||
hmap.put("Type", buf);
|
||||
|
||||
// Log.d(TAG, "IP: " + ScanACK.DevIP[index]);
|
||||
hmap.put("IP", ScanACK.IP[index]);
|
||||
|
||||
// Log.d(TAG, "Name: " + ScanACK.DevName[index]);
|
||||
hmap.put("Name", ScanACK.Name[index]);
|
||||
|
||||
DevInfo.add(hmap);
|
||||
}
|
||||
|
||||
SetAble = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
|
||||
public abstract class BaseContent implements Floating.Content, OnCheckedChangeListener {
|
||||
|
||||
protected final WifiManager mWifiManager;
|
||||
protected final Floating mFloating;
|
||||
protected final ScanResult mScanResult;
|
||||
protected final String mScanResultSecurity;
|
||||
protected final boolean mIsOpenNetwork ;
|
||||
|
||||
protected int mNumOpenNetworksKept;
|
||||
|
||||
protected View mView;
|
||||
|
||||
protected OnClickListener mCancelOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mFloating.finish();
|
||||
}
|
||||
};
|
||||
|
||||
protected String getCancelString() {
|
||||
return mFloating.getString(android.R.string.cancel);
|
||||
}
|
||||
|
||||
private static final int[] SIGNAL_LEVEL = {R.string.wifi_signal_0, R.string.wifi_signal_1,
|
||||
R.string.wifi_signal_2, R.string.wifi_signal_3};
|
||||
|
||||
public BaseContent(final Floating floating, final WifiManager wifiManager, final ScanResult scanResult) {
|
||||
super();
|
||||
mWifiManager = wifiManager;
|
||||
mFloating = floating;
|
||||
mScanResult = scanResult;
|
||||
mScanResultSecurity = Wifi.ConfigSec.getScanResultSecurity(mScanResult);
|
||||
mIsOpenNetwork = Wifi.ConfigSec.isOpenNetwork(mScanResultSecurity);
|
||||
|
||||
mView = View.inflate(mFloating, R.layout.base_content, null);
|
||||
((TextView)mView.findViewById(R.id.SignalStrength_TextView)).setText(SIGNAL_LEVEL[WifiManager.calculateSignalLevel(mScanResult.level, SIGNAL_LEVEL.length)]);
|
||||
final String rawSecurity = Wifi.ConfigSec.getDisplaySecirityString(mScanResult);
|
||||
final String readableSecurity = Wifi.ConfigSec.isOpenNetwork(rawSecurity) ? mFloating.getString(R.string.wifi_security_open) : rawSecurity;
|
||||
((TextView)mView.findViewById(R.id.Security_TextView)).setText(readableSecurity);
|
||||
((CheckBox)mView.findViewById(R.id.ShowPassword_CheckBox)).setOnCheckedChangeListener(this);
|
||||
|
||||
mNumOpenNetworksKept = Settings.Secure.getInt(floating.getContentResolver(),
|
||||
Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, 10);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View getView() {
|
||||
return mView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
((EditText)mView.findViewById(R.id.Password_EditText)).setInputType(
|
||||
InputType.TYPE_CLASS_TEXT |
|
||||
(isChecked ? InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
|
||||
:InputType.TYPE_TEXT_VARIATION_PASSWORD));
|
||||
}
|
||||
|
||||
|
||||
public OnClickListener mChangePasswordOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
changePassword();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public void changePassword() {
|
||||
mFloating.setContent(new ChangePasswordContent(mFloating, mWifiManager, mScanResult));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ChangePasswordContent extends BaseContent {
|
||||
|
||||
private ChangingAwareEditText mPasswordEditText;
|
||||
|
||||
public ChangePasswordContent(Floating floating, WifiManager wifiManager,
|
||||
ScanResult scanResult) {
|
||||
super(floating, wifiManager, scanResult);
|
||||
|
||||
mView.findViewById(R.id.Status).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.Speed).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.IPAddress).setVisibility(View.GONE);
|
||||
|
||||
mPasswordEditText = ((ChangingAwareEditText)mView.findViewById(R.id.Password_EditText));
|
||||
|
||||
((TextView)mView.findViewById(R.id.Password_TextView)).setText(R.string.please_type_passphrase);
|
||||
|
||||
((EditText)mView.findViewById(R.id.Password_EditText)).setHint(R.string.wifi_password_unchanged);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnClickListener getButtonOnClickListener(int index) {
|
||||
return mOnClickListeners[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getButtonText(int index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
return mFloating.getString(R.string.wifi_save_config);
|
||||
case 1:
|
||||
return getCancelString();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mScanResult.SSID;
|
||||
}
|
||||
|
||||
private OnClickListener mSaveOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(mPasswordEditText.getChanged()) {
|
||||
final WifiConfiguration config = Wifi.getWifiConfiguration(mWifiManager, mScanResult, mScanResultSecurity);
|
||||
boolean saveResult = false;
|
||||
if(config != null) {
|
||||
saveResult = Wifi.changePasswordAndConnect(mFloating, mWifiManager, config
|
||||
, mPasswordEditText.getText().toString()
|
||||
, mNumOpenNetworksKept);
|
||||
}
|
||||
|
||||
if(!saveResult) {
|
||||
Toast.makeText(mFloating, R.string.toastFailed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
mFloating.finish();
|
||||
}
|
||||
};
|
||||
|
||||
OnClickListener mOnClickListeners[] = {mSaveOnClick, mCancelOnClick};
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.EditText;
|
||||
|
||||
public class ChangingAwareEditText extends EditText {
|
||||
|
||||
public ChangingAwareEditText(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
private boolean mChanged = false;
|
||||
|
||||
public boolean getChanged() {
|
||||
return mChanged;
|
||||
}
|
||||
|
||||
protected void onTextChanged (CharSequence text, int start, int before, int after) {
|
||||
mChanged = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.wifi.connection;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
|
||||
public abstract class ConfigurationSecurities {
|
||||
/**
|
||||
* @return The security of a given {@link WifiConfiguration}.
|
||||
*/
|
||||
public abstract String getWifiConfigurationSecurity(WifiConfiguration wifiConfig);
|
||||
/**
|
||||
* @return The security of a given {@link ScanResult}.
|
||||
*/
|
||||
public abstract String getScanResultSecurity(ScanResult scanResult);
|
||||
/**
|
||||
* Fill in the security fields of WifiConfiguration config.
|
||||
* @param config The object to fill.
|
||||
* @param security If is OPEN, password is ignored.
|
||||
* @param password Password of the network if security is not OPEN.
|
||||
*/
|
||||
public abstract void setupSecurity(WifiConfiguration config, String security, final String password);
|
||||
public abstract String getDisplaySecirityString(final ScanResult scanResult);
|
||||
public abstract boolean isOpenNetwork(final String security);
|
||||
|
||||
public static ConfigurationSecurities newInstance() {
|
||||
// System.out.printf("Version.SDK: %d\n", Version.SDK);
|
||||
if(Version.SDK < 8) {
|
||||
return new ConfigurationSecuritiesOld();
|
||||
} else {
|
||||
return new ConfigurationSecuritiesV8();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,185 @@
|
|||
package com.wifi.connection;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
|
||||
import android.net.wifi.WifiConfiguration.GroupCipher;
|
||||
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||
import android.net.wifi.WifiConfiguration.PairwiseCipher;
|
||||
import android.net.wifi.WifiConfiguration.Protocol;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
public class ConfigurationSecuritiesOld extends ConfigurationSecurities {
|
||||
|
||||
// Constants used for different security types
|
||||
public static final String WPA2 = "WPA2";
|
||||
public static final String WPA = "WPA";
|
||||
public static final String WEP = "WEP";
|
||||
public static final String OPEN = "Open";
|
||||
// For EAP Enterprise fields
|
||||
public static final String WPA_EAP = "WPA-EAP";
|
||||
public static final String IEEE8021X = "IEEE8021X";
|
||||
|
||||
public static final String[] EAP_METHOD = { "PEAP", "TLS", "TTLS" };
|
||||
|
||||
public static final int WEP_PASSWORD_AUTO = 0;
|
||||
public static final int WEP_PASSWORD_ASCII = 1;
|
||||
public static final int WEP_PASSWORD_HEX = 2;
|
||||
|
||||
static final String[] SECURITY_MODES = { WEP, WPA, WPA2, WPA_EAP, IEEE8021X };
|
||||
|
||||
private static final String TAG = "ConfigurationSecuritiesOld";
|
||||
|
||||
@Override
|
||||
public String getWifiConfigurationSecurity(WifiConfiguration wifiConfig) {
|
||||
|
||||
if (wifiConfig.allowedKeyManagement.get(KeyMgmt.NONE)) {
|
||||
// If we never set group ciphers, wpa_supplicant puts all of them.
|
||||
// For open, we don't set group ciphers.
|
||||
// For WEP, we specifically only set WEP40 and WEP104, so CCMP
|
||||
// and TKIP should not be there.
|
||||
if (!wifiConfig.allowedGroupCiphers.get(GroupCipher.CCMP)
|
||||
&&
|
||||
(wifiConfig.allowedGroupCiphers.get(GroupCipher.WEP40)
|
||||
|| wifiConfig.allowedGroupCiphers.get(GroupCipher.WEP104))) {
|
||||
return WEP;
|
||||
} else {
|
||||
return OPEN;
|
||||
}
|
||||
} else if (wifiConfig.allowedProtocols.get(Protocol.RSN)) {
|
||||
return WPA2;
|
||||
} else if (wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_EAP)) {
|
||||
return WPA_EAP;
|
||||
} else if (wifiConfig.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) {
|
||||
return IEEE8021X;
|
||||
} else if (wifiConfig.allowedProtocols.get(Protocol.WPA)) {
|
||||
return WPA;
|
||||
} else {
|
||||
Log.w(TAG, "Unknown security type from WifiConfiguration, falling back on open.");
|
||||
return OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScanResultSecurity(ScanResult scanResult) {
|
||||
final String cap = scanResult.capabilities;
|
||||
for (int i = SECURITY_MODES.length - 1; i >= 0; i--) {
|
||||
if (cap.contains(SECURITY_MODES[i])) {
|
||||
return SECURITY_MODES[i];
|
||||
}
|
||||
}
|
||||
|
||||
return OPEN;
|
||||
}
|
||||
@Override
|
||||
public String getDisplaySecirityString(final ScanResult scanResult) {
|
||||
return getScanResultSecurity(scanResult);
|
||||
}
|
||||
|
||||
private static boolean isHexWepKey(String wepKey) {
|
||||
final int len = wepKey.length();
|
||||
|
||||
// WEP-40, WEP-104, and some vendors using 256-bit WEP (WEP-232?)
|
||||
if (len != 10 && len != 26 && len != 58) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isHex(wepKey);
|
||||
}
|
||||
|
||||
private static boolean isHex(String key) {
|
||||
for (int i = key.length() - 1; i >= 0; i--) {
|
||||
final char c = key.charAt(i);
|
||||
if (!(c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupSecurity(WifiConfiguration config, String security, final String password) {
|
||||
config.allowedAuthAlgorithms.clear();
|
||||
config.allowedGroupCiphers.clear();
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedPairwiseCiphers.clear();
|
||||
config.allowedProtocols.clear();
|
||||
|
||||
if (TextUtils.isEmpty(security)) {
|
||||
security = OPEN;
|
||||
Log.w(TAG, "Empty security, assuming open");
|
||||
}
|
||||
|
||||
if (security.equals(WEP)) {
|
||||
int wepPasswordType = WEP_PASSWORD_AUTO;
|
||||
// If password is empty, it should be left untouched
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
if (wepPasswordType == WEP_PASSWORD_AUTO) {
|
||||
if (isHexWepKey(password)) {
|
||||
config.wepKeys[0] = password;
|
||||
} else {
|
||||
config.wepKeys[0] = Wifi.convertToQuotedString(password);
|
||||
}
|
||||
} else {
|
||||
config.wepKeys[0] = wepPasswordType == WEP_PASSWORD_ASCII
|
||||
? Wifi.convertToQuotedString(password)
|
||||
: password;
|
||||
}
|
||||
}
|
||||
|
||||
config.wepTxKeyIndex = 0;
|
||||
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
|
||||
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
|
||||
config.allowedGroupCiphers.set(GroupCipher.WEP40);
|
||||
config.allowedGroupCiphers.set(GroupCipher.WEP104);
|
||||
|
||||
} else if (security.equals(WPA) || security.equals(WPA2)){
|
||||
config.allowedGroupCiphers.set(GroupCipher.TKIP);
|
||||
config.allowedGroupCiphers.set(GroupCipher.CCMP);
|
||||
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
|
||||
|
||||
config.allowedPairwiseCiphers.set(PairwiseCipher.CCMP);
|
||||
config.allowedPairwiseCiphers.set(PairwiseCipher.TKIP);
|
||||
|
||||
config.allowedProtocols.set(security.equals(WPA2) ? Protocol.RSN : Protocol.WPA);
|
||||
|
||||
// If password is empty, it should be left untouched
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
if (password.length() == 64 && isHex(password)) {
|
||||
// Goes unquoted as hex
|
||||
config.preSharedKey = password;
|
||||
} else {
|
||||
// Goes quoted as ASCII
|
||||
config.preSharedKey = Wifi.convertToQuotedString(password);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (security.equals(OPEN)) {
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
} else if (security.equals(WPA_EAP) || security.equals(IEEE8021X)) {
|
||||
config.allowedGroupCiphers.set(GroupCipher.TKIP);
|
||||
config.allowedGroupCiphers.set(GroupCipher.CCMP);
|
||||
if (security.equals(WPA_EAP)) {
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
|
||||
} else {
|
||||
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
|
||||
}
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
config.preSharedKey = Wifi.convertToQuotedString(password);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenNetwork(String security) {
|
||||
return OPEN.equals(security);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
package com.wifi.connection;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
|
||||
import android.net.wifi.WifiConfiguration.KeyMgmt;
|
||||
import android.util.Log;
|
||||
|
||||
public class ConfigurationSecuritiesV8 extends ConfigurationSecurities {
|
||||
|
||||
static final int SECURITY_NONE = 0;
|
||||
static final int SECURITY_WEP = 1;
|
||||
static final int SECURITY_PSK = 2;
|
||||
static final int SECURITY_EAP = 3;
|
||||
|
||||
enum PskType {
|
||||
UNKNOWN,
|
||||
WPA,
|
||||
WPA2,
|
||||
WPA_WPA2
|
||||
}
|
||||
|
||||
private static final String TAG = "ConfigurationSecuritiesV14";
|
||||
|
||||
private static int getSecurity(WifiConfiguration config) {
|
||||
if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) {
|
||||
return SECURITY_PSK;
|
||||
}
|
||||
if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) ||
|
||||
config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) {
|
||||
return SECURITY_EAP;
|
||||
}
|
||||
return (config.wepKeys[0] != null) ? SECURITY_WEP : SECURITY_NONE;
|
||||
}
|
||||
|
||||
private static int getSecurity(ScanResult result) {
|
||||
if (result.capabilities.contains("WEP")) {
|
||||
return SECURITY_WEP;
|
||||
} else if (result.capabilities.contains("PSK")) {
|
||||
return SECURITY_PSK;
|
||||
} else if (result.capabilities.contains("EAP")) {
|
||||
return SECURITY_EAP;
|
||||
}
|
||||
return SECURITY_NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWifiConfigurationSecurity(WifiConfiguration wifiConfig) {
|
||||
return String.valueOf(getSecurity(wifiConfig));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScanResultSecurity(ScanResult scanResult) {
|
||||
return String.valueOf(getSecurity(scanResult));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupSecurity(WifiConfiguration config, String security, String password) {
|
||||
config.allowedAuthAlgorithms.clear();
|
||||
config.allowedGroupCiphers.clear();
|
||||
config.allowedKeyManagement.clear();
|
||||
config.allowedPairwiseCiphers.clear();
|
||||
config.allowedProtocols.clear();
|
||||
|
||||
final int sec = security == null ? SECURITY_NONE : Integer.valueOf(security);
|
||||
final int passwordLen = password == null ? 0 : password.length();
|
||||
switch (sec) {
|
||||
case SECURITY_NONE:
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
break;
|
||||
|
||||
case SECURITY_WEP:
|
||||
config.allowedKeyManagement.set(KeyMgmt.NONE);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
|
||||
config.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
|
||||
if (passwordLen != 0) {
|
||||
// WEP-40, WEP-104, and 256-bit WEP (WEP-232?)
|
||||
if ((passwordLen == 10 || passwordLen == 26 || passwordLen == 58) &&
|
||||
password.matches("[0-9A-Fa-f]*")) {
|
||||
config.wepKeys[0] = password;
|
||||
} else {
|
||||
config.wepKeys[0] = '"' + password + '"';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SECURITY_PSK:
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
|
||||
if (passwordLen != 0) {
|
||||
if (password.matches("[0-9A-Fa-f]{64}")) {
|
||||
config.preSharedKey = password;
|
||||
} else {
|
||||
config.preSharedKey = '"' + password + '"';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SECURITY_EAP:
|
||||
config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
|
||||
config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
|
||||
// config.eap.setValue((String) mEapMethodSpinner.getSelectedItem());
|
||||
//
|
||||
// config.phase2.setValue((mPhase2Spinner.getSelectedItemPosition() == 0) ? "" :
|
||||
// "auth=" + mPhase2Spinner.getSelectedItem());
|
||||
// config.ca_cert.setValue((mEapCaCertSpinner.getSelectedItemPosition() == 0) ? "" :
|
||||
// KEYSTORE_SPACE + Credentials.CA_CERTIFICATE +
|
||||
// (String) mEapCaCertSpinner.getSelectedItem());
|
||||
// config.client_cert.setValue((mEapUserCertSpinner.getSelectedItemPosition() == 0) ?
|
||||
// "" : KEYSTORE_SPACE + Credentials.USER_CERTIFICATE +
|
||||
// (String) mEapUserCertSpinner.getSelectedItem());
|
||||
// config.private_key.setValue((mEapUserCertSpinner.getSelectedItemPosition() == 0) ?
|
||||
// "" : KEYSTORE_SPACE + Credentials.USER_PRIVATE_KEY +
|
||||
// (String) mEapUserCertSpinner.getSelectedItem());
|
||||
// config.identity.setValue((mEapIdentityView.length() == 0) ? "" :
|
||||
// mEapIdentityView.getText().toString());
|
||||
// config.anonymous_identity.setValue((mEapAnonymousView.length() == 0) ? "" :
|
||||
// mEapAnonymousView.getText().toString());
|
||||
// if (mPasswordView.length() != 0) {
|
||||
// config.password.setValue(mPasswordView.getText().toString());
|
||||
// }
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.e(TAG, "Invalid security type: " + sec);
|
||||
}
|
||||
|
||||
// config.proxySettings = mProxySettings;
|
||||
// config.ipAssignment = mIpAssignment;
|
||||
// config.linkProperties = new LinkProperties(mLinkProperties);
|
||||
|
||||
}
|
||||
|
||||
private static PskType getPskType(ScanResult result) {
|
||||
boolean wpa = result.capabilities.contains("WPA-PSK");
|
||||
boolean wpa2 = result.capabilities.contains("WPA2-PSK");
|
||||
if (wpa2 && wpa) {
|
||||
return PskType.WPA_WPA2;
|
||||
} else if (wpa2) {
|
||||
return PskType.WPA2;
|
||||
} else if (wpa) {
|
||||
return PskType.WPA;
|
||||
} else {
|
||||
Log.w(TAG, "Received abnormal flag string: " + result.capabilities);
|
||||
return PskType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplaySecirityString(final ScanResult scanResult) {
|
||||
final int security = getSecurity(scanResult);
|
||||
if(security == SECURITY_PSK) {
|
||||
switch(getPskType(scanResult)) {
|
||||
case WPA:
|
||||
return "WPA";
|
||||
case WPA_WPA2:
|
||||
case WPA2:
|
||||
return "WPA2";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
} else {
|
||||
switch(security) {
|
||||
case SECURITY_NONE:
|
||||
return "OPEN";
|
||||
case SECURITY_WEP:
|
||||
return "WEP";
|
||||
case SECURITY_EAP:
|
||||
return "EAP";
|
||||
}
|
||||
}
|
||||
|
||||
return "?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpenNetwork(String security) {
|
||||
return String.valueOf(SECURITY_NONE).equals(security);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ConfiguredNetworkContent extends BaseContent {
|
||||
|
||||
public ConfiguredNetworkContent(Floating floating, WifiManager wifiManager,
|
||||
ScanResult scanResult) {
|
||||
super(floating, wifiManager, scanResult);
|
||||
|
||||
mView.findViewById(R.id.Status).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.Speed).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.IPAddress).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.Password).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnClickListener getButtonOnClickListener(int index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
return mConnectOnClick;
|
||||
case 1:
|
||||
if(mIsOpenNetwork) {
|
||||
return mForgetOnClick;
|
||||
} else {
|
||||
return mOpOnClick;
|
||||
}
|
||||
case 2:
|
||||
return mCancelOnClick;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getButtonText(int index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
return mFloating.getString(R.string.connect);
|
||||
case 1:
|
||||
if(mIsOpenNetwork) {
|
||||
return mFloating.getString(R.string.forget_network);
|
||||
} else {
|
||||
return mFloating.getString(R.string.buttonOp);
|
||||
}
|
||||
case 2:
|
||||
return getCancelString();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mFloating.getString(R.string.wifi_connect_to, mScanResult.SSID);
|
||||
}
|
||||
|
||||
private OnClickListener mConnectOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final WifiConfiguration config = Wifi.getWifiConfiguration(mWifiManager, mScanResult, mScanResultSecurity);
|
||||
boolean connResult = false;
|
||||
if(config != null) {
|
||||
connResult = Wifi.connectToConfiguredNetwork(mFloating, mWifiManager, config, false);
|
||||
}
|
||||
if(!connResult) {
|
||||
Toast.makeText(mFloating, R.string.toastFailed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
mFloating.finish();
|
||||
}
|
||||
};
|
||||
|
||||
private OnClickListener mOpOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mFloating.registerForContextMenu(v);
|
||||
mFloating.openContextMenu(v);
|
||||
mFloating.unregisterForContextMenu(v);
|
||||
}
|
||||
};
|
||||
|
||||
private OnClickListener mForgetOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
forget();
|
||||
}
|
||||
};
|
||||
|
||||
private void forget() {
|
||||
final WifiConfiguration config = Wifi.getWifiConfiguration(mWifiManager, mScanResult, mScanResultSecurity);
|
||||
boolean result = false;
|
||||
if(config != null) {
|
||||
result = mWifiManager.removeNetwork(config.networkId)
|
||||
&& mWifiManager.saveConfiguration();
|
||||
}
|
||||
if(!result) {
|
||||
Toast.makeText(mFloating, R.string.toastFailed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
mFloating.finish();
|
||||
}
|
||||
|
||||
private static final int MENU_FORGET = 0;
|
||||
private static final int MENU_CHANGE_PASSWORD = 1;
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch(item.getItemId()) {
|
||||
case MENU_FORGET:
|
||||
forget();
|
||||
break;
|
||||
case MENU_CHANGE_PASSWORD:
|
||||
changePassword();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
menu.add(Menu.NONE, MENU_FORGET, Menu.NONE, R.string.forget_network);
|
||||
menu.add(Menu.NONE, MENU_CHANGE_PASSWORD, Menu.NONE, R.string.wifi_change_password);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.SupplicantState;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class CurrentNetworkContent extends BaseContent {
|
||||
private static final String TAG = "CurrentNetworkContent";
|
||||
|
||||
public CurrentNetworkContent(Floating floating, WifiManager wifiManager,
|
||||
ScanResult scanResult) {
|
||||
super(floating, wifiManager, scanResult);
|
||||
|
||||
mView.findViewById(R.id.Status).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.Speed).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.IPAddress).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.Password).setVisibility(View.GONE);
|
||||
|
||||
final WifiInfo wifiInfo = mWifiManager.getConnectionInfo();
|
||||
if(wifiInfo == null) {
|
||||
Log.d(TAG, "Get WifiInfo Failed\n");
|
||||
Toast.makeText(mFloating, R.string.toastFailed, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Log.d(TAG, "Get WifiInfo Ok\n");
|
||||
final SupplicantState state = wifiInfo.getSupplicantState();
|
||||
final NetworkInfo.DetailedState detailedState = WifiInfo.getDetailedStateOf(state);
|
||||
if(detailedState == NetworkInfo.DetailedState.CONNECTED
|
||||
|| (detailedState == NetworkInfo.DetailedState.OBTAINING_IPADDR && wifiInfo.getIpAddress() != 0)) {
|
||||
mView.findViewById(R.id.Status).setVisibility(View.VISIBLE);
|
||||
mView.findViewById(R.id.Speed).setVisibility(View.VISIBLE);
|
||||
mView.findViewById(R.id.IPAddress).setVisibility(View.VISIBLE);
|
||||
|
||||
((TextView)mView.findViewById(R.id.Status_TextView)).setText(R.string.status_connected);
|
||||
((TextView)mView.findViewById(R.id.LinkSpeed_TextView)).setText(wifiInfo.getLinkSpeed() + " " + WifiInfo.LINK_SPEED_UNITS);
|
||||
((TextView)mView.findViewById(R.id.IPAddress_TextView)).setText(getIPAddress(wifiInfo.getIpAddress()));
|
||||
} else if(detailedState == NetworkInfo.DetailedState.AUTHENTICATING
|
||||
|| detailedState == NetworkInfo.DetailedState.CONNECTING
|
||||
|| detailedState == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
|
||||
mView.findViewById(R.id.Status).setVisibility(View.VISIBLE);
|
||||
((TextView)mView.findViewById(R.id.Status_TextView)).setText(R.string.status_connecting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getButtonCount() {
|
||||
// No Modify button for open network.
|
||||
return mIsOpenNetwork ? 2 : 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnClickListener getButtonOnClickListener(int index) {
|
||||
if(mIsOpenNetwork && index == 1) {
|
||||
// No Modify button for open network.
|
||||
// index 1 is Cancel(index 2).
|
||||
return mOnClickListeners[2];
|
||||
}
|
||||
return mOnClickListeners[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getButtonText(int index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
return mFloating.getString(R.string.forget_network);
|
||||
case 1:
|
||||
if(mIsOpenNetwork) {
|
||||
// No Modify button for open network.
|
||||
// index 1 is Cancel.
|
||||
return getCancelString();
|
||||
}
|
||||
return mFloating.getString(R.string.button_change_password);
|
||||
case 2:
|
||||
return getCancelString();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mScanResult.SSID;
|
||||
}
|
||||
|
||||
private OnClickListener mForgetOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final WifiConfiguration config = Wifi.getWifiConfiguration(mWifiManager, mScanResult, mScanResultSecurity);
|
||||
boolean result = false;
|
||||
if(config != null) {
|
||||
result = mWifiManager.removeNetwork(config.networkId)
|
||||
&& mWifiManager.saveConfiguration();
|
||||
}
|
||||
if(!result) {
|
||||
Toast.makeText(mFloating, R.string.toastFailed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
mFloating.finish();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private OnClickListener mOnClickListeners[] = {mForgetOnClick, mChangePasswordOnClick, mCancelOnClick};
|
||||
|
||||
private String getIPAddress(int address) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(address & 0x000000FF).append(".")
|
||||
.append((address & 0x0000FF00) >> 8).append(".")
|
||||
.append((address & 0x00FF0000) >> 16).append(".")
|
||||
.append((address & 0xFF000000L) >> 24);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
//import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A dialog-like floating activity
|
||||
* @author Kevin Yuan
|
||||
*
|
||||
*/
|
||||
public class Floating extends Activity {
|
||||
// private static final String TAG = "Floating";
|
||||
|
||||
private static final int[] BUTTONS = {R.id.button1, R.id.button2, R.id.button3};
|
||||
|
||||
private View mView;
|
||||
private ViewGroup mContentViewContainer;
|
||||
private Content mContent;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
// It will not work if we setTheme here.
|
||||
// Please add android:theme="@android:style/Theme.Dialog" to any descendant class in AndroidManifest.xml!
|
||||
// See http://code.google.com/p/android/issues/detail?id=4394
|
||||
setTheme(android.R.style.Theme_Dialog);
|
||||
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mView = View.inflate(this, R.layout.floating, null);
|
||||
final DisplayMetrics dm = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||
mView.setMinimumWidth(Math.min(dm.widthPixels, dm.heightPixels) - 20);
|
||||
setContentView(mView);
|
||||
|
||||
mContentViewContainer = (ViewGroup) mView.findViewById(R.id.content);
|
||||
}
|
||||
|
||||
private void setDialogContentView(final View contentView) {
|
||||
// Log.d(TAG, "setDialogContentView\n");
|
||||
mContentViewContainer.removeAllViews();
|
||||
//mContentViewContainer.addView(contentView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
|
||||
/* FILL_PARENT is renamed MATCH_PARENT in API Level 8 and higher */
|
||||
mContentViewContainer.addView(contentView, new LayoutParams(LayoutParams.MATCH_PARENT , LayoutParams.WRAP_CONTENT));
|
||||
}
|
||||
|
||||
public void setContent(Content content) {
|
||||
mContent = content;
|
||||
refreshContent();
|
||||
}
|
||||
|
||||
public void refreshContent() {
|
||||
// Log.d(TAG, "refreshContent");
|
||||
setDialogContentView(mContent.getView());
|
||||
((TextView)findViewById(R.id.title)).setText(mContent.getTitle()); //getTitle
|
||||
|
||||
final int btnCount = mContent.getButtonCount();
|
||||
if(btnCount > BUTTONS.length) {
|
||||
throw new RuntimeException(String.format("%d exceeds maximum button count: %d!", btnCount, BUTTONS.length));
|
||||
}
|
||||
findViewById(R.id.buttons_view).setVisibility(btnCount > 0 ? View.VISIBLE : View.GONE);
|
||||
for(int buttonId:BUTTONS) {
|
||||
final Button btn = (Button) findViewById(buttonId);
|
||||
btn.setOnClickListener(null);
|
||||
btn.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
for(int btnIndex = 0; btnIndex < btnCount; btnIndex++){
|
||||
final Button btn = (Button)findViewById(BUTTONS[btnIndex]);
|
||||
// Log.d(TAG, "getButtonText(" + btnIndex + "): " + mContent.getButtonText(btnIndex));
|
||||
btn.setText(mContent.getButtonText(btnIndex));
|
||||
btn.setVisibility(View.VISIBLE);
|
||||
btn.setOnClickListener(mContent.getButtonOnClickListener(btnIndex));
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
if(mContent != null) {
|
||||
mContent.onCreateContextMenu(menu, v, menuInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean onContextItemSelected (MenuItem item) {
|
||||
if(mContent != null) {
|
||||
return mContent.onContextItemSelected(item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public interface Content {
|
||||
CharSequence getTitle();
|
||||
View getView();
|
||||
int getButtonCount();
|
||||
CharSequence getButtonText(int index);
|
||||
OnClickListener getButtonOnClickListener(int index);
|
||||
void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo);
|
||||
boolean onContextItemSelected (MenuItem item);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
import com.rtk.simpleconfig_wizard.SCCtlOps;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
//import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
//import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class MainActivity extends Floating {
|
||||
// private static final String TAG = "WifiMainActivity";
|
||||
|
||||
public static final String EXTRA_HOTSPOT = "com.wifi.connection.HOTSPOT";
|
||||
|
||||
private ScanResult mScanResult;
|
||||
private Floating.Content mContent;
|
||||
private WifiManager mWifiManager;
|
||||
|
||||
@Override
|
||||
protected void onNewIntent (Intent intent) {
|
||||
setIntent(intent);
|
||||
// This activity has "singleInstance" launch mode.
|
||||
// Update content to reflect the newest intent.
|
||||
doNewIntent(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mWifiManager = (WifiManager)getSystemService(WIFI_SERVICE);
|
||||
|
||||
doNewIntent(getIntent());
|
||||
}
|
||||
|
||||
private boolean isAdHoc(final ScanResult scanResule) {
|
||||
return scanResule.capabilities.indexOf("IBSS") != -1;
|
||||
}
|
||||
|
||||
private void doNewIntent(final Intent intent) {
|
||||
if(SCCtlOps.addNewNetwork)
|
||||
mScanResult = SCCtlOps.reBuiltScanResult;
|
||||
else
|
||||
mScanResult = intent.getParcelableExtra(EXTRA_HOTSPOT);
|
||||
// Log.i(TAG, "mScanResult: " + mScanResult);
|
||||
// Log.d(TAG, "mScanResult.SSID: " + mScanResult.SSID);
|
||||
// Log.d(TAG, "mScanResult.BSSID: " + mScanResult.BSSID);
|
||||
// Log.d(TAG, "mScanResult.capabilities: " + mScanResult.capabilities);
|
||||
// Log.d(TAG, "mScanResult.level: " + mScanResult.level);
|
||||
// Log.d(TAG, "mScanResult.frequency: " + mScanResult.frequency);
|
||||
|
||||
if(mScanResult == null) {
|
||||
Toast.makeText(this, "No data in Intent!", Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if(isAdHoc(mScanResult)) {
|
||||
Toast.makeText(this, R.string.adhoc_not_supported_yet, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final String security = Wifi.ConfigSec.getScanResultSecurity(mScanResult);
|
||||
final WifiConfiguration config = Wifi.getWifiConfiguration(mWifiManager, mScanResult, security);
|
||||
|
||||
if(config != null) {
|
||||
// Log.d(TAG, "Remove already configured network\n");
|
||||
mWifiManager.removeNetwork(config.networkId);
|
||||
}
|
||||
// Log.d(TAG, "NewNetworkContent\n");
|
||||
mContent = new NewNetworkContent(this, mWifiManager, mScanResult);
|
||||
|
||||
// if(config == null) {
|
||||
// Log.d(TAG, "NewNetworkContent\n");
|
||||
// mContent = new NewNetworkContent(this, mWifiManager, mScanResult);
|
||||
// } else {
|
||||
// final boolean isCurrentNetwork_ConfigurationStatus = config.status == WifiConfiguration.Status.CURRENT;
|
||||
// final WifiInfo info = mWifiManager.getConnectionInfo();
|
||||
// final boolean isCurrentNetwork_WifiInfo = info != null
|
||||
// && android.text.TextUtils.equals(info.getSSID(), mScanResult.SSID)
|
||||
// && android.text.TextUtils.equals(info.getBSSID(), mScanResult.BSSID);
|
||||
// if(isCurrentNetwork_ConfigurationStatus || isCurrentNetwork_WifiInfo) {
|
||||
// Log.d(TAG, "CurrentNetworkContent\n");
|
||||
// mContent = new CurrentNetworkContent(this, mWifiManager, mScanResult);
|
||||
// } else {
|
||||
// Log.d(TAG, "ConfiguredNetworkContent\n");
|
||||
// mContent = new ConfiguredNetworkContent(this, mWifiManager, mScanResult);
|
||||
// }
|
||||
// }
|
||||
|
||||
setContent(mContent);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,151 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import com.rtk.simpleconfig_wizard.FileOps;
|
||||
import com.rtk.simpleconfig_wizard.R;
|
||||
import com.rtk.simpleconfig_wizard.SCCtlOps;
|
||||
import com.rtk.simpleconfig_wizard.MainActivity;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiManager;
|
||||
//import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
|
||||
public class NewNetworkContent extends BaseContent {
|
||||
// private static final String TAG = "NewNetworkContent";
|
||||
|
||||
private boolean mIsOpenNetwork = false;
|
||||
|
||||
public NewNetworkContent(final Floating floating, final WifiManager wifiManager, ScanResult scanResult) {
|
||||
super(floating, wifiManager, scanResult);
|
||||
|
||||
mView.findViewById(R.id.Status).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.Speed).setVisibility(View.GONE);
|
||||
mView.findViewById(R.id.IPAddress).setVisibility(View.GONE);
|
||||
if(Wifi.ConfigSec.isOpenNetwork(mScanResultSecurity)) {
|
||||
mIsOpenNetwork = true;
|
||||
mView.findViewById(R.id.Password).setVisibility(View.GONE);
|
||||
} else {
|
||||
((TextView)mView.findViewById(R.id.Password_TextView)).setText(R.string.please_type_passphrase);
|
||||
((EditText)mView.findViewById(R.id.Password_EditText)).setText(SCCtlOps.StoredPasswd); //The last password hint
|
||||
}
|
||||
}
|
||||
|
||||
private OnClickListener mConnectOnClick = new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
|
||||
|
||||
SCCtlOps.ConnectedSSID = mScanResult.SSID; // Store SSID
|
||||
// Log.d(TAG, "SSID£º" + mScanResult.SSID);
|
||||
|
||||
boolean connResult = false;
|
||||
if(mIsOpenNetwork) {
|
||||
SCCtlOps.IsOpenNetwork = true;
|
||||
connResult = Wifi.connectToNewNetwork(mFloating, mWifiManager, mScanResult, null, mNumOpenNetworksKept);
|
||||
} else {
|
||||
SCCtlOps.IsOpenNetwork = false;
|
||||
String passwd = ((EditText)mView.findViewById(R.id.Password_EditText)).getText().toString();
|
||||
connResult = Wifi.connectToNewNetwork(mFloating, mWifiManager, mScanResult
|
||||
, passwd
|
||||
, mNumOpenNetworksKept);
|
||||
|
||||
if(connResult) {
|
||||
SCCtlOps.ConnectedPasswd = new String(passwd); // Store password
|
||||
// Log.d(TAG, "Password£º" + passwd);
|
||||
}
|
||||
}
|
||||
|
||||
// if(!connResult) {
|
||||
// Toast.makeText(mFloating, R.string.toastFailed, Toast.LENGTH_LONG).show();
|
||||
// }
|
||||
|
||||
mFloating.finish();
|
||||
|
||||
// /** Update SSID and password */
|
||||
// if(connResult) {
|
||||
// FileOps fileOps = new FileOps();
|
||||
// fileOps.UpdateSsidPasswdFile(mIsOpenNetwork);
|
||||
// }
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
private OnClickListener mOnClickListeners[] = {mConnectOnClick, mCancelOnClick};
|
||||
|
||||
@Override
|
||||
public int getButtonCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OnClickListener getButtonOnClickListener(int index) {
|
||||
return mOnClickListeners[index];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CharSequence getButtonText(int index) {
|
||||
switch(index) {
|
||||
case 0:
|
||||
return mFloating.getText(R.string.connect);
|
||||
case 1:
|
||||
return mFloating.getText(R.string.cancel);
|
||||
// return getCancelString();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mFloating.getString(R.string.wifi_connect_to, mScanResult.SSID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v,
|
||||
ContextMenuInfo menuInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Wifi Connecter
|
||||
*
|
||||
* Copyright (c) 20101 Kevin Yuan (farproc@gmail.com)
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
package com.wifi.connection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.wifi.WifiConfiguration;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.IBinder;
|
||||
|
||||
public class ReenableAllApsWhenNetworkStateChanged {
|
||||
public static void schedule(final Context ctx) {
|
||||
ctx.startService(new Intent(ctx, BackgroundService.class));
|
||||
}
|
||||
|
||||
private static void reenableAllAps(final Context ctx) {
|
||||
final WifiManager wifiMgr = (WifiManager)ctx.getSystemService(Context.WIFI_SERVICE);
|
||||
final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
|
||||
if(configurations != null) {
|
||||
for(final WifiConfiguration config:configurations) {
|
||||
wifiMgr.enableNetwork(config.networkId, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class BackgroundService extends Service {
|
||||
|
||||
private boolean mReenabled;
|
||||
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
if(WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
|
||||
final NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
final NetworkInfo.DetailedState detailed = networkInfo.getDetailedState();
|
||||
if(detailed != NetworkInfo.DetailedState.DISCONNECTED
|
||||
&& detailed != NetworkInfo.DetailedState.DISCONNECTING
|
||||
&& detailed != NetworkInfo.DetailedState.SCANNING) {
|
||||
if(!mReenabled) {
|
||||
mReenabled = true;
|
||||
reenableAllAps(context);
|
||||
stopSelf();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private IntentFilter mIntentFilter;
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null; // We need not bind to it at all.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mReenabled = false;
|
||||
mIntentFilter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
|
||||
registerReceiver(mReceiver, mIntentFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||