summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2014-02-06 17:51:30 -0800
committerFabrice Di Meglio <fdimeglio@google.com>2014-02-06 17:51:30 -0800
commit3065f75e164d71c9c45b26666e37f5acb68ab3f1 (patch)
tree6fd7890de9ca1fc89fb827b3326457a59e047038 /src/com/android/settings
parentd3aee23cb69dbee295ede91b7980b947dcf78272 (diff)
downloadpackages_apps_Settings-3065f75e164d71c9c45b26666e37f5acb68ab3f1.tar.gz
packages_apps_Settings-3065f75e164d71c9c45b26666e37f5acb68ab3f1.tar.bz2
packages_apps_Settings-3065f75e164d71c9c45b26666e37f5acb68ab3f1.zip
Fix bug #12919330 RTE in Settings: PhoneFactory probably already running
- revert changes from the CL for Drawer implementation. - we cannot convert those Activities to fragments as they are running in the Phone process Change-Id: I7e4033bc9b53daa7e7aa6f1fd74576375cde88e9
Diffstat (limited to 'src/com/android/settings')
-rw-r--r--src/com/android/settings/IccLockSettings.java31
-rw-r--r--src/com/android/settings/deviceinfo/Status.java86
2 files changed, 55 insertions, 62 deletions
diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java
index 4edaee456..b988572b7 100644
--- a/src/com/android/settings/IccLockSettings.java
+++ b/src/com/android/settings/IccLockSettings.java
@@ -27,6 +27,7 @@ import android.os.Handler;
import android.os.Message;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
+import android.preference.PreferenceActivity;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.widget.Toast;
@@ -44,7 +45,7 @@ import com.android.internal.telephony.TelephonyIntents;
* these operations.
*
*/
-public class IccLockSettings extends SettingsPreferenceFragment
+public class IccLockSettings extends PreferenceActivity
implements EditPinPreference.OnPinEnteredListener {
private static final String TAG = "IccLockSettings";
private static final boolean DBG = true;
@@ -127,11 +128,11 @@ public class IccLockSettings extends SettingsPreferenceFragment
};
// For top-level settings screen to query
- boolean isIccLockEnabled() {
- return mPhone.getIccCard().getIccLockEnabled();
+ static boolean isIccLockEnabled() {
+ return PhoneFactory.getDefaultPhone().getIccCard().getIccLockEnabled();
}
- String getSummary(Context context) {
+ static String getSummary(Context context) {
Resources res = context.getResources();
String summary = isIccLockEnabled()
? res.getString(R.string.sim_lock_on)
@@ -140,7 +141,7 @@ public class IccLockSettings extends SettingsPreferenceFragment
}
@Override
- public void onCreate(Bundle savedInstanceState) {
+ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Utils.isMonkeyRunning()) {
@@ -181,9 +182,7 @@ public class IccLockSettings extends SettingsPreferenceFragment
// Don't need any changes to be remembered
getPreferenceScreen().setPersistent(false);
- PhoneFactory.makeDefaultPhone(getActivity());
mPhone = PhoneFactory.getDefaultPhone();
-
mRes = getResources();
updatePreferences();
}
@@ -193,13 +192,13 @@ public class IccLockSettings extends SettingsPreferenceFragment
}
@Override
- public void onResume() {
+ protected void onResume() {
super.onResume();
// ACTION_SIM_STATE_CHANGED is sticky, so we'll receive current state after this call,
// which will call updatePreferences().
final IntentFilter filter = new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
- getActivity().registerReceiver(mSimStateReceiver, filter);
+ registerReceiver(mSimStateReceiver, filter);
if (mDialogState != OFF_MODE) {
showPinDialog();
@@ -210,13 +209,13 @@ public class IccLockSettings extends SettingsPreferenceFragment
}
@Override
- public void onPause() {
+ protected void onPause() {
super.onPause();
- getActivity().unregisterReceiver(mSimStateReceiver);
+ unregisterReceiver(mSimStateReceiver);
}
@Override
- public void onSaveInstanceState(Bundle out) {
+ protected void onSaveInstanceState(Bundle out) {
// Need to store this state for slider open/close
// There is one case where the dialog is popped up by the preference
// framework. In that case, let the preference framework store the
@@ -360,8 +359,8 @@ public class IccLockSettings extends SettingsPreferenceFragment
if (success) {
mPinToggle.setChecked(mToState);
} else {
- Toast.makeText(getActivity(),
- getPinPasswordErrorMessage(attemptsRemaining), Toast.LENGTH_LONG).show();
+ Toast.makeText(this, getPinPasswordErrorMessage(attemptsRemaining), Toast.LENGTH_LONG)
+ .show();
}
mPinToggle.setEnabled(true);
resetDialogState();
@@ -369,11 +368,11 @@ public class IccLockSettings extends SettingsPreferenceFragment
private void iccPinChanged(boolean success, int attemptsRemaining) {
if (!success) {
- Toast.makeText(getActivity(), getPinPasswordErrorMessage(attemptsRemaining),
+ Toast.makeText(this, getPinPasswordErrorMessage(attemptsRemaining),
Toast.LENGTH_LONG)
.show();
} else {
- Toast.makeText(getActivity(), mRes.getString(R.string.sim_change_succeeded),
+ Toast.makeText(this, mRes.getString(R.string.sim_change_succeeded),
Toast.LENGTH_SHORT)
.show();
diff --git a/src/com/android/settings/deviceinfo/Status.java b/src/com/android/settings/deviceinfo/Status.java
index f9f04165b..ef1f5c5dc 100644
--- a/src/com/android/settings/deviceinfo/Status.java
+++ b/src/com/android/settings/deviceinfo/Status.java
@@ -16,7 +16,6 @@
package com.android.settings.deviceinfo;
-import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
@@ -25,6 +24,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Build;
@@ -35,6 +35,7 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.preference.Preference;
+import android.preference.PreferenceActivity;
import android.telephony.CellBroadcastMessage;
import android.telephony.PhoneNumberUtils;
import android.telephony.PhoneStateListener;
@@ -52,7 +53,6 @@ import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.PhoneStateIntentReceiver;
import com.android.internal.util.ArrayUtils;
import com.android.settings.R;
-import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import java.lang.ref.WeakReference;
@@ -72,7 +72,7 @@ import java.lang.ref.WeakReference;
* # XMPP/buzz/tickle status : TODO
*
*/
-public class Status extends SettingsPreferenceFragment {
+public class Status extends PreferenceActivity {
private static final String KEY_DATA_STATE = "data_state";
private static final String KEY_SERVICE_STATE = "service_state";
@@ -163,8 +163,8 @@ public class Status extends SettingsPreferenceFragment {
private static class MyHandler extends Handler {
private WeakReference<Status> mStatus;
- public MyHandler(Status status) {
- mStatus = new WeakReference<Status>(status);
+ public MyHandler(Status activity) {
+ mStatus = new WeakReference<Status>(activity);
}
@Override
@@ -254,14 +254,14 @@ public class Status extends SettingsPreferenceFragment {
}
@Override
- public void onCreate(Bundle icicle) {
+ protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
mHandler = new MyHandler(this);
- mCM = (ConnectivityManager) getSystemService(Activity.CONNECTIVITY_SERVICE);
- mTelephonyManager = (TelephonyManager)getSystemService(Activity.TELEPHONY_SERVICE);
- mWifiManager = (WifiManager) getSystemService(Activity.WIFI_SERVICE);
+ mCM = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
+ mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
+ mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
addPreferencesFromResource(R.xml.device_info_status);
mBatteryLevel = findPreference(KEY_BATTERY_LEVEL);
@@ -276,14 +276,13 @@ public class Status extends SettingsPreferenceFragment {
mUnavailable = mRes.getString(R.string.status_unavailable);
if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
- PhoneFactory.makeDefaultPhone(getActivity());
mPhone = PhoneFactory.getDefaultPhone();
}
// Note - missing in zaku build, be careful later...
mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
mUptime = findPreference("up_time");
- if (mPhone == null || Utils.isWifiOnly(getActivity())) {
+ if (mPhone == null || Utils.isWifiOnly(getApplicationContext())) {
for (String key : PHONE_RELATED_ENTRIES) {
removePreferenceFromScreen(key);
}
@@ -313,7 +312,7 @@ public class Status extends SettingsPreferenceFragment {
setSummaryText(KEY_IMEI, mPhone.getDeviceId());
setSummaryText(KEY_IMEI_SV,
- ((TelephonyManager) getSystemService(Activity.TELEPHONY_SERVICE))
+ ((TelephonyManager) getSystemService(TELEPHONY_SERVICE))
.getDeviceSoftwareVersion());
// device is not CDMA, do not display CDMA features
@@ -337,7 +336,7 @@ public class Status extends SettingsPreferenceFragment {
// If formattedNumber is null or empty, it'll display as "Unknown".
setSummaryText(KEY_PHONE_NUMBER, formattedNumber);
- mPhoneStateReceiver = new PhoneStateIntentReceiver(getActivity(), mHandler);
+ mPhoneStateReceiver = new PhoneStateIntentReceiver(this, mHandler);
mPhoneStateReceiver.notifySignalStrength(EVENT_SIGNAL_STRENGTH_CHANGED);
mPhoneStateReceiver.notifyServiceState(EVENT_SERVICE_STATE_CHANGED);
@@ -369,39 +368,34 @@ public class Status extends SettingsPreferenceFragment {
} else {
removePreferenceFromScreen(KEY_SERIAL_NUMBER);
}
- }
-
- @Override
- public void onActivityCreated(Bundle savedInstanceState) {
- super.onActivityCreated(savedInstanceState);
// Make every pref on this screen copy its data to the clipboard on longpress.
// Super convenient for capturing the IMEI, MAC addr, serial, etc.
getListView().setOnItemLongClickListener(
- new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView<?> parent, View view,
- int position, long id) {
- ListAdapter listAdapter = (ListAdapter) parent.getAdapter();
- Preference pref = (Preference) listAdapter.getItem(position);
-
- ClipboardManager cm = (ClipboardManager)
- getSystemService(Context.CLIPBOARD_SERVICE);
- cm.setText(pref.getSummary());
- Toast.makeText(
- getActivity(),
- com.android.internal.R.string.text_copied,
- Toast.LENGTH_SHORT).show();
- return true;
- }
- });
+ new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view,
+ int position, long id) {
+ ListAdapter listAdapter = (ListAdapter) parent.getAdapter();
+ Preference pref = (Preference) listAdapter.getItem(position);
+
+ ClipboardManager cm = (ClipboardManager)
+ getSystemService(Context.CLIPBOARD_SERVICE);
+ cm.setText(pref.getSummary());
+ Toast.makeText(
+ Status.this,
+ com.android.internal.R.string.text_copied,
+ Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ });
}
@Override
- public void onResume() {
+ protected void onResume() {
super.onResume();
- if (mPhone != null && !Utils.isWifiOnly(getActivity())) {
+ if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) {
mPhoneStateReceiver.registerIntent();
updateSignalStrength();
@@ -410,17 +404,17 @@ public class Status extends SettingsPreferenceFragment {
mTelephonyManager.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
if (mShowLatestAreaInfo) {
- getActivity().registerReceiver(mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
+ registerReceiver(mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
CB_AREA_INFO_SENDER_PERMISSION, null);
// Ask CellBroadcastReceiver to broadcast the latest area info received
Intent getLatestIntent = new Intent(GET_LATEST_CB_AREA_INFO_ACTION);
- getActivity().sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
+ sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
CB_AREA_INFO_SENDER_PERMISSION);
}
}
- getActivity().registerReceiver(mConnectivityReceiver, mConnectivityIntentFilter,
- android.Manifest.permission.CHANGE_NETWORK_STATE, null);
- getActivity().registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
+ registerReceiver(mConnectivityReceiver, mConnectivityIntentFilter,
+ android.Manifest.permission.CHANGE_NETWORK_STATE, null);
+ registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
}
@@ -428,15 +422,15 @@ public class Status extends SettingsPreferenceFragment {
public void onPause() {
super.onPause();
- if (mPhone != null && !Utils.isWifiOnly(getActivity())) {
+ if (mPhone != null && !Utils.isWifiOnly(getApplicationContext())) {
mPhoneStateReceiver.unregisterIntent();
mTelephonyManager.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
}
if (mShowLatestAreaInfo) {
- getActivity().unregisterReceiver(mAreaInfoReceiver);
+ unregisterReceiver(mAreaInfoReceiver);
}
- getActivity().unregisterReceiver(mBatteryInfoReceiver);
- getActivity().unregisterReceiver(mConnectivityReceiver);
+ unregisterReceiver(mBatteryInfoReceiver);
+ unregisterReceiver(mConnectivityReceiver);
mHandler.removeMessages(EVENT_UPDATE_STATS);
}