diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 8f410a908c1d9..7df509ff8006c 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -3084,13 +3084,6 @@ public final class Settings { */ public static final String MOUNT_UMS_NOTIFY_ENABLED = "mount_ums_notify_enabled"; - /** - * Whether or not a notification is displayed when a Tetherable interface is detected. - * (0 = false, 1 = true) - * @hide - */ - public static final String TETHER_NOTIFY = "tether_notify"; - /** * If nonzero, ANRs in invisible background processes bring up a dialog. * Otherwise, the process will be silently killed. diff --git a/core/java/com/android/internal/app/TetherActivity.java b/core/java/com/android/internal/app/TetherActivity.java deleted file mode 100644 index 7f83b2b81a418..0000000000000 --- a/core/java/com/android/internal/app/TetherActivity.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (C) 2007 Google Inc. - * - * 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. - */ - -package com.android.internal.app; - -import android.app.AlertDialog; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.net.ConnectivityManager; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.widget.Toast; -import android.util.Log; - -/** - * This activity is shown to the user in two cases: when a connection is possible via - * a usb tether and when any type of tether is connected. In the connecting case - * It allows them to start a USB tether. In the Tethered/disconnecting case it - * will disconnect all tethers. - */ -public class TetherActivity extends AlertActivity implements - DialogInterface.OnClickListener { - - private static final int POSITIVE_BUTTON = AlertDialog.BUTTON1; - - // count of the number of tethered connections at activity create time. - private int mTethered; - - /* Used to detect when the USB cable is unplugged, so we can call finish() */ - private BroadcastReceiver mTetherReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent.getAction() == ConnectivityManager.ACTION_TETHER_STATE_CHANGED) { - handleTetherStateChanged(intent); - } - } - }; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // determine if we advertise tethering or untethering - ConnectivityManager cm = - (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); - - mTethered = cm.getTetheredIfaces().length; - int tetherable = cm.getTetherableIfaces().length; - if ((mTethered == 0) && (tetherable == 0)) { - finish(); - return; - } - - // Set up the dialog - // if we have a tethered connection we put up a "Do you want to Disconect" dialog - // otherwise we must have a tetherable interface (else we'd return above) - // and so we want to put up the "do you want to connect" dialog - if (mTethered == 0) { - mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb; - mAlertParams.mTitle = getString(com.android.internal.R.string.tether_title); - mAlertParams.mMessage = getString(com.android.internal.R.string.tether_message); - mAlertParams.mPositiveButtonText = - getString(com.android.internal.R.string.tether_button); - mAlertParams.mPositiveButtonListener = this; - mAlertParams.mNegativeButtonText = - getString(com.android.internal.R.string.tether_button_cancel); - mAlertParams.mNegativeButtonListener = this; - } else { - mAlertParams.mIconId = com.android.internal.R.drawable.ic_dialog_usb; - mAlertParams.mTitle = getString(com.android.internal.R.string.tether_stop_title); - mAlertParams.mMessage = getString(com.android.internal.R.string.tether_stop_message); - mAlertParams.mPositiveButtonText = - getString(com.android.internal.R.string.tether_stop_button); - mAlertParams.mPositiveButtonListener = this; - mAlertParams.mNegativeButtonText = - getString(com.android.internal.R.string.tether_stop_button_cancel); - mAlertParams.mNegativeButtonListener = this; - } - setupAlert(); - } - - @Override - protected void onResume() { - super.onResume(); - - registerReceiver(mTetherReceiver, new IntentFilter( - ConnectivityManager.ACTION_TETHER_STATE_CHANGED)); - } - - @Override - protected void onPause() { - super.onPause(); - - unregisterReceiver(mTetherReceiver); - } - - /** - * {@inheritDoc} - */ - public void onClick(DialogInterface dialog, int which) { - int error = ConnectivityManager.TETHER_ERROR_NO_ERROR; - - if (which == POSITIVE_BUTTON) { - ConnectivityManager cm = - (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); - // start/stop tethering - String[] tethered = cm.getTetheredIfaces(); - - if (tethered.length == 0) { - String[] tetherable = cm.getTetherableIfaces(); - String[] usbRegexs = cm.getTetherableUsbRegexs(); - for (String t : tetherable) { - for (String r : usbRegexs) { - if (t.matches(r)) { - error = cm.tether(t); - break; - } - } - } - showTetheringError(error); - } else { - for (String t : tethered) { - error = cm.untether(t); - } - showUnTetheringError(error); - } - } - // No matter what, finish the activity - finish(); - } - - private void handleTetherStateChanged(Intent intent) { - // determine if we advertise tethering or untethering - ConnectivityManager cm = - (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); - if (mTethered != cm.getTetheredIfaces().length) { - finish(); - } - } - - private void showTetheringError(int error) { - switch(error) { - case ConnectivityManager.TETHER_ERROR_NO_ERROR: - return; - default: - Toast.makeText(this, com.android.internal.R.string.tether_error_message, - Toast.LENGTH_LONG).show(); - } - } - - private void showUnTetheringError(int error) { - switch(error) { - case ConnectivityManager.TETHER_ERROR_NO_ERROR: - return; - default: - Toast.makeText(this, com.android.internal.R.string.tether_stop_error_message, - Toast.LENGTH_LONG).show(); - } - } -} diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index 63584eda79d88..a41d25bf1a974 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1271,10 +1271,6 @@ - - diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 8308801646aeb..e68f21434b483 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1101,7 +1101,7 @@ the state of network connectivity. - change tethered connectivity + Change tethered connectivity Allows an application to change the state of tethered network connectivity. @@ -2246,44 +2246,6 @@ --> favorite - - - - - USB tethering available - - Select \"Tether\" if you want to share your phone\'s data connection with your computer. - - Tether - - Cancel - - - We\'ve encountered a problem turning on Tethering. Please try again. - - - USB tethering available - - Select to tether your computer to your phone. - - Untether - - Select to untether your computer. - - - - - Disconnect tethering - - You have been sharing your phone\'s cellular data connection with your computer. Select \"Disconnect\" to disconnect USB tethering. - - Disconnect - - Cancel - - - We\'ve encountered a problem turning off Tethering. Please try again. - Car mode enabled diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java index ee54f7308aa50..78329dbf00c0f 100644 --- a/services/java/com/android/server/connectivity/Tethering.java +++ b/services/java/com/android/server/connectivity/Tethering.java @@ -40,7 +40,6 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.util.Log; -import android.widget.Toast; import com.android.internal.telephony.Phone; import com.android.internal.util.HierarchicalState; @@ -66,7 +65,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private Context mContext; private final String TAG = "Tethering"; - private boolean mPlaySounds = false; private boolean mBooted = false; //used to remember if we got connected before boot finished private boolean mDeferedUsbConnection = false; @@ -78,8 +76,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub { private HashMap mIfaces; - private ArrayList mActiveTtys; - private BroadcastReceiver mStateReceiver; private static final String USB_NEAR_IFACE_ADDR = "169.254.2.1"; @@ -112,7 +108,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub { } mIfaces = new HashMap(); - mActiveTtys = new ArrayList(); mTetherMasterSM = new TetherMasterSM("TetherMaster"); mTetherMasterSM.start(); @@ -323,142 +318,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub { mContext.sendStickyBroadcast(broadcast); Log.d(TAG, "sendTetherStateChangedBroadcast " + availableList.size() + ", " + activeList.size() + ", " + erroredList.size()); - // check if we need to send a USB notification - // Check if the user wants to be bothered - boolean tellUser = (Settings.Secure.getInt(mContext.getContentResolver(), - Settings.Secure.TETHER_NOTIFY, 0) == 1); - for (Object o : activeList) { - String s = (String)o; - for (Object regexObject : mTetherableUsbRegexs) { - if (s.matches((String)regexObject)) { - showTetheredNotification(); - return; - } - } - } - if (tellUser) { - for (Object o : availableList) { - String s = (String)o; - for (String match : mTetherableUsbRegexs) { - if (s.matches(match)) { - showTetherAvailableNotification(); - return; - } - } - } - } - clearNotification(); - } - - private void showTetherAvailableNotification() { - NotificationManager notificationManager = (NotificationManager)mContext. - getSystemService(Context.NOTIFICATION_SERVICE); - if (notificationManager == null) { - return; - } - Intent intent = new Intent(); - intent.setClass(mContext, com.android.internal.app.TetherActivity.class); - - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); - - Resources r = Resources.getSystem(); - CharSequence title = r.getText(com.android.internal.R.string. - tether_available_notification_title); - CharSequence message = r.getText(com.android.internal.R.string. - tether_available_notification_message); - - if(mTetheringNotification == null) { - mTetheringNotification = new Notification(); - mTetheringNotification.when = 0; - } - mTetheringNotification.icon = com.android.internal.R.drawable.stat_sys_tether_usb; - - boolean playSounds = false; - //playSounds = SystemProperties.get("persist.service.mount.playsnd", "1").equals("1"); - if (playSounds) { - mTetheringNotification.defaults |= Notification.DEFAULT_SOUND; - } else { - mTetheringNotification.defaults &= ~Notification.DEFAULT_SOUND; - } - - mTetheringNotification.flags = Notification.FLAG_ONGOING_EVENT; - mTetheringNotification.tickerText = title; - mTetheringNotification.setLatestEventInfo(mContext, title, message, pi); - - notificationManager.notify(mTetheringNotification.icon, mTetheringNotification); - - } - - private void showTetheredNotification() { - NotificationManager notificationManager = (NotificationManager)mContext. - getSystemService(Context.NOTIFICATION_SERVICE); - if (notificationManager == null) { - return; - } - - Intent intent = new Intent(); - intent.setClass(mContext, com.android.internal.app.TetherActivity.class); - - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0); - - Resources r = Resources.getSystem(); - CharSequence title = r.getText(com.android.internal.R.string. - tether_stop_notification_title); - CharSequence message = r.getText(com.android.internal.R.string. - tether_stop_notification_message); - - if(mTetheringNotification == null) { - mTetheringNotification = new Notification(); - mTetheringNotification.when = 0; - } - mTetheringNotification.icon = com.android.internal.R.drawable.stat_sys_tether_usb; - - boolean playSounds = false; - //playSounds = SystemProperties.get("persist.service.mount.playsnd", "1").equals("1"); - if (playSounds) { - mTetheringNotification.defaults |= Notification.DEFAULT_SOUND; - } else { - mTetheringNotification.defaults &= ~Notification.DEFAULT_SOUND; - } - - mTetheringNotification.flags = Notification.FLAG_ONGOING_EVENT; - mTetheringNotification.tickerText = title; - mTetheringNotification.setLatestEventInfo(mContext, title, message, pi); - - notificationManager.notify(mTetheringNotification.icon, mTetheringNotification); - } - - private void clearNotification() { - NotificationManager notificationManager = (NotificationManager)mContext. - getSystemService(Context.NOTIFICATION_SERVICE); - if (notificationManager != null && mTetheringNotification != null) { - notificationManager.cancel(mTetheringNotification.icon); - mTetheringNotification = null; - } - } - - private void showErrorToast(int error) { - int num; - switch(error) { - case ConnectivityManager.TETHER_ERROR_TETHER_IFACE_ERROR: - case ConnectivityManager.TETHER_ERROR_ENABLE_NAT_ERROR: - case ConnectivityManager.TETHER_ERROR_IFACE_CFG_ERROR: - case ConnectivityManager.TETHER_ERROR_MASTER_ERROR: - num = com.android.internal.R.string.tether_error_message; - break; - case ConnectivityManager.TETHER_ERROR_UNTETHER_IFACE_ERROR: - case ConnectivityManager.TETHER_ERROR_DISABLE_NAT_ERROR: - num = com.android.internal.R.string.tether_stop_error_message; - break; - default: - // do nothing - return; - } - String text = mContext.getResources().getString(num) + " - EC" + error; - Log.e(TAG, text); - Toast.makeText(mContext, text, Toast.LENGTH_LONG).show(); } private class StateReceiver extends BroadcastReceiver { @@ -748,7 +607,6 @@ public class Tethering extends INetworkManagementEventObserver.Stub { // further error.. Tethering.this.configureUsbIface(false); } - Tethering.this.showErrorToast(error); } }