Compare commits

...

13 Commits

Author SHA1 Message Date
cretin45
a517e7cdfa SetupWizard: Handle all touch events in EnableAccessibilityController
Change-Id: Icf15be21c90d32305a9c1f8b9835eb473acf1f33
(cherry picked from commit 0fde3a04cc)
2015-06-19 19:06:03 +00:00
cretin45
22159e1a42 SetupWizard: Increase delay for accessibility
Ticket: OPO-207

Change-Id: Ifff7161f95e91ec7763f388206cd1d30804ad600
(cherry picked from commit 9dd952e3f6)
(cherry picked from commit 838a8e11b2)
2015-06-19 00:44:41 +00:00
d34d
2ef228ea3d Remove use of mCanceled
It is possible for mCanceled to be set to true even though it
was canceled without ever playing back the cancelation message.
This can end up putting us in an incorrect state where the user
must release both fingers so ACTION_UP finally sets mCanceled to
false.

The cancel() method was still being called and since it does the
proper checks for removing/sending messages, the use of mCanceled
is unneccessary.

Change-Id: I38679d3bf65157a9ba5ca3d898c5c8d55e5df9f5
REF: LETTUCE-293
(cherry picked from commit a726a3d990)
2015-06-11 00:35:38 +00:00
cretin45
e499b32d70 SetupWizard: Initialize the nav keys bundle boolean
Change-Id: I50f2ef0fb7226c8b58437b669ca71df436d68ee8
2015-03-20 15:07:35 -07:00
cretin45
bdfe88d06b SetupWizard: Fix regression for devices without custom default theme
Change-Id: Ia223c1b118dbb68e596ff01cf944bc870a321752
2015-03-20 15:06:44 -07:00
cretin45
1540532700 SetupWizard: Fix regression, only init pages once
Change-Id: I1207cb3975daa752a66eb8e9e40635f9a8009509
(cherry picked from commit 83be05d6ec)
2015-03-19 17:50:29 +00:00
d34d
c756a8c22b 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: Iff50571adfabb97b10c3c3257cf9fb2d8e5b0d79
2015-03-18 10:16:54 -07:00
cretin45
d84b71f941 SetupWizard: Only go through OOBE if owner
Change-Id: I3886119d0d6fd69f18ea23d4b6435da75280dbf8
(cherry picked from commit 0ed67f547c)
2015-03-18 17:13:32 +00:00
cretin45
22e251dc86 SetupWizard: Better handling of launching into other activities
Change-Id: I4d8dc4a1b25e45c6ff35042239a0adf4c16458f1
(cherry picked from commit ed5d46703e)
2015-03-17 22:20:53 +00:00
cretin45
22d81f407a SetupWizard: Refactor for better transitions out of OOBE
Change-Id: If91da3f44dbc5383236b54da529953d48a475250
(cherry picked from commit 0d31b31aac)
2015-03-16 22:30:37 +00:00
cretin45
3e845be8c4 SetupWizard: Only update network state when resumed
Change-Id: Id018bf0ed4d9c54a1d6d57d53749c265b1d0e269
(cherry picked from commit f66c56b62f)
2015-03-12 00:16:09 +00:00
cretin45
b72a776fff SetupWizard: Update legal link
Change-Id: I1389dbb3e7e0ba3b7db992fdef02f4c8fdc1692d
(cherry picked from commit 77fce341b1)
2015-03-11 17:01:13 +00:00
cretin45
07e2d37258 SetupWizard: Fix race condition on finish
Change-Id: Ie4a5893c49db7ce9622091e05776cb5523ed5c45
(cherry picked from commit 7c8e091320)
2015-03-06 22:03:14 +00:00
21 changed files with 476 additions and 324 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/decelerate_quad">
<alpha android:fromAlpha="0.0" android:toAlpha="1.0"
android:duration="@android:integer/config_shortAnimTime"/>
</set>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2009, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/accelerate_quad">
<alpha android:fromAlpha="1.0" android:toAlpha="0"
android:duration="@android:integer/config_shortAnimTime"/>
</set>

View File

@@ -18,12 +18,25 @@
<style name="Theme.Setup" parent="@android:style/Theme.Material.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/page_background</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorPrimary">@color/primary</item>
<item name="android:colorPrimaryDark">@color/primary</item>
<item name="android:colorAccent">@color/accent</item>
<item name="android:textColorLink">@color/accent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowAnimationStyle">@style/ActivityAnimations</item>
</style>
<style name="ActivityAnimations" parent="@android:style/Animation.Activity">
<item name="android:activityOpenEnterAnimation">@anim/translucent_enter</item>
<item name="android:activityOpenExitAnimation">@anim/translucent_exit</item>
<item name="android:activityCloseEnterAnimation">@anim/translucent_enter</item>
<item name="android:activityCloseExitAnimation">@anim/translucent_exit</item>
<item name="android:taskToFrontEnterAnimation">@anim/translucent_enter</item>
<item name="android:taskToFrontExitAnimation">@anim/translucent_exit</item>
<item name="android:taskToBackEnterAnimation">@anim/translucent_enter</item>
<item name="android:taskToBackExitAnimation">@anim/translucent_exit</item>
</style>
<style name="Header">
@@ -32,6 +45,7 @@
<style name="PageContainer">
<item name="android:textColor">@color/primary_text</item>
<item name="android:background">@color/page_background</item>
</style>
<style name="PageContent">

View File

