Merge "Set default color of single-SIM PhoneAccount to NO_COLOR." into lmp-mr1-dev
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 61eaa2c..bebbf6c 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -95,7 +95,8 @@
     <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
     <uses-permission android:name="android.permission.READ_SEARCH_INDEXABLES" />
     <uses-permission android:name="android.permission.DUMP" />
-    <uses-permission android:name="android.permission.REGISTER_PROVIDER_OR_SUBSCRIPTION" />
+    <uses-permission android:name="android.permission.REGISTER_CALL_PROVIDER" />
+    <uses-permission android:name="android.permission.REGISTER_SIM_SUBSCRIPTION" />
 
     <!-- This tells the activity manager to not delay any of our activity
          start requests, even if they happen immediately after the user
@@ -146,7 +147,7 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="FdnList"
+        <activity android:name="com.android.phone.settings.fdn.FdnList"
                 android:label="@string/fdnListLabel"
                 android:theme="@style/DialerSettingsLight">
             <intent-filter>
@@ -357,7 +358,7 @@
         </activity>
 
         <!-- fdn setting -->
-        <activity android:name="FdnSetting"
+        <activity android:name="com.android.phone.settings.fdn.FdnSetting"
                 android:label="@string/fdn"
                 android:theme="@style/DialerSettingsLight">
             <intent-filter>
@@ -365,11 +366,6 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="EnableFdnScreen"
-                android:label=""
-                android:theme="@style/DialerSettingsLight">
-        </activity>
-
         <!-- SIM PIN setting -->
         <activity android:name="EnableIccPinScreen"
                 android:label="@string/enable_pin"
@@ -389,18 +385,18 @@
             </intent-filter>
         </activity>
 
-        <activity android:name="GetPin2Screen"
+        <activity android:name="com.android.phone.settings.fdn.GetPin2Screen"
                 android:label="@string/get_pin2"
                 android:theme="@style/SettingsLight"
                 android:windowSoftInputMode="stateVisible">
         </activity>
 
-        <activity android:name="EditFdnContactScreen"
+        <activity android:name="com.android.phone.settings.fdn.EditFdnContactScreen"
                 android:theme="@style/DialerSettingsLight"
                 android:windowSoftInputMode="stateVisible">
         </activity>
 
-        <activity android:name="DeleteFdnContactScreen"
+        <activity android:name="com.android.phone.settings.fdn.DeleteFdnContactScreen"
                 android:theme="@style/DialerSettingsLight"
                 android:label="@string/delete_fdn_contact">
         </activity>
diff --git a/res/xml/call_feature_setting.xml b/res/xml/call_feature_setting.xml
index f958c1a..bcda6b0 100644
--- a/res/xml/call_feature_setting.xml
+++ b/res/xml/call_feature_setting.xml
@@ -85,7 +85,7 @@
 
         <intent android:action="android.intent.action.MAIN"
             android:targetPackage="com.android.phone"
-            android:targetClass="com.android.phone.FdnSetting" />
+            android:targetClass="com.android.phone.settings.fdn.FdnSetting" />
 
     </PreferenceScreen>
 
diff --git a/res/xml/fdn_setting.xml b/res/xml/fdn_setting.xml
index 4c62cf5..d03cf7c 100644
--- a/res/xml/fdn_setting.xml
+++ b/res/xml/fdn_setting.xml
@@ -16,31 +16,31 @@
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
 
     <!-- Rearranged to use EditPinPreference -->
-    <com.android.phone.EditPinPreference 
-        android:key="button_fdn_enable_key" 
+    <com.android.phone.settings.fdn.EditPinPreference
+        android:key="button_fdn_enable_key"
         android:persistent="false"
         android:dialogMessage="@string/enter_pin2_text"
         android:title="@string/fdn_activation"/>
-        
+
     <!-- Rearranged to use EditPinPreference -->
