Compare commits

..

41 Commits

Author SHA1 Message Date
emancebo
b9d25a1a24 OOBE: fix NPE in choose data sim page
Change-Id: Ib6228e7cd223d29ac48200e9a50c0900d35f8a4e
(cherry picked from commit b2ceb1f8bb)
2015-05-18 16:25:38 +00:00
cretin45
b3a0f3f7ab SetupWizard: Use the system property mobile data page visibility
Change-Id: I3a3301bcdbc2200ba62067188e59c886a0891788
(cherry picked from commit 4d08b90df3)
2015-05-08 17:10:19 +00:00
cretin45
3a92535654 SetupWizard: Use new LegaleseViewer for privacy policy web views
WebViews are no longer allowed in priv-apps.

Change-Id: Iddf9c79d50ea9f9d9d32218342f9948a6cbf30ef
(cherry picked from commit b076a55991)
2015-05-08 17:07:43 +00:00
cretin45
ce9a742015 Setupwizard: Fix msim NPE where sim only in slot 2
Change-Id: I919129185cb49c51f9f02d9718e116e7d02b0d2c
(cherry picked from commit ac84dc0fce)
2015-05-08 17:07:00 +00:00
Michael Bestas
225b927bbd Automatic translation import
Change-Id: I6b8d3fb084df5abb3449b842ce02d1d6aaf2170a
(cherry picked from commit 676081a4ad)
2015-05-08 17:06:32 +00:00
cretin45
7dc922c743 SetupWizard: Increase delay for accessibility
Change-Id: Ifff7161f95e91ec7763f388206cd1d30804ad600
(cherry picked from commit 9dd952e3f6)
2015-05-08 17:04:59 +00:00
Roman Birg
3c37b0b69c SetupWizard: update stats permission and package
Change-Id: I3ef19b616422ca5cc0896840753192b1c1712525
Signed-off-by: Roman Birg <roman@cyngn.com>
2015-04-27 13:30:08 -07:00
dhacker29
2a98e6f6f6 Disable the CyanogenServicesPage if FEATURE_LEANBACK detected
TV devices will not benefit from having a CM account.

Change-Id: I5258a1442c400b35d92c22a2b0e8dcbe3516aead
2015-04-25 07:24:49 +00:00
Michael Bestas
3371e61bb8 Automatic translation import
Change-Id: Ifc62c159189df11f3443defc57069ab5b78b644f
2015-04-25 01:30:10 +03:00
dhacker29
218deb9952 If this is a TV device launch bluetooth pairing before Welcome page
TV devices like fugu don't have a default input method and expect to
be able to pair the bluetooth remote during setup without having to
manually initiate it with the bottom button on the device.

Change-Id: I88246fe9b28a85dc334c0108b818e78cb29491bb
2015-04-24 01:32:19 -04:00
dhacker29
de06181c7e WifiSetup: If device has Leanback feature specify tv.settings
Fugu has both com.android.settings and com.android.tv.settings so
currently it brings up a selector dialog for how to handle the wifi
intent, which leads to "Activity is launching as a new task, so
cancelling activity result." Fix this by passing the component name
in the intent if FEATURE_LEANBACK is present

Change-Id: I470590315d3f95a32b7796dd4a916a543392fcd6
2015-04-23 02:31:51 -04:00
Pawit Pornkitprasan
cfc4a0db64 SetupWizard: handle skipping id in SubInfoRecords
This extends I3b4132afccc96a5d08986a3cb902bd384931f21f to actually
work.

Change-Id: I9183626b40edda6a96888dca2816ff116b64bc5e
2015-04-20 15:55:30 -07:00
Pawit Pornkitprasan
dd500a1f42 SetupWizard: don't access SubscriptionController directly
SubscriptionController exists in the telephony process and cannot
be accessed by SetupWizard.

getInstance() will always return null.