@@ -20,8 +20,11 @@ package com.cyanogenmod.setupwizard;
import android.app.Application;
import android.app.StatusBarManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.provider.Settings;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
public class SetupWizardApp extends Application {
public static final String TAG = SetupWizardApp.class.getSimpleName();
@@ -44,6 +47,12 @@ public class SetupWizardApp extends Application {
private static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
private static final String[] THEME_PACKAGES = {
"org.cyanogenmod.theme.chooser",
"com.cyngn.theme.chooser",
"com.cyngn.themestore"
};
public static final int REQUEST_CODE_SETUP_WIFI = 0;
public static final int REQUEST_CODE_SETUP_GMS= 1;
public static final int REQUEST_CODE_RESTORE_GMS= 2;
@@ -55,8 +64,26 @@ public class SetupWizardApp extends Application {
@Override
public void onCreate() {
super.onCreate();
disableCaptivePortalDetection();
mStatusBarManager = (StatusBarManager)getSystemService(Context.STATUS_BAR_SERVICE);
try {
// Since this is a new component, we need to disable here if the user
// has already been through setup on a previous version.
final boolean isOwner = SetupWizardUtils.isOwner();
if (!isOwner
|| Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE) == 1) {
SetupWizardUtils.disableGMSSetupWizard(this);
SetupWizardUtils.disableSetupWizard(this);
if (!isOwner) {
disableThemeComponentsForSecondaryUser();
}
} else {
disableCaptivePortalDetection();
}
} catch (Settings.SettingNotFoundException e) {
// Continue with setup
disableCaptivePortalDetection();
}
}
public void disableStatusBar() {
@@ -76,4 +103,17 @@ public class SetupWizardApp extends Application {
public void enableCaptivePortalDetection() {
Settings.Global.putInt(getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 1);
}
private void disableThemeComponentsForSecondaryUser() {
PackageManager pm = getPackageManager();
for(String pkgName : THEME_PACKAGES) {
try {
pm.getApplicationInfo(pkgName, 0);
pm.setApplicationEnabledSetting(pkgName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER, 0);
} catch (PackageManager.NameNotFoundException e) {
// don't care
}
}
}
}

View File

@@ -23,7 +23,6 @@ import android.net.ConnectivityManager;
import android.telephony.TelephonyManager;
import com.android.internal.telephony.TelephonyIntents;
import com.cyanogenmod.setupwizard.ui.SetupWizardActivity;
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
import java.util.ArrayList;
@@ -47,7 +46,7 @@ public class CMSetupWizardData extends AbstractSetupData {
if (SetupWizardUtils.hasTelephony(mContext)) {
pages.add(new SimCardMissingPage(mContext, this).setHidden(isSimInserted()));
}
if (SetupWizardUtils.isMultiSimDevice(mContext) && SetupWizardUtils.isOwner()) {
if (SetupWizardUtils.isMultiSimDevice(mContext)) {
pages.add(new ChooseDataSimPage(mContext, this).setHidden(!allSimsInserted()));
}
if (SetupWizardUtils.hasTelephony(mContext)) {
@@ -57,12 +56,10 @@ public class CMSetupWizardData extends AbstractSetupData {
if (SetupWizardUtils.hasGMS(mContext)) {
pages.add(new GmsAccountPage(mContext, this).setHidden(true));
}
if (SetupWizardUtils.isOwner()) {
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));
}
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));
pages.add(new FinishPage(mContext, this));
return new PageList(pages.toArray(new SetupPage[pages.size()]));
}
@@ -86,7 +83,9 @@ public class CMSetupWizardData extends AbstractSetupData {
}
showHideMobileDataPage();
} else if (intent.getAction()
.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
.equals(ConnectivityManager.CONNECTIVITY_ACTION) ||
intent.getAction()
.equals(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE)) {
showHideAccountPages();
} else if (intent.getAction()
.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
@@ -139,6 +138,7 @@ public class CMSetupWizardData extends AbstractSetupData {
filter.addAction(TelephonyIntents.ACTION_SIM_STATE_CHANGED);
filter.addAction(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
}
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE);
filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
filter.addAction(Intent.ACTION_TIME_CHANGED);

View File

@@ -86,6 +86,8 @@ public class ChooseDataSimPage extends SetupPage {
private SparseArray<ServiceState> mServiceStates;
private SparseArray<PhoneStateListener> mPhoneStateListeners;
private boolean mIsAttached = false;
private View.OnClickListener mSetDataSimClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
@@ -121,12 +123,6 @@ public class ChooseDataSimPage extends SetupPage {
mPhoneStateListeners.put(i, createPhoneStateListener(subInfoRecord));
mPageView.addView(inflater.inflate(R.layout.divider, null));
}
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i),
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
updateSignalStrengths();
updateCurrentDataSub();
}
@@ -139,16 +135,24 @@ public class ChooseDataSimPage extends SetupPage {
@Override
public void onResume() {
super.onResume();
mIsAttached = true;
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i),
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
updateSignalStrengths();
updateCurrentDataSub();
}
@Override
public void onDetach() {
public void onPause() {
super.onPause();
mIsAttached = false;
for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i), PhoneStateListener.LISTEN_NONE);
}
super.onDetach();
}
private PhoneStateListener createPhoneStateListener(final SubInfoRecord subInfoRecord) {
@@ -156,98 +160,105 @@ public class ChooseDataSimPage extends SetupPage {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (isDetached()) return;
mSignalStrengths.put(subInfoRecord.slotId, signalStrength);
updateSignalStrength(subInfoRecord);
if (mIsAttached) {
mSignalStrengths.put(subInfoRecord.slotId, signalStrength);
updateSignalStrength(subInfoRecord);
}
}
@Override
public void onServiceStateChanged(ServiceState state) {
if (isDetached()) return;
mServiceStates.put(subInfoRecord.slotId, state);
updateSignalStrength(subInfoRecord);
if (mIsAttached) {
mServiceStates.put(subInfoRecord.slotId, state);
updateSignalStrength(subInfoRecord);
}
}
};
}
private void updateSignalStrengths() {
if (isDetached()) return;
for (int i = 0; i < mSubInfoRecords.size(); i++) {
updateSignalStrength(mSubInfoRecords.get(i));
if (mIsAttached) {
for (int i = 0; i < mSubInfoRecords.size(); i++) {
updateSignalStrength(mSubInfoRecords.get(i));
}
}
}
private void setDataSubChecked(SubInfoRecord subInfoRecord) {
if (isDetached()) return;
for (int i = 0; i < mCheckBoxes.size(); i++) {
if (subInfoRecord.slotId == i) {
mCheckBoxes.get(i).setChecked(true);
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
SetupStats.Action.PREFERRED_DATA_SIM,
SetupStats.Label.SLOT, String.valueOf(i + 1));
} else {
mCheckBoxes.get(i).setChecked(false);
}
if (mIsAttached) {
for (int i = 0; i < mCheckBoxes.size(); i++) {
if (subInfoRecord.slotId == i) {
mCheckBoxes.get(i).setChecked(true);
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
SetupStats.Action.PREFERRED_DATA_SIM,
SetupStats.Label.SLOT, String.valueOf(i + 1));
} else {
mCheckBoxes.get(i).setChecked(false);
}
}
}
}
private void updateCurrentDataSub() {
if (isDetached()) return;
for (int i = 0; i < mSubInfoRecords.size(); i++) {
SubInfoRecord subInfoRecord = mSubInfoRecords.get(i);
mCheckBoxes.get(i).setChecked(SubscriptionManager.getDefaultDataSubId()
== subInfoRecord.subId);
if (mIsAttached) {
for (int i = 0; i < mSubInfoRecords.size(); i++) {
SubInfoRecord subInfoRecord = mSubInfoRecords.get(i);
mCheckBoxes.get(i).setChecked(SubscriptionManager.getDefaultDataSubId()
== subInfoRecord.subId);
}
}
}
private void updateCarrierText(SubInfoRecord subInfoRecord) {
if (isDetached()) return;
String name = mPhone.getNetworkOperatorName(subInfoRecord.subId);
ServiceState serviceState = mServiceStates.get(subInfoRecord.slotId);
if (TextUtils.isEmpty(name)) {
if (serviceState != null && serviceState.isEmergencyOnly()) {
name = getString(R.string.setup_mobile_data_emergency_only);
} else {
name = getString(R.string.setup_mobile_data_no_service);
if (mIsAttached) {
String name = mPhone.getNetworkOperatorName(subInfoRecord.subId);
ServiceState serviceState = mServiceStates.get(subInfoRecord.slotId);
if (TextUtils.isEmpty(name)) {
if (serviceState != null && serviceState.isEmergencyOnly()) {
name = getString(R.string.setup_mobile_data_emergency_only);
} else {
name = getString(R.string.setup_mobile_data_no_service);
}
}
String formattedName =
getString(R.string.data_sim_name, subInfoRecord.slotId + 1, name);
mNameViews.get(subInfoRecord.slotId).setText(formattedName);
}
String formattedName =
getString(R.string.data_sim_name, subInfoRecord.slotId + 1, name);
mNameViews.get(subInfoRecord.slotId).setText(formattedName);
}
private void updateSignalStrength(SubInfoRecord subInfoRecord) {
if (isDetached()) return;
ImageView signalView = mSignalViews.get(subInfoRecord.slotId);
SignalStrength signalStrength = mSignalStrengths.get(subInfoRecord.slotId);
if (!hasService(subInfoRecord)) {
signalView.setImageResource(R.drawable.ic_signal_no_signal);
} else {
if (signalStrength != null) {
int resId;
switch (signalStrength.getLevel()) {
case 4:
resId = R.drawable.ic_signal_4;
break;
case 3:
resId = R.drawable.ic_signal_3;
break;
case 2:
resId = R.drawable.ic_signal_2;
break;
case 1:
resId = R.drawable.ic_signal_1;
break;
default:
resId = R.drawable.ic_signal_0;
break;
if (mIsAttached) {
ImageView signalView = mSignalViews.get(subInfoRecord.slotId);
SignalStrength signalStrength = mSignalStrengths.get(subInfoRecord.slotId);
if (!hasService(subInfoRecord)) {
signalView.setImageResource(R.drawable.ic_signal_no_signal);
} else {
if (signalStrength != null) {
int resId;
switch (signalStrength.getLevel()) {
case 4:
resId = R.drawable.ic_signal_4;
break;
case 3:
resId = R.drawable.ic_signal_3;
break;
case 2:
resId = R.drawable.ic_signal_2;
break;
case 1:
resId = R.drawable.ic_signal_1;
break;
default:
resId = R.drawable.ic_signal_0;
break;
}
signalView.setImageResource(resId);
}
signalView.setImageResource(resId);
}
updateCarrierText(subInfoRecord);
}
updateCarrierText(subInfoRecord);
}
private boolean hasService(SubInfoRecord subInfoRecord) {

View File

@@ -28,6 +28,7 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
@@ -83,17 +84,13 @@ public class CyanogenServicesPage extends SetupPage {
if (!SetupWizardUtils.accountExists(mContext,
mContext.getString(R.string.cm_account_type))) {
super.doLoadAction(fragmentManager, action);
launchCyanogenAccountSetup();
} else {
getCallbacks().onNextPage();
}
}
}
@Override
public void onFragmentReady() {
launchCyanogenAccountSetup();
}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN) {
@@ -127,6 +124,7 @@ public class CyanogenServicesPage extends SetupPage {
null, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
boolean error = false;
try {
Bundle result = future.getResult();
Intent intent = result
@@ -135,24 +133,26 @@ public class CyanogenServicesPage extends SetupPage {
ActivityOptions.makeCustomAnimation(mContext,
android.R.anim.fade_in,
android.R.anim.fade_out);
if (!mFragment.isDetached()) {
SetupStats
.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
SetupStats.Label.PAGE,
SetupStats.Label.CYANOGEN_ACCOUNT);
mFragment.startActivityForResult(intent,
SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN,
options.toBundle());
} else {
if (getCallbacks().
isCurrentPage(CyanogenServicesPage.this)) {
getCallbacks().onNextPage();
}
}
SetupStats
.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
SetupStats.Label.PAGE,
SetupStats.Label.CYANOGEN_ACCOUNT);
mFragment.startActivityForResult(intent,
SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN,
options.toBundle());
} catch (OperationCanceledException e) {
error = true;
} catch (IOException e) {
error = true;
} catch (AuthenticatorException e) {
Log.e(TAG, "Error launching cm account", e);
error = true;
} finally {
if (error && getCallbacks().
isCurrentPage(CyanogenServicesPage.this)) {
getCallbacks().onNextPage();
}
}
}
}, null);

View File

@@ -62,7 +62,7 @@ public class CyanogenSettingsPage extends SetupPage {
public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme";
public static final String SETTING_METRICS = "settings.cyanogen.allow_metrics";
public static final String PRIVACY_POLICY_URI = "https://cyngn.com/legal";
public static final String PRIVACY_POLICY_URI = "https://cyngn.com/oobe-legal?hideHeader=1";
public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
@@ -207,7 +207,7 @@ public class CyanogenSettingsPage extends SetupPage {
SetupWizardUtils.isSimMissing(context));
}
protected static boolean hideThemeSwitch(Context context) {
private static boolean hideThemeSwitch(Context context) {
return ThemeUtils.getDefaultThemePackageName(context).equals(ThemeConfig.SYSTEM_DEFAULT);
}
@@ -222,6 +222,10 @@ public class CyanogenSettingsPage extends SetupPage {
private CheckBox mNavKeys;
private CheckBox mSecureSms;
private boolean mHideNavKeysRow = false;
private boolean mHideThemeRow = false;
private boolean mHideSmsRow = false;
private View.OnClickListener mMetricsClickListener = new View.OnClickListener() {
@Override
@@ -261,7 +265,6 @@ public class CyanogenSettingsPage extends SetupPage {
@Override
protected void initializePage() {
final Bundle myPageBundle = mPage.getData();
String privacy_policy = getString(R.string.services_privacy_policy);
String policySummary = getString(R.string.services_explanation, privacy_policy);
SpannableString ss = new SpannableString(policySummary);
@@ -292,14 +295,10 @@ public class CyanogenSettingsPage extends SetupPage {
TextView metrics = (TextView) mRootView.findViewById(R.id.enable_metrics_summary);
metrics.setText(metricsSpan);
mMetrics = (CheckBox) mRootView.findViewById(R.id.enable_metrics_checkbox);
boolean metricsChecked =
!myPageBundle.containsKey(KEY_SEND_METRICS) || myPageBundle
.getBoolean(KEY_SEND_METRICS);
mMetrics.setChecked(metricsChecked);
myPageBundle.putBoolean(KEY_SEND_METRICS, metricsChecked);
mDefaultThemeRow = mRootView.findViewById(R.id.theme);
if (hideThemeSwitch(getActivity())) {
mHideThemeRow = hideThemeSwitch(getActivity());
if (mHideThemeRow) {
mDefaultThemeRow.setVisibility(View.GONE);
} else {
mDefaultThemeRow.setOnClickListener(mDefaultThemeClickListener);
@@ -315,11 +314,6 @@ public class CyanogenSettingsPage extends SetupPage {
TextView theme = (TextView) mRootView.findViewById(R.id.enable_theme_summary);
theme.setText(themeSpan);
mDefaultTheme = (CheckBox) mRootView.findViewById(R.id.enable_theme_checkbox);
boolean themesChecked =
!myPageBundle.containsKey(KEY_APPLY_DEFAULT_THEME) || myPageBundle
.getBoolean(KEY_APPLY_DEFAULT_THEME);
mDefaultTheme.setChecked(themesChecked);
myPageBundle.putBoolean(KEY_APPLY_DEFAULT_THEME, themesChecked);
}
mNavKeysRow = mRootView.findViewById(R.id.nav_keys);
@@ -331,7 +325,8 @@ public class CyanogenSettingsPage extends SetupPage {
needsNavBar = windowManager.needsNavigationBar();
} catch (RemoteException e) {
}
if (hideKeyDisabler() || needsNavBar) {
mHideNavKeysRow = hideKeyDisabler();
if (mHideNavKeysRow || needsNavBar) {
mNavKeysRow.setVisibility(View.GONE);
} else {
boolean navKeysDisabled =
@@ -350,15 +345,11 @@ public class CyanogenSettingsPage extends SetupPage {
0, useSecureSms.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
TextView secureSms = (TextView) mRootView.findViewById(R.id.secure_sms_summary);
secureSms.setText(secureSmsSpan);
if (hideWhisperPush(getActivity())) {
mHideSmsRow = hideWhisperPush(getActivity());
if (mHideSmsRow) {
mSecureSmsRow.setVisibility(View.GONE);
}
mSecureSms = (CheckBox) mRootView.findViewById(R.id.secure_sms_checkbox);
boolean smsChecked = myPageBundle.containsKey(KEY_REGISTER_WHISPERPUSH) ?
myPageBundle.getBoolean(KEY_REGISTER_WHISPERPUSH) :
false;
mSecureSms.setChecked(smsChecked);
myPageBundle.putBoolean(KEY_REGISTER_WHISPERPUSH, smsChecked);
}
@Override
@@ -370,15 +361,53 @@ public class CyanogenSettingsPage extends SetupPage {
public void onResume() {
super.onResume();
updateDisableNavkeysOption();
updateMetricsOption();
updateThemeOption();
updateSmsOption();
}
private void updateMetricsOption() {
final Bundle myPageBundle = mPage.getData();
boolean metricsChecked =
!myPageBundle.containsKey(KEY_SEND_METRICS) || myPageBundle
.getBoolean(KEY_SEND_METRICS);
mMetrics.setChecked(metricsChecked);
myPageBundle.putBoolean(KEY_SEND_METRICS, metricsChecked);
}
private void updateThemeOption() {
if (!mHideThemeRow) {
final Bundle myPageBundle = mPage.getData();
boolean themesChecked =
!myPageBundle.containsKey(KEY_APPLY_DEFAULT_THEME) || myPageBundle
.getBoolean(KEY_APPLY_DEFAULT_THEME);
mDefaultTheme.setChecked(themesChecked);
myPageBundle.putBoolean(KEY_APPLY_DEFAULT_THEME, themesChecked);
}
}
private void updateSmsOption() {
if (!mHideSmsRow) {
final Bundle myPageBundle = mPage.getData();
boolean smsChecked = myPageBundle.containsKey(KEY_REGISTER_WHISPERPUSH) ?
myPageBundle.getBoolean(KEY_REGISTER_WHISPERPUSH) :
false;
mSecureSms.setChecked(smsChecked);
myPageBundle.putBoolean(KEY_REGISTER_WHISPERPUSH, smsChecked);
}
}
private void updateDisableNavkeysOption() {
boolean enabled = Settings.Secure.getInt(getActivity().getContentResolver(),
Settings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) != 0;
boolean checked = mPage.getData().containsKey(KEY_ENABLE_NAV_KEYS) ?
mPage.getData().getBoolean(KEY_ENABLE_NAV_KEYS) :
enabled;
mNavKeys.setChecked(checked);
if (!mHideNavKeysRow) {
final Bundle myPageBundle = mPage.getData();
boolean enabled = Settings.Secure.getInt(getActivity().getContentResolver(),
Settings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) != 0;
boolean checked = myPageBundle.containsKey(KEY_ENABLE_NAV_KEYS) ?
myPageBundle.getBoolean(KEY_ENABLE_NAV_KEYS) :
enabled;
mNavKeys.setChecked(checked);
myPageBundle.putBoolean(KEY_ENABLE_NAV_KEYS, checked);
}
}
}

View File

@@ -114,14 +114,10 @@ public class GmsAccountPage extends SetupPage {
getCallbacks().onPreviousPage();
} else {
super.doLoadAction(fragmentManager, action);
launchGmsAccountSetup();
}
}
@Override
public void onFragmentReady() {
launchGmsAccountSetup();
}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS) {
@@ -217,6 +213,7 @@ public class GmsAccountPage extends SetupPage {
bundle, null, new AccountManagerCallback<Bundle>() {
@Override
public void run(AccountManagerFuture<Bundle> future) {
boolean error = false;
try {
Bundle result = future.getResult();
Intent intent = result
@@ -225,20 +222,23 @@ public class GmsAccountPage extends SetupPage {
ActivityOptions.makeCustomAnimation(mContext,
android.R.anim.fade_in,
android.R.anim.fade_out);
if (!mFragment.isDetached()) {
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
SetupStats.Label.PAGE, SetupStats.Label.GMS_ACCOUNT);
mFragment.startActivityForResult(intent,
SetupWizardApp.REQUEST_CODE_SETUP_GMS, options.toBundle());
} else {
if (getCallbacks().isCurrentPage(GmsAccountPage.this)) {
getCallbacks().onNextPage();
}
}
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
SetupStats.Label.PAGE, SetupStats.Label.GMS_ACCOUNT);
mFragment.startActivityForResult(intent,
SetupWizardApp.REQUEST_CODE_SETUP_GMS, options.toBundle());
} catch (OperationCanceledException e) {
error = true;
} catch (IOException e) {
error = true;
} catch (AuthenticatorException e) {
Log.e(TAG, "Error launching gms account", e);
error = true;
} finally {
if (error && getCallbacks().
isCurrentPage(GmsAccountPage.this)) {
getCallbacks().onNextPage();
}
}
}
}, null);

View File

@@ -16,7 +16,6 @@
package com.cyanogenmod.setupwizard.setup;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
@@ -79,21 +78,25 @@ public class MobileDataPage extends SetupPage {
private SignalStrength mSignalStrength;
private ServiceState mServiceState;
private boolean mIsAttached = false;
private PhoneStateListener mPhoneStateListener =
new PhoneStateListener(SubscriptionManager.getDefaultDataSubId()) {
@Override
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
if (isDetached()) return;
mSignalStrength = signalStrength;
updateSignalStrength();
if (mIsAttached) {
mSignalStrength = signalStrength;
updateSignalStrength();
}
}
@Override
public void onServiceStateChanged(ServiceState state) {
if (isDetached()) return;
mServiceState = state;
updateSignalStrength();
if (mIsAttached) {
mServiceState = state;
updateSignalStrength();
}
}
};
@@ -129,66 +132,66 @@ public class MobileDataPage extends SetupPage {
@Override
public void onResume() {
super.onResume();
mIsAttached = true;
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
mPhone.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
updateDataConnectionStatus();
updateSignalStrength();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
mPhone.listen(mPhoneStateListener,
PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
}
@Override
public void onDetach() {
public void onPause() {
super.onPause();
mIsAttached = false;
mPhone.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE);
super.onDetach();
}
private void updateCarrierText() {
if (isDetached()) return;
String name = mPhone.getNetworkOperatorName(SubscriptionManager.getDefaultDataSubId());
if (TextUtils.isEmpty(name)) {
if (mServiceState != null && mServiceState.isEmergencyOnly()) {
name = getString(R.string.setup_mobile_data_emergency_only);
} else {
name = getString(R.string.setup_mobile_data_no_service);
if (mIsAttached) {
String name =
mPhone.getNetworkOperatorName(SubscriptionManager.getDefaultDataSubId());
if (TextUtils.isEmpty(name)) {
if (mServiceState != null && mServiceState.isEmergencyOnly()) {
name = getString(R.string.setup_mobile_data_emergency_only);
} else {
name = getString(R.string.setup_mobile_data_no_service);
}
}
mNameView.setText(name);
}
mNameView.setText(name);
}
private void updateSignalStrength() {
if (isDetached()) return;
if (!hasService()) {
mSignalView.setImageResource(R.drawable.ic_signal_no_signal);
} else {
if (mSignalStrength != null) {
int resId;
switch (mSignalStrength.getLevel()) {
case 4:
resId = R.drawable.ic_signal_4;
break;
case 3:
resId = R.drawable.ic_signal_3;
break;
case 2:
resId = R.drawable.ic_signal_2;
break;
case 1:
resId = R.drawable.ic_signal_1;
break;
default:
resId = R.drawable.ic_signal_0;
break;
if (mIsAttached) {
if (!hasService()) {
mSignalView.setImageResource(R.drawable.ic_signal_no_signal);
} else {
if (mSignalStrength != null) {
int resId;
switch (mSignalStrength.getLevel()) {
case 4:
resId = R.drawable.ic_signal_4;
break;
case 3:
resId = R.drawable.ic_signal_3;
break;
case 2:
resId = R.drawable.ic_signal_2;
break;
case 1:
resId = R.drawable.ic_signal_1;
break;
default:
resId = R.drawable.ic_signal_0;
break;
}
mSignalView.setImageResource(resId);
}
mSignalView.setImageResource(resId);
}
updateCarrierText();
}
updateCarrierText();
}
private void updateDataConnectionStatus() {

View File

@@ -136,18 +136,13 @@ public class OtherSettingsPage extends SetupPage {
}
};
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mContentResolver = getActivity().getContentResolver();
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
}
@Override
protected void initializePage() {
final boolean hasGms = SetupWizardUtils.hasGMS(getActivity());
final boolean hasTelephony = SetupWizardUtils.hasTelephony(getActivity());
mContentResolver = getActivity().getContentResolver();
mBackupManager = IBackupManager.Stub.asInterface(
ServiceManager.getService(Context.BACKUP_SERVICE));
TextView summaryView = (TextView) mRootView.findViewById(android.R.id.summary);
if (hasGms) {
String privacy_policy = getString(R.string.services_privacy_policy);

View File

@@ -43,7 +43,6 @@ public interface Page {
public boolean doPreviousAction();
public boolean doNextAction();
public void doLoadAction(FragmentManager fragmentManager, int action);
public void onFragmentReady();
public void onFinishSetup();
public boolean onActivityResult(int requestCode, int resultCode, Intent data);
public SetupDataCallbacks getCallbacks();

View File

@@ -96,9 +96,6 @@ public abstract class SetupPage implements Page {
}
}
@Override
public void onFragmentReady(){}
@Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
return false;

View File

@@ -136,8 +136,10 @@ public class WifiSetupPage extends SetupPage {
return R.string.loading;
}
@Override
public void onFragmentReady() {
public void doLoadAction(FragmentManager fragmentManager, int action) {
super.doLoadAction(fragmentManager, action);
launchWifiSetup();
}

View File

@@ -16,9 +16,39 @@
package com.cyanogenmod.setupwizard.ui;
import android.content.Intent;
import android.os.Bundle;
import com.cyanogenmod.setupwizard.R;
public class LoadingFragment extends SetupPageFragment {
private StartActivityForResultRunnable mStartActivityForResultRunnable;
@Override
public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
if (isResumed()) {
super.startActivityForResult(intent, requestCode, options);
} else {
mStartActivityForResultRunnable =
new StartActivityForResultRunnable(this, intent, requestCode, options);
}
}
@Override
public void onResume() {
super.onResume();
if (mStartActivityForResultRunnable != null) {
mStartActivityForResultRunnable.run();
}
}
@Override
public void onPause() {
super.onPause();
mStartActivityForResultRunnable = null;
}
@Override
protected void initializePage() {}
@@ -26,4 +56,26 @@ public class LoadingFragment extends SetupPageFragment {
protected int getLayoutResource() {
return R.layout.setup_loading_page;
}
private static class StartActivityForResultRunnable implements Runnable {
private final LoadingFragment mLoadingFragment;
private final Intent mIntent;
private final int mRequestCode;
private final Bundle mOptions;
private StartActivityForResultRunnable(LoadingFragment loadingFragment,
Intent intent, int requestCode, Bundle options) {
mLoadingFragment = loadingFragment;
mIntent = intent;
mRequestCode = requestCode;
mOptions = options;
}
@Override
public void run() {
mLoadingFragment.startActivityForResult(mIntent, mRequestCode, mOptions);
mLoadingFragment.mStartActivityForResultRunnable = null;
}
}
}

View File

@@ -58,20 +58,8 @@ public abstract class SetupPageFragment extends Fragment {
mRootView = inflater.inflate(getLayoutResource(), container, false);
mTitleView = (TextView) mRootView.findViewById(android.R.id.title);
mHeaderView = (ViewGroup ) mRootView.findViewById(R.id.header);
getActivity().startPostponedEnterTransition();
return mRootView;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mPage = mCallbacks.getPage(mKey);
if (mTitleView != null) {
mTitleView.setText(mPage.getTitleResId());
}
initializePage();
mPage.onFragmentReady();
mCallbacks.onPageLoaded(mPage);
return mRootView;
}
@Override
@@ -89,6 +77,17 @@ public abstract class SetupPageFragment extends Fragment {
mCallbacks = null;
}
@Override
public void onResume() {
super.onResume();
mPage = mCallbacks.getPage(mKey);
if (mTitleView != null) {
mTitleView.setText(mPage.getTitleResId());
}
mCallbacks.onPageLoaded(mPage);
getActivity().startPostponedEnterTransition();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mPage.onActivityResult(requestCode, resultCode, data);

View File

@@ -51,7 +51,8 @@ import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
import java.util.ArrayList;
public class SetupWizardActivity extends Activity implements SetupDataCallbacks {
public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
ThemeManager.ThemeChangeListener {
private static final String TAG = SetupWizardActivity.class.getSimpleName();
@@ -68,23 +69,18 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
private final Handler mHandler = new Handler();
private boolean mIsGuestUser = false;
private volatile boolean mIsFinishing = false;
private static long sLaunchTime = 0;
private final ArrayList<Runnable> mFinishRunnables = new ArrayList<Runnable>();
private ThemeManager.ThemeChangeListener mThemeChangeListener;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (sLaunchTime == 0) {
SetupStats.addEvent(SetupStats.Categories.APP_LAUNCH, TAG);
sLaunchTime = System.nanoTime();
}
getWindow().setWindowAnimations(android.R.anim.fade_in);
setContentView(R.layout.setup_main);
mRootView = findViewById(R.id.root);
mReveal = (ImageView)mRootView.findViewById(R.id.reveal);
@@ -124,23 +120,11 @@ 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);
}
});
// Since this is a new component, we need to disable here if the user
// has already been through setup on a previous version.
try {
if (Settings.Secure.getInt(getContentResolver(),
Settings.Secure.USER_SETUP_COMPLETE) == 1) {
finalizeSetup();
}
} catch (Settings.SettingNotFoundException e) {
// Continue with setup
}
mIsGuestUser = SetupWizardUtils.isGuestUser(this);
if (mIsGuestUser) {
finalizeSetup();
}
registerReceiver(mSetupData, mSetupData.getIntentFilter());
}
@@ -292,48 +276,41 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
mFinishingProgressBar.setIndeterminate(true);
mFinishingProgressBar.startAnimation(fadeIn);
final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE);
mThemeChangeListener = new ThemeManager.ThemeChangeListener() {
@Override
public void onProgress(int progress) {
if (progress > 0) {
mFinishingProgressBar.setIndeterminate(false);
mFinishingProgressBar.setProgress(progress);
}
}
@Override
public void onFinish(boolean isSuccess) {
finishSetup();
}
};
tm.addClient(mThemeChangeListener);
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();
}
@Override
public void onProgress(int progress) {
if (progress > 0) {
mFinishingProgressBar.setIndeterminate(false);
mFinishingProgressBar.setProgress(progress);
}
}
@Override
public void finishSetup() {
if (!mIsFinishing) {
mIsFinishing = true;
mHandler.post(new Runnable() {
@Override
public void run() {
final SetupWizardApp setupWizardApp = (SetupWizardApp)getApplication();
setupWizardApp.sendStickyBroadcastAsUser(
new Intent(SetupWizardApp.ACTION_FINISHED),
UserHandle.getCallingUserHandle());
setupRevealImage();
}
});
setupRevealImage();
}
}
@Override
public void finish() {
super.finish();
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
overridePendingTransition(R.anim.translucent_enter, R.anim.translucent_exit);
}
private void setupRevealImage() {
@@ -342,39 +319,26 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
mFinishingProgressBar.startAnimation(fadeOut);
mFinishingProgressBar.setVisibility(View.INVISIBLE);
final Thread t = new Thread() {
@Override
public void run() {
final Point p = new Point();
getWindowManager().getDefaultDisplay().getRealSize(p);
final WallpaperManager wallpaperManager =
WallpaperManager.getInstance(SetupWizardActivity.this);
wallpaperManager.forgetLoadedWallpaper();
final Bitmap wallpaper = wallpaperManager.getBitmap();
Bitmap cropped = null;
if (wallpaper != null) {
cropped = Bitmap.createBitmap(wallpaper, 0,
0, Math.min(p.x, wallpaper.getWidth()),
Math.min(p.y, wallpaper.getHeight()));
}
final Bitmap croppedWallpaper = cropped;
mHandler.post(new Runnable() {
@Override
public void run() {
if (croppedWallpaper != null) {
mReveal.setScaleType(ImageView.ScaleType.CENTER_CROP);
mReveal.setImageBitmap(croppedWallpaper);
} else {
mReveal.setBackground(wallpaperManager
.getBuiltInDrawable(p.x, p.y, false, 0, 0));
}
animateOut();
}
});
}
};
t.start();
final Point p = new Point();
getWindowManager().getDefaultDisplay().getRealSize(p);
final WallpaperManager wallpaperManager =
WallpaperManager.getInstance(SetupWizardActivity.this);
wallpaperManager.forgetLoadedWallpaper();
final Bitmap wallpaper = wallpaperManager.getBitmap();
Bitmap cropped = null;
if (wallpaper != null) {
cropped = Bitmap.createBitmap(wallpaper, 0,
0, Math.min(p.x, wallpaper.getWidth()),
Math.min(p.y, wallpaper.getHeight()));
}
if (cropped != null) {
mReveal.setScaleType(ImageView.ScaleType.CENTER_CROP);
mReveal.setImageBitmap(cropped);
} else {
mReveal.setBackground(wallpaperManager
.getBuiltInDrawable(p.x, p.y, false, 0, 0));
}
animateOut();
}
private void animateOut() {
@@ -421,7 +385,7 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks
}
final ThemeManager tm =
(ThemeManager) SetupWizardActivity.this.getSystemService(THEME_SERVICE);
tm.removeClient(mThemeChangeListener);
tm.removeClient(SetupWizardActivity.this);
SetupStats.sendEvents(SetupWizardActivity.this);
SetupWizardUtils.disableGMSSetupWizard(SetupWizardActivity.this);
Intent intent = new Intent(Intent.ACTION_MAIN);

View File

@@ -47,8 +47,8 @@ import java.util.List;
public class EnableAccessibilityController {
private static final int SPEAK_WARNING_DELAY_MILLIS = 2000;
private static final int ENABLE_ACCESSIBILITY_DELAY_MILLIS = 6000;
private static final int SPEAK_WARNING_DELAY_MILLIS = 5000;
private static final int ENABLE_ACCESSIBILITY_DELAY_MILLIS = 12000;
public static final int MESSAGE_SPEAK_WARNING = 1;
public static final int MESSAGE_SPEAK_ENABLE_CANCELED = 2;
@@ -91,7 +91,6 @@ public class EnableAccessibilityController {
private final float mTouchSlop;
private boolean mDestroyed;
private boolean mCanceled;
private float mFirstPointerDownX;
private float mFirstPointerDownY;
@@ -130,7 +129,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;
}
@@ -168,7 +167,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;
@@ -177,19 +176,19 @@ 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) {
@@ -200,17 +199,18 @@ 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)) {
@@ -287,4 +287,4 @@ public class EnableAccessibilityController {
}
}
}
}
}

View File

@@ -27,7 +27,6 @@ import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -43,11 +42,6 @@ public class SetupWizardUtils {
private SetupWizardUtils(){}
public static boolean isStatsCollectionEnabled(Context context) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.STATS_COLLECTION, 1) != 0;
}
public static void tryEnablingWifi(Context context) {
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
if (!wifiManager.isWifiEnabled()) {
@@ -160,7 +154,7 @@ public class SetupWizardUtils {
disableComponentArray(context, packageInfo.services);
disableComponentArray(context, packageInfo.receivers);
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Enable to disable GMS");
Log.e(TAG, "Unable to disable GMS");
}
}

View File

@@ -30,6 +30,7 @@
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
<uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<application android:icon="@drawable/icon">
<uses-library android:name="android.test.runner" />

View File

@@ -18,6 +18,7 @@ package com.cyanogenmod.setupwizard.tests;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -66,6 +67,8 @@ public class ManualTestActivity extends Activity {
pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP);
pm.clearApplicationUserData("com.cyanogenmod.setupwizard", null);
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses("com.cyanogenmod.setupwizard");
try {
PackageInfo packageInfo = getPackageManager()
.getPackageInfo("com.google.android.setupwizard",
@@ -110,7 +113,6 @@ public class ManualTestActivity extends Activity {
private void setSetupComplete() {
Settings.Secure.putInt(getContentResolver(), Settings.Secure.USER_SETUP_COMPLETE, 1);
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0);
Intent intent = new Intent("android.intent.action.MAIN");
intent.addCategory("android.intent.category.HOME");
final PackageManager pm = getPackageManager();
@@ -118,6 +120,8 @@ public class ManualTestActivity extends Activity {
"com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
pm.setComponentEnabledSetting(componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
ActivityManager am = (ActivityManager) getSystemService(Activity.ACTIVITY_SERVICE);
am.killBackgroundProcesses("com.cyanogenmod.setupwizard");
try {
PackageInfo packageInfo = this.getPackageManager()
.getPackageInfo("com.google.android.setupwizard",