SetupWizard: Part 1: Initial wizard manager conversion
Part 1 implements SetupWizard support if GMS is present. Change-Id: I0d465a9d84f0c477acc8309511894e9b194762f7
This commit is contained in:
@@ -24,6 +24,7 @@ LOCAL_JAVA_LIBRARIES := \
|
||||
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
|
||||
LOCAL_AAPT_FLAGS := --auto-add-overlay
|
||||
|
||||
include frameworks/opt/setupwizard/navigationbar/common.mk
|
||||
include frameworks/opt/setupwizard/library/common.mk
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
@@ -43,8 +43,6 @@
|
||||
<uses-permission android:name="android.permission.BACKUP" />
|
||||
<uses-permission android:name="cyanogenmod.permission.FINISH_SETUP" />
|
||||
<uses-permission android:name="cyanogenmod.permission.LEGALESE" />
|
||||
<uses-permission android:name="com.cyngn.stats.SEND_ANALYTICS" />
|
||||
<uses-permission android:name="com.cyanogen.permission.REQUEST_KILL_SWITCH_OP" />
|
||||
<uses-permission android:name="cyanogenmod.permission.WRITE_SETTINGS"/>
|
||||
<uses-permission android:name="cyanogenmod.permission.WRITE_SECURE_SETTINGS"/>
|
||||
|
||||
@@ -60,8 +58,6 @@
|
||||
<protected-broadcast android:name="com.cyanogenmod.setupwizard.SETUP_FINISHED"
|
||||
android:permission="cyanogenmod.permission.FINISH_SETUP"/>
|
||||
|
||||
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="23" />
|
||||
|
||||
<application android:label="@string/app_name"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:theme="@style/Theme.Setup"
|
||||
@@ -77,20 +73,67 @@
|
||||
android:immersive="true"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
|
||||
<intent-filter android:priority="9">
|
||||
<!-- <intent-filter android:priority="9">
|
||||
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
|
||||
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter> -->
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ui.WelcomeActivity"
|
||||
android:label="@string/product_name"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
android:immersive="true"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="com.cyanogenmod.setupwizard.LINEAGE_WELCOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name=".setup.FinishSetupReceiver"
|
||||
android:exported="true">
|
||||
<activity android:name=".ui.LocaleActivity"
|
||||
android:label="@string/product_name"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
android:immersive="true"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="com.cyanogenmod.setupwizard.ACTION_FINISH_SETUPWIZARD" />
|
||||
<action android:name="com.cyanogenmod.setupwizard.LINEAGE_LOCALE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ui.LineageSettingsActivity"
|
||||
android:label="@string/product_name"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
android:immersive="true"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="com.cyanogenmod.setupwizard.LINEAGE_SETTINGS" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ui.FinishActivity"
|
||||
android:label="@string/product_name"
|
||||
android:excludeFromRecents="true"
|
||||
android:configChanges="mcc|mnc"
|
||||
android:immersive="true"
|
||||
android:windowSoftInputMode="stateAlwaysHidden">
|
||||
<intent-filter>
|
||||
<action android:name="com.cyanogenmod.setupwizard.LINEAGE_SETUP_COMPLETE" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name=".PartnerReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="com.android.setupwizard.action.PARTNER_CUSTOMIZATION" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
@@ -17,6 +17,6 @@
|
||||
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="300"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="-100%"
|
||||
android:fromXDelta="100%"
|
||||
android:toXDelta="0%"
|
||||
android:interpolator="@android:anim/decelerate_interpolator" />
|
||||
|
@@ -17,6 +17,6 @@
|
||||
|
||||
<translate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:duration="300"
|
||||
android:fromXDelta="-100%"
|
||||
android:toXDelta="0%"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="100%"
|
||||
android:interpolator="@android:anim/decelerate_interpolator" />
|
||||
|
70
res/layout/finish_activity.xml
Normal file
70
res/layout/finish_activity.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
<com.cyanogenmod.setupwizard.ui.widget.ScrimInsetsFrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:fitsSystemWindows="true"
|
||||
app:insetForeground="@android:color/transparent">
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/primary">
|
||||
|
||||
<Space android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/brand_logo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/logo"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:padding="@dimen/content_margin_left"/>
|
||||
|
||||
<Space android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
|
||||
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
|
||||
android:id="@+id/navigation_bar"
|
||||
style="@style/setup_wizard_navbar_style" />
|
||||
|
||||
</LinearLayout>
|
||||
<ImageView android:id="@+id/reveal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/reveal"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/finishing_bar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="8dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:visibility="gone"/>
|
||||
</com.cyanogenmod.setupwizard.ui.widget.ScrimInsetsFrameLayout>
|
32
res/layout/logo_welcome.xml
Normal file
32
res/layout/logo_welcome.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 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.
|
||||
-->
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/primary">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/brand_logo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/logo"
|
||||
android:paddingLeft="@dimen/header_logo_margin_left"
|
||||
android:paddingBottom="@dimen/header_logo_margin_bottom"/>
|
||||
|
||||
|
||||
</RelativeLayout>
|
204
res/layout/setup_lineage_settings.xml
Normal file
204
res/layout/setup_lineage_settings.xml
Normal file
@@ -0,0 +1,204 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/primary">
|
||||
|
||||
|
||||
<include layout="@layout/header_condensed" />
|
||||
|
||||
<FrameLayout android:id="@+id/page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ScrollView android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="true">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- The caption about privacy policy -->
|
||||
<TextView
|
||||
android:id="@+id/privacy_policy"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="15sp"
|
||||
android:layout_marginBottom="@dimen/summary_margin_bottom"
|
||||
android:paddingLeft="@dimen/content_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_right"
|
||||
style="@style/PageSummaryText"
|
||||
android:text="@string/services_explanation"
|
||||
android:clickable="true"/>
|
||||
|
||||
<!-- Whether or not to enable metrics -->
|
||||
<LinearLayout
|
||||
android:id="@+id/metrics"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/location_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_right"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true">
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/enable_metrics_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginTop="5dp"
|
||||
android:duplicateParentState="true"
|
||||
android:clickable="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/enable_metrics_summary"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="15sp"
|
||||
android:lineSpacingExtra="@dimen/setup_line_spacing"
|
||||
android:gravity="top"
|
||||
android:layout_marginLeft="@dimen/location_text_margin_left"
|
||||
android:layout_marginRight="@dimen/location_text_margin_right"
|
||||
android:paddingBottom="@dimen/content_margin_bottom"
|
||||
android:text="@string/services_metrics_label"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Whether or not to enable default theme -->
|
||||
<LinearLayout
|
||||
android:id="@+id/theme"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/location_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_right"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true">
|
||||
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/enable_theme_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginTop="5dp"
|
||||
android:duplicateParentState="true"
|
||||
android:clickable="false"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/enable_theme_summary"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="15sp"
|
||||
android:lineSpacingExtra="@dimen/setup_line_spacing"
|
||||
android:gravity="top"
|
||||
android:layout_marginLeft="@dimen/location_text_margin_left"
|
||||
android:layout_marginRight="@dimen/location_text_margin_right"
|
||||
android:paddingBottom="@dimen/content_margin_bottom"
|
||||
android:text="@string/services_metrics_label"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Checkbox for using on-screen nav keys -->
|
||||
<LinearLayout
|
||||
android:id="@+id/nav_keys"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/location_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_right"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/nav_keys_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginTop="5dp"
|
||||
android:duplicateParentState="true"
|
||||
android:clickable="false" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nav_keys_summary"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="15sp"
|
||||
android:lineSpacingExtra="@dimen/setup_line_spacing"
|
||||
android:gravity="top"
|
||||
android:layout_marginLeft="@dimen/location_text_margin_left"
|
||||
android:layout_marginRight="@dimen/location_text_margin_right"
|
||||
android:paddingBottom="@dimen/content_margin_bottom"
|
||||
android:text="@string/services_os_nav_keys_label"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/privacy_guard"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/location_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_right"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clickable="true">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/privacy_guard_checkbox"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginTop="5dp"
|
||||
android:duplicateParentState="true"
|
||||
android:clickable="false" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/privacy_guard_summary"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textSize="15sp"
|
||||
android:lineSpacingExtra="@dimen/setup_line_spacing"
|
||||
android:gravity="top"
|
||||
android:layout_marginLeft="@dimen/location_text_margin_left"
|
||||
android:layout_marginRight="@dimen/location_text_margin_right"
|
||||
android:paddingBottom="@dimen/content_margin_bottom"
|
||||
android:text="@string/services_os_privacy_guard"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</FrameLayout>
|
||||
|
||||
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
|
||||
android:id="@+id/navigation_bar"
|
||||
style="@style/setup_wizard_navbar_style" />
|
||||
|
||||
</LinearLayout>
|
@@ -15,21 +15,21 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/primary">
|
||||
|
||||
<include layout="@layout/header_condensed" />
|
||||
|
||||
<RelativeLayout android:id="@+id/page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/content_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_left"
|
||||
style="@style/PageContent">
|
||||
<RelativeLayout android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="@dimen/content_margin_left"
|
||||
android:paddingRight="@dimen/content_margin_left">
|
||||
|
||||
<com.cyanogenmod.setupwizard.ui.LocalePicker
|
||||
android:id="@+id/locale_list"
|
||||
@@ -41,4 +41,10 @@
|
||||
android:layout_centerHorizontal="true"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
|
||||
android:id="@+id/navigation_bar"
|
||||
style="@style/setup_wizard_navbar_style" />
|
||||
|
||||
</LinearLayout>
|
||||
|
49
res/layout/welcome_activity.xml
Normal file
49
res/layout/welcome_activity.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 The CyanogenMod Project
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/primary">
|
||||
|
||||
<Space android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/brand_logo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/logo"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:padding="@dimen/content_margin_left"/>
|
||||
|
||||
<Space android:layout_width="match_parent"
|
||||
android:layout_height="0px"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
|
||||
<fragment android:name="com.android.setupwizard.navigationbar.SetupWizardNavBar"
|
||||
android:id="@+id/navigation_bar"
|
||||
style="@style/setup_wizard_navbar_style" />
|
||||
|
||||
</LinearLayout>
|
84
res/raw/wizard_script.xml
Executable file
84
res/raw/wizard_script.xml
Executable file
@@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2014 Google Inc.
|
||||
Copyright (C) 2017 The LineageOS 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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
The wizard:uris recorded here have the inconvenience of being generated by hand, but they allow
|
||||
for the full spread of launch flags (we need FLAG_ACTIVITY_NEW_TASK [0x10000000]), where the
|
||||
<intent> tag processed by Intent.parseIntent() does not.
|
||||
|
||||
adb shell am to-intent-uri -a com.android.setupwizard.WELCOME -f 0x10000000 \-\-ez firstRun true
|
||||
-->
|
||||
|
||||
<WizardScript wizard:firstAction="oem_pre_setup"
|
||||
xmlns:wizard="http://schemas.android.com/apk/res/com.google.android.setupwizard">
|
||||
<!-- Preliminary setup for OEMs -->
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.OEM_PRE_SETUP;end" id="oem_pre_setup">
|
||||
<result wizard:action="welcome" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_WELCOME;end" id="welcome">
|
||||
<result wizard:action="locale" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_LOCALE;end" id="locale">
|
||||
<result wizard:action="sim_missing" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_qr_provision_flow" id="qr_provision_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.SIM_MISSING;end" id="sim_missing">
|
||||
<result wizard:action="carrier_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.CARRIER_SETUP;end" id="carrier_setup">
|
||||
<result wizard:action="background_activation" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.BACKGROUND_ACTIVATION;end" id="background_activation">
|
||||
<result wizard:action="sim_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.SIM_SETUP;end" id="sim_setup">
|
||||
<result wizard:action="flow_choice" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.FLOW_CHOICE;end" id="flow_choice">
|
||||
<result wizard:resultCode="-1" wizard:action="restore_choice" wizard:name="ok" />
|
||||
<result wizard:resultCode="1" wizard:action="setup_as_new_flow" wizard:name="skip" />
|
||||
<result wizard:action="restore_with_account_flow" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.RESTORE_CHOICE;end" id="restore_choice">
|
||||
<result wizard:resultCode="101" wizard:action="restore_with_device_flow" wizard:name="d2d" />
|
||||
<result wizard:resultCode="102" wizard:action="restore_with_ios_flow" wizard:name="ios_restore" />
|
||||
<result wizard:action="restore_with_account_flow" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_restore_with_account_flow" id="restore_with_account_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_restore_with_device_flow" id="restore_with_device_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_restore_with_ios_flow" id="restore_with_ios_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_setup_as_new_flow" id="setup_as_new_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_SETTINGS;end" id="oem_post_setup">
|
||||
<result wizard:action="finish" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_SETUP_COMPLETE;end" id="finish">
|
||||
<result wizard:action="exit" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.EXIT;end" id="exit" />
|
||||
</WizardScript>
|
81
res/raw/wizard_script_user.xml
Executable file
81
res/raw/wizard_script_user.xml
Executable file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
Copyright (c) 2014 Google Inc.
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
The wizard:uris recorded here have the inconvenience of being generated by hand, but they allow
|
||||
for the full spread of launch flags (we need FLAG_ACTIVITY_NEW_TASK [0x10000000]), where the
|
||||
<intent> tag processed by Intent.parseIntent() does not.
|
||||
|
||||
adb shell am to-intent-uri -a com.android.setupwizard.WELCOME -f 0x10000000 \-\-ez firstRun true
|
||||
-->
|
||||
<WizardScript wizard:firstAction="oem_pre_setup"
|
||||
xmlns:wizard="http://schemas.android.com/apk/res/com.google.android.setupwizard">
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.OEM_PRE_SETUP;end" id="oem_pre_setup">
|
||||
<result wizard:action="welcome" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_WELCOME;end" id="welcome">
|
||||
<result wizard:action="secondary_user_warning" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.USER_WARNING;end" id="secondary_user_warning">
|
||||
<result wizard:resultCode="111" wizard:action="oem_post_setup" wizard:name="dpm_user_complete" />
|
||||
<result wizard:action="network_settings" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.NETWORK_SETTINGS;end" id="network_settings">
|
||||
<result wizard:resultCode="101" wizard:action="wifi_settings" wizard:name="see_all_wifi" />
|
||||
<result wizard:resultCode="1" wizard:action="no_account_flow" wizard:name="skip" />
|
||||
<result wizard:action="captive_portal" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.WIFI_SETTINGS;end" id="wifi_settings">
|
||||
<result wizard:action="captive_portal" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.CAPTIVE_PORTAL;end" id="captive_portal">
|
||||
<result wizard:action="gms_checkin" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.google.android.setupwizard.GMS_CHECKIN;end" id="gms_checkin">
|
||||
<result wizard:action="load_account_intent" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.google.android.setupwizard.LOAD_ADD_ACCOUNT_INTENT;end" id="load_account_intent">
|
||||
<result wizard:action="account_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.google.android.setupwizard.ACCOUNT_SETUP;end" id="account_setup">
|
||||
<result wizard:resultCode="1" wizard:action="no_account_flow" wizard:name="skip" />
|
||||
<result wizard:resultCode="111" wizard:action="oem_post_setup" wizard:name="dpm_user_complete" />
|
||||
<result wizard:action="gms_account_checkin" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.google.android.setupwizard.GMS_ACCOUNT_CHECKIN;end" id="gms_account_checkin">
|
||||
<result wizard:resultCode="1" wizard:action="mfm_check" wizard:name="skip" />
|
||||
<result wizard:action="start_vpa" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.google.android.setupwizard.START_VPA;end" id="start_vpa">
|
||||
<result wizard:action="mfm_check" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.google.android.setupwizard.ACCOUNT_CHECK;end" id="mfm_check">
|
||||
<result wizard:resultCode="1" wizard:action="no_account_flow" wizard:name="skip" />
|
||||
<result wizard:action="account_flow" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_user_account_flow" id="account_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:script="android.resource://com.google.android.setupwizard/xml/wizard_script_user_no_account_flow" id="no_account_flow">
|
||||
<result wizard:action="oem_post_setup" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.cyanogenmod.setupwizard.LINEAGE_SETUP_COMPLETE;end" id="oem_post_setup">
|
||||
<result wizard:action="exit" />
|
||||
</WizardAction>
|
||||
<WizardAction wizard:uri="intent:#Intent;action=com.android.setupwizard.EXIT;end" id="exit" />
|
||||
</WizardScript>
|
@@ -21,6 +21,11 @@
|
||||
<string name="os_name" translatable="false">LineageOS</string>
|
||||
<string name="default_theme_name" translatable="false">Material</string>
|
||||
|
||||
<!-- Partner SUW Strings -->
|
||||
<string name="theme_type" translatable="false">material_light</string>
|
||||
<string name="wizard_script_uri" translatable="false">android.resource://com.cyanogenmod.setupwizard/raw/wizard_script</string>
|
||||
<string name="wizard_script_user_uri" translatable="false">android.resource://com.cyanogenmod.setupwizard/raw/wizard_script_user</string>
|
||||
|
||||
<string name="next">Next</string>
|
||||
<string name="skip">Skip</string>
|
||||
<string name="start">Start</string>
|
||||
|
29
src/com/cyanogenmod/setupwizard/PartnerReceiver.java
Normal file
29
src/com/cyanogenmod/setupwizard/PartnerReceiver.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.cyanogenmod.setupwizard;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016 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.
|
||||
*/
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
public class PartnerReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
@@ -18,16 +18,13 @@ package com.cyanogenmod.setupwizard;
|
||||
|
||||
|
||||
import android.app.Application;
|
||||
import android.app.StatusBarManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
|
||||
public class SetupWizardApp extends Application {
|
||||
|
||||
public static final String TAG = SetupWizardApp.class.getSimpleName();
|
||||
@@ -36,11 +33,7 @@ public class SetupWizardApp extends Application {
|
||||
|
||||
public static final String ACTION_FINISHED = "com.cyanogenmod.setupwizard.SETUP_FINISHED";
|
||||
|
||||
public static final String ACCOUNT_TYPE_CYANOGEN = "com.cyanogen";
|
||||
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 ACTION_SETUP_FINGERPRINT = "android.settings.FINGERPRINT_SETUP";
|
||||
public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN";
|
||||
@@ -48,19 +41,18 @@ public class SetupWizardApp extends Application {
|
||||
public static final String EXTRA_FIRST_RUN = "firstRun";
|
||||
public static final String EXTRA_ALLOW_SKIP = "allowSkip";
|
||||
public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect";
|
||||
public static final String EXTRA_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
|
||||
public static final String EXTRA_USE_IMMERSIVE = "useImmersiveMode";
|
||||
public static final String EXTRA_THEME = "theme";
|
||||
public static final String EXTRA_MATERIAL_LIGHT = "material_light";
|
||||
public static final String EXTRA_CKSOP = "cksOp";
|
||||
public static final String EXTRA_LOGIN_FOR_KILL_SWITCH = "authCks";
|
||||
public static final String EXTRA_TITLE = "title";
|
||||
public static final String EXTRA_DETAILS = "details";
|
||||
public static final String EXTRA_FRAGMENT = "fragment";
|
||||
public static final String EXTRA_ACTION_ID = "actionId";
|
||||
public static final String EXTRA_SUPRESS_D2D_SETUP = "suppress_device_to_device_setup";
|
||||
|
||||
public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled";
|
||||
public static final String KEY_SEND_METRICS = "send_metrics";
|
||||
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
|
||||
public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme";
|
||||
public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight";
|
||||
public static final String KEY_PRIVACY_GUARD = "privacy_guard_default";
|
||||
|
||||
private static final String[] THEME_PACKAGES = {
|
||||
"org.cyanogenmod.theme.chooser",
|
||||
@@ -70,24 +62,19 @@ public class SetupWizardApp extends Application {
|
||||
};
|
||||
|
||||
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;
|
||||
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 REQUEST_CODE_UNLOCK = 6;
|
||||
public static final int REQUEST_CODE_SETUP_FINGERPRINT = 7;
|
||||
public static final int REQUEST_CODE_VENDOR_SETUP_GMS = 8;
|
||||
public static final int REQUEST_CODE_SETUP_LOCKSCREEN = 9;
|
||||
|
||||
public static final int RADIO_READY_TIMEOUT = 10 * 1000;
|
||||
|
||||
private boolean mIsRadioReady = false;
|
||||
|
||||
private boolean mIsAuthorized = false;
|
||||
private boolean mIgnoreSimLocale = false;
|
||||
|
||||
private StatusBarManager mStatusBarManager;
|
||||
|
||||
private final Bundle mSettingsBundle = new Bundle();
|
||||
private final Handler mHandler = new Handler();
|
||||
|
||||
private final Runnable mRadioTimeoutRunnable = new Runnable() {
|
||||
@@ -100,35 +87,16 @@ public class SetupWizardApp extends Application {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
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) {
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
Settings.Global.putInt(getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
||||
Settings.Secure.putInt(getContentResolver(),
|
||||
Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||
CMSettings.Secure.putInt(getContentResolver(),
|
||||
CMSettings.Secure.CM_SETUP_WIZARD_COMPLETED, 1);
|
||||
SetupWizardUtils.disableGMSSetupWizard(SetupWizardApp.this);
|
||||
SetupWizardUtils.disableSetupWizard(SetupWizardApp.this);
|
||||
if (!isOwner) {
|
||||
disableThemeComponentsForSecondaryUser();
|
||||
}
|
||||
}
|
||||
};
|
||||
t.run();
|
||||
} else {
|
||||
disableCaptivePortalDetection();
|
||||
}
|
||||
} catch (Settings.SettingNotFoundException e) {
|
||||
// Continue with setup
|
||||
final boolean isOwner = SetupWizardUtils.isOwner();
|
||||
if (!isOwner) {
|
||||
Thread t = new Thread(){
|
||||
@Override
|
||||
public void run() {
|
||||
disableThemeComponentsForSecondaryUser();
|
||||
}
|
||||
};
|
||||
t.run();
|
||||
} else {
|
||||
disableCaptivePortalDetection();
|
||||
}
|
||||
mHandler.postDelayed(mRadioTimeoutRunnable, SetupWizardApp.RADIO_READY_TIMEOUT);
|
||||
@@ -153,18 +121,16 @@ public class SetupWizardApp extends Application {
|
||||
mIsAuthorized = isAuthorized;
|
||||
}
|
||||
|
||||
public void disableStatusBar() {
|
||||
mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND |
|
||||
StatusBarManager.DISABLE_NOTIFICATION_ALERTS |
|
||||
StatusBarManager.DISABLE_NOTIFICATION_ICONS |
|
||||
StatusBarManager.DISABLE_NOTIFICATION_TICKER |
|
||||
StatusBarManager.DISABLE_RECENT |
|
||||
StatusBarManager.DISABLE_HOME |
|
||||
StatusBarManager.DISABLE_SEARCH);
|
||||
public boolean ignoreSimLocale() {
|
||||
return mIgnoreSimLocale;
|
||||
}
|
||||
|
||||
public void enableStatusBar() {
|
||||
mStatusBarManager.disable(StatusBarManager.DISABLE_NONE);
|
||||
public void setIgnoreSimLocale(boolean ignoreSimLocale) {
|
||||
mIgnoreSimLocale = ignoreSimLocale;
|
||||
}
|
||||
|
||||
public Bundle getSettingsBundle() {
|
||||
return mSettingsBundle;
|
||||
}
|
||||
|
||||
public void disableCaptivePortalDetection() {
|
||||
|
@@ -20,13 +20,12 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import org.cyanogenmod.internal.util.PackageManagerUtils;
|
||||
@@ -53,7 +52,6 @@ public class CMSetupWizardData extends AbstractSetupData {
|
||||
pages.add(new BluetoothSetupPage(mContext, this));
|
||||
}
|
||||
pages.add(new WelcomePage(mContext, this));
|
||||
pages.add(new LocalePage(mContext, this));
|
||||
pages.add(new DateTimePage(mContext, this));
|
||||
if (SetupWizardUtils.hasWifi(mContext)) {
|
||||
pages.add(new WifiSetupPage(mContext, this));
|
||||
@@ -80,7 +78,6 @@ public class CMSetupWizardData extends AbstractSetupData {
|
||||
pages.add(new FingerprintSetupPage(mContext, this));
|
||||
}
|
||||
pages.add(new ScreenLockSetupPage(mContext, this));
|
||||
pages.add(new CyanogenSettingsPage(mContext, this));
|
||||
pages.add(new FinishPage(mContext, this));
|
||||
return new PageList(pages.toArray(new SetupPage[pages.size()]));
|
||||
}
|
||||
@@ -92,7 +89,6 @@ public class CMSetupWizardData extends AbstractSetupData {
|
||||
showHideDataSimPage();
|
||||
showHideSimMissingPage();
|
||||
showHideMobileDataPage();
|
||||
updateLocalePage();
|
||||
} else if (intent.getAction()
|
||||
.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
||||
showHideMobileDataPage();
|
||||
@@ -149,13 +145,6 @@ public class CMSetupWizardData extends AbstractSetupData {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLocalePage() {
|
||||
LocalePage localePage = (LocalePage) getPage(LocalePage.TAG);
|
||||
if (localePage != null) {
|
||||
localePage.simChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public IntentFilter getIntentFilter() {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
if (SetupWizardUtils.hasTelephony(mContext)) {
|
||||
|
@@ -1,399 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.ThemeConfig;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.View;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
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.util.SetupWizardUtils;
|
||||
|
||||
import cyanogenmod.hardware.CMHardwareManager;
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
import cyanogenmod.themes.ThemeManager;
|
||||
|
||||
public class CyanogenSettingsPage extends SetupPage {
|
||||
|
||||
public static final String TAG = "CyanogenSettingsPage";
|
||||
|
||||
public static final String KEY_SEND_METRICS = "send_metrics";
|
||||
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
|
||||
public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme";
|
||||
public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight";
|
||||
public static final String KEY_PRIVACY_GUARD = "privacy_guard_default";
|
||||
|
||||
public static final String PRIVACY_POLICY_URI = "http://lineageos.org/legal";
|
||||
|
||||
public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) {
|
||||
super(context, callbacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getFragment(FragmentManager fragmentManager, int action) {
|
||||
Fragment fragment = fragmentManager.findFragmentByTag(getKey());
|
||||
if (fragment == null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
|
||||
args.putInt(Page.KEY_PAGE_ACTION, action);
|
||||
fragment = new CyanogenSettingsFragment();
|
||||
fragment.setArguments(args);
|
||||
}
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleResId() {
|
||||
return R.string.setup_services;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconResId() {
|
||||
return R.drawable.ic_features;
|
||||
}
|
||||
|
||||
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
CMSettings.Global.putInt(context.getContentResolver(),
|
||||
CMSettings.Global.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
|
||||
CMHardwareManager hardware = CMHardwareManager.getInstance(context);
|
||||
hardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, enabled);
|
||||
|
||||
/* Save/restore button timeouts to disable them in softkey mode */
|
||||
if (enabled) {
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 0);
|
||||
} else {
|
||||
int currentBrightness = CMSettings.Secure.getInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 100);
|
||||
int oldBright = prefs.getInt(KEY_BUTTON_BACKLIGHT,
|
||||
currentBrightness);
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, oldBright);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishSetup() {
|
||||
getCallbacks().addFinishRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getData().containsKey(DISABLE_NAV_KEYS)) {
|
||||
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
|
||||
SetupStats.Action.ENABLE_NAV_KEYS,
|
||||
SetupStats.Label.CHECKED,
|
||||
String.valueOf(getData().getBoolean(DISABLE_NAV_KEYS)));
|
||||
writeDisableNavkeysOption(mContext, getData().getBoolean(DISABLE_NAV_KEYS));
|
||||
}
|
||||
}
|
||||
});
|
||||
handleEnableMetrics();
|
||||
handleDefaultThemeSetup();
|
||||
handlePrivacyGuard();
|
||||
}
|
||||
|
||||
private void handleEnableMetrics() {
|
||||
Bundle privacyData = getData();
|
||||
if (privacyData != null
|
||||
&& privacyData.containsKey(KEY_SEND_METRICS)) {
|
||||
CMSettings.Secure.putInt(mContext.getContentResolver(),
|
||||
CMSettings.Secure.STATS_COLLECTION, privacyData.getBoolean(KEY_SEND_METRICS)
|
||||
? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDefaultThemeSetup() {
|
||||
Bundle privacyData = getData();
|
||||
if (!SetupWizardUtils.getDefaultThemePackageName(mContext).equals(
|
||||
ThemeConfig.SYSTEM_DEFAULT) && privacyData != null &&
|
||||
privacyData.getBoolean(KEY_APPLY_DEFAULT_THEME)) {
|
||||
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
|
||||
SetupStats.Action.APPLY_CUSTOM_THEME,
|
||||
SetupStats.Label.CHECKED,
|
||||
String.valueOf(privacyData.getBoolean(KEY_APPLY_DEFAULT_THEME)));
|
||||
Log.i(TAG, "Applying default theme");
|
||||
final ThemeManager tm = ThemeManager.getInstance(mContext);
|
||||
tm.applyDefaultTheme();
|
||||
|
||||
} else {
|
||||
getCallbacks().finishSetup();
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePrivacyGuard() {
|
||||
Bundle mPrivacyData = getData();
|
||||
if (mPrivacyData != null && mPrivacyData.containsKey(KEY_PRIVACY_GUARD)) {
|
||||
CMSettings.Secure.putInt(mContext.getContentResolver(),
|
||||
CMSettings.Secure.PRIVACY_GUARD_DEFAULT,
|
||||
mPrivacyData.getBoolean(KEY_PRIVACY_GUARD) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hideKeyDisabler(Context ctx) {
|
||||
final CMHardwareManager hardware = CMHardwareManager.getInstance(ctx);
|
||||
return !hardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE);
|
||||
}
|
||||
|
||||
private static boolean isKeyDisablerActive(Context ctx) {
|
||||
final CMHardwareManager hardware = CMHardwareManager.getInstance(ctx);
|
||||
return hardware.get(CMHardwareManager.FEATURE_KEY_DISABLE);
|
||||
}
|
||||
|
||||
private static boolean hideThemeSwitch(Context context) {
|
||||
return SetupWizardUtils.getDefaultThemePackageName(context)
|
||||
.equals(ThemeConfig.SYSTEM_DEFAULT);
|
||||
}
|
||||
|
||||
public static class CyanogenSettingsFragment extends SetupPageFragment {
|
||||
|
||||
private View mKillSwitchView;
|
||||
private TextView mKillSwitchTitle;
|
||||
private ImageView mKillSwitchStatus;
|
||||
private View mMetricsRow;
|
||||
private View mDefaultThemeRow;
|
||||
private View mNavKeysRow;
|
||||
private View mPrivacyGuardRow;
|
||||
private CheckBox mMetrics;
|
||||
private CheckBox mDefaultTheme;
|
||||
private CheckBox mNavKeys;
|
||||
private CheckBox mPrivacyGuard;
|
||||
|
||||
private boolean mHideNavKeysRow = false;
|
||||
private boolean mHideThemeRow = false;
|
||||
|
||||
|
||||
private View.OnClickListener mMetricsClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mMetrics.isChecked();
|
||||
mMetrics.setChecked(checked);
|
||||
mPage.getData().putBoolean(KEY_SEND_METRICS, checked);
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener mDefaultThemeClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mDefaultTheme.isChecked();
|
||||
mDefaultTheme.setChecked(checked);
|
||||
mPage.getData().putBoolean(KEY_APPLY_DEFAULT_THEME, checked);
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener mNavKeysClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mNavKeys.isChecked();
|
||||
mNavKeys.setChecked(checked);
|
||||
mPage.getData().putBoolean(DISABLE_NAV_KEYS, checked);
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener mPrivacyGuardClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mPrivacyGuard.isChecked();
|
||||
mPrivacyGuard.setChecked(checked);
|
||||
mPage.getData().putBoolean(KEY_PRIVACY_GUARD, checked);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void initializePage() {
|
||||
String privacy_policy = getString(R.string.services_privacy_policy);
|
||||
String policySummary = getString(R.string.services_explanation, privacy_policy);
|
||||
SpannableString ss = new SpannableString(policySummary);
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
// At this point of the setup, the device has already been unlocked (if frp
|
||||
// had been enabled), so there should be no issues regarding security
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
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,
|
||||
policySummary.length() - privacy_policy.length() - 1,
|
||||
policySummary.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TextView privacyPolicy = (TextView) mRootView.findViewById(R.id.privacy_policy);
|
||||
privacyPolicy.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
privacyPolicy.setText(ss);
|
||||
|
||||
mKillSwitchView = mRootView.findViewById(R.id.killswitch);
|
||||
mKillSwitchTitle = (TextView)mRootView.findViewById(R.id.killswitch_title);
|
||||
mKillSwitchStatus = (ImageView)mRootView.findViewById(R.id.killswitch_check);
|
||||
if (hideKillSwitch()) {
|
||||
mKillSwitchView.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (SetupWizardUtils.isDeviceLocked()) {
|
||||
mKillSwitchTitle.setEnabled(true);
|
||||
mKillSwitchStatus.setImageResource(R.drawable.tick);
|
||||
} else {
|
||||
mKillSwitchTitle.setEnabled(false);
|
||||
mKillSwitchStatus.setImageResource(R.drawable.cross);
|
||||
}
|
||||
}
|
||||
|
||||
mMetricsRow = mRootView.findViewById(R.id.metrics);
|
||||
mMetricsRow.setOnClickListener(mMetricsClickListener);
|
||||
String metricsHelpImproveCM =
|
||||
getString(R.string.services_help_improve_cm, getString(R.string.os_name));
|
||||
String metricsSummary = getString(R.string.services_metrics_label,
|
||||
metricsHelpImproveCM, getString(R.string.os_name));
|
||||
final SpannableStringBuilder metricsSpan = new SpannableStringBuilder(metricsSummary);
|
||||
metricsSpan.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD),
|
||||
0, metricsHelpImproveCM.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TextView metrics = (TextView) mRootView.findViewById(R.id.enable_metrics_summary);
|
||||
metrics.setText(metricsSpan);
|
||||
mMetrics = (CheckBox) mRootView.findViewById(R.id.enable_metrics_checkbox);
|
||||
|
||||
mDefaultThemeRow = mRootView.findViewById(R.id.theme);
|
||||
mHideThemeRow = hideThemeSwitch(getActivity());
|
||||
if (mHideThemeRow) {
|
||||
mDefaultThemeRow.setVisibility(View.GONE);
|
||||
} else {
|
||||
mDefaultThemeRow.setOnClickListener(mDefaultThemeClickListener);
|
||||
String defaultTheme =
|
||||
getString(R.string.services_apply_theme,
|
||||
getString(R.string.default_theme_name));
|
||||
String defaultThemeSummary = getString(R.string.services_apply_theme_label,
|
||||
defaultTheme);
|
||||
final SpannableStringBuilder themeSpan =
|
||||
new SpannableStringBuilder(defaultThemeSummary);
|
||||
themeSpan.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD),
|
||||
0, defaultTheme.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TextView theme = (TextView) mRootView.findViewById(R.id.enable_theme_summary);
|
||||
theme.setText(themeSpan);
|
||||
mDefaultTheme = (CheckBox) mRootView.findViewById(R.id.enable_theme_checkbox);
|
||||
}
|
||||
|
||||
mNavKeysRow = mRootView.findViewById(R.id.nav_keys);
|
||||
mNavKeysRow.setOnClickListener(mNavKeysClickListener);
|
||||
mNavKeys = (CheckBox) mRootView.findViewById(R.id.nav_keys_checkbox);
|
||||
boolean needsNavBar = true;
|
||||
try {
|
||||
IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
|
||||
needsNavBar = windowManager.needsNavigationBar();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
mHideNavKeysRow = hideKeyDisabler(getActivity());
|
||||
if (mHideNavKeysRow || needsNavBar) {
|
||||
mNavKeysRow.setVisibility(View.GONE);
|
||||
} else {
|
||||
boolean navKeysDisabled =
|
||||
isKeyDisablerActive(getActivity());
|
||||
mNavKeys.setChecked(navKeysDisabled);
|
||||
}
|
||||
|
||||
mPrivacyGuardRow = mRootView.findViewById(R.id.privacy_guard);
|
||||
mPrivacyGuardRow.setOnClickListener(mPrivacyGuardClickListener);
|
||||
mPrivacyGuard = (CheckBox) mRootView.findViewById(R.id.privacy_guard_checkbox);
|
||||
mPrivacyGuard.setChecked(CMSettings.Secure.getInt(getActivity().getContentResolver(),
|
||||
CMSettings.Secure.PRIVACY_GUARD_DEFAULT, 0) == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResource() {
|
||||
return R.layout.setup_cyanogen_services;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateDisableNavkeysOption();
|
||||
updateMetricsOption();
|
||||
updateThemeOption();
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
mDefaultTheme.setChecked(themesChecked);
|
||||
myPageBundle.putBoolean(KEY_APPLY_DEFAULT_THEME, themesChecked);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisableNavkeysOption() {
|
||||
if (!mHideNavKeysRow) {
|
||||
final Bundle myPageBundle = mPage.getData();
|
||||
boolean enabled = CMSettings.Secure.getInt(getActivity().getContentResolver(),
|
||||
CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) != 0;
|
||||
boolean checked = myPageBundle.containsKey(DISABLE_NAV_KEYS) ?
|
||||
myPageBundle.getBoolean(DISABLE_NAV_KEYS) :
|
||||
enabled;
|
||||
mNavKeys.setChecked(checked);
|
||||
myPageBundle.putBoolean(DISABLE_NAV_KEYS, checked);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hideKillSwitch() {
|
||||
return !SetupWizardUtils.hasKillSwitch();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,31 +0,0 @@
|
||||
package com.cyanogenmod.setupwizard.setup;
|
||||
|
||||
import android.app.StatusBarManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
public class FinishSetupReceiver extends BroadcastReceiver {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (SetupWizardUtils.isDeviceLocked() || SetupWizardUtils.frpEnabled(context)) {
|
||||
return;
|
||||
}
|
||||
Settings.Global.putInt(context.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 1);
|
||||
Settings.Secure.putInt(context.getContentResolver(),
|
||||
Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||
((StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE)).disable(
|
||||
StatusBarManager.DISABLE_NONE);
|
||||
Settings.Global.putInt(context.getContentResolver(),
|
||||
SetupWizardApp.KEY_DETECT_CAPTIVE_PORTAL, 1);
|
||||
cyanogenmod.providers.CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
cyanogenmod.providers.CMSettings.Secure.CM_SETUP_WIZARD_COMPLETED, 1);
|
||||
SetupWizardUtils.disableGMSSetupWizard(context);
|
||||
SetupWizardUtils.disableSetupWizard(context);
|
||||
}
|
||||
}
|
@@ -1,343 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.AuthenticatorException;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.service.persistentdata.PersistentDataBlockManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.setupwizardlib.util.ResultCodes;
|
||||
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.util.SetupWizardUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GmsAccountPage extends SetupPage {
|
||||
|
||||
public static final String TAG = "GmsAccountPage";
|
||||
|
||||
public static final String ACTION_RESTORE = "com.google.android.setupwizard.RESTORE";
|
||||
public static final String ACTION_PROGRESS = "com.google.android.setupwizard.PROGRESS";
|
||||
public static final String ACTION_VENDOR_SETUP = "com.google.android.setupwizard.VENDOR_SETUP";
|
||||
public static final String RESTORE_ACTION_ID = "mfm_restore_start";
|
||||
public static final String RESTORE_CHECK_ID = "restore_check";
|
||||
public static final String FRAGMENT_START_RESTORE =
|
||||
"com.google.android.setupwizard.account.StartRestoreFragment";
|
||||
public static final String FRAGMENT_CHECK_RESTORE =
|
||||
"com.google.android.setupwizard.account.CheckRestoreTokenFragment";
|
||||
|
||||
public static final String EXTRA_AUTH_ACCOUNT = "authAccount";
|
||||
public static final String EXTRA_RESTORE_ACCOUNT = "restoreAccount";
|
||||
public static final String EXTRA_RESTORE_TOKEN = "restoreToken";
|
||||
|
||||
private static final String RESTORE_WIZARD_SCRIPT =
|
||||
"android.resource://com.google.android.setupwizard/xml/wizard_script";
|
||||
|
||||
private Fragment mFragment;
|
||||
|
||||
public GmsAccountPage(final Context context, SetupDataCallbacks callbacks) {
|
||||
super(context, callbacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getFragment(FragmentManager fragmentManager, int action) {
|
||||
mFragment = fragmentManager.findFragmentByTag(getKey());
|
||||
if (mFragment == null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
|
||||
args.putInt(Page.KEY_PAGE_ACTION, action);
|
||||
mFragment = new LoadingFragment();
|
||||
mFragment.setArguments(args);
|
||||
}
|
||||
return mFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleResId() {
|
||||
return R.string.loading;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconResId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextButtonTitleResId() {
|
||||
return R.string.skip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doLoadAction(FragmentManager fragmentManager, int action) {
|
||||
if (action == Page.ACTION_PREVIOUS) {
|
||||
getCallbacks().onPreviousPage();
|
||||
} else {
|
||||
super.doLoadAction(fragmentManager, action);
|
||||
if (!SetupWizardUtils.isNetworkConnected(mContext) && !SetupWizardUtils.frpEnabled(mContext)) {
|
||||
if (SetupWizardApp.DEBUG) {
|
||||
Log.d(TAG, "No network, no FRP enforcement, skip GMS account");
|
||||
}
|
||||
getCallbacks().onNextPage();
|
||||
} else if (!SetupWizardUtils.accountExists(mContext, SetupWizardApp.ACCOUNT_TYPE_GMS)) {
|
||||
launchGmsAccountSetup();
|
||||
} else {
|
||||
// This can happen if the user goes from setup -> restore, but chooses to set
|
||||
// their device up as "new". Thus we need to not re-prompt this entire flow,
|
||||
// skip ahead. CYNGNOS-2459
|
||||
if (SetupWizardApp.DEBUG) {
|
||||
Log.d(TAG, "Google account already setup, skip gms setup");
|
||||
}
|
||||
setHidden(true);
|
||||
getCallbacks().onNextPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (SetupWizardApp.DEBUG) {
|
||||
Log.d(TAG, "Received activity result from requestCode " + requestCode
|
||||
+ " with a resultCode of " + resultCode);
|
||||
if (data != null) {
|
||||
Bundle extras = data.getExtras();
|
||||
Log.d(TAG, "Within the activity result there were extras:");
|
||||
for (String extra : extras.keySet()) {
|
||||
Log.d(TAG, "The key " + extra + " has a value of " + extras.get(extra));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS &&
|
||||
resultCode == ResultCodes.RESULT_SKIP) {
|
||||
launchGmsVendorSetup();
|
||||
} else if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS && data != null) {
|
||||
if (SetupWizardUtils.isOwner() && resultCode == Activity.RESULT_OK) {
|
||||
|
||||
// If we don't have a restore token and a restore account, then we need to
|
||||
// prompt with the restore picker from googles setup wizard so the user
|
||||
// can select what device they would like to restore from. Otherwise,
|
||||
// we're coming from a Tap&Go scenario and we should just restore.
|
||||
boolean restorePicker = !data.hasExtra(EXTRA_RESTORE_TOKEN)
|
||||
&& !data.hasExtra(EXTRA_RESTORE_ACCOUNT) &&
|
||||
data.hasExtra(EXTRA_AUTH_ACCOUNT);
|
||||
|
||||
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
|
||||
SetupStats.Action.EXTERNAL_PAGE_RESULT,
|
||||
SetupStats.Label.GMS_ACCOUNT, "success");
|
||||
launchGmsRestorePage(restorePicker);
|
||||
} else {
|
||||
handleResult(requestCode, resultCode);
|
||||
}
|
||||
} else {
|
||||
if (requestCode == SetupWizardApp.REQUEST_CODE_RESTORE_GMS) {
|
||||
setHidden(true);
|
||||
}
|
||||
handleResult(requestCode, resultCode);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doNextAction() {
|
||||
final boolean canSkip = canSkip();
|
||||
// return true to force this page to handle the next action.
|
||||
return !canSkip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinishSetup() {
|
||||
|
||||
}
|
||||
|
||||
private void handleResult(int requestCode, int resultCode) {
|
||||
if (resultCode == Activity.RESULT_CANCELED) {
|
||||
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
|
||||
SetupStats.Action.EXTERNAL_PAGE_RESULT,
|
||||
requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS ?
|
||||
SetupStats.Label.GMS_ACCOUNT : SetupStats.Label.RESTORE, "canceled");
|
||||
getCallbacks().onPreviousPage();
|
||||
} else {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
|
||||
SetupStats.Action.EXTERNAL_PAGE_RESULT,
|
||||
requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS ?
|
||||
SetupStats.Label.GMS_ACCOUNT : SetupStats.Label.RESTORE, "success");
|
||||
getCallbacks().onNextPage();
|
||||
} else {
|
||||
if (canSkip()) {
|
||||
SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
|
||||
SetupStats.Action.EXTERNAL_PAGE_RESULT,
|
||||
requestCode == SetupWizardApp.REQUEST_CODE_SETUP_GMS ?
|
||||
SetupStats.Label.GMS_ACCOUNT : SetupStats.Label.RESTORE, "skipped");
|
||||
getCallbacks().onNextPage();
|
||||
} else {
|
||||
getCallbacks().onPreviousPage();
|
||||
}
|
||||
}
|
||||
if (SetupWizardUtils.accountExists(mContext, SetupWizardApp.ACCOUNT_TYPE_GMS)) {
|
||||
setHidden(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void launchGmsRestorePage(boolean restorePicker) {
|
||||
if (SetupWizardApp.DEBUG) {
|
||||
Log.d(TAG, "Launching gms restore page with restorePicker " + restorePicker);
|
||||
}
|
||||
try {
|
||||
// GMS can disable this after logging in sometimes
|
||||
if (SetupWizardUtils.enableGMSSetupWizard(mContext)) {
|
||||
Intent intent = new Intent(ACTION_PROGRESS);
|
||||
if (!restorePicker) {
|
||||
intent.setAction(ACTION_PROGRESS);
|
||||
intent.putExtra(SetupWizardApp.EXTRA_FRAGMENT, FRAGMENT_START_RESTORE);
|
||||
intent.putExtra(SetupWizardApp.EXTRA_ACTION_ID, RESTORE_ACTION_ID);
|
||||
} else {
|
||||
intent.setAction(ACTION_PROGRESS);
|
||||
intent.putExtra(SetupWizardApp.EXTRA_ACTION_ID, RESTORE_CHECK_ID);
|
||||
intent.putExtra(SetupWizardApp.EXTRA_FRAGMENT, FRAGMENT_CHECK_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();
|
||||
}
|
||||
}
|
||||
|
||||
private void launchGmsVendorSetup() {
|
||||
if (SetupWizardApp.DEBUG) {
|
||||
Log.d(TAG, "Launching gms vendor setup page");
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_VENDOR_SETUP);
|
||||
intent.setPackage(SetupWizardUtils.GOOGLE_SETUPWIZARD_PACKAGE);
|
||||
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);
|
||||
ActivityOptions options =
|
||||
ActivityOptions.makeCustomAnimation(mContext,
|
||||
android.R.anim.fade_in,
|
||||
android.R.anim.fade_out);
|
||||
mFragment.startActivityForResult(
|
||||
intent,
|
||||
SetupWizardApp.REQUEST_CODE_VENDOR_SETUP_GMS, options.toBundle());
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
// Move on if the vendor setup activity is not found.
|
||||
getCallbacks().onNextPage();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canSkip() {
|
||||
final PersistentDataBlockManager pdbManager = (PersistentDataBlockManager)
|
||||
mContext.getSystemService(Context.PERSISTENT_DATA_BLOCK_SERVICE);
|
||||
return pdbManager == null
|
||||
|| pdbManager.getDataBlockSize() == 0
|
||||
|| pdbManager.getOemUnlockEnabled();
|
||||
}
|
||||
|
||||
private void launchGmsAccountSetup() {
|
||||
if (SetupWizardApp.DEBUG) {
|
||||
Log.d(TAG, "Launching gms account page");
|
||||
}
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
|
||||
bundle.putBoolean(SetupWizardApp.EXTRA_ALLOW_SKIP, true);
|
||||
bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
|
||||
bundle.putBoolean(SetupWizardApp.EXTRA_SUPRESS_D2D_SETUP, true);
|
||||
|
||||
AccountManager
|
||||
.get(mContext).addAccount(SetupWizardApp.ACCOUNT_TYPE_GMS, null, null,
|
||||
bundle, null, new AccountManagerCallback<Bundle>() {
|
||||
@Override
|
||||
public void run(AccountManagerFuture<Bundle> future) {
|
||||
boolean error = false;
|
||||
try {
|
||||
Bundle result = future.getResult();
|
||||
Intent intent = result
|
||||
.getParcelable(AccountManager.KEY_INTENT);
|
||||
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.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)) {
|
||||
if (canSkip()) {
|
||||
getCallbacks().onNextPage();
|
||||
} else {
|
||||
getCallbacks().onPreviousPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
@@ -1,348 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.Fragment;
|
||||
import android.app.FragmentManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.telephony.MccTable;
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
|
||||
import com.cyanogenmod.setupwizard.ui.LocalePicker;
|
||||
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocalePage extends SetupPage {
|
||||
|
||||
public static final String TAG = "LocalePage";
|
||||
|
||||
private LocaleFragment mLocaleFragment;
|
||||
|
||||
public LocalePage(Context context, SetupDataCallbacks callbacks) {
|
||||
super(context, callbacks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getFragment(FragmentManager fragmentManager, int action) {
|
||||
mLocaleFragment = (LocaleFragment)fragmentManager.findFragmentByTag(getKey());
|
||||
if (mLocaleFragment == null) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
|
||||
args.putInt(Page.KEY_PAGE_ACTION, action);
|
||||
mLocaleFragment = new LocaleFragment();
|
||||
mLocaleFragment.setArguments(args);
|
||||
}
|
||||
return mLocaleFragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTitleResId() {
|
||||
return R.string.setup_locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconResId() {
|
||||
return R.drawable.ic_locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doNextAction() {
|
||||
if (isLocked()) {
|
||||
confirmCyanogenCredentials(mLocaleFragment);
|
||||
return true;
|
||||
} else {
|
||||
if (mLocaleFragment != null) {
|
||||
mLocaleFragment.sendLocaleStats();
|
||||
}
|
||||
return super.doNextAction();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == SetupWizardApp.REQUEST_CODE_UNLOCK) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
((SetupWizardApp) mContext.getApplicationContext()).setIsAuthorized(true);
|
||||
getCallbacks().onNextPage();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNextButtonTitleResId() {
|
||||
if (isLocked()) {
|
||||
return R.string.setup_unlock;
|
||||
} else {
|
||||
return R.string.next;
|
||||
}
|
||||
}
|
||||
|
||||
private void confirmCyanogenCredentials(final Fragment fragment) {
|
||||
AccountManager accountManager = AccountManager.get(mContext);
|
||||
accountManager.editProperties(SetupWizardApp.ACCOUNT_TYPE_CYANOGEN, null,
|
||||
new AccountManagerCallback<Bundle>() {
|
||||
public void run(AccountManagerFuture<Bundle> f) {
|
||||
try {
|
||||
Bundle b = f.getResult();
|
||||
Intent i = b.getParcelable(AccountManager.KEY_INTENT);
|
||||
i.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
|
||||
i.putExtra(SetupWizardApp.EXTRA_SHOW_BUTTON_BAR, true);
|
||||
i.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
|
||||
i.putExtra(SetupWizardApp.EXTRA_LOGIN_FOR_KILL_SWITCH, true);
|
||||
fragment.startActivityForResult(i,
|
||||
SetupWizardApp.REQUEST_CODE_UNLOCK);
|
||||
} catch (Throwable t) {
|
||||
Log.e(getKey(), "confirmCredentials failed", t);
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
|
||||
private boolean isLocked() {
|
||||
boolean isAuthorized = ((SetupWizardApp) mContext.getApplicationContext()).isAuthorized();
|
||||
if (SetupWizardUtils.isDeviceLocked()) {
|
||||
return !isAuthorized;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void simChanged() {
|
||||
if (mLocaleFragment != null) {
|
||||
mLocaleFragment.fetchAndUpdateSimLocale();
|
||||
}
|
||||
}
|
||||
|
||||
public static class LocaleFragment extends SetupPageFragment {
|
||||
|
||||
private ArrayAdapter<com.android.internal.app.LocalePicker.LocaleInfo> mLocaleAdapter;
|
||||
private Locale mInitialLocale;
|
||||
private Locale mCurrentLocale;
|
||||
private int[] mAdapterIndices;
|
||||
private boolean mIgnoreSimLocale;
|
||||
private LocalePicker mLanguagePicker;
|
||||
private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
|
||||
private final Handler mHandler = new Handler();
|
||||
private boolean mPendingLocaleUpdate;
|
||||
private boolean mPaused = true;
|
||||
|
||||
private final Runnable mUpdateLocale = new Runnable() {
|
||||
public void run() {
|
||||
if (mCurrentLocale != null) {
|
||||
mLanguagePicker.setEnabled(false);
|
||||
com.android.internal.app.LocalePicker.updateLocale(mCurrentLocale);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void initializePage() {
|
||||
mLanguagePicker = (LocalePicker) mRootView.findViewById(R.id.locale_list);
|
||||
loadLanguages();
|
||||
}
|
||||
|
||||
private void loadLanguages() {
|
||||
mLocaleAdapter = com.android.internal.app.LocalePicker.constructAdapter(getActivity(),
|
||||
R.layout.locale_picker_item, R.id.locale);
|
||||
mCurrentLocale = mInitialLocale = Locale.getDefault();
|
||||
fetchAndUpdateSimLocale();
|
||||
mAdapterIndices = new int[mLocaleAdapter.getCount()];
|
||||
int currentLocaleIndex = 0;
|
||||
String [] labels = new String[mLocaleAdapter.getCount()];
|
||||
for (int i=0; i<mAdapterIndices.length; i++) {
|
||||
com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo =
|
||||
mLocaleAdapter.getItem(i);
|
||||
Locale localLocale = localLocaleInfo.getLocale();
|
||||
if (localLocale.equals(mCurrentLocale)) {
|
||||
currentLocaleIndex = i;
|
||||
}
|
||||
mAdapterIndices[i] = i;
|
||||
labels[i] = localLocaleInfo.getLabel();
|
||||
}
|
||||
mLanguagePicker.setDisplayedValues(labels);
|
||||
mLanguagePicker.setMaxValue(labels.length - 1);
|
||||
mLanguagePicker.setValue(currentLocaleIndex);
|
||||
mLanguagePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||
mLanguagePicker.setOnValueChangedListener(new LocalePicker.OnValueChangeListener() {
|
||||
public void onValueChange(LocalePicker picker, int oldVal, int newVal) {
|
||||
setLocaleFromPicker();
|
||||
}
|
||||
});
|
||||
mLanguagePicker.setOnScrollListener(new LocalePicker.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChange(LocalePicker view, int scrollState) {
|
||||
if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
|
||||
mIgnoreSimLocale = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLocaleFromPicker() {
|
||||
mIgnoreSimLocale = true;
|
||||
int i = mAdapterIndices[mLanguagePicker.getValue()];
|
||||
final com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i);
|
||||
onLocaleChanged(localLocaleInfo.getLocale());
|
||||
}
|
||||
|
||||
private void onLocaleChanged(Locale paramLocale) {
|
||||
mLanguagePicker.setEnabled(true);
|
||||
Resources localResources = getActivity().getResources();
|
||||
Configuration localConfiguration1 = localResources.getConfiguration();
|
||||
Configuration localConfiguration2 = new Configuration();
|
||||
localConfiguration2.locale = paramLocale;
|
||||
localResources.updateConfiguration(localConfiguration2, null);
|
||||
localResources.updateConfiguration(localConfiguration1, null);
|
||||
mHandler.removeCallbacks(mUpdateLocale);
|
||||
mCurrentLocale = paramLocale;
|
||||
mHandler.postDelayed(mUpdateLocale, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResource() {
|
||||
return R.layout.setup_locale;
|
||||
}
|
||||
|
||||
public void sendLocaleStats() {
|
||||
if (!mCurrentLocale.equals(mInitialLocale)) {
|
||||
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
|
||||
SetupStats.Action.CHANGE_LOCALE, SetupStats.Label.LOCALE,
|
||||
mCurrentLocale.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
public void fetchAndUpdateSimLocale() {
|
||||
if (mIgnoreSimLocale || isDetached()) {
|
||||
return;
|
||||
}
|
||||
if (mPaused) {
|
||||
mPendingLocaleUpdate = true;
|
||||
return;
|
||||
}
|
||||
if (mFetchUpdateSimLocaleTask != null) {
|
||||
mFetchUpdateSimLocaleTask.cancel(true);
|
||||
}
|
||||
mFetchUpdateSimLocaleTask = new FetchUpdateSimLocaleTask();
|
||||
mFetchUpdateSimLocaleTask.execute();
|
||||
}
|
||||
|
||||
private class FetchUpdateSimLocaleTask extends AsyncTask<Void, Void, Locale> {
|
||||
@Override
|
||||
protected Locale doInBackground(Void... params) {
|
||||
Locale locale = null;
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
// If the sim is currently pin locked, return
|
||||
TelephonyManager telephonyManager = (TelephonyManager)
|
||||
activity.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
int state = telephonyManager.getSimState();
|
||||
if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
|
||||
state == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final SubscriptionManager subscriptionManager =
|
||||
SubscriptionManager.from(activity);
|
||||
List<SubscriptionInfo> activeSubs =
|
||||
subscriptionManager.getActiveSubscriptionInfoList();
|
||||
if (activeSubs == null || activeSubs.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fetch locale for active sim's MCC
|
||||
int mcc = activeSubs.get(0).getMcc();
|
||||
locale = MccTable.getLocaleFromMcc(activity, mcc, null);
|
||||
|
||||
// If that fails, fall back to preferred languages reported
|
||||
// by the sim
|
||||
if (locale == null) {
|
||||
String localeString = telephonyManager.getLocaleFromDefaultSim();
|
||||
if (localeString != null) {
|
||||
locale = Locale.forLanguageTag(localeString);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Locale simLocale) {
|
||||
if (simLocale != null && !simLocale.equals(mCurrentLocale)) {
|
||||
if (!mIgnoreSimLocale && !isDetached()) {
|
||||
String label = getString(R.string.sim_locale_changed,
|
||||
simLocale.getDisplayName());
|
||||
Toast.makeText(getActivity(), label, Toast.LENGTH_SHORT).show();
|
||||
onLocaleChanged(simLocale);
|
||||
mIgnoreSimLocale = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mPaused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mPaused = false;
|
||||
if (mLanguagePicker != null) {
|
||||
mLanguagePicker.setEnabled(true);
|
||||
}
|
||||
if (mPendingLocaleUpdate) {
|
||||
mPendingLocaleUpdate = false;
|
||||
fetchAndUpdateSimLocale();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
117
src/com/cyanogenmod/setupwizard/ui/BaseSetupWizardActivity.java
Normal file
117
src/com/cyanogenmod/setupwizard/ui/BaseSetupWizardActivity.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.ui;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
|
||||
import com.android.setupwizard.navigationbar.SetupWizardNavBar.NavigationBarListener;
|
||||
import com.android.setupwizardlib.util.SystemBarHelper;
|
||||
|
||||
public abstract class BaseSetupWizardActivity extends Activity implements NavigationBarListener {
|
||||
|
||||
/* Logging */
|
||||
public static final boolean LOGV = true;
|
||||
|
||||
public static final String TAG = BaseSetupWizardActivity.class.getSimpleName();
|
||||
|
||||
private SetupWizardNavBar mNavigationBar;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SystemBarHelper.hideSystemBars(getWindow());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigationBarCreated(SetupWizardNavBar bar) {
|
||||
mNavigationBar = bar;
|
||||
bar.setUseImmersiveMode(true);
|
||||
bar.getView().addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View view, int left, int top, int right, int bottom,
|
||||
int oldLeft, int oldTop, int oldRight, int oldBottom) {
|
||||
view.requestApplyInsets();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void setBackDrawable(Drawable drawable) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getBackButton().setCompoundDrawables(drawable, null, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setNextDrawable(Drawable drawable) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getBackButton().setCompoundDrawables(null, null, drawable, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setBackAllowed(boolean allowed) {
|
||||
// Enable / disable navigation bar back button
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getBackButton().setEnabled(allowed);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setNextAllowed(boolean allowed) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getNextButton().setEnabled(allowed);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setNextText(int resId) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getNextButton().setText(resId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setBackText(int resId) {
|
||||
if (mNavigationBar != null) {
|
||||
mNavigationBar.getBackButton().setText(resId);
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideNextButton() {
|
||||
if (mNavigationBar != null) {
|
||||
Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
|
||||
final Button next = mNavigationBar.getNextButton();
|
||||
next.startAnimation(fadeOut);
|
||||
next.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void hideBackButton() {
|
||||
if (mNavigationBar != null) {
|
||||
Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
|
||||
final Button back = mNavigationBar.getBackButton();
|
||||
back.startAnimation(fadeOut);
|
||||
back.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
325
src/com/cyanogenmod/setupwizard/ui/FinishActivity.java
Normal file
325
src/com/cyanogenmod/setupwizard/ui/FinishActivity.java
Normal file
@@ -0,0 +1,325 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.ui;
|
||||
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_APPLY_DEFAULT_THEME;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_BUTTON_BACKLIGHT;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_PRIVACY_GUARD;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_SEND_METRICS;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.app.Activity;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.ThemeConfig;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Binder;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewAnimationUtils;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.android.setupwizardlib.util.WizardManagerHelper;
|
||||
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
|
||||
import com.cyanogenmod.setupwizard.util.EnableAccessibilityController;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import cyanogenmod.hardware.CMHardwareManager;
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
import cyanogenmod.themes.ThemeManager;
|
||||
|
||||
public class FinishActivity extends BaseSetupWizardActivity
|
||||
implements ThemeManager.ThemeChangeListener {
|
||||
|
||||
public static final String TAG = FinishActivity.class.getSimpleName();
|
||||
|
||||
private ImageView mReveal;
|
||||
private ProgressBar mFinishingProgressBar;
|
||||
|
||||
private EnableAccessibilityController mEnableAccessibilityController;
|
||||
|
||||
private SetupWizardApp mSetupWizardApp;
|
||||
|
||||
private final Handler mHandler = new Handler();
|
||||
|
||||
private volatile boolean mIsFinishing = false;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mSetupWizardApp = (SetupWizardApp) getApplication();
|
||||
setContentView(R.layout.finish_activity);
|
||||
mReveal = (ImageView) findViewById(R.id.reveal);
|
||||
mFinishingProgressBar = (ProgressBar)findViewById(R.id.finishing_bar);
|
||||
mEnableAccessibilityController =
|
||||
EnableAccessibilityController.getInstance(getApplicationContext());
|
||||
setNextText(R.string.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
super.finish();
|
||||
overridePendingTransition(R.anim.translucent_enter, R.anim.translucent_exit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateBack() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
startFinishSequence();
|
||||
}
|
||||
|
||||
private void finishSetup() {
|
||||
if (!mIsFinishing) {
|
||||
mSetupWizardApp.sendStickyBroadcastAsUser(
|
||||
new Intent(SetupWizardApp.ACTION_FINISHED),
|
||||
Binder.getCallingUserHandle());
|
||||
mIsFinishing = true;
|
||||
setupRevealImage();
|
||||
}
|
||||
}
|
||||
|
||||
private void startFinishSequence() {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
hideBackButton();
|
||||
hideNextButton();
|
||||
mSetupWizardApp.enableCaptivePortalDetection();
|
||||
Animation fadeIn = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
|
||||
mFinishingProgressBar.setVisibility(View.VISIBLE);
|
||||
mFinishingProgressBar.setIndeterminate(true);
|
||||
mFinishingProgressBar.startAnimation(fadeIn);
|
||||
final ThemeManager tm = ThemeManager.getInstance(this);
|
||||
try {
|
||||
tm.registerThemeChangeListener(this);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "ThemeChangeListener already registered");
|
||||
}
|
||||
handleDefaultThemeSetup(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish(boolean isSuccess) {
|
||||
if (isResumed()) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startFinishSequence();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
if (progress > 0) {
|
||||
mFinishingProgressBar.setIndeterminate(false);
|
||||
mFinishingProgressBar.setProgress(progress);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupRevealImage() {
|
||||
mFinishingProgressBar.setProgress(100);
|
||||
Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
|
||||
mFinishingProgressBar.startAnimation(fadeOut);
|
||||
mFinishingProgressBar.setVisibility(View.INVISIBLE);
|
||||
|
||||
final Point p = new Point();
|
||||
getWindowManager().getDefaultDisplay().getRealSize(p);
|
||||
final WallpaperManager wallpaperManager =
|
||||
WallpaperManager.getInstance(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() {
|
||||
int cx = (mReveal.getLeft() + mReveal.getRight()) / 2;
|
||||
int cy = (mReveal.getTop() + mReveal.getBottom()) / 2;
|
||||
int finalRadius = Math.max(mReveal.getWidth(), mReveal.getHeight());
|
||||
Animator anim =
|
||||
ViewAnimationUtils.createCircularReveal(mReveal, cx, cy, 0, finalRadius);
|
||||
anim.setDuration(900);
|
||||
anim.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
mReveal.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
completeSetup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {}
|
||||
});
|
||||
anim.start();
|
||||
}
|
||||
|
||||
private void completeSetup() {
|
||||
if (mEnableAccessibilityController != null) {
|
||||
mEnableAccessibilityController.onDestroy();
|
||||
}
|
||||
new FinishTask(this).execute();
|
||||
}
|
||||
|
||||
private static void handleEnableMetrics(SetupWizardApp setupWizardApp) {
|
||||
Bundle privacyData = setupWizardApp.getSettingsBundle();
|
||||
if (privacyData != null
|
||||
&& privacyData.containsKey(KEY_SEND_METRICS)) {
|
||||
CMSettings.Secure.putInt(setupWizardApp.getContentResolver(),
|
||||
CMSettings.Secure.STATS_COLLECTION, privacyData.getBoolean(KEY_SEND_METRICS)
|
||||
? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleDefaultThemeSetup(FinishActivity finishActivity) {
|
||||
Bundle privacyData = finishActivity.mSetupWizardApp.getSettingsBundle();
|
||||
if (!SetupWizardUtils.getDefaultThemePackageName(finishActivity.mSetupWizardApp)
|
||||
.equals(ThemeConfig.SYSTEM_DEFAULT) && privacyData != null &&
|
||||
privacyData.getBoolean(KEY_APPLY_DEFAULT_THEME)) {
|
||||
Log.i(TAG, "Applying default theme");
|
||||
final ThemeManager tm = ThemeManager.getInstance(finishActivity.mSetupWizardApp);
|
||||
tm.applyDefaultTheme();
|
||||
} else {
|
||||
finishActivity.finishSetup();
|
||||
}
|
||||
}
|
||||
|
||||
private static void handlePrivacyGuard(SetupWizardApp setupWizardApp) {
|
||||
Bundle mPrivacyData = setupWizardApp.getSettingsBundle();
|
||||
if (mPrivacyData != null && mPrivacyData.containsKey(KEY_PRIVACY_GUARD)) {
|
||||
CMSettings.Secure.putInt(setupWizardApp.getContentResolver(),
|
||||
CMSettings.Secure.PRIVACY_GUARD_DEFAULT,
|
||||
mPrivacyData.getBoolean(KEY_PRIVACY_GUARD) ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleNavKeys(SetupWizardApp setupWizardApp) {
|
||||
if (setupWizardApp.getSettingsBundle().containsKey(DISABLE_NAV_KEYS)) {
|
||||
SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
|
||||
SetupStats.Action.ENABLE_NAV_KEYS,
|
||||
SetupStats.Label.CHECKED,
|
||||
String.valueOf(setupWizardApp.getSettingsBundle()
|
||||
.getBoolean(DISABLE_NAV_KEYS)));
|
||||
writeDisableNavkeysOption(setupWizardApp,
|
||||
setupWizardApp.getSettingsBundle().getBoolean(DISABLE_NAV_KEYS));
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
|
||||
CMSettings.Global.putInt(context.getContentResolver(),
|
||||
CMSettings.Global.DEV_FORCE_SHOW_NAVBAR, enabled ? 1 : 0);
|
||||
CMHardwareManager hardware = CMHardwareManager.getInstance(context);
|
||||
hardware.set(CMHardwareManager.FEATURE_KEY_DISABLE, enabled);
|
||||
|
||||
/* Save/restore button timeouts to disable them in softkey mode */
|
||||
if (enabled) {
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 0);
|
||||
} else {
|
||||
int currentBrightness = CMSettings.Secure.getInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, 100);
|
||||
int oldBright = prefs.getInt(KEY_BUTTON_BACKLIGHT,
|
||||
currentBrightness);
|
||||
CMSettings.Secure.putInt(context.getContentResolver(),
|
||||
CMSettings.Secure.BUTTON_BRIGHTNESS, oldBright);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class FinishTask extends AsyncTask<Void, Void, Boolean> {
|
||||
|
||||
private final FinishActivity mActivity;
|
||||
|
||||
public FinishTask(FinishActivity activity) {
|
||||
mActivity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
SetupWizardApp app = (SetupWizardApp)mActivity.getApplication();
|
||||
handlePrivacyGuard(app);
|
||||
handleEnableMetrics(app);
|
||||
handleNavKeys(app);
|
||||
Settings.Global.putInt(mActivity.getContentResolver(),
|
||||
Settings.Global.DEVICE_PROVISIONED, 1);
|
||||
Settings.Secure.putInt(mActivity.getContentResolver(),
|
||||
Settings.Secure.USER_SETUP_COMPLETE, 1);
|
||||
CMSettings.Secure.putInt(mActivity.getContentResolver(),
|
||||
CMSettings.Secure.CM_SETUP_WIZARD_COMPLETED, 1);
|
||||
final ThemeManager tm = ThemeManager.getInstance(app);
|
||||
tm.unregisterThemeChangeListener(mActivity);
|
||||
final WallpaperManager wallpaperManager =
|
||||
WallpaperManager.getInstance(app);
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
SetupWizardUtils.disableSetupWizard(app);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean aBoolean) {
|
||||
Intent intent = WizardManagerHelper.getNextIntent(mActivity.getIntent(),
|
||||
Activity.RESULT_OK);
|
||||
mActivity.startActivityForResult(intent, 1);
|
||||
}
|
||||
}
|
||||
}
|
285
src/com/cyanogenmod/setupwizard/ui/LineageSettingsActivity.java
Normal file
285
src/com/cyanogenmod/setupwizard/ui/LineageSettingsActivity.java
Normal file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.ui;
|
||||
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.DISABLE_NAV_KEYS;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_APPLY_DEFAULT_THEME;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_PRIVACY_GUARD;
|
||||
import static com.cyanogenmod.setupwizard.SetupWizardApp.KEY_SEND_METRICS;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.ThemeConfig;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.util.Log;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.View;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.setupwizardlib.util.WizardManagerHelper;
|
||||
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import cyanogenmod.hardware.CMHardwareManager;
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
|
||||
public class LineageSettingsActivity extends BaseSetupWizardActivity {
|
||||
|
||||
public static final String TAG = LineageSettingsActivity.class.getSimpleName();
|
||||
|
||||
public static final String PRIVACY_POLICY_URI = "http://lineageos.org/legal";
|
||||
|
||||
private SetupWizardApp mSetupWizardApp;
|
||||
|
||||
private View mMetricsRow;
|
||||
private View mDefaultThemeRow;
|
||||
private View mNavKeysRow;
|
||||
private View mPrivacyGuardRow;
|
||||
private CheckBox mMetrics;
|
||||
private CheckBox mDefaultTheme;
|
||||
private CheckBox mNavKeys;
|
||||
private CheckBox mPrivacyGuard;
|
||||
|
||||
private boolean mHideNavKeysRow = false;
|
||||
private boolean mHideThemeRow = false;
|
||||
|
||||
private View.OnClickListener mMetricsClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mMetrics.isChecked();
|
||||
mMetrics.setChecked(checked);
|
||||
mSetupWizardApp.getSettingsBundle().putBoolean(KEY_SEND_METRICS, checked);
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener mDefaultThemeClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mDefaultTheme.isChecked();
|
||||
mDefaultTheme.setChecked(checked);
|
||||
mSetupWizardApp.getSettingsBundle().putBoolean(KEY_APPLY_DEFAULT_THEME, checked);
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener mNavKeysClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mNavKeys.isChecked();
|
||||
mNavKeys.setChecked(checked);
|
||||
mSetupWizardApp.getSettingsBundle().putBoolean(DISABLE_NAV_KEYS, checked);
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener mPrivacyGuardClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
boolean checked = !mPrivacyGuard.isChecked();
|
||||
mPrivacyGuard.setChecked(checked);
|
||||
mSetupWizardApp.getSettingsBundle().putBoolean(KEY_PRIVACY_GUARD, checked);
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mSetupWizardApp = (SetupWizardApp) getApplication();
|
||||
setContentView(R.layout.setup_lineage_settings);
|
||||
TextView title = (TextView) findViewById(android.R.id.title);
|
||||
title.setText(R.string.setup_services);
|
||||
ImageView icon = (ImageView) findViewById(R.id.header_icon);
|
||||
icon.setImageResource(R.drawable.ic_features);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
setNextText(R.string.next);
|
||||
String privacy_policy = getString(R.string.services_privacy_policy);
|
||||
String policySummary = getString(R.string.services_explanation, privacy_policy);
|
||||
SpannableString ss = new SpannableString(policySummary);
|
||||
ClickableSpan clickableSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(View textView) {
|
||||
// At this point of the setup, the device has already been unlocked (if frp
|
||||
// had been enabled), so there should be no issues regarding security
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse(PRIVACY_POLICY_URI));
|
||||
try {
|
||||
startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Unable to start activity " + intent.toString(), e);
|
||||
}
|
||||
}
|
||||
};
|
||||
ss.setSpan(clickableSpan,
|
||||
policySummary.length() - privacy_policy.length() - 1,
|
||||
policySummary.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TextView privacyPolicy = (TextView) findViewById(R.id.privacy_policy);
|
||||
privacyPolicy.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
privacyPolicy.setText(ss);
|
||||
|
||||
mMetricsRow = findViewById(R.id.metrics);
|
||||
mMetricsRow.setOnClickListener(mMetricsClickListener);
|
||||
String metricsHelpImproveCM =
|
||||
getString(R.string.services_help_improve_cm, getString(R.string.os_name));
|
||||
String metricsSummary = getString(R.string.services_metrics_label,
|
||||
metricsHelpImproveCM, getString(R.string.os_name));
|
||||
final SpannableStringBuilder metricsSpan = new SpannableStringBuilder(metricsSummary);
|
||||
metricsSpan.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD),
|
||||
0, metricsHelpImproveCM.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TextView metrics = (TextView) findViewById(R.id.enable_metrics_summary);
|
||||
metrics.setText(metricsSpan);
|
||||
mMetrics = (CheckBox) findViewById(R.id.enable_metrics_checkbox);
|
||||
|
||||
mDefaultThemeRow = findViewById(R.id.theme);
|
||||
mHideThemeRow = hideThemeSwitch(this);
|
||||
if (mHideThemeRow) {
|
||||
mDefaultThemeRow.setVisibility(View.GONE);
|
||||
} else {
|
||||
mDefaultThemeRow.setOnClickListener(mDefaultThemeClickListener);
|
||||
String defaultTheme =
|
||||
getString(R.string.services_apply_theme,
|
||||
getString(R.string.default_theme_name));
|
||||
String defaultThemeSummary = getString(R.string.services_apply_theme_label,
|
||||
defaultTheme);
|
||||
final SpannableStringBuilder themeSpan =
|
||||
new SpannableStringBuilder(defaultThemeSummary);
|
||||
themeSpan.setSpan(new android.text.style.StyleSpan(android.graphics.Typeface.BOLD),
|
||||
0, defaultTheme.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
TextView theme = (TextView) findViewById(R.id.enable_theme_summary);
|
||||
theme.setText(themeSpan);
|
||||
mDefaultTheme = (CheckBox) findViewById(R.id.enable_theme_checkbox);
|
||||
}
|
||||
|
||||
mNavKeysRow = findViewById(R.id.nav_keys);
|
||||
mNavKeysRow.setOnClickListener(mNavKeysClickListener);
|
||||
mNavKeys = (CheckBox) findViewById(R.id.nav_keys_checkbox);
|
||||
boolean needsNavBar = true;
|
||||
try {
|
||||
IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
|
||||
needsNavBar = windowManager.needsNavigationBar();
|
||||
} catch (RemoteException e) {
|
||||
}
|
||||
mHideNavKeysRow = hideKeyDisabler(this);
|
||||
if (mHideNavKeysRow || needsNavBar) {
|
||||
mNavKeysRow.setVisibility(View.GONE);
|
||||
} else {
|
||||
boolean navKeysDisabled = isKeyDisablerActive(this);
|
||||
mNavKeys.setChecked(navKeysDisabled);
|
||||
}
|
||||
|
||||
mPrivacyGuardRow = findViewById(R.id.privacy_guard);
|
||||
mPrivacyGuardRow.setOnClickListener(mPrivacyGuardClickListener);
|
||||
mPrivacyGuard = (CheckBox) findViewById(R.id.privacy_guard_checkbox);
|
||||
mPrivacyGuard.setChecked(CMSettings.Secure.getInt(getContentResolver(),
|
||||
CMSettings.Secure.PRIVACY_GUARD_DEFAULT, 0) == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateDisableNavkeysOption();
|
||||
updateMetricsOption();
|
||||
updateThemeOption();
|
||||
updatePrivacyGuardOption();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateBack() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
|
||||
private void updateMetricsOption() {
|
||||
final Bundle myPageBundle = mSetupWizardApp.getSettingsBundle();
|
||||
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 = mSetupWizardApp.getSettingsBundle();
|
||||
boolean themesChecked;
|
||||
if (myPageBundle.containsKey(KEY_APPLY_DEFAULT_THEME)) {
|
||||
themesChecked = myPageBundle.getBoolean(KEY_APPLY_DEFAULT_THEME);
|
||||
} else {
|
||||
themesChecked = getResources().getBoolean(
|
||||
R.bool.check_custom_theme_by_default);
|
||||
}
|
||||
mDefaultTheme.setChecked(themesChecked);
|
||||
myPageBundle.putBoolean(KEY_APPLY_DEFAULT_THEME, themesChecked);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisableNavkeysOption() {
|
||||
if (!mHideNavKeysRow) {
|
||||
final Bundle myPageBundle = mSetupWizardApp.getSettingsBundle();
|
||||
boolean enabled = CMSettings.Secure.getInt(getContentResolver(),
|
||||
CMSettings.Secure.DEV_FORCE_SHOW_NAVBAR, 0) != 0;
|
||||
boolean checked = myPageBundle.containsKey(DISABLE_NAV_KEYS) ?
|
||||
myPageBundle.getBoolean(DISABLE_NAV_KEYS) :
|
||||
enabled;
|
||||
mNavKeys.setChecked(checked);
|
||||
myPageBundle.putBoolean(DISABLE_NAV_KEYS, checked);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePrivacyGuardOption() {
|
||||
final Bundle bundle = mSetupWizardApp.getSettingsBundle();
|
||||
boolean enabled = CMSettings.Secure.getInt(getContentResolver(),
|
||||
CMSettings.Secure.PRIVACY_GUARD_DEFAULT, 0) != 0;
|
||||
boolean checked = bundle.containsKey(KEY_PRIVACY_GUARD) ?
|
||||
bundle.getBoolean(KEY_PRIVACY_GUARD) :
|
||||
enabled;
|
||||
mPrivacyGuard.setChecked(checked);
|
||||
bundle.putBoolean(KEY_PRIVACY_GUARD, checked);
|
||||
}
|
||||
|
||||
private static boolean hideKeyDisabler(Context context) {
|
||||
final CMHardwareManager hardware = CMHardwareManager.getInstance(context);
|
||||
return !hardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE);
|
||||
}
|
||||
|
||||
private static boolean isKeyDisablerActive(Context context) {
|
||||
final CMHardwareManager hardware = CMHardwareManager.getInstance(context);
|
||||
return hardware.get(CMHardwareManager.FEATURE_KEY_DISABLE);
|
||||
}
|
||||
|
||||
private static boolean hideThemeSwitch(Context context) {
|
||||
return SetupWizardUtils.getDefaultThemePackageName(context)
|
||||
.equals(ThemeConfig.SYSTEM_DEFAULT);
|
||||
}
|
||||
}
|
255
src/com/cyanogenmod/setupwizard/ui/LocaleActivity.java
Normal file
255
src/com/cyanogenmod/setupwizard/ui/LocaleActivity.java
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.telephony.SubscriptionInfo;
|
||||
import android.telephony.SubscriptionManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.NumberPicker;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.internal.telephony.MccTable;
|
||||
import com.android.internal.telephony.TelephonyIntents;
|
||||
import com.android.setupwizardlib.util.WizardManagerHelper;
|
||||
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleActivity extends BaseSetupWizardActivity {
|
||||
|
||||
public static final String TAG = LocaleActivity.class.getSimpleName();
|
||||
|
||||
private ArrayAdapter<com.android.internal.app.LocalePicker.LocaleInfo> mLocaleAdapter;
|
||||
private Locale mCurrentLocale;
|
||||
private int[] mAdapterIndices;
|
||||
private LocalePicker mLanguagePicker;
|
||||
private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
|
||||
private final Handler mHandler = new Handler();
|
||||
private boolean mPendingLocaleUpdate;
|
||||
private boolean mPaused = true;
|
||||
|
||||
private final Runnable mUpdateLocale = new Runnable() {
|
||||
public void run() {
|
||||
if (mCurrentLocale != null) {
|
||||
mLanguagePicker.setEnabled(false);
|
||||
com.android.internal.app.LocalePicker.updateLocale(mCurrentLocale);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver mSimChangedReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
|
||||
fetchAndUpdateSimLocale();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.setup_locale);
|
||||
TextView title = (TextView) findViewById(android.R.id.title);
|
||||
title.setText(R.string.setup_locale);
|
||||
ImageView icon = (ImageView) findViewById(R.id.header_icon);
|
||||
icon.setImageResource(R.drawable.ic_locale);
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
setNextText(R.string.next);
|
||||
mLanguagePicker = (LocalePicker) findViewById(R.id.locale_list);
|
||||
loadLanguages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
mPaused = true;
|
||||
unregisterReceiver(mSimChangedReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
mPaused = false;
|
||||
registerReceiver(mSimChangedReceiver,
|
||||
new IntentFilter(TelephonyIntents.ACTION_SIM_STATE_CHANGED));
|
||||
if (mLanguagePicker != null) {
|
||||
mLanguagePicker.setEnabled(true);
|
||||
}
|
||||
if (mPendingLocaleUpdate) {
|
||||
mPendingLocaleUpdate = false;
|
||||
fetchAndUpdateSimLocale();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateBack() {
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
|
||||
startActivityForResult(intent, 1);
|
||||
}
|
||||
|
||||
private void loadLanguages() {
|
||||
mLocaleAdapter = com.android.internal.app.LocalePicker.constructAdapter(this,
|
||||
R.layout.locale_picker_item, R.id.locale);
|
||||
mCurrentLocale = Locale.getDefault();
|
||||
fetchAndUpdateSimLocale();
|
||||
mAdapterIndices = new int[mLocaleAdapter.getCount()];
|
||||
int currentLocaleIndex = 0;
|
||||
String [] labels = new String[mLocaleAdapter.getCount()];
|
||||
for (int i=0; i<mAdapterIndices.length; i++) {
|
||||
com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo =
|
||||
mLocaleAdapter.getItem(i);
|
||||
Locale localLocale = localLocaleInfo.getLocale();
|
||||
if (localLocale.equals(mCurrentLocale)) {
|
||||
currentLocaleIndex = i;
|
||||
}
|
||||
mAdapterIndices[i] = i;
|
||||
labels[i] = localLocaleInfo.getLabel();
|
||||
}
|
||||
mLanguagePicker.setDisplayedValues(labels);
|
||||
mLanguagePicker.setMaxValue(labels.length - 1);
|
||||
mLanguagePicker.setValue(currentLocaleIndex);
|
||||
mLanguagePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||
mLanguagePicker.setOnValueChangedListener(new LocalePicker.OnValueChangeListener() {
|
||||
public void onValueChange(LocalePicker picker, int oldVal, int newVal) {
|
||||
setLocaleFromPicker();
|
||||
}
|
||||
});
|
||||
mLanguagePicker.setOnScrollListener(new LocalePicker.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChange(LocalePicker view, int scrollState) {
|
||||
if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
|
||||
((SetupWizardApp)getApplication()).setIgnoreSimLocale(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLocaleFromPicker() {
|
||||
((SetupWizardApp)getApplication()).setIgnoreSimLocale(true);
|
||||
int i = mAdapterIndices[mLanguagePicker.getValue()];
|
||||
final com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i);
|
||||
onLocaleChanged(localLocaleInfo.getLocale());
|
||||
}
|
||||
|
||||
private void onLocaleChanged(Locale paramLocale) {
|
||||
mLanguagePicker.setEnabled(true);
|
||||
Resources localResources = getResources();
|
||||
Configuration localConfiguration1 = localResources.getConfiguration();
|
||||
Configuration localConfiguration2 = new Configuration();
|
||||
localConfiguration2.locale = paramLocale;
|
||||
localResources.updateConfiguration(localConfiguration2, null);
|
||||
localResources.updateConfiguration(localConfiguration1, null);
|
||||
mHandler.removeCallbacks(mUpdateLocale);
|
||||
mCurrentLocale = paramLocale;
|
||||
mHandler.postDelayed(mUpdateLocale, 1000);
|
||||
}
|
||||
|
||||
private void fetchAndUpdateSimLocale() {
|
||||
if (((SetupWizardApp)getApplication()).ignoreSimLocale() || isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if (mPaused) {
|
||||
mPendingLocaleUpdate = true;
|
||||
return;
|
||||
}
|
||||
if (mFetchUpdateSimLocaleTask != null) {
|
||||
mFetchUpdateSimLocaleTask.cancel(true);
|
||||
}
|
||||
mFetchUpdateSimLocaleTask = new FetchUpdateSimLocaleTask();
|
||||
mFetchUpdateSimLocaleTask.execute();
|
||||
}
|
||||
|
||||
private class FetchUpdateSimLocaleTask extends AsyncTask<Void, Void, Locale> {
|
||||
@Override
|
||||
protected Locale doInBackground(Void... params) {
|
||||
Locale locale = null;
|
||||
Activity activity = LocaleActivity.this;
|
||||
if (!activity.isFinishing() || !activity.isDestroyed()) {
|
||||
// If the sim is currently pin locked, return
|
||||
TelephonyManager telephonyManager = (TelephonyManager)
|
||||
activity.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
int state = telephonyManager.getSimState();
|
||||
if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
|
||||
state == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final SubscriptionManager subscriptionManager =
|
||||
SubscriptionManager.from(activity);
|
||||
List<SubscriptionInfo> activeSubs =
|
||||
subscriptionManager.getActiveSubscriptionInfoList();
|
||||
if (activeSubs == null || activeSubs.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Fetch locale for active sim's MCC
|
||||
int mcc = activeSubs.get(0).getMcc();
|
||||
locale = MccTable.getLocaleFromMcc(activity, mcc, null);
|
||||
|
||||
// If that fails, fall back to preferred languages reported
|
||||
// by the sim
|
||||
if (locale == null) {
|
||||
String localeString = telephonyManager.getLocaleFromDefaultSim();
|
||||
if (localeString != null) {
|
||||
locale = Locale.forLanguageTag(localeString);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Locale simLocale) {
|
||||
if (simLocale != null && !simLocale.equals(mCurrentLocale)) {
|
||||
if (!((SetupWizardApp)getApplication()).ignoreSimLocale() && !isDestroyed()) {
|
||||
String label = getString(R.string.sim_locale_changed,
|
||||
simLocale.getDisplayName());
|
||||
Toast.makeText(LocaleActivity.this, label, Toast.LENGTH_SHORT).show();
|
||||
onLocaleChanged(simLocale);
|
||||
((SetupWizardApp)getApplication()).setIgnoreSimLocale(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -31,7 +31,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -43,21 +42,21 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import com.android.setupwizardlib.util.SystemBarHelper;
|
||||
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.SetupWizardApp;
|
||||
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
|
||||
import com.cyanogenmod.setupwizard.setup.CMSetupWizardData;
|
||||
import com.cyanogenmod.setupwizard.setup.GmsAccountPage;
|
||||
import com.cyanogenmod.setupwizard.setup.Page;
|
||||
import com.cyanogenmod.setupwizard.setup.SetupDataCallbacks;
|
||||
import com.cyanogenmod.setupwizard.util.EnableAccessibilityController;
|
||||
import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cyanogenmod.providers.CMSettings;
|
||||
import cyanogenmod.themes.ThemeManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
ThemeManager.ThemeChangeListener {
|
||||
@@ -103,7 +102,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
mReveal = (ImageView)mRootView.findViewById(R.id.reveal);
|
||||
mButtonBar = findViewById(R.id.button_bar);
|
||||
mFinishingProgressBar = (ProgressBar)findViewById(R.id.finishing_bar);
|
||||
((SetupWizardApp)getApplicationContext()).disableStatusBar();
|
||||
mSetupData = (CMSetupWizardData)getLastNonConfigurationInstance();
|
||||
if (mSetupData == null) {
|
||||
mSetupData = new CMSetupWizardData(getApplicationContext());
|
||||
@@ -145,14 +143,8 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
Settings.Secure.BACKUP_AUTO_RESTORE, 0) == 1) ||
|
||||
(Settings.Secure.getInt(getContentResolver(),
|
||||
Settings.Secure.BACKUP_ENABLED, 0) == 1);
|
||||
if (TextUtils.equals(lastPage, GmsAccountPage.TAG) && backupEnabled) {
|
||||
// We probably already restored, skip ahead!
|
||||
mSetupData.setCurrentPage(mSetupData.getNextPage(lastPage).getKey());
|
||||
} else {
|
||||
// else just restore
|
||||
mSetupData.setCurrentPage(sharedPreferences.getString(KEY_LAST_PAGE_TAG,
|
||||
mSetupData.getCurrentPage().getKey()));
|
||||
}
|
||||
mSetupData.setCurrentPage(sharedPreferences.getString(KEY_LAST_PAGE_TAG,
|
||||
mSetupData.getCurrentPage().getKey()));
|
||||
Page page = mSetupData.getCurrentPage();
|
||||
page.doLoadAction(getFragmentManager(), Page.ACTION_NEXT);
|
||||
}
|
||||
@@ -323,7 +315,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
mPrevButton.startAnimation(fadeOut);
|
||||
mPrevButton.setVisibility(View.INVISIBLE);
|
||||
final SetupWizardApp setupWizardApp = (SetupWizardApp)getApplication();
|
||||
setupWizardApp.enableStatusBar();
|
||||
setupWizardApp.enableCaptivePortalDetection();
|
||||
Animation fadeIn = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
|
||||
mFinishingProgressBar.setVisibility(View.VISIBLE);
|
||||
@@ -454,7 +445,6 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
|
||||
final ThemeManager tm = ThemeManager.getInstance(SetupWizardActivity.this);
|
||||
tm.unregisterThemeChangeListener(SetupWizardActivity.this);
|
||||
SetupStats.sendEvents(SetupWizardActivity.this);
|
||||
SetupWizardUtils.disableGMSSetupWizard(SetupWizardActivity.this);
|
||||
final WallpaperManager wallpaperManager =
|
||||
WallpaperManager.getInstance(SetupWizardActivity.this);
|
||||
wallpaperManager.forgetLoadedWallpaper();
|
||||
|
83
src/com/cyanogenmod/setupwizard/ui/WelcomeActivity.java
Normal file
83
src/com/cyanogenmod/setupwizard/ui/WelcomeActivity.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The CyanogenMod Project
|
||||
* Copyright (C) 2017 The LineageOS 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.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.setupwizardlib.util.WizardManagerHelper;
|
||||
|
||||
import com.cyanogenmod.setupwizard.R;
|
||||
import com.cyanogenmod.setupwizard.util.EnableAccessibilityController;
|
||||
|
||||
public class WelcomeActivity extends BaseSetupWizardActivity {
|
||||
|
||||
public static final String TAG = WelcomeActivity.class.getSimpleName();
|
||||
|
||||
private static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL";
|
||||
|
||||
private View mRootView;
|
||||
private EnableAccessibilityController mEnableAccessibilityController;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.welcome_activity);
|
||||
mRootView = findViewById(R.id.root);
|
||||
setNextText(R.string.next);
|
||||
setBackText(R.string.emergency_call);
|
||||
setBackDrawable(null);
|
||||
mEnableAccessibilityController =
|
||||
EnableAccessibilityController.getInstance(getApplicationContext());
|
||||
mRootView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
boolean consumeIntercept = mEnableAccessibilityController.onInterceptTouchEvent(event);
|
||||
boolean consumeTouch = mEnableAccessibilityController.onTouchEvent(event);
|
||||
return consumeIntercept && consumeTouch;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateBack() {
|
||||
Intent intent = new Intent(ACTION_EMERGENCY_DIAL);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
ActivityOptions options =
|
||||
ActivityOptions.makeCustomAnimation(this,
|
||||
android.R.anim.fade_in,
|
||||
android.R.anim.fade_out);
|
||||
startActivity(intent, options.toBundle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNavigateNext() {
|
||||
ActivityOptions options =
|
||||
ActivityOptions.makeCustomAnimation(this,
|
||||
R.anim.slide_left,
|
||||
0);
|
||||
Intent intent = WizardManagerHelper.getNextIntent(getIntent(), Activity.RESULT_OK);
|
||||
startActivityForResult(intent, 1, options.toBundle());
|
||||
}
|
||||
|
||||
}
|
@@ -195,6 +195,11 @@ public class SetupWizardUtils {
|
||||
return Binder.getCallingUserHandle().isOwner();
|
||||
}
|
||||
|
||||
public static boolean hasGMS(Context context) {
|
||||
return GooglePlayServicesUtil.isGooglePlayServicesAvailable(context) !=
|
||||
ConnectionResult.SERVICE_MISSING;
|
||||
}
|
||||
|
||||
public static boolean accountExists(Context context, String accountType) {
|
||||
return AccountManager.get(context).getAccountsByType(accountType).length > 0;
|
||||
}
|
||||
@@ -211,48 +216,15 @@ public class SetupWizardUtils {
|
||||
|
||||
public static void disableSetupWizard(Context context) {
|
||||
disableComponent(context, context.getPackageName(),
|
||||
"com.cyanogenmod.setupwizard.ui.SetupWizardActivity");
|
||||
SetupWizardActivity.class.getName());
|
||||
disableComponent(context, context.getPackageName(),
|
||||
"com.cyanogenmod.setupwizard.setup.FinishSetupReceiver");
|
||||
}
|
||||
|
||||
public static void disableGMSSetupWizard(Context context) {
|
||||
try {
|
||||
PackageInfo packageInfo = context.getPackageManager()
|
||||
.getPackageInfo(GOOGLE_SETUPWIZARD_PACKAGE,
|
||||
PackageManager.GET_ACTIVITIES |
|
||||
PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES);
|
||||
disableComponentArray(context, packageInfo.activities);
|
||||
disableComponentArray(context, packageInfo.services);
|
||||
disableComponentArray(context, packageInfo.receivers);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Unable to disable GMS");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean enableGMSSetupWizard(Context context) {
|
||||
try {
|
||||
PackageInfo packageInfo = context.getPackageManager()
|
||||
.getPackageInfo(GOOGLE_SETUPWIZARD_PACKAGE,
|
||||
PackageManager.GET_ACTIVITIES |
|
||||
PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES);
|
||||
enableComponentArray(context, packageInfo.activities);
|
||||
enableComponentArray(context, packageInfo.services);
|
||||
enableComponentArray(context, packageInfo.receivers);
|
||||
return true;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Unable to enable GMS");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void disableComponentArray(Context context, ComponentInfo[] components) {
|
||||
if(components != null) {
|
||||
ComponentInfo[] componentInfos = components;
|
||||
for(int i = 0; i < componentInfos.length; i++) {
|
||||
disableComponent(context, componentInfos[i].packageName, componentInfos[i].name);
|
||||
}
|
||||
}
|
||||
"com.cyanogenmod.setupwizard.ui.WelcomeActivity");
|
||||
disableComponent(context, context.getPackageName(),
|
||||
"com.cyanogenmod.setupwizard.ui.LocaleActivity");
|
||||
disableComponent(context, context.getPackageName(),
|
||||
"com.cyanogenmod.setupwizard.ui.LineageSettingsActivity");
|
||||
disableComponent(context, context.getPackageName(),
|
||||
"com.cyanogenmod.setupwizard.ui.FinishActivity");
|
||||
}
|
||||
|
||||
private static void disableComponent(Context context, String packageName, String name) {
|
||||
@@ -264,24 +236,6 @@ public class SetupWizardUtils {
|
||||
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
|
||||
}
|
||||
|
||||
private static void enableComponentArray(Context context, ComponentInfo[] components) {
|
||||
if(components != null) {
|
||||
ComponentInfo[] componentInfos = components;
|
||||
for(int i = 0; i < componentInfos.length; i++) {
|
||||
enableComponent(context, componentInfos[i].packageName, componentInfos[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void enableComponent(Context context, String packageName, String name) {
|
||||
enableComponent(context, new ComponentName(packageName, name));
|
||||
}
|
||||
|
||||
private static void enableComponent(Context context, ComponentName component) {
|
||||
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);
|
||||
|
Reference in New Issue
Block a user