Remove PreferenceActivity
Its broken and isn't worth maintaining, instead port the few things using it over to SettingsPreferenceActivity with wrapping blank Activities like the rest of Settings. Change-Id: Ic82f0dcb63ed9b4078f7da6a79c0c52f0130e8d1 Fixes: 28779941
This commit is contained in:
		@@ -327,7 +327,7 @@
 | 
			
		||||
                android:value="true" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name=".wifi.WifiInfo"
 | 
			
		||||
        <activity android:name=".Settings$WifiInfoActivity"
 | 
			
		||||
                android:theme="@style/Theme.SubSettingsDialogWhenLarge"
 | 
			
		||||
                android:taskAffinity="com.android.settings"
 | 
			
		||||
                android:parentActivityName="Settings$WifiSettingsActivity">
 | 
			
		||||
@@ -336,6 +336,8 @@
 | 
			
		||||
                <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                       android:value="com.android.settings.wifi.WifiInfo" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name=".wifi.WifiConfigInfo"
 | 
			
		||||
@@ -349,13 +351,15 @@
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name=".wifi.WifiAPITest"
 | 
			
		||||
        <activity android:name=".Settings$WifiAPITestActivity"
 | 
			
		||||
                android:theme="@style/Theme.SubSettingsDialogWhenLarge">
 | 
			
		||||
            <intent-filter>
 | 
			
		||||
                <action android:name="android.intent.action.MAIN"/>
 | 
			
		||||
                <category android:name="android.intent.category.DEVELOPMENT_PREFERENCE" />
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                       android:value="com.android.settings.wifi.WifiAPITest" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name=".wifi.WifiStatusTest"
 | 
			
		||||
@@ -1448,7 +1452,7 @@
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
        </activity-alias>
 | 
			
		||||
 | 
			
		||||
        <activity android:name="IccLockSettings"
 | 
			
		||||
        <activity android:name="Settings$IccLockSettingsActivity"
 | 
			
		||||
                android:label="@string/sim_lock_settings"
 | 
			
		||||
                android:theme="@style/Theme.SubSettingsDialogWhenLarge"
 | 
			
		||||
                android:process="com.android.phone">
 | 
			
		||||
@@ -1457,6 +1461,8 @@
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
                <category android:name="android.intent.category.VOICE_LAUNCH" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                android:value="com.android.settings.IccLockSettings" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name="Settings$AccessibilitySettingsActivity"
 | 
			
		||||
@@ -1739,7 +1745,7 @@
 | 
			
		||||
        <activity android:name=".EncryptionInterstitial"/>
 | 
			
		||||
 | 
			
		||||
        <!-- Runs in the phone process since it needs access to the Phone object -->
 | 
			
		||||
        <activity android:name=".deviceinfo.Status"
 | 
			
		||||
        <activity android:name=".Settings$StatusActivity"
 | 
			
		||||
                android:label="@string/device_status_activity_title"
 | 
			
		||||
                android:theme="@style/Theme.SubSettingsDialogWhenLarge"
 | 
			
		||||
                android:process="com.android.phone">
 | 
			
		||||
@@ -1748,10 +1754,12 @@
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
                <category android:name="android.intent.category.VOICE_LAUNCH" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                android:value="com.android.settings.deviceinfo.Status" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <!-- Runs in the phone process since it needs access to the Phone object -->
 | 
			
		||||
        <activity android:name=".deviceinfo.SimStatus"
 | 
			
		||||
        <activity android:name=".Settings$SimStatusActivity"
 | 
			
		||||
                android:label="@string/sim_status_title"
 | 
			
		||||
                android:theme="@style/Theme.SubSettingsDialogWhenLarge"
 | 
			
		||||
                android:process="com.android.phone">
 | 
			
		||||
@@ -1760,10 +1768,12 @@
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
                <category android:name="android.intent.category.VOICE_LAUNCH" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                android:value="com.android.settings.deviceinfo.SimStatus" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <!-- Runs in the phone process since it needs access to the Phone object -->
 | 
			
		||||
        <activity android:name=".deviceinfo.ImeiInformation"
 | 
			
		||||
        <activity android:name=".Settings$ImeiInformationActivity"
 | 
			
		||||
                android:label="@string/imei_information_title"
 | 
			
		||||
                android:theme="@style/Theme.SubSettingsDialogWhenLarge"
 | 
			
		||||
                android:process="com.android.phone">
 | 
			
		||||
@@ -1772,6 +1782,8 @@
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
                <category android:name="android.intent.category.VOICE_LAUNCH" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                android:value="com.android.settings.deviceinfo.ImeiInformation" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name="Settings$StorageSettingsActivity"
 | 
			
		||||
@@ -1876,7 +1888,7 @@
 | 
			
		||||
                android:exported="true"
 | 
			
		||||
                android:permission="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
 | 
			
		||||
 | 
			
		||||
        <activity android:name="ApnEditor"
 | 
			
		||||
        <activity android:name="Settings$ApnEditorActivity"
 | 
			
		||||
                android:label="@string/apn_edit">
 | 
			
		||||
            <intent-filter>
 | 
			
		||||
                <action android:name="android.intent.action.VIEW" />
 | 
			
		||||
@@ -1890,6 +1902,8 @@
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
                <data android:mimeType="vnd.android.cursor.dir/telephony-carrier" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                       android:value="com.android.settings.ApnEditor" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name="Settings$DevelopmentSettingsActivity"
 | 
			
		||||
@@ -2154,11 +2168,13 @@
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name="TestingSettings" android:label="@string/testing">
 | 
			
		||||
        <activity android:name="Settings$TestingSettingsActivity" android:label="@string/testing">
 | 
			
		||||
            <intent-filter>
 | 
			
		||||
                <action android:name="android.intent.action.MAIN" />
 | 
			
		||||
                <category android:name="android.intent.category.DEFAULT" />
 | 
			
		||||
            </intent-filter>
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                android:value="com.android.settings.TestingSettings" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <receiver android:name="TestingSettingsBroadcastReceiver">
 | 
			
		||||
@@ -2319,10 +2335,13 @@
 | 
			
		||||
                android:value="true" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name="com.android.settings.accounts.ChooseAccountActivity"
 | 
			
		||||
        <activity android:name="Settings$ChooseAccountActivity"
 | 
			
		||||
            android:label="@string/header_add_an_account"
 | 
			
		||||
            android:configChanges="orientation|keyboardHidden|screenSize"
 | 
			
		||||
            android:theme="@style/Theme.SubSettingsDialogWhenLarge"/>
 | 
			
		||||
            android:theme="@style/Theme.SubSettingsDialogWhenLarge">
 | 
			
		||||
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
 | 
			
		||||
                       android:value="com.android.settings.accounts.ChooseAccountActivity" />
 | 
			
		||||
        </activity>
 | 
			
		||||
 | 
			
		||||
        <activity android:name=".CryptKeeper"
 | 
			
		||||
                  androidprv:systemUserOnly="true"
 | 
			
		||||
 
 | 
			
		||||
@@ -47,7 +47,7 @@
 | 
			
		||||
            android:layout_height="0dip" />
 | 
			
		||||
 | 
			
		||||
        <FrameLayout
 | 
			
		||||
            android:id="@+id/main_content"
 | 
			
		||||
            android:id="@+id/prefs_container"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="0dip"
 | 
			
		||||
            android:layout_weight="1"
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@
 | 
			
		||||
                android:summary="@string/device_status_summary">
 | 
			
		||||
            <intent android:action="android.intent.action.MAIN"
 | 
			
		||||
                    android:targetPackage="com.android.settings"
 | 
			
		||||
                    android:targetClass="com.android.settings.deviceinfo.Status" />
 | 
			
		||||
                    android:targetClass="com.android.settings.Settings$StatusActivity" />
 | 
			
		||||
        </PreferenceScreen>
 | 
			
		||||
 | 
			
		||||
        <!-- Manual -->
 | 
			
		||||
 
 | 
			
		||||
