Compare commits
	
		
			41 Commits
		
	
	
		
			stable/cm-
			...
			stable/cm-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					b9d25a1a24 | ||
| 
						 | 
					b3a0f3f7ab | ||
| 
						 | 
					3a92535654 | ||
| 
						 | 
					ce9a742015 | ||
| 
						 | 
					225b927bbd | ||
| 
						 | 
					7dc922c743 | ||
| 
						 | 
					3c37b0b69c | ||
| 
						 | 
					2a98e6f6f6 | ||
| 
						 | 
					3371e61bb8 | ||
| 
						 | 
					218deb9952 | ||
| 
						 | 
					de06181c7e | ||
| 
						 | 
					cfc4a0db64 | ||
| 
						 | 
					dd500a1f42 | ||
| 
						 | 
					317a6cb891 | ||
| 
						 | 
					f654deb217 | ||
| 
						 | 
					bfd7ca0545 | ||
| 
						 | 
					714be1a490 | ||
| 
						 | 
					317a15e0eb | ||
| 
						 | 
					e68543ad74 | ||
| 
						 | 
					6d63e95342 | ||
| 
						 | 
					e79aa7f0bf | ||
| 
						 | 
					22df00177f | ||
| 
						 | 
					645ffa8436 | ||
| 
						 | 
					27457414c8 | ||
| 
						 | 
					b00440ec27 | ||
| 
						 | 
					76101714d7 | ||
| 
						 | 
					2a01a24066 | ||
| 
						 | 
					d0389e4e6e | ||
| 
						 | 
					dbc1ceb8ca | ||
| 
						 | 
					88aba00aa3 | ||
| 
						 | 
					2104b3f5db | ||
| 
						 | 
					98b5eb9958 | ||
| 
						 | 
					c225cd58f7 | ||
| 
						 | 
					bfde63c27c | ||
| 
						 | 
					0ed67f547c | ||
| 
						 | 
					f66c56b62f | ||
| 
						 | 
					77fce341b1 | ||
| 
						 | 
					0d31b31aac | ||
| 
						 | 
					7732b7485d | ||
| 
						 | 
					7faec91e22 | ||
| 
						 | 
					7c8e091320 | 
@@ -17,8 +17,6 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
 | 
			
		||||
    play \
 | 
			
		||||
    libphonenumber
 | 
			
		||||
 | 
			
		||||
LOCAL_JAVA_LIBRARIES += org.cyanogenmod.hardware
 | 
			
		||||
 | 
			
		||||
# Include res dir from chips
 | 
			
		||||
google_play_dir := ../../../external/google/google_play_services/libproject/google-play-services_lib/res
 | 
			
		||||
res_dir := $(google_play_dir) res
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@
 | 
			
		||||
    <uses-permission android:name="android.permission.BACKUP" />
 | 
			
		||||
    <uses-permission android:name="org.whispersystems.whisperpush.permissions.REGISTER" />
 | 
			
		||||
    <uses-permission android:name="cyanogenmod.permission.FINISH_SETUP" />
 | 
			
		||||
    <uses-permission android:name="cyanogenmod.permission.LEGALESE" />
 | 
			
		||||
    <uses-permission android:name="com.cyngn.cmstats.SEND_ANALYTICS" />
 | 
			
		||||
 | 
			
		||||
    <permission
 | 
			
		||||
@@ -66,10 +67,9 @@
 | 
			
		||||
    <application android:label="@string/app_name"
 | 
			
		||||
                 android:icon="@drawable/icon"
 | 
			
		||||
                 android:theme="@style/Theme.Setup"
 | 
			
		||||
                 android:uiOptions="none"
 | 
			
		||||
                 android:name=".SetupWizardApp">
 | 
			
		||||
 | 
			
		||||
        <uses-library android:name="org.cyanogenmod.hardware" android:required="false" />
 | 
			
		||||
 | 
			
		||||
        <meta-data android:name="com.google.android.gms.version"
 | 
			
		||||
                   android:value="@integer/google_play_services_version" />
 | 
			
		||||
 | 
			
		||||
@@ -77,9 +77,9 @@
 | 
			
		||||
                  android:label="@string/product_name"
 | 
			
		||||
                  android:launchMode="singleInstance"
 | 
			
		||||
                  android:excludeFromRecents="true"
 | 
			
		||||
                  android:uiOptions="none"
 | 
			
		||||
                  android:configChanges="themeChange|mcc|mnc"
 | 
			
		||||
                  android:immersive="true">
 | 
			
		||||
                  android:immersive="true"
 | 
			
		||||
                  android:windowSoftInputMode="stateAlwaysHidden">
 | 
			
		||||
 | 
			
		||||
            <intent-filter android:priority="9">
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -20,5 +20,4 @@
 | 
			
		||||
    <!-- The type of sim image to display.
 | 
			
		||||
         0=default sim image, 1=sim on side, 2=sim on back-->
 | 
			
		||||
    <integer name="sim_image_type">0</integer>
 | 
			
		||||
    <bool name="check_custom_theme_by_default">true</bool>
 | 
			
		||||
</resources>
 | 
			
		||||
 
 | 
			
		||||