-    <com.android.phone.EditPinPreference 
-        android:key="button_change_pin2_key" 
+    <com.android.phone.settings.fdn.EditPinPreference
+        android:key="button_change_pin2_key"
         android:title="@string/change_pin2"
         android:dialogTitle="@string/change_pin2"
         android:summary="@string/sum_fdn_change_pin"
         android:persistent="false"/>
-        
-    <PreferenceScreen 
-        android:key="button_fdn_list_key" 
+
+    <PreferenceScreen
+        android:key="button_fdn_list_key"
         android:title="@string/manage_fdn_list"
         android:summary="@string/sum_fdn_manage_list"
         android:persistent="false">
-        
+
         <!-- Intent to lauch the FDN list. -->
         <intent android:action="android.intent.action.MAIN"
             android:targetPackage="com.android.phone"
-            android:targetClass="com.android.phone.FdnList" />
-            
+            android:targetClass="com.android.phone.settings.fdn.FdnList" />
+
     </PreferenceScreen>
-    
+
 </PreferenceScreen>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index abc0edd..d56a274 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -216,6 +216,11 @@
     private static final int MSG_VM_OK = 600;
     private static final int MSG_VM_NOCHANGE = 700;
 
+    /**
+     * @see CallForwardInfo#status
+     */
+    private static final int CALL_FORWARD_INFO_INACTIVE_STATUS = 0;
+
     // voicemail notification vibration string constants
     private static final String VOICEMAIL_VIBRATION_ALWAYS = "always";
     private static final String VOICEMAIL_VIBRATION_NEVER = "never";
@@ -500,7 +505,10 @@
         }
 
         if (preference == mSubMenuVoicemailSettings) {
-            handleVMBtnClickRequest();
+            VoicemailProviderSettings newSettings = new VoicemailProviderSettings(
+                    mSubMenuVoicemailSettings.getPhoneNumber(),
+                    VoicemailProviderSettings.NO_FORWARDING);
+            saveVoiceMailAndForwardingNumber(getCurrentVoicemailProviderKey(), newSettings);
         }
     }
 
@@ -531,20 +539,6 @@
         return getString(R.string.voicemail_abbreviated) + " " + vmDisplay;
     }
 
