summaryrefslogtreecommitdiff
authorkejun.gao <kejun.gao@amlogic.com>2012-03-06 13:24:49 (GMT)
committer kejun.gao <kejun.gao@amlogic.com>2012-03-06 13:26:29 (GMT)
commit16387be8350c45dfb42c6a24b4df6b1695993306 (patch)
treeea8a7534625b7ddbae6414cdd0e471358af2abd3
parent9c532f50308afe5b9bfe7ec0a35d1a18355d404b (diff)
downloadPPPoE-16387be8350c45dfb42c6a24b4df6b1695993306.zip
PPPoE-16387be8350c45dfb42c6a24b4df6b1695993306.tar.gz
PPPoE-16387be8350c45dfb42c6a24b4df6b1695993306.tar.bz2
Before connect pppoe, set net.pppoe.running.
After disconnect pppoe, clear net.pppoe.running.
Diffstat
-rwxr-xr-xAndroid.mk1
-rwxr-xr-xAndroidManifest.xml6
-rwxr-xr-xres/values-zh-rCN/strings.xml1
-rwxr-xr-xres/values-zh-rTW/strings.xml1
-rwxr-xr-xres/values/strings.xml1
-rwxr-xr-xsrc/com/amlogic/PPPoE/PppoeConfigDialog.java78
6 files changed, 75 insertions, 13 deletions
diff --git a/Android.mk b/Android.mk
index fb0af7e..d212f1f 100755
--- a/Android.mk
+++ b/Android.mk
@@ -7,6 +7,7 @@ LOCAL_JAVA_LIBRARIES := amlogic.pppoe
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_PACKAGE_NAME := PPPoE
+LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 4786f1a..5efd0b7 100755
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -2,7 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amlogic.PPPoE"
android:versionCode="1"
- android:versionName="1.0">
+ android:versionName="1.0"
+ android:sharedUserId="android.uid.system">
+
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="com.google.android.gm.permission.WRITE_GMAIL" />
@@ -60,4 +62,4 @@
</activity>
</application>
-</manifest> \ No newline at end of file
+</manifest>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index 10d965f..e09888c 100755
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -16,6 +16,7 @@
<string name="pppoe_connect_failed">宽带拨号失败</string>
<string name="pppoe_disconnect_ok">宽带拨号断开成功</string>
<string name="pppoe_disconnect_failed">宽带拨号断开失败</string>
+ <string name="pppoe_ppp_interface_occupied">ppp接口被占用</string>
<string name="amlogic_ok">确定</string>
<string name="pppoe_auto_dial">自动拨号</string>
</resources>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index 08b4627..9c3872e 100755
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -16,6 +16,7 @@
<string name="pppoe_connect_failed">寬帶撥號失败</string>
<string name="pppoe_disconnect_ok">寬帶撥號断开成功</string>
<string name="pppoe_disconnect_failed">寬帶撥號断开失败</string>
+ <string name="pppoe_ppp_interface_occupied">ppp接口被佔用</string>
<string name="amlogic_ok">確定</string>
<string name="pppoe_auto_dial">自动撥號</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 082e059..5f0f685 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -16,6 +16,7 @@
<string name="pppoe_connect_failed">Connect failed!</string>
<string name="pppoe_disconnect_ok">Disconnect OK!</string>
<string name="pppoe_disconnect_failed">Disconnect failed!</string>
+ <string name="pppoe_ppp_interface_occupied">ppp interface occupied!</string>
<string name="amlogic_ok">OK</string>
<string name="pppoe_auto_dial">automatic dial</string>
</resources>
diff --git a/src/com/amlogic/PPPoE/PppoeConfigDialog.java b/src/com/amlogic/PPPoE/PppoeConfigDialog.java
index 60162a1..182f0de 100755
--- a/src/com/amlogic/PPPoE/PppoeConfigDialog.java
+++ b/src/com/amlogic/PPPoE/PppoeConfigDialog.java
@@ -5,6 +5,7 @@ import java.util.TimerTask;
import com.amlogic.PPPoE.R;
import android.os.Message;
import android.os.Handler;
+import android.os.SystemProperties;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
@@ -56,6 +57,60 @@ public class PppoeConfigDialog extends AlertDialog implements DialogInterface.On
private CheckBox mCbAutoDial;
Timer connect_timer = null;
Timer disconnect_timer = null;
+ private final String pppoe_running_flag = "net.pppoe.running";
+
+ private boolean is_pppoe_running()
+ {
+ String propVal = SystemProperties.get(pppoe_running_flag);
+ int n = 0;
+ if (propVal.length() != 0) {
+ try {
+ n = Integer.parseInt(propVal);
+ } catch (NumberFormatException e) {}
+ } else {
+ Log.d(TAG, "net.pppoe.running not FOUND");
+ }
+
+ return (n != 0);
+ }
+
+
+
+ private void set_pppoe_running_flag()
+ {
+ SystemProperties.set(pppoe_running_flag, "100");
+ String propVal = SystemProperties.get(pppoe_running_flag);
+ int n = 0;
+ if (propVal.length() != 0) {
+ try {
+ n = Integer.parseInt(propVal);
+ Log.d(TAG, "set_pppoe_running_flag as " + n);
+ } catch (NumberFormatException e) {}
+ } else {
+ Log.d(TAG, "failed to set_pppoe_running_flag");
+ }
+
+ return;
+ }
+
+
+ private void clear_pppoe_running_flag()
+ {
+ SystemProperties.set(pppoe_running_flag, "0");
+ String propVal = SystemProperties.get(pppoe_running_flag);
+ int n = 0;
+ if (propVal.length() != 0) {
+ try {
+ n = Integer.parseInt(propVal);
+ Log.d(TAG, "clear_pppoe_running_flag as " + n);
+ } catch (NumberFormatException e) {}
+ } else {
+ Log.d(TAG, "failed to clear_pppoe_running_flag");
+ }
+
+ return;
+ }
+
public PppoeConfigDialog(Context context)
{
@@ -79,8 +134,10 @@ public class PppoeConfigDialog extends AlertDialog implements DialogInterface.On
mCbAutoDial.setVisibility(View.GONE);
this.setInverseBackgroundForced(true);
if(connectStatus() != PppoeOperation.PPP_STATUS_CONNECTED)
+ {
this.setButton(BUTTON_POSITIVE, context.getText(R.string.pppoe_dial), this);
- else{
+ }
+ else {
//hide Username
mView.findViewById(R.id.user_pppoe_text).setVisibility(View.GONE);
mPppoeName.setVisibility(View.GONE);
@@ -89,6 +146,13 @@ public class PppoeConfigDialog extends AlertDialog implements DialogInterface.On
mView.findViewById(R.id.passwd_pppoe_text).setVisibility(View.GONE);
mPppoePasswd.setVisibility(View.GONE);
this.setButton(BUTTON_POSITIVE, context.getText(R.string.pppoe_disconnect), this);
+
+ /*
+ if (!is_pppoe_running()) {
+ showAlertDialog(context.getResources().getString(R.string.pppoe_ppp_interface_occupied));
+ return;
+ }
+ */
}
this.setButton(BUTTON_NEGATIVE, context.getText(R.string.menu_cancel), this);
@@ -259,20 +323,11 @@ public class PppoeConfigDialog extends AlertDialog implements DialogInterface.On
connect_timer.schedule(check_task, 30000);
showWaitDialog(R.string.pppoe_dial_waiting_msg);
+ set_pppoe_running_flag();
operation.connect(name, passwd);
}
}
-
- private void waitOk(final int ms)
- {
- try {Thread.sleep(ms);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
private void handleStopDial()
{
boolean result = operation.disconnect();
@@ -283,6 +338,7 @@ public class PppoeConfigDialog extends AlertDialog implements DialogInterface.On
case MSG_DISCONNECT_TIMEOUT:
waitDialog.cancel();
showAlertDialog(context.getResources().getString(R.string.pppoe_disconnect_ok));
+ clear_pppoe_running_flag();
break;
}