@@ -33,13 +33,13 @@
 | 
			
		||||
        android:title="@string/sim_status_title"
 | 
			
		||||
        android:persistent="false">
 | 
			
		||||
        <intent android:targetPackage="com.android.settings"
 | 
			
		||||
            android:targetClass="com.android.settings.deviceinfo.SimStatus" />
 | 
			
		||||
            android:targetClass="com.android.settings.Settings$SimStatusActivity" />
 | 
			
		||||
    </PreferenceScreen>
 | 
			
		||||
    <PreferenceScreen android:key="imei_info"
 | 
			
		||||
        android:title="@string/imei_information_title"
 | 
			
		||||
        android:persistent="false">
 | 
			
		||||
        <intent android:targetPackage="com.android.settings"
 | 
			
		||||
            android:targetClass="com.android.settings.deviceinfo.ImeiInformation" />
 | 
			
		||||
            android:targetClass="com.android.settings.Settings$ImeiInformationActivity" />
 | 
			
		||||
    </PreferenceScreen>
 | 
			
		||||
    <com.android.settings.CopyablePreference android:key="wifi_ip_address"
 | 
			
		||||
        android:enabled="false"
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@
 | 
			
		||||
 | 
			
		||||
            <intent android:action="android.intent.action.MAIN"
 | 
			
		||||
                    android:targetPackage="com.android.settings"
 | 
			
		||||
                    android:targetClass="com.android.settings.IccLockSettings"/>
 | 
			
		||||
                    android:targetClass="com.android.settings.Settings$IccLockSettingsActivity"/>
 | 
			
		||||
 | 
			
		||||
        </Preference>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@
 | 
			
		||||
        <intent
 | 
			
		||||
                android:action="android.intent.action.MAIN"
 | 
			
		||||
                android:targetPackage="com.android.settings"
 | 
			
		||||
                android:targetClass="com.android.settings.wifi.WifiInfo" />
 | 
			
		||||
                android:targetClass="com.android.settings.Settings$WifiInfoActivity" />
 | 
			
		||||
    </PreferenceScreen>
 | 
			
		||||
 | 
			
		||||
    <!--    
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ android:key="parent">
 | 
			
		||||
                <intent
 | 
			
		||||
                android:action="android.intent.action.MAIN"
 | 
			
		||||
                android:targetPackage="com.android.settings"
 | 
			
		||||
                android:targetClass="com.android.settings.wifi.WifiAPITest" />
 | 
			
		||||
                android:targetClass="com.android.settings.Settings$WifiAPITestActivity" />
 | 
			
		||||
    </Preference>
 | 
			
		||||
 | 
			
		||||
    <Preference
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,12 @@
 | 
			
		||||
 | 
			
		||||
package com.android.settings;
 | 
			
		||||
 | 
			
		||||
import static android.app.Activity.RESULT_OK;
 | 
			
		||||
import static android.content.Context.TELEPHONY_SERVICE;
 | 
			
		||||
 | 
			
		||||
import android.app.AlertDialog;
 | 
			
		||||
import android.app.Dialog;
 | 
			
		||||
import android.app.DialogFragment;
 | 
			
		||||
import android.content.ContentUris;
 | 
			
		||||
import android.content.ContentValues;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
@@ -31,6 +35,7 @@ import android.support.v14.preference.SwitchPreference;
 | 
			
		||||
import android.support.v7.preference.EditTextPreference;
 | 
			
		||||
import android.support.v7.preference.ListPreference;
 | 
			
		||||
import android.support.v7.preference.Preference;
 | 
			
		||||
import android.support.v7.preference.Preference.OnPreferenceChangeListener;
 | 
			
		||||
import android.telephony.ServiceState;
 | 
			
		||||
import android.telephony.SubscriptionManager;
 | 
			
		||||
import android.telephony.TelephonyManager;
 | 
			
		||||
@@ -38,14 +43,18 @@ import android.text.TextUtils;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
import android.view.KeyEvent;
 | 
			
		||||
import android.view.Menu;
 | 
			
		||||
import android.view.MenuInflater;
 | 
			
		||||