Change-Id: I017682d3aad539e1954348664b1c1fec7f76009d
2015-04-20 15:53:19 -07:00
Michael Bestas
317a6cb891 Automatic translation import
Change-Id: I1649ba39d39b73ce351909a310041d6f6b0a99b7
2015-04-17 23:06:02 +03:00
cretin45
f654deb217 SetupWizard: Give radio a 10 second chance to come up
Change-Id: Iadd817b200106783dd67edbc5ad03928ce2baa6b
2015-04-17 03:44:08 +03:00
cretin45
bfd7ca0545 Setupwizard: Make sure to advance if GMS is absent
Change-Id: Ia0c4d83c9a9f7c581208d753024f55f48326afc7
(cherry picked from commit cb09e29e29)
2015-04-09 20:36:04 +00:00
cretin45
714be1a490 SetupWizard: Aggressively hide nav bar on soft key devices
Change-Id: Ic23fd7e605a323411fe2f581235ff3ed45bfcaed
(cherry picked from commit 1d7988a4c7)
2015-04-09 20:35:42 +00:00
cretin45
317a15e0eb SetupWizard: Ensure page object isn't null if FM destroyed
Change-Id: Ia794e7656587ca803d02418d3d84d4df5027cd00
(cherry picked from commit 62b79e3880)
2015-04-09 20:35:15 +00:00
Michael Bestas
e68543ad74 Automatic translation import
Change-Id: Ifa97d2292f1ab37a21a8695a53e673f406df706b
(cherry picked from commit cc9467cfbd)
2015-04-09 20:34:34 +00:00
cretin45
6d63e95342 SetupWizard: Handle all touch events in EnableAccessibilityController
Change-Id: Icf15be21c90d32305a9c1f8b9835eb473acf1f33
(cherry picked from commit 0fde3a04cc)
2015-04-09 20:34:18 +00:00
cretin45
e79aa7f0bf SetupWizard: Don't assume order of SubInfoRecords
Change-Id: I3b4132afccc96a5d08986a3cb902bd384931f21f
2015-04-09 13:32:59 -07:00
Aaahh
22df00177f SetupWizard: Disable Checkbox on Resume
Change-Id: Ica6f3043b9b0d3703b6ce6f47a43b5201deb05b7
(cherry picked from commit 9192fc6903)
2015-04-09 19:14:13 +00:00
Michael Bestas
645ffa8436 Automatic translation import
Change-Id: Icd2308a33556872fa1564058b8250c60dc1b8372
(cherry picked from commit 6fb3d23f09)
2015-04-01 02:05:09 +00:00
cretin45
27457414c8 SetupWizard: Lock orientation prior to finish animation
Change-Id: I43a69937e2deb5f55585522fe5d00c51ffdae569
(cherry picked from commit c8e4c29020)
2015-04-01 02:04:23 +00:00
Michael Bestas
b00440ec27 Automatic translation import
Change-Id: I9aa0c0cf342d79ffcdb42e8c87284ad354fc9563
(cherry picked from commit afcf65d6c0)
2015-04-01 02:03:40 +00:00
cretin45
76101714d7 SetupWizard: Initialize the nav keys bundle boolean
Change-Id: I50f2ef0fb7226c8b58437b669ca71df436d68ee8
(cherry picked from commit 33683fc2ce)
2015-04-01 02:03:03 +00:00
cretin45
2a01a24066 SetupWizard: Fix regression for devices without custom default theme
Change-Id: Ia223c1b118dbb68e596ff01cf944bc870a321752
(cherry picked from commit 838248ab86)
2015-04-01 02:02:23 +00:00
cretin45
d0389e4e6e SetupWizard: Fix regression, only init pages once
Change-Id: I1207cb3975daa752a66eb8e9e40635f9a8009509
(cherry picked from commit 83be05d6ec)
2015-04-01 02:01:32 +00:00
cretin45
dbc1ceb8ca SetupWizard: Better handling of launching into other activities
Change-Id: I4d8dc4a1b25e45c6ff35042239a0adf4c16458f1
(cherry picked from commit ed5d46703e)
2015-04-01 01:59:25 +00:00
d34d
88aba00aa3 Disable theme components for secondary users
This patch is to mitigate theming problems with multiple users.
Once themes properly support multiple users we can revert this.

Change-Id: Idc89a273bc1563fc668ca2a5a591cf133e8d5406
(cherry picked from commit 836f867086)
2015-04-01 01:58:53 +00:00
Michael Bestas
2104b3f5db Automatic translation import
Change-Id: If0a158896a3ec49fb0b32c48c6f426dea4d9b653
(cherry picked from commit c7b84c2793)
2015-04-01 01:52:07 +00:00
Roman Birg
98b5eb9958 SetupWizard: don't crash without SIMs
SubscriptionManager may be null

Change-Id: Ia2112044400576a93931474a3fff2af161ccda21
Signed-off-by: Roman Birg <roman@cyngn.com>
2015-03-26 03:44:35 -07:00
Steve Kondik
c225cd58f7 setupwizard: Adapt to MR1 multisim APIs
Change-Id: Icb5bad076fe5a5e8a26befc5bedd04981c374117
2015-03-22 17:18:31 -07:00
cretin45
bfde63c27c SetupWizard: #blamethemes
Themes keep breaking the handle themeConfig flag. This provides a workaround for cases the activity gets torn down during the finish process.

Change-Id: I6664ded3dfff5b69c1217f89f25106953cb5f92a
2015-03-13 16:18:24 -07:00
cretin45
0ed67f547c SetupWizard: Only go through OOBE if owner
Change-Id: I3886119d0d6fd69f18ea23d4b6435da75280dbf8
2015-03-12 13:50:19 -07:00
cretin45
f66c56b62f SetupWizard: Only update network state when resumed
Change-Id: Id018bf0ed4d9c54a1d6d57d53749c265b1d0e269
2015-03-11 17:14:22 -07:00
cretin45
77fce341b1 SetupWizard: Update legal link
Change-Id: I1389dbb3e7e0ba3b7db992fdef02f4c8fdc1692d
2015-03-11 09:59:24 -07:00
cretin45
0d31b31aac SetupWizard: Refactor for better transitions out of OOBE
Change-Id: If91da3f44dbc5383236b54da529953d48a475250
2015-03-09 14:49:31 -07:00
Scott Mertz
7732b7485d SetupWizard: move to CmHardwareService
Change-Id: I9413151fe307d23196ea5736dc8c50966a43a7cc
2015-03-07 00:56:09 +00:00
Michael Bestas
7faec91e22 Automatic translation import
Change-Id: Ie14f953a377b6d9410c6b5b386334e153abd4964
2015-03-06 22:14:59 +00:00
cretin45
7c8e091320 SetupWizard: Fix race condition on finish
Change-Id: Ie4a5893c49db7ce9622091e05776cb5523ed5c45
2015-03-06 14:01:53 -08:00
17 changed files with 366 additions and 153 deletions

View File

@@ -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

View File

@@ -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">

View File

@@ -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>

View File

@@ -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;

View File

@@ -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";

View File

@@ -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;
}

View File

@@ -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()) {

View 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());
}
}

View File

@@ -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();
}
}
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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() {

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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)) {

View File

@@ -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");
}