@@ -37,6 +37,7 @@ public class SetupWizardApp extends Application {
 | 
			
		||||
    public static final String ACCOUNT_TYPE_GMS = "com.google";
 | 
			
		||||
 | 
			
		||||
    public static final String ACTION_SETUP_WIFI = "com.android.net.wifi.SETUP_WIFI_NETWORK";
 | 
			
		||||
    public static final String ACTION_VIEW_LEGAL = "cyanogenmod.intent.action.LEGALESE";
 | 
			
		||||
 | 
			
		||||
    public static final String EXTRA_FIRST_RUN = "firstRun";
 | 
			
		||||
    public static final String EXTRA_ALLOW_SKIP = "allowSkip";
 | 
			
		||||
@@ -59,6 +60,7 @@ public class SetupWizardApp extends Application {
 | 
			
		||||
    public static final int REQUEST_CODE_RESTORE_GMS= 2;
 | 
			
		||||
    public static final int REQUEST_CODE_SETUP_CYANOGEN= 3;
 | 
			
		||||
    public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4;
 | 
			
		||||
    public static final int REQUEST_CODE_SETUP_BLUETOOTH= 5;
 | 
			
		||||
 | 
			
		||||
    public static final int RADIO_READY_TIMEOUT = 10 * 1000;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,8 +28,8 @@ public class SetupStats {
 | 
			
		||||
 | 
			
		||||
    private static final String TAG = SetupStats.class.getSimpleName();
 | 
			
		||||
 | 
			
		||||
    private static final String ANALYTIC_INTENT = "com.cyngn.cmstats.action.SEND_ANALYTIC_EVENT";
 | 
			
		||||
    private static final String ANALYTIC_PERMISSION = "com.cyngn.cmstats.RECEIVE_ANALYTICS";
 | 
			
		||||
    private static final String ANALYTIC_INTENT = "com.cyngn.stats.action.SEND_ANALYTIC_EVENT";
 | 
			
		||||
    private static final String ANALYTIC_PERMISSION = "com.cyngn.stats.SEND_ANALYTICS";
 | 
			
		||||
 | 
			
		||||
    public static final String TRACKING_ID = "tracking_id";
 | 
			
		||||
 | 
			
		||||
@@ -146,6 +146,7 @@ public class SetupStats {
 | 
			
		||||
        public static final String LOCALE = "local";
 | 
			
		||||
        public static final String RESULT = "result";
 | 
			
		||||
        public static final String WIFI_SETUP = "wifi_setup";
 | 
			
		||||
        public static final String BLUETOOTH_SETUP = "bluetooth_setup";
 | 
			
		||||
        public static final String CYANOGEN_ACCOUNT = "cyanogen_account_setup";
 | 
			
		||||
        public static final String CAPTIVE_PORTAL_LOGIN = "captive_portal_login";
 | 
			
		||||
        public static final String EMERGENCY_CALL = "emergency_call";
 | 
			
		||||
 
 | 
			
		||||
@@ -18,12 +18,13 @@
 | 
			
		||||
package com.cyanogenmod.setupwizard.cmstats;
 | 
			
		||||
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.pm.ApplicationInfo;
 | 
			
		||||
import android.content.pm.PackageInfo;
 | 
			
		||||
import android.content.pm.PackageManager;
 | 
			
		||||
import android.provider.Settings;
 | 
			
		||||
 | 
			
		||||
public class StatsUtils {
 | 
			
		||||
    private static final String STATS_PACKAGE = "com.cyngn.cmstats";
 | 
			
		||||
    private static final String STATS_PACKAGE = "com.cyngn.stats";
 | 
			
		||||
 | 
			
		||||
    public static boolean isStatsCollectionEnabled(Context context) {
 | 
			
		||||
        return Settings.Secure.getInt(context.getContentResolver(),
 | 
			
		||||
@@ -33,7 +34,8 @@ public class StatsUtils {
 | 
			
		||||
    public static boolean isStatsPackageInstalled(Context context) {
 | 
			
		||||
        try {
 | 
			
		||||
            PackageInfo pi = context.getPackageManager().getPackageInfo(STATS_PACKAGE, 0);
 | 
			
		||||
            return pi.applicationInfo.enabled;
 | 
			
		||||
            return pi.applicationInfo.enabled
 | 
			
		||||
                    && ((pi.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
 | 
			
		||||
        } catch (PackageManager.NameNotFoundException e) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,8 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
 | 
			
		||||
 | 
			
		||||
    private boolean mIsResumed = false;
 | 
			
		||||
 | 
			
		||||
    private boolean mIsFinished = false;
 | 
			
		||||
 | 
			
		||||
    private OnResumeRunnable mOnResumeRunnable;
 | 
			
		||||
 | 
			
		||||
    public AbstractSetupData(Context context) {
 | 
			
		||||
@@ -186,6 +188,7 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void finishPages() {
 | 
			
		||||
        mIsFinished = true;
 | 
			
		||||
        for (Page page : mPageList.values()) {
 | 
			
		||||
            page.onFinishSetup();
 | 
			
		||||
        }
 | 
			
		||||
@@ -198,6 +201,10 @@ public abstract class AbstractSetupData extends BroadcastReceiver implements Set
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isFinished() {
 | 
			
		||||
        return mIsFinished;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Bundle save() {
 | 
			
		||||
        Bundle bundle = new Bundle();
 | 
			
		||||
        for (Page page : mPageList.values()) {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										120
									
								
								src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										120
									
								
								src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,120 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (C) 2015 The CyanogenMod 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.cyanogenmod.setupwizard.setup;
 | 
			
		||||
 | 
			
		||||
import android.app.Activity;
 | 
			
		||||
import android.app.ActivityOptions;
 | 
			
		||||
import android.app.FragmentManager;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.Handler;
 | 
			
		||||
import android.provider.Settings;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
 | 
			
		||||
import com.cyanogenmod.setupwizard.R;
 | 
			
		||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
 | 
			
		||||
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
 | 
			
		||||
import com.cyanogenmod.setupwizard.ui.LoadingFragment;
 | 
			
		||||
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
 | 
			
		||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.net.HttpURLConnection;
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
 | 
			
		||||
public class BluetoothSetupPage extends SetupPage {
 | 
			
		||||
 | 
			
		||||
    public static final String TAG = "BluetoothSetupPage";
 | 
			
		||||
 | 
			
		||||
    private static final String ACTION_CONNECT_INPUT =
 | 
			
		||||
            "com.google.android.intent.action.CONNECT_INPUT";
 | 
			
		||||
 | 
			
		||||
    private static final String INTENT_EXTRA_NO_INPUT_MODE = "no_input_mode";
 | 
			
		||||
 | 
			
		||||
    private LoadingFragment mLoadingFragment;
 | 
			
		||||
 | 
			
		||||
    public BluetoothSetupPage(Context context, SetupDataCallbacks callbacks) {
 | 
			
		||||
        super(context, callbacks);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public SetupPageFragment getFragment(FragmentManager fragmentManager, int action) {
 | 
			
		||||
        mLoadingFragment = (LoadingFragment)fragmentManager.findFragmentByTag(getKey());
 | 
			
		||||
        if (mLoadingFragment == null) {
 | 
			
		||||
            Bundle args = new Bundle();
 | 
			
		||||
            args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
 | 
			
		||||
            args.putInt(Page.KEY_PAGE_ACTION, action);
 | 
			
		||||
            mLoadingFragment = new LoadingFragment();
 | 
			
		||||
            mLoadingFragment.setArguments(args);
 | 
			
		||||
        }
 | 
			
		||||
        return mLoadingFragment;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getNextButtonTitleResId() {
 | 
			
		||||
        return R.string.skip;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getKey() {
 | 
			
		||||
        return TAG;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getTitleResId() {
 | 
			
		||||
        return R.string.loading;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void doLoadAction(FragmentManager fragmentManager, int action) {
 | 
			
		||||
        super.doLoadAction(fragmentManager, action);
 | 
			
		||||
        launchConnectInput();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
 | 
			
		||||
        if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_BLUETOOTH) {
 | 
			
		||||
            SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
 | 
			
		||||
                    SetupStats.Action.EXTERNAL_PAGE_RESULT,
 | 
			
		||||
                    SetupStats.Label.BLUETOOTH_SETUP, "success");
 | 
			
		||||
            getCallbacks().onNextPage();
 | 
			
		||||
        }  else {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void launchConnectInput() {
 | 
			
		||||
        Intent intent = new Intent();
 | 
			
		||||
        intent.setComponent(SetupWizardUtils.mTvAddAccessorySettingsActivity);
 | 
			
		||||
        intent.setAction(ACTION_CONNECT_INPUT);
 | 
			
		||||
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 | 
			
		||||
        intent.putExtra(INTENT_EXTRA_NO_INPUT_MODE, true);
 | 
			
		||||
        ActivityOptions options =
 | 
			
		||||
                ActivityOptions.makeCustomAnimation(mContext,
 | 
			
		||||
                        android.R.anim.fade_in,
 | 
			
		||||
                        android.R.anim.fade_out);
 | 
			
		||||
        SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
 | 
			
		||||
                SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
 | 
			
		||||
                SetupStats.Label.PAGE,  SetupStats.Label.BLUETOOTH_SETUP);
 | 
			
		||||
        mLoadingFragment.startActivityForResult(intent,
 | 
			
		||||
                SetupWizardApp.REQUEST_CODE_SETUP_BLUETOOTH, options.toBundle());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -20,7 +20,7 @@ import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.content.IntentFilter;
 | 
			
		||||
import android.net.ConnectivityManager;
 | 
			
		||||
import android.telephony.SubInfoRecord;
 | 
			
		||||
import android.os.SystemProperties;
 | 
			
		||||
import android.telephony.SubscriptionManager;
 | 
			
		||||
import android.telephony.TelephonyManager;
 | 
			
		||||
 | 
			
		||||
@@ -28,7 +28,6 @@ import com.android.internal.telephony.TelephonyIntents;
 | 
			
		||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
 | 
			
		||||
@@ -36,6 +35,8 @@ public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
 | 
			
		||||
    private boolean mTimeSet = false;
 | 
			
		||||
    private boolean mTimeZoneSet = false;
 | 
			
		||||
    private boolean mMobileDataEnabled = SystemProperties
 | 
			
		||||
            .getBoolean("ro.com.android.mobiledata", true);
 | 
			
		||||
 | 
			
		||||
    public CMSetupWizardData(Context context) {
 | 
			
		||||
        super(context);
 | 
			
		||||
@@ -44,6 +45,9 @@ public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
    @Override
 | 
			
		||||
    protected PageList onNewPageList() {
 | 
			
		||||
        ArrayList<Page> pages = new ArrayList<Page>();
 | 
			
		||||
        if (SetupWizardUtils.hasLeanback(mContext)) {
 | 
			
		||||
            pages.add(new BluetoothSetupPage(mContext, this));
 | 
			
		||||
        }
 | 
			
		||||
        pages.add(new WelcomePage(mContext, this));
 | 
			
		||||
        pages.add(new WifiSetupPage(mContext, this));
 | 
			
		||||
        if (SetupWizardUtils.hasTelephony(mContext)) {
 | 
			
		||||
@@ -56,12 +60,14 @@ public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
        }
 | 
			
		||||
        if (SetupWizardUtils.hasTelephony(mContext)) {
 | 
			
		||||
            pages.add(new MobileDataPage(mContext, this)
 | 
			
		||||
                    .setHidden(!isSimInserted() || SetupWizardUtils.isMobileDataEnabled(mContext)));
 | 
			
		||||
                    .setHidden(!isSimInserted() || mMobileDataEnabled));
 | 
			
		||||
        }
 | 
			
		||||
        if (SetupWizardUtils.hasGMS(mContext)) {
 | 
			
		||||
            pages.add(new GmsAccountPage(mContext, this).setHidden(true));
 | 
			
		||||
        }
 | 
			
		||||
        pages.add(new CyanogenServicesPage(mContext, this).setHidden(true));
 | 
			
		||||
        if (!SetupWizardUtils.hasLeanback(mContext)) {
 | 
			
		||||
            pages.add(new CyanogenServicesPage(mContext, this).setHidden(true));
 | 
			
		||||
        }
 | 
			
		||||
        pages.add(new CyanogenSettingsPage(mContext, this));
 | 
			
		||||
        pages.add(new OtherSettingsPage(mContext, this));
 | 
			
		||||
        pages.add(new DateTimePage(mContext, this));
 | 
			
		||||
@@ -80,6 +86,7 @@ public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
                .equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
 | 
			
		||||
                intent.getAction()
 | 
			
		||||
                        .equals(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE)) {
 | 
			
		||||
            showHideMobileDataPage();
 | 
			
		||||
            showHideAccountPages();
 | 
			
		||||
        } else  if (intent.getAction()
 | 
			
		||||
                .equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
 | 
			
		||||
@@ -133,7 +140,7 @@ public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
        MobileDataPage mobileDataPage =
 | 
			
		||||
                (MobileDataPage) getPage(MobileDataPage.TAG);
 | 
			
		||||
        if (mobileDataPage != null) {
 | 
			
		||||
            mobileDataPage.setHidden(!isSimInserted());
 | 
			
		||||
            mobileDataPage.setHidden(!isSimInserted() || mMobileDataEnabled);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -177,14 +184,13 @@ public class CMSetupWizardData extends AbstractSetupData {
 | 
			
		||||
    private boolean allSimsInserted() {
 | 
			
		||||
        TelephonyManager tm = TelephonyManager.from(mContext);
 | 
			
		||||
        int simSlotCount = tm.getSimCount();
 | 
			
		||||
        List<SubInfoRecord> subInfoRecords =  SubscriptionManager.getActiveSubInfoList();
 | 
			
		||||
        for (int i = 0; i < simSlotCount; i++) {
 | 
			
		||||
            int state = tm.getSimState(i);
 | 
			
		||||
            if (state == TelephonyManager.SIM_STATE_ABSENT) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return simSlotCount == subInfoRecords.size();
 | 
			
		||||
        return simSlotCount == SubscriptionManager.from(mContext).getActiveSubscriptionInfoCount();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import android.os.Handler;
 | 
			
		||||
import android.telephony.PhoneStateListener;
 | 
			
		||||
import android.telephony.ServiceState;
 | 
			
		||||
import android.telephony.SignalStrength;
 | 
			
		||||
import android.telephony.SubInfoRecord;
 | 
			
		||||
import android.telephony.SubscriptionInfo;
 | 
			
		||||
import android.telephony.SubscriptionManager;
 | 
			
		||||
import android.telephony.TelephonyManager;
 | 
			
		||||
import android.text.TextUtils;
 | 
			
		||||
@@ -87,7 +87,7 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
        private SparseArray<CheckBox> mCheckBoxes;
 | 
			
		||||
 | 
			
		||||
        private TelephonyManager mPhone;
 | 
			
		||||
        private SparseArray<SubInfoRecord> mSubInfoRecords;
 | 
			
		||||
        private SparseArray<SubscriptionInfo> mSubInfoRecords;
 | 
			
		||||
        private SparseArray<SignalStrength> mSignalStrengths;
 | 
			
		||||
        private SparseArray<ServiceState> mServiceStates;
 | 
			
		||||
        private SparseArray<PhoneStateListener> mPhoneStateListeners;
 | 
			
		||||
@@ -95,6 +95,7 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
        private boolean mIsAttached = false;
 | 
			
		||||
 | 
			
		||||
        private Context mContext;
 | 
			
		||||
        private SubscriptionManager mSubscriptionManager;
 | 
			
		||||
 | 
			
		||||
        private final Handler mHandler = new Handler();
 | 
			
		||||
 | 
			
		||||
@@ -108,9 +109,9 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
        private View.OnClickListener mSetDataSimClickListener = new View.OnClickListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void onClick(View view) {
 | 
			
		||||
                SubInfoRecord subInfoRecord = (SubInfoRecord)view.getTag();
 | 
			
		||||
                SubscriptionInfo subInfoRecord = (SubscriptionInfo)view.getTag();
 | 
			
		||||
                if (subInfoRecord != null) {
 | 
			
		||||
                    SubscriptionManager.setDefaultDataSubId(subInfoRecord.subId);
 | 
			
		||||
                    mSubscriptionManager.setDefaultDataSubId(subInfoRecord.getSubscriptionId());
 | 
			
		||||
                    setDataSubChecked(subInfoRecord);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
@@ -120,11 +121,12 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
        protected void initializePage() {
 | 
			
		||||
            mPageView = (ViewGroup)mRootView.findViewById(R.id.page_view);
 | 
			
		||||
            mProgressBar = (ProgressBar) mRootView.findViewById(R.id.progress);
 | 
			
		||||
            List<SubInfoRecord> subInfoRecords =  SubscriptionManager.getActiveSubInfoList();
 | 
			
		||||
            int simCount = subInfoRecords.size();
 | 
			
		||||
            mSubInfoRecords = new SparseArray<SubInfoRecord>(simCount);
 | 
			
		||||
            for (SubInfoRecord subInfoRecord : subInfoRecords) {
 | 
			
		||||
                mSubInfoRecords.put(subInfoRecord.slotId, subInfoRecord);
 | 
			
		||||
            List<SubscriptionInfo> subInfoRecords = mSubscriptionManager.getActiveSubscriptionInfoList();
 | 
			
		||||
            int simCount =
 | 
			
		||||
                    subInfoRecords != null ? subInfoRecords.size() : 0;
 | 
			
		||||
            mSubInfoRecords = new SparseArray<SubscriptionInfo>(simCount);
 | 
			
		||||
            for (SubscriptionInfo subInfoRecord : subInfoRecords) {
 | 
			
		||||
                mSubInfoRecords.put(subInfoRecord.getSimSlotIndex(), subInfoRecord);
 | 
			
		||||
            }
 | 
			
		||||
            mNameViews = new SparseArray<TextView>(simCount);
 | 
			
		||||
            mSignalViews = new SparseArray<ImageView>(simCount);
 | 
			
		||||
@@ -136,17 +138,14 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
            for (int i = 0; i < simCount; i++) {
 | 
			
		||||
                View simRow = inflater.inflate(R.layout.data_sim_row, null);
 | 
			
		||||
                mPageView.addView(simRow);
 | 
			
		||||
                SubInfoRecord subInfoRecord = mSubInfoRecords.valueAt(i);
 | 
			
		||||
                SubscriptionInfo subInfoRecord = mSubInfoRecords.valueAt(i);
 | 
			
		||||
                simRow.setTag(subInfoRecord);
 | 
			
		||||
                simRow.setOnClickListener(mSetDataSimClickListener);
 | 
			
		||||
                mNameViews.put(subInfoRecord.slotId,
 | 
			
		||||
                        (TextView) simRow.findViewById(R.id.sim_title));
 | 
			
		||||
                mSignalViews.put(subInfoRecord.slotId,
 | 
			
		||||
                        (ImageView) simRow.findViewById(R.id.signal));
 | 
			
		||||
                mCheckBoxes.put(subInfoRecord.slotId,
 | 
			
		||||
                        (CheckBox) simRow.findViewById(R.id.enable_check));
 | 
			
		||||
                mPhoneStateListeners.put(subInfoRecord.slotId,
 | 
			
		||||
                        createPhoneStateListener(subInfoRecord));
 | 
			
		||||
                int slot = subInfoRecord.getSimSlotIndex();
 | 
			
		||||
                mNameViews.put(slot, (TextView) simRow.findViewById(R.id.sim_title));
 | 
			
		||||
                mSignalViews.put(slot, (ImageView) simRow.findViewById(R.id.signal));
 | 
			
		||||
                mCheckBoxes.put(slot, (CheckBox) simRow.findViewById(R.id.enable_check));
 | 
			
		||||
                mPhoneStateListeners.put(slot, createPhoneStateListener(subInfoRecord));
 | 
			
		||||
                mPageView.addView(inflater.inflate(R.layout.divider, null));
 | 
			
		||||
            }
 | 
			
		||||
            updateSignalStrengths();
 | 
			
		||||
@@ -158,11 +157,17 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
            return R.layout.choose_data_sim_page;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
            super.onCreate(savedInstanceState);
 | 
			
		||||
            mContext = getActivity().getApplicationContext();
 | 
			
		||||
            mSubscriptionManager = SubscriptionManager.from(mContext);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        @Override
 | 
			
		||||
        public void onResume() {
 | 
			
		||||
            super.onResume();
 | 
			
		||||
            mIsAttached = true;
 | 
			
		||||
            mContext = getActivity().getApplicationContext();
 | 
			
		||||
            mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
 | 
			
		||||
            for (int i = 0; i < mPhoneStateListeners.size(); i++) {
 | 
			
		||||
                mPhone.listen(mPhoneStateListeners.valueAt(i),
 | 
			
		||||
@@ -188,14 +193,13 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private PhoneStateListener createPhoneStateListener(final SubInfoRecord subInfoRecord) {
 | 
			
		||||
            return new PhoneStateListener(subInfoRecord.subId) {
 | 
			
		||||
        private PhoneStateListener createPhoneStateListener(final SubscriptionInfo subInfoRecord) {
 | 
			
		||||
            return new PhoneStateListener(subInfoRecord.getSubscriptionId()) {
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onSignalStrengthsChanged(SignalStrength signalStrength) {
 | 
			
		||||
                        mSignalStrengths.put(subInfoRecord.slotId, signalStrength);
 | 
			
		||||
                        updateSignalStrength(subInfoRecord);
 | 
			
		||||
 | 
			
		||||
                    mSignalStrengths.put(subInfoRecord.getSimSlotIndex(), signalStrength);
 | 
			
		||||
                    updateSignalStrength(subInfoRecord);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                @Override
 | 
			
		||||
@@ -203,7 +207,7 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
                    if (SetupWizardUtils.isRadioReady(mContext, state)) {
 | 
			
		||||
                        hideWaitForRadio();
 | 
			
		||||
                    }
 | 
			
		||||
                    mServiceStates.put(subInfoRecord.slotId, state);
 | 
			
		||||
                    mServiceStates.put(subInfoRecord.getSimSlotIndex(), state);
 | 
			
		||||
                    updateSignalStrength(subInfoRecord);
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
@@ -230,14 +234,14 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void setDataSubChecked(SubInfoRecord subInfoRecord) {
 | 
			
		||||
        private void setDataSubChecked(SubscriptionInfo subInfoRecord) {
 | 
			
		||||
            if (mIsAttached) {
 | 
			
		||||
                for (int i = 0; i < mCheckBoxes.size(); i++) {
 | 
			
		||||
                    if (subInfoRecord.slotId == i) {
 | 
			
		||||
                        mCheckBoxes.get(subInfoRecord.slotId).setChecked(true);
 | 
			
		||||
                    if (subInfoRecord.getSimSlotIndex() == i) {
 | 
			
		||||
                        mCheckBoxes.get(i).setChecked(true);
 | 
			
		||||
                        SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
 | 
			
		||||
                                SetupStats.Action.PREFERRED_DATA_SIM,
 | 
			
		||||
                                SetupStats.Label.SLOT, String.valueOf(subInfoRecord.slotId + 1));
 | 
			
		||||
                                SetupStats.Label.SLOT, String.valueOf(i + 1));
 | 
			
		||||
                    } else {
 | 
			
		||||
                        mCheckBoxes.get(i).setChecked(false);
 | 
			
		||||
                    }
 | 
			
		||||
@@ -249,19 +253,17 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
        private void updateCurrentDataSub() {
 | 
			
		||||
            if (mIsAttached) {
 | 
			
		||||
                for (int i = 0; i < mSubInfoRecords.size(); i++) {
 | 
			
		||||
                    SubInfoRecord subInfoRecord = mSubInfoRecords.valueAt(i);
 | 
			
		||||
                    final long defaultDataSubId =  SubscriptionManager.getDefaultDataSubId();
 | 
			
		||||
                    mCheckBoxes.get(subInfoRecord.slotId)
 | 
			
		||||
                            .setChecked(defaultDataSubId == subInfoRecord.subId);
 | 
			
		||||
 | 
			
		||||
                    SubscriptionInfo subInfoRecord = mSubInfoRecords.valueAt(i);
 | 
			
		||||
                    mCheckBoxes.get(i).setChecked(mSubscriptionManager.getDefaultDataPhoneId()
 | 
			
		||||
                            == subInfoRecord.getSimSlotIndex());
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void updateCarrierText(SubInfoRecord subInfoRecord) {
 | 
			
		||||
        private void updateCarrierText(SubscriptionInfo subInfoRecord) {
 | 
			
		||||
            if (mIsAttached) {
 | 
			
		||||
                String name = mPhone.getNetworkOperatorName(subInfoRecord.subId);
 | 
			
		||||
                ServiceState serviceState = mServiceStates.get(subInfoRecord.slotId);
 | 
			
		||||
                String name = mPhone.getNetworkOperatorName(subInfoRecord.getSimSlotIndex());
 | 
			
		||||
                ServiceState serviceState = mServiceStates.get(subInfoRecord.getSimSlotIndex());
 | 
			
		||||
                if (TextUtils.isEmpty(name)) {
 | 
			
		||||
                    if (serviceState != null && serviceState.isEmergencyOnly()) {
 | 
			
		||||
                        name = getString(R.string.setup_mobile_data_emergency_only);
 | 
			
		||||
@@ -270,15 +272,16 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                String formattedName =
 | 
			
		||||
                        getString(R.string.data_sim_name, subInfoRecord.slotId + 1, name);
 | 
			
		||||
                mNameViews.get(subInfoRecord.slotId).setText(formattedName);
 | 
			
		||||
                        getString(R.string.data_sim_name,
 | 
			
		||||
                                  subInfoRecord.getSimSlotIndex() + 1, name);
 | 
			
		||||
                mNameViews.get(subInfoRecord.getSimSlotIndex()).setText(formattedName);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void updateSignalStrength(SubInfoRecord subInfoRecord) {
 | 
			
		||||
        private void updateSignalStrength(SubscriptionInfo subInfoRecord) {
 | 
			
		||||
            if (mIsAttached) {
 | 
			
		||||
                ImageView signalView = mSignalViews.get(subInfoRecord.slotId);
 | 
			
		||||
                SignalStrength signalStrength = mSignalStrengths.get(subInfoRecord.slotId);
 | 
			
		||||
                ImageView signalView = mSignalViews.get(subInfoRecord.getSimSlotIndex());
 | 
			
		||||
                SignalStrength signalStrength = mSignalStrengths.get(subInfoRecord.getSimSlotIndex());
 | 
			
		||||
                if (!hasService(subInfoRecord)) {
 | 
			
		||||
                    signalView.setImageResource(R.drawable.ic_signal_no_signal);
 | 
			
		||||
                } else {
 | 
			
		||||
@@ -308,9 +311,9 @@ public class ChooseDataSimPage extends SetupPage {
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private boolean hasService(SubInfoRecord subInfoRecord) {
 | 
			
		||||
        private boolean hasService(SubscriptionInfo subInfoRecord) {
 | 
			
		||||
            boolean retVal;
 | 
			
		||||
            ServiceState serviceState = mServiceStates.get(subInfoRecord.slotId);
 | 
			
		||||
            ServiceState serviceState = mServiceStates.get(subInfoRecord.getSimSlotIndex());
 | 
			
		||||
            if (serviceState != null) {
 | 
			
		||||
                // Consider the device to be in service if either voice or data service is available.
 | 
			
		||||
                // Some SIM cards are marketed as data-only and do not support voice service, and on
 | 
			
		||||
 
 | 
			
		||||
@@ -18,13 +18,15 @@ package com.cyanogenmod.setupwizard.setup;
 | 
			
		||||
 | 
			
		||||
import android.app.Fragment;
 | 
			
		||||
import android.app.FragmentManager;
 | 
			
		||||
import android.content.ComponentName;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.content.SharedPreferences;
 | 
			
		||||
import android.content.pm.PackageInfo;
 | 
			
		||||
import android.content.pm.PackageManager;
 | 
			
		||||
import android.content.pm.ThemeUtils;
 | 
			
		||||
import android.content.res.ThemeConfig;
 | 
			
		||||
import android.content.res.ThemeManager;
 | 
			
		||||
import android.hardware.CmHardwareManager;
 | 
			
		||||
import android.net.Uri;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.RemoteException;
 | 
			
		||||
import android.preference.PreferenceManager;
 | 
			
		||||
@@ -43,6 +45,7 @@ import android.widget.CheckBox;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
 | 
			
		||||
import com.cyanogenmod.setupwizard.R;
 | 
			
		||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
 | 
			
		||||
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
 | 
			
		||||
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
 | 
			
		||||
import com.cyanogenmod.setupwizard.ui.WebViewDialogFragment;
 | 
			
		||||
@@ -52,8 +55,6 @@ import com.cyanogenmod.setupwizard.util.WhisperPushUtils;
 | 
			
		||||
import com.google.android.gms.common.ConnectionResult;
 | 
			
		||||
import com.google.android.gms.common.GooglePlayServicesUtil;
 | 
			
		||||
 | 
			
		||||
import org.cyanogenmod.hardware.KeyDisabler;
 | 
			
		||||
 | 
			
		||||
public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
 | 
			
		||||
    public static final String TAG = "CyanogenSettingsPage";
 | 
			
		||||
@@ -66,8 +67,6 @@ public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
    public static final String SETTING_METRICS = "settings.cyanogen.allow_metrics";
 | 
			
		||||
    public static final String PRIVACY_POLICY_URI = "https://cyngn.com/oobe-legal?hideHeader=1";
 | 
			
		||||
 | 
			
		||||
    private static final String WHISPERPUSH_PACKAGE = "org.whispersystems.whisperpush";
 | 
			
		||||
 | 
			
		||||
    public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) {
 | 
			
		||||
        super(context, callbacks);
 | 
			
		||||
    }
 | 
			
		||||
@@ -102,7 +101,9 @@ public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
 | 
			
		||||
        Settings.Secure.putInt(context.getContentResolver(),
 | 
			
		||||
                Settings.Secure.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
 | 
			
		||||
        KeyDisabler.setActive(enabled);
 | 
			
		||||
        final CmHardwareManager cmHardwareManager =
 | 
			
		||||
                (CmHardwareManager) context.getSystemService(Context.CMHW_SERVICE);
 | 
			
		||||
        cmHardwareManager.set(CmHardwareManager.FEATURE_KEY_DISABLE, enabled);
 | 
			
		||||
 | 
			
		||||
        /* Save/restore button timeouts to disable them in softkey mode */
 | 
			
		||||
        SharedPreferences.Editor editor = prefs.edit();
 | 
			
		||||
@@ -185,34 +186,21 @@ public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean hideKeyDisabler() {
 | 
			
		||||
        try {
 | 
			
		||||
            return !KeyDisabler.isSupported();
 | 
			
		||||
        } catch (NoClassDefFoundError e) {
 | 
			
		||||
            // Hardware abstraction framework not installed
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    private static boolean hideKeyDisabler(Context ctx) {
 | 
			
		||||
        final CmHardwareManager cmHardwareManager =
 | 
			
		||||
                (CmHardwareManager) ctx.getSystemService(Context.CMHW_SERVICE);
 | 
			
		||||
        return !cmHardwareManager.isSupported(CmHardwareManager.FEATURE_KEY_DISABLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean isKeyDisablerActive() {
 | 
			
		||||
        try {
 | 
			
		||||
            return KeyDisabler.isActive();
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    private static boolean isKeyDisablerActive(Context ctx) {
 | 
			
		||||
        final CmHardwareManager cmHardwareManager =
 | 
			
		||||
                (CmHardwareManager) ctx.getSystemService(Context.CMHW_SERVICE);
 | 
			
		||||
        return cmHardwareManager.get(CmHardwareManager.FEATURE_KEY_DISABLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean hideWhisperPush(Context context) {
 | 
			
		||||
        final int playServicesAvailable = GooglePlayServicesUtil
 | 
			
		||||
                .isGooglePlayServicesAvailable(context);
 | 
			
		||||
        try {
 | 
			
		||||
            PackageInfo pi = context.getPackageManager().getPackageInfo(WHISPERPUSH_PACKAGE, 0);
 | 
			
		||||
            if (pi == null) {
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (PackageManager.NameNotFoundException e) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return playServicesAvailable != ConnectionResult.SUCCESS
 | 
			
		||||
                || !SetupWizardUtils.hasTelephony(context)
 | 
			
		||||
                || (SetupWizardUtils.hasTelephony(context) &&
 | 
			
		||||
@@ -283,9 +271,13 @@ public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
            ClickableSpan clickableSpan = new ClickableSpan() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void onClick(View textView) {
 | 
			
		||||
                    WebViewDialogFragment.newInstance()
 | 
			
		||||
                            .setUri(PRIVACY_POLICY_URI)
 | 
			
		||||
                            .show(getActivity().getFragmentManager(), WebViewDialogFragment.TAG);
 | 
			
		||||
                    final Intent intent = new Intent(SetupWizardApp.ACTION_VIEW_LEGAL);
 | 
			
		||||
                    intent.setData(Uri.parse(PRIVACY_POLICY_URI));
 | 
			
		||||
                    try {
 | 
			
		||||
                        getActivity().startActivity(intent);
 | 
			
		||||
                    } catch (Exception e) {
 | 
			
		||||
                        Log.e(TAG, "Unable to start activity " + intent.toString(), e);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            };
 | 
			
		||||
            ss.setSpan(clickableSpan,
 | 
			
		||||
@@ -337,12 +329,12 @@ public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
                needsNavBar = windowManager.needsNavigationBar();
 | 
			
		||||
            } catch (RemoteException e) {
 | 
			
		||||
            }
 | 
			
		||||
            mHideNavKeysRow = hideKeyDisabler();
 | 
			
		||||
            mHideNavKeysRow = hideKeyDisabler(getActivity());
 | 
			
		||||
            if (mHideNavKeysRow || needsNavBar) {
 | 
			
		||||
                mNavKeysRow.setVisibility(View.GONE);
 | 
			
		||||
            } else {
 | 
			
		||||
                boolean navKeysDisabled =
 | 
			
		||||
                        isKeyDisablerActive();
 | 
			
		||||
                        isKeyDisablerActive(getActivity());
 | 
			
		||||
                mNavKeys.setChecked(navKeysDisabled);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -390,13 +382,9 @@ public class CyanogenSettingsPage extends SetupPage {
 | 
			
		||||
        private void updateThemeOption() {
 | 
			
		||||
            if (!mHideThemeRow) {
 | 
			
		||||
                final Bundle myPageBundle = mPage.getData();
 | 
			
		||||
                boolean themesChecked;
 | 
			
		||||
                if (myPageBundle.containsKey(KEY_APPLY_DEFAULT_THEME)) {
 | 
			
		||||
                    themesChecked = myPageBundle.getBoolean(KEY_APPLY_DEFAULT_THEME);
 | 
			
		||||
                } else {
 | 
			
		||||
                    themesChecked = getActivity().getResources().getBoolean(
 | 
			
		||||
                            R.bool.check_custom_theme_by_default);
 | 
			
		||||
                }
 | 
			
		||||
                boolean themesChecked =
 | 
			
		||||
                        !myPageBundle.containsKey(KEY_APPLY_DEFAULT_THEME) || myPageBundle
 | 
			
		||||
                                .getBoolean(KEY_APPLY_DEFAULT_THEME);
 | 
			
		||||
                mDefaultTheme.setChecked(themesChecked);
 | 
			
		||||
                myPageBundle.putBoolean(KEY_APPLY_DEFAULT_THEME, themesChecked);
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
@@ -176,31 +176,33 @@ public class GmsAccountPage extends SetupPage {
 | 
			
		||||
    private void launchGmsRestorePage() {
 | 
			
		||||
        try {
 | 
			
		||||
            // GMS can disable this after logging in sometimes
 | 
			
		||||
            SetupWizardUtils.enableGMSSetupWizard(mContext);
 | 
			
		||||
            Intent intent = new Intent(ACTION_RESTORE);
 | 
			
		||||
            intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
 | 
			
		||||
            intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
 | 
			
		||||
            intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
 | 
			
		||||
            intent.putExtra(SetupWizardApp.EXTRA_THEME, SetupWizardApp.EXTRA_MATERIAL_LIGHT);
 | 
			
		||||
            // XXX: Fool G's setup wizard into thinking it is their setup wizard.
 | 
			
		||||
            // This is necessary to get the material theme on the restore page.
 | 
			
		||||
            intent.putExtra("scriptUri", RESTORE_WIZARD_SCRIPT);
 | 
			
		||||
            ActivityOptions options =
 | 
			
		||||
                    ActivityOptions.makeCustomAnimation(mContext,
 | 
			
		||||
                            android.R.anim.fade_in,
 | 
			
		||||
                            android.R.anim.fade_out);
 | 
			
		||||
            SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
 | 
			
		||||
                    SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
 | 
			
		||||
                    SetupStats.Label.PAGE, SetupStats.Label.RESTORE);
 | 
			
		||||
            mFragment.startActivityForResult(
 | 
			
		||||
                    intent,
 | 
			
		||||
                    SetupWizardApp.REQUEST_CODE_RESTORE_GMS, options.toBundle());
 | 
			
		||||
            if (SetupWizardUtils.enableGMSSetupWizard(mContext)) {
 | 
			
		||||
                Intent intent = new Intent(ACTION_RESTORE);
 | 
			
		||||
                intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
 | 
			
		||||
                intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
 | 
			
		||||
                intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
 | 
			
		||||
                intent.putExtra(SetupWizardApp.EXTRA_THEME, SetupWizardApp.EXTRA_MATERIAL_LIGHT);
 | 
			
		||||
                // XXX: Fool G's setup wizard into thinking it is their setup wizard.
 | 
			
		||||
                // This is necessary to get the material theme on the restore page.
 | 
			
		||||
                intent.putExtra("scriptUri", RESTORE_WIZARD_SCRIPT);
 | 
			
		||||
                ActivityOptions options =
 | 
			
		||||
                        ActivityOptions.makeCustomAnimation(mContext,
 | 
			
		||||
                                android.R.anim.fade_in,
 | 
			
		||||
                                android.R.anim.fade_out);
 | 
			
		||||
                SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
 | 
			
		||||
                        SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
 | 
			
		||||
                        SetupStats.Label.PAGE, SetupStats.Label.RESTORE);
 | 
			
		||||
                mFragment.startActivityForResult(
 | 
			
		||||
                        intent,
 | 
			
		||||
                        SetupWizardApp.REQUEST_CODE_RESTORE_GMS, options.toBundle());
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
        } catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            // XXX: In open source, we don't know what gms version a user has.
 | 
			
		||||
            // Bail if the restore activity is not found.
 | 
			
		||||
            getCallbacks().onNextPage();
 | 
			
		||||
        }
 | 
			
		||||
        getCallbacks().onNextPage();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void launchGmsAccountSetup() {
 | 
			
		||||
 
 | 
			
		||||
@@ -19,11 +19,14 @@ package com.cyanogenmod.setupwizard.setup;
 | 
			
		||||
import android.app.Fragment;
 | 
			
		||||
import android.app.FragmentManager;
 | 
			
		||||
import android.app.backup.IBackupManager;
 | 
			
		||||
import android.content.ComponentName;
 | 
			
		||||
import android.content.ContentQueryMap;
 | 
			
		||||
import android.content.ContentResolver;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.content.Intent;
 | 
			
		||||
import android.database.Cursor;
 | 
			
		||||
import android.location.LocationManager;
 | 
			
		||||
import android.net.Uri;
 | 
			
		||||
import android.os.Bundle;
 | 
			
		||||
import android.os.RemoteException;
 | 
			
		||||
import android.os.ServiceManager;
 | 
			
		||||
@@ -32,6 +35,7 @@ import android.text.SpannableString;
 | 
			
		||||
import android.text.Spanned;
 | 
			
		||||
import android.text.method.LinkMovementMethod;
 | 
			
		||||
import android.text.style.ClickableSpan;
 | 
			
		||||
import android.util.Log;
 | 
			
		||||
import android.view.View;
 | 
			
		||||
import android.widget.CheckBox;
 | 
			
		||||
import android.widget.TextView;
 | 
			
		||||
@@ -151,10 +155,13 @@ public class OtherSettingsPage extends SetupPage {
 | 
			
		||||
                ClickableSpan clickableSpan = new ClickableSpan() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void onClick(View textView) {
 | 
			
		||||
                        WebViewDialogFragment.newInstance()
 | 
			
		||||
                                .setUri(PRIVACY_POLICY_URI)
 | 
			
		||||
                                .show(getActivity().getFragmentManager(),
 | 
			
		||||
                                        WebViewDialogFragment.TAG);
 | 
			
		||||
                        final Intent intent = new Intent(SetupWizardApp.ACTION_VIEW_LEGAL);
 | 
			
		||||
                        intent.setData(Uri.parse(PRIVACY_POLICY_URI));
 | 
			
		||||
                        try {
 | 
			
		||||
                            getActivity().startActivity(intent);
 | 
			
		||||
                        } catch (Exception e) {
 | 
			
		||||
                            Log.e(TAG, "Unable to start activity " + intent.toString());
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                };
 | 
			
		||||
                ss.setSpan(clickableSpan,
 | 
			
		||||
@@ -270,6 +277,10 @@ public class OtherSettingsPage extends SetupPage {
 | 
			
		||||
                    SetupStats.Action.ENABLE_NETWORK_LOCATION,
 | 
			
		||||
                    SetupStats.Label.CHECKED, String.valueOf(networkEnabled));
 | 
			
		||||
            mLocationAccess.setChecked(gpsEnabled || networkEnabled);
 | 
			
		||||
            mGps.setEnabled(gpsEnabled || networkEnabled);
 | 
			
		||||
            mGpsRow.setEnabled(gpsEnabled || networkEnabled);
 | 
			
		||||
            mNetwork.setEnabled(gpsEnabled || networkEnabled);
 | 
			
		||||
            mNetworkRow.setEnabled(gpsEnabled || networkEnabled);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void onToggleLocationAccess(boolean checked) {
 | 
			
		||||
 
 | 
			
		||||
@@ -222,6 +222,9 @@ public class WifiSetupPage extends SetupPage {
 | 
			
		||||
    private void launchWifiSetup() {
 | 
			
		||||
        SetupWizardUtils.tryEnablingWifi(mContext);
 | 
			
		||||
        Intent intent = new Intent(SetupWizardApp.ACTION_SETUP_WIFI);
 | 
			
		||||
        if (SetupWizardUtils.hasLeanback(mContext)) {
 | 
			
		||||
            intent.setComponent(SetupWizardUtils.mTvwifisettingsActivity);
 | 
			
		||||
        }
 | 
			
		||||
        intent.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
 | 
			
		||||
        intent.putExtra(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
 | 
			
		||||
        intent.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
 | 
			
		||||
 
 | 
			
		||||
@@ -56,6 +56,12 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
 | 
			
		||||
    private static final String TAG = SetupWizardActivity.class.getSimpleName();
 | 
			
		||||
 | 
			
		||||
    private static final int UI_FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
 | 
			
		||||
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
 | 
			
		||||
            | View.SYSTEM_UI_FLAG_IMMERSIVE
 | 
			
		||||
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
 | 
			
		||||
            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
 | 
			
		||||
 | 
			
		||||
    private View mRootView;
 | 
			
		||||
    private View mButtonBar;
 | 
			
		||||
    private Button mNextButton;
 | 
			
		||||
@@ -77,12 +83,25 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
 | 
			
		||||
    public void onCreate(Bundle savedInstanceState) {
 | 
			
		||||
        super.onCreate(savedInstanceState);
 | 
			
		||||
        final View decorView = getWindow().getDecorView();
 | 
			
		||||
        decorView.setSystemUiVisibility(UI_FLAGS);
 | 
			
		||||
        decorView.setOnSystemUiVisibilityChangeListener(
 | 
			
		||||
                new View.OnSystemUiVisibilityChangeListener() {
 | 
			
		||||
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void onSystemUiVisibilityChange(int visibility) {
 | 
			
		||||
                        if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
 | 
			
		||||
                            decorView.setSystemUiVisibility(UI_FLAGS);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
        if (sLaunchTime == 0) {
 | 
			
		||||
            SetupStats.addEvent(SetupStats.Categories.APP_LAUNCH, TAG);
 | 
			
		||||
            sLaunchTime = System.nanoTime();
 | 
			
		||||
        }
 | 
			
		||||
        setContentView(R.layout.setup_main);
 | 
			
		||||
        mRootView = findViewById(R.id.root);
 | 
			
		||||
        mRootView.setSystemUiVisibility(UI_FLAGS);
 | 
			
		||||
        mReveal = (ImageView)mRootView.findViewById(R.id.reveal);
 | 
			
		||||
        mButtonBar = findViewById(R.id.button_bar);
 | 
			
		||||
        mFinishingProgressBar = (ProgressBar)findViewById(R.id.finishing_bar);
 | 
			
		||||
@@ -93,6 +112,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
        }
 | 
			
		||||
        mNextButton = (Button) findViewById(R.id.next_button);
 | 
			
		||||
        mPrevButton = (Button) findViewById(R.id.prev_button);
 | 
			
		||||
        if (mSetupData.isFinished()) {
 | 
			
		||||
            mNextButton.setVisibility(View.INVISIBLE);
 | 
			
		||||
            mPrevButton.setVisibility(View.INVISIBLE);
 | 
			
		||||
        }
 | 
			
		||||
        mSetupData.registerListener(this);
 | 
			
		||||
        mNextButton.setOnClickListener(new View.OnClickListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
@@ -120,7 +143,9 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
        mRootView.setOnTouchListener(new View.OnTouchListener() {
 | 
			
		||||
            @Override
 | 
			
		||||
            public boolean onTouch(View v, MotionEvent event) {
 | 
			
		||||
                return mEnableAccessibilityController.onInterceptTouchEvent(event);
 | 
			
		||||
                return
 | 
			
		||||
                    mEnableAccessibilityController.onInterceptTouchEvent(event) &
 | 
			
		||||
                    mEnableAccessibilityController.onTouchEvent(event);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        registerReceiver(mSetupData, mSetupData.getIntentFilter());
 | 
			
		||||
@@ -128,14 +153,21 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected void onResume() {
 | 
			
		||||
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
 | 
			
		||||
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
 | 
			
		||||
                | View.SYSTEM_UI_FLAG_IMMERSIVE
 | 
			
		||||
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
 | 
			
		||||
        final View decorView = getWindow().getDecorView();
 | 
			
		||||
        decorView.setSystemUiVisibility(UI_FLAGS);
 | 
			
		||||
        super.onResume();
 | 
			
		||||
        mSetupData.onResume();
 | 
			
		||||
        onPageTreeChanged();
 | 
			
		||||
        enableButtonBar(true);
 | 
			
		||||
        if (mSetupData.isFinished()) {
 | 
			
		||||
            mHandler.postDelayed(new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    finishSetup();
 | 
			
		||||
                }
 | 
			
		||||
            }, 500);
 | 
			
		||||
        }  else {
 | 
			
		||||
            mSetupData.onResume();
 | 
			
		||||
            onPageTreeChanged();
 | 
			
		||||
            enableButtonBar(true);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -276,17 +308,18 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
        final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE);
 | 
			
		||||
        tm.addClient(this);
 | 
			
		||||
        mSetupData.finishPages();
 | 
			
		||||
        SetupStats.addEvent(SetupStats.Categories.APP_FINISHED, TAG,
 | 
			
		||||
                SetupStats.Label.TOTAL_TIME, String.valueOf(
 | 
			
		||||
                        System.nanoTime() - sLaunchTime));
 | 
			
		||||
        setupWizardApp.sendStickyBroadcastAsUser(
 | 
			
		||||
                new Intent(SetupWizardApp.ACTION_FINISHED),
 | 
			
		||||
                UserHandle.getCallingUserHandle());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onFinish(boolean isSuccess) {
 | 
			
		||||
        finishSetup();
 | 
			
		||||
        if (isResumed()) {
 | 
			
		||||
            mHandler.post(new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    finishSetup();
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
@@ -300,6 +333,13 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
    @Override
 | 
			
		||||
    public void finishSetup() {
 | 
			
		||||
        if (!mIsFinishing) {
 | 
			
		||||
            SetupStats.addEvent(SetupStats.Categories.APP_FINISHED, TAG,
 | 
			
		||||
                    SetupStats.Label.TOTAL_TIME, String.valueOf(
 | 
			
		||||
                            System.nanoTime() - sLaunchTime));
 | 
			
		||||
            final SetupWizardApp setupWizardApp = (SetupWizardApp)getApplication();
 | 
			
		||||
            setupWizardApp.sendStickyBroadcastAsUser(
 | 
			
		||||
                    new Intent(SetupWizardApp.ACTION_FINISHED),
 | 
			
		||||
                    UserHandle.getCallingUserHandle());
 | 
			
		||||
            mIsFinishing = true;
 | 
			
		||||
            setupRevealImage();
 | 
			
		||||
        }
 | 
			
		||||
@@ -394,10 +434,10 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
 | 
			
		||||
                wallpaperManager.forgetLoadedWallpaper();
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        finish();
 | 
			
		||||
        for (Runnable runnable : mFinishRunnables) {
 | 
			
		||||
            runnable.run();
 | 
			
		||||
        }
 | 
			
		||||
        finish();
 | 
			
		||||
        SetupWizardUtils.disableSetupWizard(SetupWizardActivity.this);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -91,6 +91,7 @@ public class EnableAccessibilityController {
 | 
			
		||||
    private final float mTouchSlop;
 | 
			
		||||
 | 
			
		||||
    private boolean mDestroyed;
 | 
			
		||||
    private boolean mCanceled;
 | 
			
		||||
 | 
			
		||||
    private float mFirstPointerDownX;
 | 
			
		||||
    private float mFirstPointerDownY;
 | 
			
		||||
@@ -129,7 +130,7 @@ public class EnableAccessibilityController {
 | 
			
		||||
        // accessibility service, then we have nothing to do.
 | 
			
		||||
        if (accessibilityManager.isEnabled()
 | 
			
		||||
                && !accessibilityManager.getEnabledAccessibilityServiceList(
 | 
			
		||||
                        AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty()) {
 | 
			
		||||
                AccessibilityServiceInfo.FEEDBACK_SPOKEN).isEmpty()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -167,7 +168,7 @@ public class EnableAccessibilityController {
 | 
			
		||||
            mHandler.sendEmptyMessageDelayed(MESSAGE_SPEAK_WARNING,
 | 
			
		||||
                    SPEAK_WARNING_DELAY_MILLIS);
 | 
			
		||||
            mHandler.sendEmptyMessageDelayed(MESSAGE_ENABLE_ACCESSIBILITY,
 | 
			
		||||
                   ENABLE_ACCESSIBILITY_DELAY_MILLIS);
 | 
			
		||||
                    ENABLE_ACCESSIBILITY_DELAY_MILLIS);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
@@ -176,13 +177,25 @@ public class EnableAccessibilityController {
 | 
			
		||||
    public boolean onTouchEvent(MotionEvent event) {
 | 
			
		||||
        final int pointerCount = event.getPointerCount();
 | 
			
		||||
        final int action = event.getActionMasked();
 | 
			
		||||
        if (mCanceled) {
 | 
			
		||||
            if (action == MotionEvent.ACTION_UP) {
 | 
			
		||||
                mCanceled = false;
 | 
			
		||||
            }
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        switch (action) {
 | 
			
		||||
            case MotionEvent.ACTION_POINTER_DOWN: {
 | 
			
		||||
                if (pointerCount > 2) {
 | 
			
		||||
                    cancel();
 | 
			
		||||
                }
 | 
			
		||||
            } break;
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
            case MotionEvent.ACTION_MOVE: {
 | 
			
		||||
                //We only care about a 2 fingered move
 | 
			
		||||
                if (pointerCount < 2) {
 | 
			
		||||
                    cancel();
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
                final float firstPointerMove = MathUtils.dist(event.getX(0),
 | 
			
		||||
                        event.getY(0), mFirstPointerDownX, mFirstPointerDownY);
 | 
			
		||||
                if (Math.abs(firstPointerMove) > mTouchSlop) {
 | 
			
		||||
@@ -193,16 +206,19 @@ public class EnableAccessibilityController {
 | 
			
		||||
                if (Math.abs(secondPointerMove) > mTouchSlop) {
 | 
			
		||||
                    cancel();
 | 
			
		||||
                }
 | 
			
		||||
            } break;
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
            case MotionEvent.ACTION_POINTER_UP:
 | 
			
		||||
            case MotionEvent.ACTION_CANCEL: {
 | 
			
		||||
                cancel();
 | 
			
		||||
            } break;
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void cancel() {
 | 
			
		||||
        mCanceled = true;
 | 
			
		||||
        if (mHandler.hasMessages(MESSAGE_SPEAK_WARNING)) {
 | 
			
		||||
            mHandler.removeMessages(MESSAGE_SPEAK_WARNING);
 | 
			
		||||
        } else if (mHandler.hasMessages(MESSAGE_ENABLE_ACCESSIBILITY)) {
 | 
			
		||||
 
 | 
			
		||||
@@ -80,10 +80,10 @@ public class SetupWizardUtils {
 | 
			
		||||
        TelephonyManager tm =
 | 
			
		||||
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
 | 
			
		||||
        if (tm.isMultiSimEnabled()) {
 | 
			
		||||
            int phoneId = SubscriptionManager.getDefaultDataPhoneId();
 | 
			
		||||
            int phoneId = SubscriptionManager.from(context).getDefaultDataPhoneId();
 | 
			
		||||
            android.provider.Settings.Global.putInt(context.getContentResolver(),
 | 
			
		||||
                    android.provider.Settings.Global.MOBILE_DATA + phoneId, enabled ? 1 : 0);
 | 
			
		||||
            long subId = SubscriptionManager.getDefaultDataSubId();
 | 
			
		||||
            int subId = SubscriptionManager.getDefaultDataSubId();
 | 
			
		||||
            tm.setDataEnabledUsingSubId(subId, enabled);
 | 
			
		||||
        } else {
 | 
			
		||||
            android.provider.Settings.Global.putInt(context.getContentResolver(),
 | 
			
		||||
@@ -113,7 +113,7 @@ public class SetupWizardUtils {
 | 
			
		||||
    public static boolean isSimMissing(Context context) {
 | 
			
		||||
        TelephonyManager tm =
 | 
			
		||||
                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
 | 
			
		||||
        int simCount = SubscriptionManager.getActiveSubInfoCount();
 | 
			
		||||
        int simCount = SubscriptionManager.from(context).getDefaultDataPhoneId();
 | 
			
		||||
        for (int i = 0; i < simCount; i++) {
 | 
			
		||||
            int simState = tm.getSimState(i);
 | 
			
		||||
            if (simState != TelephonyManager.SIM_STATE_ABSENT &&
 | 
			
		||||
@@ -174,7 +174,7 @@ public class SetupWizardUtils {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void enableGMSSetupWizard(Context context) {
 | 
			
		||||
    public static boolean enableGMSSetupWizard(Context context) {
 | 
			
		||||
        try {
 | 
			
		||||
            PackageInfo packageInfo = context.getPackageManager()
 | 
			
		||||
                    .getPackageInfo(GOOGLE_SETUPWIZARD_PACKAGE,
 | 
			
		||||
@@ -183,8 +183,10 @@ public class SetupWizardUtils {
 | 
			
		||||
            enableComponentArray(context, packageInfo.activities);
 | 
			
		||||
            enableComponentArray(context, packageInfo.services);
 | 
			
		||||
            enableComponentArray(context, packageInfo.receivers);
 | 
			
		||||
            return true;
 | 
			
		||||
        } catch (PackageManager.NameNotFoundException e) {
 | 
			
		||||
            Log.e(TAG, "Unable to disable GMS");
 | 
			
		||||
            Log.e(TAG, "Unable to enable GMS");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@@ -223,4 +225,17 @@ public class SetupWizardUtils {
 | 
			
		||||
        context.getPackageManager().setComponentEnabledSetting(component,
 | 
			
		||||
                PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean hasLeanback(Context context) {
 | 
			
		||||
        PackageManager packageManager = context.getPackageManager();
 | 
			
		||||
        return packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static final ComponentName mTvwifisettingsActivity =
 | 
			
		||||
            new ComponentName("com.android.tv.settings",
 | 
			
		||||
                    "com.android.tv.settings.connectivity.setup.WifiSetupActivity");
 | 
			
		||||
 | 
			
		||||
    public static final ComponentName mTvAddAccessorySettingsActivity =
 | 
			
		||||
            new ComponentName("com.android.tv.settings",
 | 
			
		||||
                    "com.android.tv.settings.accessories.AddAccessoryActivity");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user