-
-    // override the startsubactivity call to make changes in state consistent.
-    @Override
-    public void startActivityForResult(Intent intent, int requestCode) {
-        if (requestCode == -1) {
-            // this is an intent requested from the preference framework.
-            super.startActivityForResult(intent, requestCode);
-            return;
-        }
-
-        if (DBG) log("startSubActivity: starting requested subactivity");
-        super.startActivityForResult(intent, requestCode);
-    }
-
     private void switchToPreviousVoicemailProvider() {
         if (DBG) log("switchToPreviousVoicemailProvider " + mPreviousVMProviderKey);
         if (mPreviousVMProviderKey != null) {
@@ -721,21 +715,6 @@
         super.onActivityResult(requestCode, resultCode, data);
     }
 
-    // Voicemail button logic
-    private void handleVMBtnClickRequest() {
-        // normally called on the dialog close.
-
-        // Since we're stripping the formatting out on the getPhoneNumber()
-        // call now, we won't need to do so here anymore.
-
-        saveVoiceMailAndForwardingNumber(
-                getCurrentVoicemailProviderKey(),
-                new VoicemailProviderSettings(mSubMenuVoicemailSettings.getPhoneNumber(),
-                        VoicemailProviderSettings.NO_FORWARDING)
-        );
-    }
-
-
     /**
      * Wrapper around showDialog() that will silently do nothing if we're
      * not in the foreground.
@@ -928,17 +907,18 @@
         return result;
     }
 
-    private boolean isUpdateRequired(CallForwardInfo oldInfo,
-            CallForwardInfo newInfo) {
-        boolean result = true;
-        if (0 == newInfo.status) {
-            // If we're disabling a type of forwarding, and it's already
-            // disabled for the account, don't make any change
-            if (oldInfo != null && oldInfo.status == 0) {
-                result = false;
-            }
+    private boolean isUpdateRequired(CallForwardInfo oldInfo, CallForwardInfo newInfo) {
+        if (oldInfo == null) {
+            return true;
         }
-        return result;
+
+        // If we're disabling a type of forwarding, don't make any change if it's already disabled.
+        if (newInfo.status == CALL_FORWARD_INFO_INACTIVE_STATUS
+                && oldInfo.status == CALL_FORWARD_INFO_INACTIVE_STATUS) {
+            return false;
+        }
+
+        return true;
     }
 
     private void resetForwardingChangeState() {
@@ -1000,9 +980,7 @@
             switch (msg.what) {
                 case EVENT_VOICEMAIL_CHANGED:
                     mVoicemailChangeResult = result;
-                    mVMChangeCompletedSuccessfully = checkVMChangeSuccess() == null;
-                    if (DBG) log("VM change complete msg, VM change done = " +
-                            String.valueOf(mVMChangeCompletedSuccessfully));
+                    mVMChangeCompletedSuccessfully = isVmChangeSuccess();
                     done = true;
                     break;
                 case EVENT_FORWARDING_CHANGED:
@@ -1013,9 +991,8 @@
                     } else {
                         if (DBG) log("Success in setting fwd# " + msg.arg1);
                     }
-                    final boolean completed = checkForwardingCompleted();
-                    if (completed) {
-                        if (checkFwdChangeSuccess() == null) {
+                    if (isForwardingCompleted()) {
+                        if (isFwdChangeSuccess()) {
                             if (DBG) log("Overall fwd changes completed ok, starting vm change");
                             setVMNumberWithCarrier();
                         } else {
@@ -1048,7 +1025,7 @@
                 if (mForwardingChangeResults != null) {
                     dismissDialogSafely(VOICEMAIL_FWD_SAVING_DIALOG);
                 }
-                handleSetVMOrFwdMessage();
+                handleSetVmOrFwdMessage();
             }
         }
     };
@@ -1080,7 +1057,7 @@
             }
             final boolean done =
                 (!mVMChangeCompletedSuccessfully || mVoicemailChangeResult != null) &&
-                (!mFwdChangesRequireRollback || checkForwardingCompleted());
+                (!mFwdChangesRequireRollback || isForwardingCompleted());
             if (done) {
                 if (DBG) log("All VM reverts done");
                 dismissDialogSafely(VOICEMAIL_REVERTING_DIALOG);
@@ -1090,91 +1067,61 @@
     };
 
     /**
-     * @return true if forwarding change has completed
+     * Return true if there is a change result for every reason for which we expect a result.
      */
-    private boolean checkForwardingCompleted() {
-        boolean result;
+    private boolean isForwardingCompleted() {
         if (mForwardingChangeResults == null) {
-            result = true;
-        } else {
-            // return true iff there is a change result for every reason for
-            // which we expected a result
-            result = true;
-            for (Integer reason : mExpectedChangeResultReasons) {
-                if (mForwardingChangeResults.get(reason) == null) {
-                    result = false;
-                    break;
-                }
+            return true;
+        }
+
+        for (Integer reason : mExpectedChangeResultReasons) {
+            if (mForwardingChangeResults.get(reason) == null) {
+                return false;
             }
         }
-        return result;
+
+        return true;
     }
-    /**
-     * @return error string or null if successful
-     */
-    private String checkFwdChangeSuccess() {
-        String result = null;
-        Iterator<Map.Entry<Integer,AsyncResult>> it =
-            mForwardingChangeResults.entrySet().iterator();
-        while (it.hasNext()) {
-            Map.Entry<Integer,AsyncResult> entry = it.next();
-            Throwable exception = entry.getValue().exception;
+
+    private boolean isFwdChangeSuccess() {
+        if (mForwardingChangeResults == null) {
+            return true;
+        }
+
+        for (AsyncResult result : mForwardingChangeResults.values()) {
+            Throwable exception = result.exception;
             if (exception != null) {
-                result = exception.getMessage();
-                if (result == null) {
-                    result = "";
-                }
-                break;
+                String msg = exception.getMessage();
+                msg = (msg != null) ? msg : "";
+                Log.w(LOG_TAG, "Failed to change forwarding setting. Reason: " + msg);
+                return false;
             }
         }
-        return result;
+        return true;
     }
 
-    /**
-     * @return error string or null if successful
-     */
-    private String checkVMChangeSuccess() {
+    private boolean isVmChangeSuccess() {
         if (mVoicemailChangeResult.exception != null) {
-            final String msg = mVoicemailChangeResult.exception.getMessage();
-            if (msg == null) {
-                return "";
-            }
-            return msg;
+            String msg = mVoicemailChangeResult.exception.getMessage();
+            msg = (msg != null) ? msg : "";
+            Log.w(LOG_TAG, "Failed to change voicemail. Reason: " + msg);
+            return false;
         }
-        return null;
+
+        if (DBG) log("VM change completed successfully.");
+        return true;
     }
 
-    private void handleSetVMOrFwdMessage() {
-        if (DBG) {
-            log("handleSetVMMessage: set VM request complete");
-        }
-        boolean success = true;
-        boolean fwdFailure = false;
-        String exceptionMessage = "";
-        if (mForwardingChangeResults != null) {
-            exceptionMessage = checkFwdChangeSuccess();
-            if (exceptionMessage != null) {
-                success = false;
-                fwdFailure = true;
-            }
-        }
-        if (success) {
-            exceptionMessage = checkVMChangeSuccess();
-            if (exceptionMessage != null) {
-                success = false;
-            }
-        }
-        if (success) {
-            if (DBG) log("change VM success!");
-            handleVMAndFwdSetSuccess(MSG_VM_OK);
+    private void handleSetVmOrFwdMessage() {
+        if (DBG) log("handleSetVMMessage: set VM request complete");
+
+        if (!isFwdChangeSuccess()) {
+            handleVmOrFwdSetError(MSG_FW_SET_EXCEPTION);
+        } else if (!isVmChangeSuccess()) {
+            handleVmOrFwdSetError(MSG_VM_EXCEPTION);
         } else {
-            if (fwdFailure) {
-                Log.w(LOG_TAG, "Failed to change fowarding setting. Reason: " + exceptionMessage);
-                handleVMOrFwdSetError(MSG_FW_SET_EXCEPTION);
-            } else {
-                Log.w(LOG_TAG, "Failed to change voicemail. Reason: " + exceptionMessage);
-                handleVMOrFwdSetError(MSG_VM_EXCEPTION);
-            }
+            if (DBG) log("change VM success!");
+            handleVmAndFwdSetSuccess(MSG_VM_OK);
         }
     }
 
@@ -1185,7 +1132,7 @@
      * @param msgId Message ID used for the specific error case. {@link #MSG_FW_SET_EXCEPTION} or
      * {@link #MSG_VM_EXCEPTION}
      */
-    private void handleVMOrFwdSetError(int msgId) {
+    private void handleVmOrFwdSetError(int msgId) {
         if (mChangingVMorFwdDueToProviderChange) {
             mVMOrFwdSetError = msgId;
             mChangingVMorFwdDueToProviderChange = false;
@@ -1201,9 +1148,9 @@
      * Called when Voicemail Provider and its forwarding settings were successfully finished.
      * This updates a bunch of variables and show "success" dialog.
      */
-    private void handleVMAndFwdSetSuccess(int msg) {
+    private void handleVmAndFwdSetSuccess(int msg) {
         if (DBG) {
-            log("handleVMAndFwdSetSuccess(). current voicemail provider key: "
+            log("handleVmAndFwdSetSuccess(). current voicemail provider key: "
                     + getCurrentVoicemailProviderKey());
         }
         mPreviousVMProviderKey = getCurrentVoicemailProviderKey();
@@ -1717,7 +1664,7 @@
         for (int i = 0; i < resolveInfos.size(); i++) {
             final ResolveInfo ri= resolveInfos.get(i);
             final ActivityInfo currentActivityInfo = ri.activityInfo;
-            final String key = makeKeyForActivity(currentActivityInfo);
+            final String key = currentActivityInfo.name;
             if (key.equals(providerToIgnore)) {
                 if (DBG) log("Ignoring key: " + key);
                 len--;
@@ -1747,7 +1694,7 @@
         values[0] = DEFAULT_VM_PROVIDER_KEY;
         int entryIdx = 1;
         for (int i = 0; i < resolveInfos.size(); i++) {
-            final String key = makeKeyForActivity(resolveInfos.get(i).activityInfo);
+            final String key = resolveInfos.get(i).activityInfo.name;
             if (!mVMProvidersData.containsKey(key)) {
                 continue;
             }
@@ -1770,10 +1717,6 @@
         updateVMPreferenceWidgets(mPreviousVMProviderKey);
     }
 
-    private String makeKeyForActivity(ActivityInfo ai) {
-        return ai.name;
-    }
-
     /**
      * Simulates user clicking on a passed preference.
      * Usually needed when the preference is a dialog preference and we want to invoke
diff --git a/src/com/android/phone/EnableFdnScreen.java b/src/com/android/phone/EnableFdnScreen.java
deleted file mode 100644
index 0db47c3..0000000
--- a/src/com/android/phone/EnableFdnScreen.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * 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.phone;
-
-import android.app.Activity;
-import android.os.AsyncResult;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.text.TextUtils;
-import android.text.method.DigitsKeyListener;
-import android.util.Log;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.internal.telephony.CommandException;
-import com.android.internal.telephony.Phone;
-
-/**
- * UI to enable/disable FDN.
- */
-public class EnableFdnScreen extends Activity {
-    private static final String LOG_TAG = PhoneGlobals.LOG_TAG;
-    private static final boolean DBG = false;
-
-    private static final int ENABLE_FDN_COMPLETE = 100;
-
-    private LinearLayout mPinFieldContainer;
-    private EditText mPin2Field;
-    private TextView mStatusField;
-    private boolean mEnable;
-    private Phone mPhone;
-
-    private Handler mHandler = new Handler() {
-        public void handleMessage(Message msg) {
-            switch (msg.what) {
-                case ENABLE_FDN_COMPLETE:
-                    AsyncResult ar = (AsyncResult) msg.obj;
-                    handleResult(ar);
-                    break;
-            }
-
-            return;
-        }
-    };
-
-    @Override
-    protected void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
-
-        setContentView(R.layout.enable_fdn_screen);
-        setupView();
-
-        mPhone = PhoneGlobals.getPhone();
-        mEnable = !mPhone.getIccCard().getIccFdnEnabled();
-
-        int id = mEnable ? R.string.enable_fdn : R.string.disable_fdn;
-        setTitle(getResources().getText(id));
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
-        mPhone = PhoneGlobals.getPhone();
-    }
-
-    private void setupView() {
-        mPin2Field = (EditText) findViewById(R.id.pin);
-        mPin2Field.setKeyListener(DigitsKeyListener.getInstance());
-        mPin2Field.setMovementMethod(null);
-        mPin2Field.setOnClickListener(mClicked);
-
-        mPinFieldContainer = (LinearLayout) findViewById(R.id.pinc);
-        mStatusField = (TextView) findViewById(R.id.status);
-    }
-
-    private void showStatus(CharSequence statusMsg) {
-        if (statusMsg != null) {
-            mStatusField.setText(statusMsg);
-            mStatusField.setVisibility(View.VISIBLE);
-            mPinFieldContainer.setVisibility(View.GONE);
-        } else {
-            mPinFieldContainer.setVisibility(View.VISIBLE);
-            mStatusField.setVisibility(View.GONE);
-        }
-    }
-
-    private String getPin2() {
-        return mPin2Field.getText().toString();
-    }
-
-    private void enableFdn() {
-        Message callback = Message.obtain(mHandler, ENABLE_FDN_COMPLETE);
-        mPhone.getIccCard().setIccFdnEnabled(mEnable, getPin2(), callback);
-        if (DBG) log("enableFdn: please wait...");
-    }
-
-    private void handleResult(AsyncResult ar) {
-        if (ar.exception == null) {
-            if (DBG) log("handleResult: success!");
-            showStatus(getResources().getText(mEnable ?
-                            R.string.enable_fdn_ok : R.string.disable_fdn_ok));
-        } else if (ar.exception instanceof CommandException
-                /* && ((CommandException)ar.exception).getCommandError() ==
-                    CommandException.Error.GENERIC_FAILURE */ ) {
-            if (DBG) log("handleResult: failed!");
-            showStatus(getResources().getText(
-                    R.string.pin_failed));
-        }
-
-        mHandler.postDelayed(new Runnable() {
-            public void run() {
-                finish();
-            }
-        }, 3000);
-    }
-
-    private View.OnClickListener mClicked = new View.OnClickListener() {
-        public void onClick(View v) {
-            if (TextUtils.isEmpty(mPin2Field.getText())) {
-                return;
-            }
-
-            showStatus(getResources().getText(
-                    R.string.enable_in_progress));
-
-            enableFdn();
-        }
-    };
-
-    private void log(String msg) {
-        Log.d(LOG_TAG, "[EnableSimPin] " + msg);
-    }
-}
diff --git a/src/com/android/phone/PhoneGlobals.java b/src/com/android/phone/PhoneGlobals.java
index 55449d7..62eb272 100644
--- a/src/com/android/phone/PhoneGlobals.java
+++ b/src/com/android/phone/PhoneGlobals.java
@@ -68,7 +68,7 @@
  * phone process.
  */
 public class PhoneGlobals extends ContextWrapper {
-    /* package */ static final String LOG_TAG = "PhoneApp";
+    public static final String LOG_TAG = "PhoneApp";
 
     /**
      * Phone app-wide debug level:
@@ -481,7 +481,7 @@
     /**
      * Returns the Phone associated with this instance
      */
-    static Phone getPhone() {
+    public static Phone getPhone() {
         return getInstance().phone;
     }
 
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index b6a4498..f598daf 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -773,7 +773,7 @@
         boolean isValid = false;
         List<SubInfoRecord> slist = SubscriptionManager.getActiveSubInfoList();
         for (SubInfoRecord subInfoRecord : slist) {
-            if (subInfoRecord.subId == subId) {
+            if (subInfoRecord.getSubscriptionId() == subId) {
                 isValid = true;
                 break;
             }
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 5f5a32e..b3b1d80 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -291,11 +291,10 @@
     }
 
     private void initAccountList() {
-        List<SubInfoRecord> subscriptions = SubscriptionManager.getActiveSubInfoList();
-        for (int i = 0; i < subscriptions.size(); i++) {
-            String label = subscriptions.get(i).getLabel();
+        for (SubInfoRecord subscription : SubscriptionManager.getActiveSubInfoList()) {
+            String label = subscription.getDisplayName().toString();
             Intent intent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS);
-            intent.putExtra(CallFeaturesSetting.SUB_ID_EXTRA, subscriptions.get(i).subId);
+            intent.putExtra(CallFeaturesSetting.SUB_ID_EXTRA, subscription.getSubscriptionId());
             intent.putExtra(CallFeaturesSetting.SUB_LABEL_EXTRA, label);
 
             Preference accountPreference = new Preference(mApplicationContext);
diff --git a/src/com/android/phone/DeleteFdnContactScreen.java b/src/com/android/phone/settings/fdn/DeleteFdnContactScreen.java
similarity index 97%
rename from src/com/android/phone/DeleteFdnContactScreen.java
rename to src/com/android/phone/settings/fdn/DeleteFdnContactScreen.java
index 074078c..c0fc1e8 100644
--- a/src/com/android/phone/DeleteFdnContactScreen.java
+++ b/src/com/android/phone/settings/fdn/DeleteFdnContactScreen.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.phone.settings.fdn;
 
 import android.app.Activity;
 import android.content.AsyncQueryHandler;
@@ -29,6 +29,9 @@
 import android.view.Window;
 import android.widget.Toast;
 
+import com.android.phone.PhoneGlobals;
+import com.android.phone.R;
+
 import static android.view.Window.PROGRESS_VISIBILITY_OFF;
 import static android.view.Window.PROGRESS_VISIBILITY_ON;
 
diff --git a/src/com/android/phone/EditFdnContactScreen.java b/src/com/android/phone/settings/fdn/EditFdnContactScreen.java
similarity index 98%
rename from src/com/android/phone/EditFdnContactScreen.java
rename to src/com/android/phone/settings/fdn/EditFdnContactScreen.java
index 753ae3f..3064a7a 100644
--- a/src/com/android/phone/EditFdnContactScreen.java
+++ b/src/com/android/phone/settings/fdn/EditFdnContactScreen.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.phone.settings.fdn;
 
 import static android.view.Window.PROGRESS_VISIBILITY_OFF;
 import static android.view.Window.PROGRESS_VISIBILITY_ON;
@@ -47,6 +47,8 @@
 import android.widget.TextView;
 import android.widget.Toast;
 
+import com.android.phone.PhoneGlobals;
+import com.android.phone.R;
 import com.android.internal.telephony.Phone;
 import com.android.internal.telephony.PhoneFactory;
 
diff --git a/src/com/android/phone/EditPinPreference.java b/src/com/android/phone/settings/fdn/EditPinPreference.java
similarity index 92%
rename from src/com/android/phone/EditPinPreference.java
rename to src/com/android/phone/settings/fdn/EditPinPreference.java
index af0040d..eaa3507 100644
--- a/src/com/android/phone/EditPinPreference.java
+++ b/src/com/android/phone/settings/fdn/EditPinPreference.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.phone.settings.fdn;
 
 import android.app.AlertDialog;
 import android.content.Context;
@@ -26,27 +26,29 @@
 import android.view.View;
 import android.widget.EditText;
 
+import com.android.phone.R;
+
 import java.util.Map;
 
 /**
  * Class similar to the com.android.settings.EditPinPreference
- * class, with a couple of modifications, including a different layout 
+ * class, with a couple of modifications, including a different layout
  * for the dialog.
  */
 public class EditPinPreference extends EditTextPreference {
 
     private boolean shouldHideButtons;
-    
+
     interface OnPinEnteredListener {
         void onPinEntered(EditPinPreference preference, boolean positiveResult);
     }
-    
+
     private OnPinEnteredListener mPinListener;
 
     public void setOnPinEnteredListener(OnPinEnteredListener listener) {
         mPinListener = listener;
     }
-    
+
     public EditPinPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
@@ -54,16 +56,16 @@
     public EditPinPreference(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
     }
-    
+
     /**
-     * Overridden to setup the correct dialog layout, as well as setting up 
+     * Overridden to setup the correct dialog layout, as well as setting up
      * other properties for the pin / puk entry field.
      */
     @Override
     protected View onCreateDialogView() {
         // set the dialog layout
         setDialogLayoutResource(R.layout.pref_dialog_editpin);
-        
+
         View dialog = super.onCreateDialogView();
 
         getEditText().setInputType(InputType.TYPE_CLASS_NUMBER |
@@ -71,26 +73,26 @@
 
         return dialog;
     }
-    
+
     @Override
     protected void onBindDialogView(View view) {
         super.onBindDialogView(view);
-        
+
         // If the layout does not contain an edittext, hide the buttons.
         shouldHideButtons = (view.findViewById(android.R.id.edit) == null);
     }
-    
+
     @Override
     protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
         super.onPrepareDialogBuilder(builder);
-        
+
         // hide the buttons if we need to.
         if (shouldHideButtons) {
             builder.setPositiveButton(null, this);
             builder.setNegativeButton(null, this);
         }
     }
-    
+
     @Override
     protected void onDialogClosed(boolean positiveResult) {
         super.onDialogClosed(positiveResult);
@@ -98,11 +100,11 @@
             mPinListener.onPinEntered(this, positiveResult);
         }
     }
-    
+
     /**
-     * Externally visible method to bring up the dialog to 
-     * for multi-step / multi-dialog requests (like changing 
-     * the SIM pin). 
+     * Externally visible method to bring up the dialog to
+     * for multi-step / multi-dialog requests (like changing
+     * the SIM pin).
      */
     public void showPinDialog() {
         showDialog(null);
diff --git a/src/com/android/phone/FdnList.java b/src/com/android/phone/settings/fdn/FdnList.java
similarity index 97%
rename from src/com/android/phone/FdnList.java
rename to src/com/android/phone/settings/fdn/FdnList.java
index 9748898..0f189d4 100644
--- a/src/com/android/phone/FdnList.java
+++ b/src/com/android/phone/settings/fdn/FdnList.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.phone.settings.fdn;
 
 import android.app.ActionBar;
 import android.content.Intent;
@@ -26,6 +26,9 @@
 import android.view.View;
 import android.widget.ListView;
 
+import com.android.phone.R;
+import com.android.phone.ADNList;
+
 /**
  * Fixed Dialing Number (FDN) List UI for the Phone app. FDN is a feature of the service provider
  * that allows a user to specify a limited set of phone numbers that the SIM can dial.
diff --git a/src/com/android/phone/FdnSetting.java b/src/com/android/phone/settings/fdn/FdnSetting.java
similarity index 98%
rename from src/com/android/phone/FdnSetting.java
rename to src/com/android/phone/settings/fdn/FdnSetting.java
index a471093..35e15e5 100644
--- a/src/com/android/phone/FdnSetting.java
+++ b/src/com/android/phone/settings/fdn/FdnSetting.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.phone.settings.fdn;
 
 import android.app.ActionBar;
 import android.app.AlertDialog;
@@ -32,6 +32,9 @@
 
 import com.android.internal.telephony.CommandException;
 import com.android.internal.telephony.Phone;
+import com.android.phone.CallFeaturesSetting;
+import com.android.phone.PhoneGlobals;
+import com.android.phone.R;
 
 /**
  * FDN settings UI for the Phone app.
diff --git a/src/com/android/phone/GetPin2Screen.java b/src/com/android/phone/settings/fdn/GetPin2Screen.java
similarity index 96%
rename from src/com/android/phone/GetPin2Screen.java
rename to src/com/android/phone/settings/fdn/GetPin2Screen.java
index bf2e170..5959a51 100644
--- a/src/com/android/phone/GetPin2Screen.java
+++ b/src/com/android/phone/settings/fdn/GetPin2Screen.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.android.phone;
+package com.android.phone.settings.fdn;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -31,6 +31,9 @@
 import android.widget.EditText;
 import android.widget.TextView;
 
+import com.android.phone.PhoneGlobals;
+import com.android.phone.R;
+
 /**
  * Pin2 entry screen.
  */
diff --git a/src/com/android/services/telephony/TelecomAccountRegistry.java b/src/com/android/services/telephony/TelecomAccountRegistry.java
index 746c8bc..45d285f 100644
--- a/src/com/android/services/telephony/TelecomAccountRegistry.java
+++ b/src/com/android/services/telephony/TelecomAccountRegistry.java
@@ -131,8 +131,8 @@
                 // slotId from the subId or the phoneId in all instances.
                 SubInfoRecord record = SubscriptionManager.getSubInfoForSubscriber(subId);
                 if (record != null) {
-                    subDisplayName = record.displayName;
-                    slotId = record.slotId;
+                    subDisplayName = record.getDisplayName().toString();
+                    slotId = record.getSubscriptionId();
 
                     // Assign a "fake" color while the underlying Telephony stuff is refactored.
                     color = makeFakeColor(subId);