import android.view.MenuItem;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.View.OnKeyListener;
 | 
			
		||||
 | 
			
		||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
        implements Preference.OnPreferenceChangeListener {
 | 
			
		||||
public class ApnEditor extends SettingsPreferenceFragment
 | 
			
		||||
        implements OnPreferenceChangeListener, OnKeyListener {
 | 
			
		||||
 | 
			
		||||
    private final static String TAG = ApnEditor.class.getSimpleName();
 | 
			
		||||
 | 
			
		||||
@@ -60,7 +69,6 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
    private static final int MENU_DELETE = Menu.FIRST;
 | 
			
		||||
    private static final int MENU_SAVE = Menu.FIRST + 1;
 | 
			
		||||
    private static final int MENU_CANCEL = Menu.FIRST + 2;
 | 
			
		||||
    private static final int ERROR_DIALOG_ID = 0;
 | 
			
		||||
 | 
			
		||||
    private static String sNotSet;
 | 
			
		||||
    private EditTextPreference mName;
 | 
			
		||||
@@ -152,7 +160,7 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle icicle) {
 | 
			
		||||
    public void onCreate(Bundle icicle) {
 | 
			
		||||
        super.onCreate(icicle);
 | 
			
		||||
 | 
			
		||||
        addPreferencesFromResource(R.xml.apn_editor);
 | 
			
		||||
@@ -242,7 +250,7 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        mCursor = managedQuery(mUri, sProjection, null, null);
 | 
			
		||||
        mCursor = getActivity().managedQuery(mUri, sProjection, null, null);
 | 
			
		||||
        mCursor.moveToFirst();
 | 
			
		||||
 | 
			
		||||
        mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
 | 
			
		||||
@@ -526,8 +534,8 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onCreateOptionsMenu(Menu menu) {
 | 
			
		||||
        super.onCreateOptionsMenu(menu);
 | 
			
		||||
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
 | 
			
		||||
        super.onCreateOptionsMenu(menu, inflater);
 | 
			
		||||
        // If it's a new APN, then cancel will delete the new entry in onPause
 | 
			
		||||
        if (!mNewApn) {
 | 
			
		||||
            menu.add(0, MENU_DELETE, 0, R.string.menu_delete)
 | 
			
		||||
@@ -537,7 +545,6 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
            .setIcon(android.R.drawable.ic_menu_save);
 | 
			
		||||
        menu.add(0, MENU_CANCEL, 0, R.string.menu_cancel)
 | 
			
		||||
            .setIcon(android.R.drawable.ic_menu_close_clear_cancel);
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -562,7 +569,13 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onKeyDown(int keyCode, KeyEvent event) {
 | 
			
		||||
    public void onViewCreated(View view, Bundle savedInstanceState) {
 | 
			
		||||
        super.onViewCreated(view, savedInstanceState);
 | 
			
		||||
        view.setOnKeyListener(this);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean onKey(View v, int keyCode, KeyEvent event) {
 | 
			
		||||
        if (event.getAction() != KeyEvent.ACTION_DOWN) return false;
 | 
			
		||||
        switch (keyCode) {
 | 
			
		||||
            case KeyEvent.KEYCODE_BACK: {
 | 
			
		||||
                if (validateAndSave(false)) {
 | 
			
		||||
@@ -571,11 +584,11 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return super.onKeyDown(keyCode, event);
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onSaveInstanceState(Bundle icicle) {
 | 
			
		||||
    public void onSaveInstanceState(Bundle icicle) {
 | 
			
		||||
        super.onSaveInstanceState(icicle);
 | 
			
		||||
        if (validateAndSave(true)) {
 | 
			
		||||
            icicle.putInt(SAVED_POS, mCursor.getInt(ID_INDEX));
 | 
			
		||||
@@ -595,7 +608,7 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
        String mnc = checkNotSet(mMnc.getText());
 | 
			
		||||
 | 
			
		||||
        if (getErrorMsg() != null && !force) {
 | 
			
		||||
            showDialog(ERROR_DIALOG_ID);
 | 
			
		||||
            ErrorDialog.showError(this);
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -703,35 +716,6 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
        return errorMsg;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected Dialog onCreateDialog(int id) {
 | 
			
		||||
 | 
			
		||||
        if (id == ERROR_DIALOG_ID) {
 | 
			
		||||
            String msg = getErrorMsg();
 | 
			
		||||
 | 
			
		||||
            return new AlertDialog.Builder(this)
 | 
			
		||||
                    .setTitle(R.string.error_title)
 | 
			
		||||
                    .setPositiveButton(android.R.string.ok, null)
 | 
			
		||||
                    .setMessage(msg)
 | 
			
		||||
                    .create();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return super.onCreateDialog(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onPrepareDialog(int id, Dialog dialog) {
 | 
			
		||||
        super.onPrepareDialog(id, dialog);
 | 
			
		||||
 | 
			
		||||
        if (id == ERROR_DIALOG_ID) {
 | 
			
		||||
            String msg = getErrorMsg();
 | 
			
		||||
 | 
			
		||||
            if (msg != null) {
 | 
			
		||||
                ((AlertDialog)dialog).setMessage(msg);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void deleteApn() {
 | 
			
		||||
        getContentResolver().delete(mUri, null, null);
 | 
			
		||||
        finish();
 | 
			
		||||
@@ -765,4 +749,24 @@ public class ApnEditor extends InstrumentedPreferenceActivity
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class ErrorDialog extends DialogFragment {
 | 
			
		||||
 | 
			
		||||
        public static void showError(ApnEditor editor) {
 | 
			
		||||
            ErrorDialog dialog = new ErrorDialog();
 | 
			
		||||
            dialog.setTargetFragment(editor, 0);
 | 
			
		||||
            dialog.show(editor.getFragmentManager(), "error");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public Dialog onCreateDialog(Bundle savedInstanceState) {
 | 
			
		||||
            String msg = ((ApnEditor) getTargetFragment()).getErrorMsg();
 | 
			
		||||
 | 
			
		||||
            return new AlertDialog.Builder(getContext())
 | 
			
		||||
                    .setTitle(R.string.error_title)
 | 
			
		||||
                    .setPositiveButton(android.R.string.ok, null)
 | 
			
		||||
                    .setMessage(msg)
 | 
			
		||||
                    .create();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -31,7 +31,9 @@ import android.telephony.SubscriptionInfo;
 | 
			
		||||
import android.telephony.SubscriptionManager;
 | 
			
		||||
import android.telephony.TelephonyManager;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.ListView;
 | 
			
		||||
import android.widget.TabHost;
 | 
			
		||||
import android.widget.TabHost.OnTabChangeListener;
 | 
			
		||||
@@ -53,7 +55,7 @@ import com.android.internal.telephony.TelephonyIntents;
 | 
			
		||||
 * these operations.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
public class IccLockSettings extends SettingsPreferenceFragment
 | 
			
		||||
        implements EditPinPreference.OnPinEnteredListener {
 | 
			
		||||
    private static final String TAG = "IccLockSettings";
 | 
			
		||||
    private static final boolean DBG = true;
 | 
			
		||||
@@ -153,12 +155,8 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
    public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        final Context context = getApplicationContext();
 | 
			
		||||
        final TelephonyManager tm =
 | 
			
		||||
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
 | 
			
		||||
        final int numSims = tm.getSimCount();
 | 
			
		||||
 | 
			
		||||
        if (Utils.isMonkeyRunning()) {
 | 
			
		||||
            finish();
 | 
			
		||||
@@ -198,33 +196,53 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
        // Don't need any changes to be remembered
 | 
			
		||||
        getPreferenceScreen().setPersistent(false);
 | 
			
		||||
 | 
			
		||||
        if (numSims > 1) {
 | 
			
		||||
            setContentView(R.layout.icc_lock_tabs);
 | 
			
		||||
        mRes = getResources();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
            mTabHost = (TabHost) findViewById(android.R.id.tabhost);
 | 
			
		||||
            mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
 | 
			
		||||
            mListView = (ListView) findViewById(android.R.id.list);
 | 
			
		||||
    @Override
 | 
			
		||||
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
 | 
			
		||||
            Bundle savedInstanceState) {
 | 
			
		||||
 | 
			
		||||
        final TelephonyManager tm =
 | 
			
		||||
                (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
 | 
			
		||||
        final int numSims = tm.getSimCount();
 | 
			
		||||
        if (numSims > 1) {
 | 
			
		||||
            View view = inflater.inflate(R.layout.icc_lock_tabs, container, false);
 | 
			
		||||
            final ViewGroup prefs_container = (ViewGroup) view.findViewById(R.id.prefs_container);
 | 
			
		||||
            Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
 | 
			
		||||
            View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
 | 
			
		||||
            prefs_container.addView(prefs);
 | 
			
		||||
 | 
			
		||||
            mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
 | 
			
		||||
            mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs);
 | 
			
		||||
            mListView = (ListView) view.findViewById(android.R.id.list);
 | 
			
		||||
 | 
			
		||||
            mTabHost.setup();
 | 
			
		||||
            mTabHost.setOnTabChangedListener(mTabListener);
 | 
			
		||||
            mTabHost.clearAllTabs();
 | 
			
		||||
 | 
			
		||||
            SubscriptionManager sm = SubscriptionManager.from(this);
 | 
			
		||||
            SubscriptionManager sm = SubscriptionManager.from(getContext());
 | 
			
		||||
            for (int i = 0; i < numSims; ++i) {
 | 
			
		||||
                final SubscriptionInfo subInfo = sm.getActiveSubscriptionInfoForSimSlotIndex(i);
 | 
			
		||||
                mTabHost.addTab(buildTabSpec(String.valueOf(i),
 | 
			
		||||
                        String.valueOf(subInfo == null
 | 
			
		||||
                            ? context.getString(R.string.sim_editor_title, i + 1)
 | 
			
		||||
                            ? getContext().getString(R.string.sim_editor_title, i + 1)
 | 
			
		||||
                            : subInfo.getDisplayName())));
 | 
			
		||||
            }
 | 
			
		||||
            final SubscriptionInfo sir = sm.getActiveSubscriptionInfoForSimSlotIndex(0);
 | 
			
		||||
 | 
			
		||||
            mPhone = (sir == null) ? null
 | 
			
		||||
                : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId()));
 | 
			
		||||
            return view;
 | 
			
		||||
        } else {
 | 
			
		||||
            mPhone = PhoneFactory.getDefaultPhone();
 | 
			
		||||
            return super.onCreateView(inflater, container, savedInstanceState);
 | 
			
		||||
        }
 | 
			
		||||
        mRes = getResources();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onViewCreated(View view, Bundle savedInstanceState) {
 | 
			
		||||
        super.onViewCreated(view, savedInstanceState);
 | 
			
		||||
        updatePreferences();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -243,13 +261,13 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onResume() {
 | 
			
		||||
    public 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);
 | 
			
		||||
        registerReceiver(mSimStateReceiver, filter);
 | 
			
		||||
        getContext().registerReceiver(mSimStateReceiver, filter);
 | 
			
		||||
 | 
			
		||||
        if (mDialogState != OFF_MODE) {
 | 
			
		||||
            showPinDialog();
 | 
			
		||||
@@ -260,13 +278,13 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onPause() {
 | 
			
		||||
    public void onPause() {
 | 
			
		||||
        super.onPause();
 | 
			
		||||
        unregisterReceiver(mSimStateReceiver);
 | 
			
		||||
        getContext().unregisterReceiver(mSimStateReceiver);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onSaveInstanceState(Bundle out) {
 | 
			
		||||
    public 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
 | 
			
		||||
@@ -412,8 +430,8 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
        if (success) {
 | 
			
		||||
            mPinToggle.setChecked(mToState);
 | 
			
		||||
        } else {
 | 
			
		||||
            Toast.makeText(this, getPinPasswordErrorMessage(attemptsRemaining), Toast.LENGTH_LONG)
 | 
			
		||||
                    .show();
 | 
			
		||||
            Toast.makeText(getContext(), getPinPasswordErrorMessage(attemptsRemaining),
 | 
			
		||||
                    Toast.LENGTH_LONG).show();
 | 
			
		||||
        }
 | 
			
		||||
        mPinToggle.setEnabled(true);
 | 
			
		||||
        resetDialogState();
 | 
			
		||||
@@ -421,11 +439,11 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
 | 
			
		||||
    private void iccPinChanged(boolean success, int attemptsRemaining) {
 | 
			
		||||
        if (!success) {
 | 
			
		||||
            Toast.makeText(this, getPinPasswordErrorMessage(attemptsRemaining),
 | 
			
		||||
            Toast.makeText(getContext(), getPinPasswordErrorMessage(attemptsRemaining),
 | 
			
		||||
                    Toast.LENGTH_LONG)
 | 
			
		||||
                    .show();
 | 
			
		||||
        } else {
 | 
			
		||||
            Toast.makeText(this, mRes.getString(R.string.sim_change_succeeded),
 | 
			
		||||
            Toast.makeText(getContext(), mRes.getString(R.string.sim_change_succeeded),
 | 
			
		||||
                    Toast.LENGTH_SHORT)
 | 
			
		||||
                    .show();
 | 
			
		||||
 | 
			
		||||
@@ -476,7 +494,7 @@ public class IccLockSettings extends InstrumentedPreferenceActivity
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onTabChanged(String tabId) {
 | 
			
		||||
            final int slotId = Integer.parseInt(tabId);
 | 
			
		||||
            final SubscriptionInfo sir = SubscriptionManager.from(getBaseContext())
 | 
			
		||||
            final SubscriptionInfo sir = SubscriptionManager.from(getActivity().getBaseContext())
 | 
			
		||||
                    .getActiveSubscriptionInfoForSimSlotIndex(slotId);
 | 
			
		||||
 | 
			
		||||
            mPhone = (sir == null) ? null
 | 
			
		||||
 
 | 
			
		||||
@@ -1,45 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2015 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.settings;
 | 
			
		||||
 | 
			
		||||
import com.android.internal.logging.MetricsLogger;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Instrumented activity that logs visibility state.
 | 
			
		||||
 */
 | 
			
		||||
public abstract class InstrumentedPreferenceActivity extends PreferenceActivity {
 | 
			
		||||
    /**
 | 
			
		||||
     * Declare the view of this category.
 | 
			
		||||
     *
 | 
			
		||||
     * Categories are defined in {@link com.android.internal.logging.MetricsProto.MetricsEvent}
 | 
			
		||||
     * or if there is no relevant existing category you may define one in
 | 
			
		||||
     * {@link com.android.settings.InstrumentedFragment}.
 | 
			
		||||
     */
 | 
			
		||||
    protected abstract int getMetricsCategory();
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onResume() {
 | 
			
		||||
        super.onResume();
 | 
			
		||||
        MetricsLogger.visible(this, getMetricsCategory());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onPause() {
 | 
			
		||||
        super.onPause();
 | 
			
		||||
        MetricsLogger.hidden(this, getMetricsCategory());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,82 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2015 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.settings;
 | 
			
		||||
 | 
			
		||||
import android.annotation.Nullable;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.support.v7.preference.Preference;
 | 
			
		||||
import android.support.v7.preference.PreferenceScreen;
 | 
			
		||||
 | 
			
		||||
public class PreferenceActivity extends SettingsActivity {
 | 
			
		||||
 | 
			
		||||
    private PreferenceActivityFragment mFragment;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(@Nullable Bundle savedInstanceState) {
 | 
			
		||||
        getIntent().putExtra(EXTRA_SHOW_FRAGMENT, PreferenceActivityFragment.class.getName());
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void addPreferencesFromResource(int resource) {
 | 
			
		||||
        mFragment.addPreferencesFromResource(resource);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Preference findPreference(String preference) {
 | 
			
		||||
        return mFragment.findPreference(preference);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public PreferenceScreen getPreferenceScreen() {
 | 
			
		||||
        return mFragment.getPreferenceScreen();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPreferenceScreen(PreferenceScreen screen) {
 | 
			
		||||
        mFragment.setPreferenceScreen(screen);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean onPreferenceTreeClick(Preference preference) {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected boolean isValidFragment(String fragmentName) {
 | 
			
		||||
        return super.isValidFragment(fragmentName)
 | 
			
		||||
                || PreferenceActivityFragment.class.getName().equals(fragmentName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static class PreferenceActivityFragment extends SettingsPreferenceFragment {
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
 | 
			
		||||
            ((PreferenceActivity) getActivity()).mFragment = this;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public boolean onPreferenceTreeClick(Preference preference) {
 | 
			
		||||
            if (((PreferenceActivity) getActivity()).onPreferenceTreeClick(preference)) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
            return super.onPreferenceTreeClick(preference);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        protected int getMetricsCategory() {
 | 
			
		||||
            if (getActivity() instanceof InstrumentedPreferenceActivity) {
 | 
			
		||||
                return ((InstrumentedPreferenceActivity) getActivity()).getMetricsCategory();
 | 
			
		||||
            }
 | 
			
		||||
            return InstrumentedFragment.PREFERENCE_ACTIVITY_FRAGMENT;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -140,6 +140,16 @@ public class Settings extends SettingsActivity {
 | 
			
		||||
    public static class WallpaperSettingsActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class ManagedProfileSettingsActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
 | 
			
		||||
    public static class ApnEditorActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class ChooseAccountActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class IccLockSettingsActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class ImeiInformationActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class SimStatusActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class StatusActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class TestingSettingsActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class WifiAPITestActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class WifiInfoActivity extends SettingsActivity { /* empty */ }
 | 
			
		||||
 | 
			
		||||
    // Categories.
 | 
			
		||||
    public static class WirelessSettings extends SettingsActivity { /* empty */ }
 | 
			
		||||
    public static class DeviceSettings extends SettingsActivity { /* empty */ }
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,7 @@ import com.android.settings.accessibility.AccessibilitySettingsForSetupWizard;
 | 
			
		||||
import com.android.settings.accessibility.CaptionPropertiesFragment;
 | 
			
		||||
import com.android.settings.accounts.AccountSettings;
 | 
			
		||||
import com.android.settings.accounts.AccountSyncSettings;
 | 
			
		||||
import com.android.settings.accounts.ChooseAccountActivity;
 | 
			
		||||
import com.android.settings.accounts.ManagedProfileSettings;
 | 
			
		||||
import com.android.settings.applications.AdvancedAppSettings;
 | 
			
		||||
import com.android.settings.applications.DrawOverlayDetails;
 | 
			
		||||
@@ -72,9 +73,12 @@ import com.android.settings.bluetooth.BluetoothSettings;
 | 
			
		||||
import com.android.settings.dashboard.DashboardSummary;
 | 
			
		||||
import com.android.settings.dashboard.SearchResultsSummary;
 | 
			
		||||
import com.android.settings.datausage.DataUsageSummary;
 | 
			
		||||
import com.android.settings.deviceinfo.ImeiInformation;
 | 
			
		||||
import com.android.settings.deviceinfo.PrivateVolumeForget;
 | 
			
		||||
import com.android.settings.deviceinfo.PrivateVolumeSettings;
 | 
			
		||||
import com.android.settings.deviceinfo.PublicVolumeSettings;
 | 
			
		||||
import com.android.settings.deviceinfo.SimStatus;
 | 
			
		||||
import com.android.settings.deviceinfo.Status;
 | 
			
		||||
import com.android.settings.deviceinfo.StorageSettings;
 | 
			
		||||
import com.android.settings.fuelgauge.BatterySaverSettings;
 | 
			
		||||
import com.android.settings.fuelgauge.PowerUsageDetail;
 | 
			
		||||
@@ -116,6 +120,8 @@ import com.android.settings.wfd.WifiDisplaySettings;
 | 
			
		||||
import com.android.settings.widget.SwitchBar;
 | 
			
		||||
import com.android.settings.wifi.AdvancedWifiSettings;
 | 
			
		||||
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
 | 
			
		||||
import com.android.settings.wifi.WifiAPITest;
 | 
			
		||||
import com.android.settings.wifi.WifiInfo;
 | 
			
		||||
import com.android.settings.wifi.WifiSettings;
 | 
			
		||||
import com.android.settings.wifi.p2p.WifiP2pSettings;
 | 
			
		||||
import com.android.settingslib.drawer.DashboardCategory;
 | 
			
		||||
@@ -315,6 +321,7 @@ public class SettingsActivity extends SettingsDrawerActivity
 | 
			
		||||
            AppNotificationSettings.class.getName(),
 | 
			
		||||
            OtherSoundSettings.class.getName(),
 | 
			
		||||
            ApnSettings.class.getName(),
 | 
			
		||||
            ApnEditor.class.getName(),
 | 
			
		||||
            WifiCallingSettings.class.getName(),
 | 
			
		||||
            ZenModePrioritySettings.class.getName(),
 | 
			
		||||
            ZenModeAutomationSettings.class.getName(),
 | 
			
		||||
@@ -330,6 +337,14 @@ public class SettingsActivity extends SettingsDrawerActivity
 | 
			
		||||
            WallpaperTypeSettings.class.getName(),
 | 
			
		||||
            VrListenerSettings.class.getName(),
 | 
			
		||||
            ManagedProfileSettings.class.getName(),
 | 
			
		||||
            ChooseAccountActivity.class.getName(),
 | 
			
		||||
            IccLockSettings.class.getName(),
 | 
			
		||||
            ImeiInformation.class.getName(),
 | 
			
		||||
            SimStatus.class.getName(),
 | 
			
		||||
            Status.class.getName(),
 | 
			
		||||
            TestingSettings.class.getName(),
 | 
			
		||||
            WifiAPITest.class.getName(),
 | 
			
		||||
            WifiInfo.class.getName(),
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,7 @@ import android.app.Fragment;
 | 
			
		||||
import android.content.ContentResolver;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.DialogInterface;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.content.pm.PackageManager;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.support.annotation.XmlRes;
 | 
			
		||||
@@ -42,6 +43,7 @@ import android.view.MenuInflater;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.Button;
 | 
			
		||||
 | 
			
		||||
import com.android.settings.applications.LayoutPreference;
 | 
			
		||||
import com.android.settings.widget.FloatingActionButton;
 | 
			
		||||
import com.android.settingslib.HelpUtils;
 | 
			
		||||
@@ -693,6 +695,27 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected Intent getIntent() {
 | 
			
		||||
        if (getActivity() == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
        return getActivity().getIntent();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setResult(int result, Intent intent) {
 | 
			
		||||
        if (getActivity() == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        getActivity().setResult(result, intent);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setResult(int result) {
 | 
			
		||||
        if (getActivity() == null) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        getActivity().setResult(result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected final Context getPrefContext() {
 | 
			
		||||
        return getPreferenceManager().getContext();
 | 
			
		||||
    }
 | 
			
		||||
@@ -704,10 +727,6 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
 | 
			
		||||
            SettingsActivity sa = (SettingsActivity) activity;
 | 
			
		||||
            sa.startPreferencePanel(fragmentClass, extras, titleRes, null, caller, requestCode);
 | 
			
		||||
            return true;
 | 
			
		||||
        } else if (activity instanceof PreferenceActivity) {
 | 
			
		||||
            PreferenceActivity sa = (PreferenceActivity) activity;
 | 
			
		||||
            sa.startPreferencePanel(fragmentClass, extras, titleRes, null, caller, requestCode);
 | 
			
		||||
            return true;
 | 
			
		||||
        } else {
 | 
			
		||||
            Log.w(TAG,
 | 
			
		||||
                    "Parent isn't SettingsActivity nor PreferenceActivity, thus there's no way to "
 | 
			
		||||
 
 | 
			
		||||
@@ -20,15 +20,17 @@ import android.os.Bundle;
 | 
			
		||||
import android.os.UserManager;
 | 
			
		||||
import android.support.v7.preference.PreferenceScreen;
 | 
			
		||||
 | 
			
		||||
public class TestingSettings extends PreferenceActivity {
 | 
			
		||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
 | 
			
		||||
public class TestingSettings extends SettingsPreferenceFragment {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
    public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        
 | 
			
		||||
        addPreferencesFromResource(R.xml.testing_settings);
 | 
			
		||||
 | 
			
		||||
        final UserManager um = UserManager.get(this);
 | 
			
		||||
        final UserManager um = UserManager.get(getContext());
 | 
			
		||||
        if (!um.isAdminUser()) {
 | 
			
		||||
            PreferenceScreen preferenceScreen = (PreferenceScreen)
 | 
			
		||||
                    findPreference("radio_info_settings");
 | 
			
		||||
@@ -36,4 +38,8 @@ public class TestingSettings extends PreferenceActivity {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected int getMetricsCategory() {
 | 
			
		||||
        return MetricsEvent.TESTING;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,6 +6,8 @@ import android.content.Intent;
 | 
			
		||||
 | 
			
		||||
import static com.android.internal.telephony.TelephonyIntents.SECRET_CODE_ACTION;
 | 
			
		||||
 | 
			
		||||
import com.android.settings.Settings.TestingSettingsActivity;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
 | 
			
		||||
  
 | 
			
		||||
@@ -16,7 +18,7 @@ public class TestingSettingsBroadcastReceiver extends BroadcastReceiver {
 | 
			
		||||
    public void onReceive(Context context, Intent intent) {
 | 
			
		||||
        if (intent.getAction().equals(SECRET_CODE_ACTION)) {
 | 
			
		||||
            Intent i = new Intent(Intent.ACTION_MAIN);
 | 
			
		||||
            i.setClass(context, TestingSettings.class);
 | 
			
		||||
            i.setClass(context, TestingSettingsActivity.class);
 | 
			
		||||
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 | 
			
		||||
            context.startActivity(i);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ import android.widget.Toast;
 | 
			
		||||
 | 
			
		||||
import com.android.settings.ChooseLockSettingsHelper;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.Settings;
 | 
			
		||||
import com.android.settings.Utils;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@@ -216,7 +217,7 @@ public class AddAccountSettings extends Activity {
 | 
			
		||||
                getIntent().getStringArrayExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY);
 | 
			
		||||
        final String[] accountTypes =
 | 
			
		||||
                getIntent().getStringArrayExtra(AccountPreferenceBase.ACCOUNT_TYPES_FILTER_KEY);
 | 
			
		||||
        final Intent intent = new Intent(this, ChooseAccountActivity.class);
 | 
			
		||||
        final Intent intent = new Intent(this, Settings.ChooseAccountActivity.class);
 | 
			
		||||
        if (authorities != null) {
 | 
			
		||||
            intent.putExtra(AccountPreferenceBase.AUTHORITIES_FILTER_KEY, authorities);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,10 @@
 | 
			
		||||
 | 
			
		||||
package com.android.settings.accounts;
 | 
			
		||||
 | 
			
		||||
import static android.app.Activity.RESULT_CANCELED;
 | 
			
		||||
import static android.app.Activity.RESULT_OK;
 | 
			
		||||
import static android.content.Intent.EXTRA_USER;
 | 
			
		||||
 | 
			
		||||
import android.accounts.AccountManager;
 | 
			
		||||
import android.accounts.AuthenticatorDescription;
 | 
			
		||||
import android.content.ContentResolver;
 | 
			
		||||
@@ -32,14 +36,15 @@ import android.support.v7.preference.Preference;
 | 
			
		||||
import android.support.v7.preference.PreferenceGroup;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
 | 
			
		||||
import com.google.android.collect.Maps;
 | 
			
		||||
 | 
			
		||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
import com.android.internal.util.CharSequences;
 | 
			
		||||
import com.android.settings.InstrumentedPreferenceActivity;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.SettingsPreferenceFragment;
 | 
			
		||||
import com.android.settings.Utils;
 | 
			
		||||
import com.android.settingslib.RestrictedLockUtils;
 | 
			
		||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 | 
			
		||||
 | 
			
		||||
import com.google.android.collect.Maps;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collections;
 | 
			
		||||
@@ -47,17 +52,13 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import static android.content.Intent.EXTRA_USER;
 | 
			
		||||
 | 
			
		||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Activity asking a user to select an account to be set up.
 | 
			
		||||
 *
 | 
			
		||||
 * An extra {@link UserHandle} can be specified in the intent as {@link EXTRA_USER}, if the user for
 | 
			
		||||
 * which the action needs to be performed is different to the one the Settings App will run in.
 | 
			
		||||
 */
 | 
			
		||||
public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
 | 
			
		||||
public class ChooseAccountActivity extends SettingsPreferenceFragment {
 | 
			
		||||
 | 
			
		||||
    private static final String TAG = "ChooseAccountActivity";
 | 
			
		||||
    private String[] mAuthorities;
 | 
			
		||||
@@ -97,7 +98,7 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle icicle) {
 | 
			
		||||
    public void onCreate(Bundle icicle) {
 | 
			
		||||
        super.onCreate(icicle);
 | 
			
		||||
 | 
			
		||||
        addPreferencesFromResource(R.xml.add_account_settings);
 | 
			
		||||
@@ -112,9 +113,9 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        mAddAccountGroup = getPreferenceScreen();
 | 
			
		||||
        mUm = UserManager.get(this);
 | 
			
		||||
        mUserHandle = Utils.getSecureTargetUser(getActivityToken(), mUm, null /* arguments */,
 | 
			
		||||
                getIntent().getExtras());
 | 
			
		||||
        mUm = UserManager.get(getContext());
 | 
			
		||||
        mUserHandle = Utils.getSecureTargetUser(getActivity().getActivityToken(), mUm,
 | 
			
		||||
                null /* arguments */, getIntent().getExtras());
 | 
			
		||||
        updateAuthDescriptions();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -123,7 +124,7 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
 | 
			
		||||
     * and update any UI that depends on AuthenticatorDescriptions in onAuthDescriptionsUpdated().
 | 
			
		||||
     */
 | 
			
		||||
    private void updateAuthDescriptions() {
 | 
			
		||||
        mAuthDescs = AccountManager.get(this).getAuthenticatorTypesAsUser(
 | 
			
		||||
        mAuthDescs = AccountManager.get(getContext()).getAuthenticatorTypesAsUser(
 | 
			
		||||
                mUserHandle.getIdentifier());
 | 
			
		||||
        for (int i = 0; i < mAuthDescs.length; i++) {
 | 
			
		||||
            mTypeToAuthDescription.put(mAuthDescs[i].type, mAuthDescs[i]);
 | 
			
		||||
@@ -233,7 +234,8 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
 | 
			
		||||
        if (mTypeToAuthDescription.containsKey(accountType)) {
 | 
			
		||||
            try {
 | 
			
		||||
                AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
 | 
			
		||||
                Context authContext = createPackageContextAsUser(desc.packageName, 0, mUserHandle);
 | 
			
		||||
                Context authContext = getActivity()
 | 
			
		||||
                        .createPackageContextAsUser(desc.packageName, 0, mUserHandle);
 | 
			
		||||
                icon = getPackageManager().getUserBadgedIcon(
 | 
			
		||||
                        authContext.getDrawable(desc.iconId), mUserHandle);
 | 
			
		||||
            } catch (PackageManager.NameNotFoundException e) {
 | 
			
		||||
@@ -259,7 +261,8 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
 | 
			
		||||
        if (mTypeToAuthDescription.containsKey(accountType)) {
 | 
			
		||||
            try {
 | 
			
		||||
                AuthenticatorDescription desc = mTypeToAuthDescription.get(accountType);
 | 
			
		||||
                Context authContext = createPackageContextAsUser(desc.packageName, 0, mUserHandle);
 | 
			
		||||
                Context authContext = getActivity()
 | 
			
		||||
                        .createPackageContextAsUser(desc.packageName, 0, mUserHandle);
 | 
			
		||||
                label = authContext.getResources().getText(desc.labelId);
 | 
			
		||||
            } catch (PackageManager.NameNotFoundException e) {
 | 
			
		||||
                Log.w(TAG, "No label name for account type " + accountType);
 | 
			
		||||
 
 | 
			
		||||
@@ -27,10 +27,10 @@ import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
import com.android.internal.telephony.Phone;
 | 
			
		||||
import com.android.internal.telephony.PhoneConstants;
 | 
			
		||||
import com.android.internal.telephony.PhoneFactory;
 | 
			
		||||
import com.android.settings.InstrumentedPreferenceActivity;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.SettingsPreferenceFragment;
 | 
			
		||||
 | 
			
		||||
public class ImeiInformation extends InstrumentedPreferenceActivity {
 | 
			
		||||
public class ImeiInformation extends SettingsPreferenceFragment {
 | 
			
		||||
 | 
			
		||||
    private static final String KEY_PRL_VERSION = "prl_version";
 | 
			
		||||
    private static final String KEY_MIN_NUMBER = "min_number";
 | 
			
		||||
@@ -43,9 +43,9 @@ public class ImeiInformation extends InstrumentedPreferenceActivity {
 | 
			
		||||
    private boolean isMultiSIM = false;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
    public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        mSubscriptionManager = SubscriptionManager.from(this);
 | 
			
		||||
        mSubscriptionManager = SubscriptionManager.from(getContext());
 | 
			
		||||
        final TelephonyManager telephonyManager =
 | 
			
		||||
            (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
 | 
			
		||||
        initPreferenceScreen(telephonyManager.getSimCount());
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,9 @@
 | 
			
		||||
 | 
			
		||||
package com.android.settings.deviceinfo;
 | 
			
		||||
 | 
			
		||||
import static android.content.Context.CARRIER_CONFIG_SERVICE;
 | 
			
		||||
import static android.content.Context.TELEPHONY_SERVICE;
 | 
			
		||||
 | 
			
		||||
import android.content.BroadcastReceiver;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
@@ -27,6 +30,7 @@ import android.os.PersistableBundle;
 | 
			
		||||
import android.os.UserHandle;
 | 
			
		||||
import android.os.UserManager;
 | 
			
		||||
import android.support.v7.preference.Preference;
 | 
			
		||||
import android.telephony.CarrierConfigManager;
 | 
			
		||||
import android.telephony.CellBroadcastMessage;
 | 
			
		||||
import android.telephony.PhoneNumberUtils;
 | 
			
		||||
import android.telephony.PhoneStateListener;
 | 
			
		||||
@@ -35,10 +39,11 @@ import android.telephony.SignalStrength;
 | 
			
		||||
import android.telephony.SubscriptionInfo;
 | 
			
		||||
import android.telephony.SubscriptionManager;
 | 
			
		||||
import android.telephony.TelephonyManager;
 | 
			
		||||
import android.telephony.CarrierConfigManager;
 | 
			
		||||
import android.text.TextUtils;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
import android.view.LayoutInflater;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.view.ViewGroup;
 | 
			
		||||
import android.widget.ListView;
 | 
			
		||||
import android.widget.TabHost;
 | 
			
		||||
import android.widget.TabHost.OnTabChangeListener;
 | 
			
		||||
@@ -50,8 +55,9 @@ import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
import com.android.internal.telephony.DefaultPhoneNotifier;
 | 
			
		||||
import com.android.internal.telephony.Phone;
 | 
			
		||||
import com.android.internal.telephony.PhoneFactory;
 | 
			
		||||
import com.android.settings.InstrumentedPreferenceActivity;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.SettingsPreferenceFragment;
 | 
			
		||||
import com.android.settings.Utils;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
@@ -67,7 +73,7 @@ import java.util.List;
 | 
			
		||||
 * # Signal Strength
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
public class SimStatus extends SettingsPreferenceFragment {
 | 
			
		||||
    private static final String TAG = "SimStatus";
 | 
			
		||||
 | 
			
		||||
    private static final String KEY_DATA_STATE = "data_state";
 | 
			
		||||
@@ -131,12 +137,13 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle icicle) {
 | 
			
		||||
    public void onCreate(Bundle icicle) {
 | 
			
		||||
        super.onCreate(icicle);
 | 
			
		||||
        mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
 | 
			
		||||
        mCarrierConfigManager = (CarrierConfigManager) getSystemService(CARRIER_CONFIG_SERVICE);
 | 
			
		||||
 | 
			
		||||
        mSelectableSubInfos = SubscriptionManager.from(this).getActiveSubscriptionInfoList();
 | 
			
		||||
        mSelectableSubInfos = SubscriptionManager.from(getContext())
 | 
			
		||||
                .getActiveSubscriptionInfoList();
 | 
			
		||||
 | 
			
		||||
        addPreferencesFromResource(R.xml.device_info_sim_status);
 | 
			
		||||
 | 
			
		||||
@@ -145,17 +152,28 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
        // Note - missing in zaku build, be careful later...
 | 
			
		||||
        mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH);
 | 
			
		||||
 | 
			
		||||
        updatePhoneInfos();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
 | 
			
		||||
            Bundle savedInstanceState) {
 | 
			
		||||
        if (mSelectableSubInfos == null) {
 | 
			
		||||
            mSir = null;
 | 
			
		||||
        } else {
 | 
			
		||||
            mSir = mSelectableSubInfos.size() > 0 ? mSelectableSubInfos.get(0) : null;
 | 
			
		||||
 | 
			
		||||
            if (mSelectableSubInfos.size() > 1) {
 | 
			
		||||
                setContentView(R.layout.icc_lock_tabs);
 | 
			
		||||
                View view = inflater.inflate(R.layout.icc_lock_tabs, container, false);
 | 
			
		||||
                final ViewGroup prefs_container = (ViewGroup) view.findViewById(
 | 
			
		||||
                        R.id.prefs_container);
 | 
			
		||||
                Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
 | 
			
		||||
                View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
 | 
			
		||||
                prefs_container.addView(prefs);
 | 
			
		||||
 | 
			
		||||
                mTabHost = (TabHost) findViewById(android.R.id.tabhost);
 | 
			
		||||
                mTabWidget = (TabWidget) findViewById(android.R.id.tabs);
 | 
			
		||||
                mListView = (ListView) findViewById(android.R.id.list);
 | 
			
		||||
                mTabHost = (TabHost) view.findViewById(android.R.id.tabhost);
 | 
			
		||||
                mTabWidget = (TabWidget) view.findViewById(android.R.id.tabs);
 | 
			
		||||
                mListView = (ListView) view.findViewById(android.R.id.list);
 | 
			
		||||
 | 
			
		||||
                mTabHost.setup();
 | 
			
		||||
                mTabHost.setOnTabChangedListener(mTabListener);
 | 
			
		||||
@@ -167,7 +185,7 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        updatePhoneInfos();
 | 
			
		||||
        return super.onCreateView(inflater, container, savedInstanceState);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -176,7 +194,7 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onResume() {
 | 
			
		||||
    public void onResume() {
 | 
			
		||||
        super.onResume();
 | 
			
		||||
        if (mPhone != null) {
 | 
			
		||||
            updatePreference();
 | 
			
		||||
@@ -189,11 +207,12 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
                    | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS
 | 
			
		||||
                    | PhoneStateListener.LISTEN_SERVICE_STATE);
 | 
			
		||||
            if (mShowLatestAreaInfo) {
 | 
			
		||||
                registerReceiver(mAreaInfoReceiver, new IntentFilter(CB_AREA_INFO_RECEIVED_ACTION),
 | 
			
		||||
                getContext().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);
 | 
			
		||||
                sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
 | 
			
		||||
                getContext().sendBroadcastAsUser(getLatestIntent, UserHandle.ALL,
 | 
			
		||||
                        CB_AREA_INFO_SENDER_PERMISSION);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -208,7 +227,7 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
                    PhoneStateListener.LISTEN_NONE);
 | 
			
		||||
        }
 | 
			
		||||
        if (mShowLatestAreaInfo) {
 | 
			
		||||
            unregisterReceiver(mAreaInfoReceiver);
 | 
			
		||||
            getContext().unregisterReceiver(mAreaInfoReceiver);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -250,7 +269,7 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
 | 
			
		||||
        boolean show4GForLTE = false;
 | 
			
		||||
        try {
 | 
			
		||||
            Context con = createPackageContext("com.android.systemui", 0);
 | 
			
		||||
            Context con = getActivity().createPackageContext("com.android.systemui", 0);
 | 
			
		||||
            int id = con.getResources().getIdentifier("config_show4GForLTE",
 | 
			
		||||
                    "bool", "com.android.systemui");
 | 
			
		||||
            show4GForLTE = con.getResources().getBoolean(id);
 | 
			
		||||
@@ -395,7 +414,7 @@ public class SimStatus extends InstrumentedPreferenceActivity {
 | 
			
		||||
            // TODO: http://b/23763013
 | 
			
		||||
            final Phone phone = PhoneFactory.getPhone(SubscriptionManager.getPhoneId(
 | 
			
		||||
                        mSir.getSubscriptionId()));
 | 
			
		||||
            if (UserManager.get(this).isAdminUser()
 | 
			
		||||
            if (UserManager.get(getContext()).isAdminUser()
 | 
			
		||||
                    && SubscriptionManager.isValidSubscriptionId(mSir.getSubscriptionId())) {
 | 
			
		||||
                if (phone == null) {
 | 
			
		||||
                    Log.e(TAG, "Unable to locate a phone object for the given Subscription ID.");
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,9 @@
 | 
			
		||||
 | 
			
		||||
package com.android.settings.deviceinfo;
 | 
			
		||||
 | 
			
		||||
import static android.content.Context.CONNECTIVITY_SERVICE;
 | 
			
		||||
import static android.content.Context.WIFI_SERVICE;
 | 
			
		||||
 | 
			
		||||
import android.bluetooth.BluetoothAdapter;
 | 
			
		||||
import android.content.BroadcastReceiver;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
@@ -37,8 +40,8 @@ import android.text.TextUtils;
 | 
			
		||||
 | 
			
		||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
import com.android.internal.util.ArrayUtils;
 | 
			
		||||
import com.android.settings.InstrumentedPreferenceActivity;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.SettingsPreferenceFragment;
 | 
			
		||||
import com.android.settings.Utils;
 | 
			
		||||
 | 
			
		||||
import java.lang.ref.WeakReference;
 | 
			
		||||
@@ -51,7 +54,7 @@ import java.lang.ref.WeakReference;
 | 
			
		||||
 * # XMPP/buzz/tickle status : TODO
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
public class Status extends InstrumentedPreferenceActivity {
 | 
			
		||||
public class Status extends SettingsPreferenceFragment {
 | 
			
		||||
 | 
			
		||||
    private static final String KEY_BATTERY_STATUS = "battery_status";
 | 
			
		||||
    private static final String KEY_BATTERY_LEVEL = "battery_level";
 | 
			
		||||
@@ -152,7 +155,7 @@ public class Status extends InstrumentedPreferenceActivity {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle icicle) {
 | 
			
		||||
    public void onCreate(Bundle icicle) {
 | 
			
		||||
        super.onCreate(icicle);
 | 
			
		||||
 | 
			
		||||
        mHandler = new MyHandler(this);
 | 
			
		||||
@@ -202,8 +205,8 @@ public class Status extends InstrumentedPreferenceActivity {
 | 
			
		||||
        // Remove SimStatus and Imei for Secondary user as it access Phone b/19165700
 | 
			
		||||
        // Also remove on Wi-Fi only devices.
 | 
			
		||||
        //TODO: the bug above will surface in split system user mode.
 | 
			
		||||
        if (!UserManager.get(this).isAdminUser()
 | 
			
		||||
                || Utils.isWifiOnly(this)) {
 | 
			
		||||
        if (!UserManager.get(getContext()).isAdminUser()
 | 
			
		||||
                || Utils.isWifiOnly(getContext())) {
 | 
			
		||||
            removePreferenceFromScreen(KEY_SIM_STATUS);
 | 
			
		||||
            removePreferenceFromScreen(KEY_IMEI_INFO);
 | 
			
		||||
        }
 | 
			
		||||
@@ -215,11 +218,12 @@ public class Status extends InstrumentedPreferenceActivity {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onResume() {
 | 
			
		||||
    public void onResume() {
 | 
			
		||||
        super.onResume();
 | 
			
		||||
        registerReceiver(mConnectivityReceiver, mConnectivityIntentFilter,
 | 
			
		||||
        getContext().registerReceiver(mConnectivityReceiver, mConnectivityIntentFilter,
 | 
			
		||||
                         android.Manifest.permission.CHANGE_NETWORK_STATE, null);
 | 
			
		||||
        registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
 | 
			
		||||
        getContext().registerReceiver(mBatteryInfoReceiver,
 | 
			
		||||
                new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
 | 
			
		||||
        mHandler.sendEmptyMessage(EVENT_UPDATE_STATS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -227,8 +231,8 @@ public class Status extends InstrumentedPreferenceActivity {
 | 
			
		||||
    public void onPause() {
 | 
			
		||||
        super.onPause();
 | 
			
		||||
 | 
			
		||||
        unregisterReceiver(mBatteryInfoReceiver);
 | 
			
		||||
        unregisterReceiver(mConnectivityReceiver);
 | 
			
		||||
        getContext().unregisterReceiver(mBatteryInfoReceiver);
 | 
			
		||||
        getContext().unregisterReceiver(mConnectivityReceiver);
 | 
			
		||||
        mHandler.removeMessages(EVENT_UPDATE_STATS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,8 @@
 | 
			
		||||
 | 
			
		||||
package com.android.settings.wifi;
 | 
			
		||||
 | 
			
		||||
import static android.content.Context.WIFI_SERVICE;
 | 
			
		||||
 | 
			
		||||
import android.app.AlertDialog;
 | 
			
		||||
import android.content.DialogInterface;
 | 
			
		||||
import android.net.wifi.WifiManager;
 | 
			
		||||
@@ -25,15 +27,16 @@ import android.support.v7.preference.PreferenceScreen;
 | 
			
		||||
import android.text.Editable;
 | 
			
		||||
import android.widget.EditText;
 | 
			
		||||
 | 
			
		||||
import com.android.settings.PreferenceActivity;
 | 
			
		||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.SettingsPreferenceFragment;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Provide an interface for testing out the Wifi API
 | 
			
		||||
 */
 | 
			
		||||
public class WifiAPITest extends PreferenceActivity implements
 | 
			
		||||
Preference.OnPreferenceClickListener {
 | 
			
		||||
public class WifiAPITest extends SettingsPreferenceFragment implements
 | 
			
		||||
        Preference.OnPreferenceClickListener {
 | 
			
		||||
 | 
			
		||||
    private static final String TAG = "WifiAPITest";
 | 
			
		||||
    private int netid;
 | 
			
		||||
@@ -58,15 +61,14 @@ Preference.OnPreferenceClickListener {
 | 
			
		||||
    //============================
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
    public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
 | 
			
		||||
        onCreatePreferences();
 | 
			
		||||
        mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private void onCreatePreferences() {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
 | 
			
		||||
        addPreferencesFromResource(R.layout.wifi_api_test);
 | 
			
		||||
 | 
			
		||||
        final PreferenceScreen preferenceScreen = getPreferenceScreen();
 | 
			
		||||
@@ -82,6 +84,11 @@ Preference.OnPreferenceClickListener {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected int getMetricsCategory() {
 | 
			
		||||
        return MetricsEvent.TESTING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //============================
 | 
			
		||||
    // Preference callbacks
 | 
			
		||||
    //============================
 | 
			
		||||
@@ -99,11 +106,11 @@ Preference.OnPreferenceClickListener {
 | 
			
		||||
        if (pref == mWifiDisconnect) {
 | 
			
		||||
            mWifiManager.disconnect();
 | 
			
		||||
        } else if (pref == mWifiDisableNetwork) {
 | 
			
		||||
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
 | 
			
		||||
            AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
 | 
			
		||||
            alert.setTitle("Input");
 | 
			
		||||
            alert.setMessage("Enter Network ID");
 | 
			
		||||
            // Set an EditText view to get user input
 | 
			
		||||
            final EditText input = new EditText(this);
 | 
			
		||||
            final EditText input = new EditText(getPrefContext());
 | 
			
		||||
            alert.setView(input);
 | 
			
		||||
            alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
 | 
			
		||||
                    public void onClick(DialogInterface dialog, int whichButton) {
 | 
			
		||||
@@ -125,11 +132,11 @@ Preference.OnPreferenceClickListener {
 | 
			
		||||
                    });
 | 
			
		||||
            alert.show();
 | 
			
		||||
        } else if (pref == mWifiEnableNetwork) {
 | 
			
		||||
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
 | 
			
		||||
            AlertDialog.Builder alert = new AlertDialog.Builder(getContext());
 | 
			
		||||
            alert.setTitle("Input");
 | 
			
		||||
            alert.setMessage("Enter Network ID");
 | 
			
		||||
            // Set an EditText view to get user input
 | 
			
		||||
            final EditText input = new EditText(this);
 | 
			
		||||
            final EditText input = new EditText(getPrefContext());
 | 
			
		||||
            alert.setView(input);
 | 
			
		||||
            alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
 | 
			
		||||
                    public void onClick(DialogInterface dialog, int whichButton) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,19 +18,24 @@ package com.android.settings.wifi;
 | 
			
		||||
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
 | 
			
		||||
import com.android.settings.PreferenceActivity;
 | 
			
		||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
 | 
			
		||||
import com.android.settings.R;
 | 
			
		||||
import com.android.settings.SettingsPreferenceFragment;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Wifi information menu item on the diagnostic screen
 | 
			
		||||
 */
 | 
			
		||||
public class WifiInfo extends PreferenceActivity {
 | 
			
		||||
public class WifiInfo extends SettingsPreferenceFragment {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
    public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        addPreferencesFromResource(R.xml.testing_wifi_settings);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected int getMetricsCategory() {
 | 
			
		||||
        return MetricsEvent.TESTING;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user