| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The CyanogenMod Project |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 3 | * Copyright (C) 2017 The LineageOS Project |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | package com.cyanogenmod.setupwizard; |
| 19 | |
| 20 | |
| 21 | import android.app.Application; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 22 | import android.os.Bundle; |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 23 | import android.os.Handler; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 24 | import android.util.Log; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 25 | |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 26 | import com.cyanogenmod.setupwizard.util.NetworkMonitor; |
| 27 | import com.cyanogenmod.setupwizard.util.PhoneMonitor; |
| cretin45 | 0d31b31 | 2015-03-09 14:49:31 -0700 | [diff] [blame] | 28 | import com.cyanogenmod.setupwizard.util.SetupWizardUtils; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 29 | import com.cyanogenmod.setupwizard.wizardmanager.WizardManager; |
| cretin45 | 0d31b31 | 2015-03-09 14:49:31 -0700 | [diff] [blame] | 30 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 31 | public class SetupWizardApp extends Application { |
| 32 | |
| 33 | public static final String TAG = SetupWizardApp.class.getSimpleName(); |
| 34 | // Leave this off for release |
| 35 | public static final boolean DEBUG = false; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 36 | /* Verbose Logging */ |
| 37 | public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE); |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 38 | |
| cretin45 | 48ca24e | 2015-01-19 14:29:43 -0800 | [diff] [blame] | 39 | public static final String ACTION_FINISHED = "com.cyanogenmod.setupwizard.SETUP_FINISHED"; |
| Abhisek Devkota | aadbc73 | 2018-01-31 01:33:59 -0800 | [diff] [blame] | 40 | public static final String ACTION_SETUP_WIFI = "android.net.wifi.PICK_WIFI_NETWORK"; |
| d34d | 68d2ba7 | 2015-12-03 16:52:30 -0800 | [diff] [blame] | 41 | public static final String ACTION_SETUP_FINGERPRINT = "android.settings.FINGERPRINT_SETUP"; |
| Ricardo Cerqueira | 8331602 | 2016-08-10 12:33:05 +0100 | [diff] [blame] | 42 | public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN"; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 43 | public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL"; |
| 44 | public static final String ACTION_NEXT = "com.android.wizard.NEXT"; |
| 45 | public static final String ACTION_LOAD = "com.android.wizard.LOAD"; |
| 46 | |
| d34d | b28f9c0 | 2015-07-07 17:30:20 -0700 | [diff] [blame] | 47 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 48 | public static final String EXTRA_FIRST_RUN = "firstRun"; |
| 49 | public static final String EXTRA_ALLOW_SKIP = "allowSkip"; |
| 50 | public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect"; |
| cretin45 | 30af327 | 2015-01-23 10:14:07 -0800 | [diff] [blame] | 51 | public static final String EXTRA_USE_IMMERSIVE = "useImmersiveMode"; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 52 | public static final String EXTRA_HAS_MULTIPLE_USERS = "hasMultipleUsers"; |
| cretin45 | 3441abd | 2015-02-02 16:44:52 -0800 | [diff] [blame] | 53 | public static final String EXTRA_THEME = "theme"; |
| 54 | public static final String EXTRA_MATERIAL_LIGHT = "material_light"; |
| d34d | b28f9c0 | 2015-07-07 17:30:20 -0700 | [diff] [blame] | 55 | public static final String EXTRA_TITLE = "title"; |
| 56 | public static final String EXTRA_DETAILS = "details"; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 57 | public static final String EXTRA_SCRIPT_URI = "scriptUri"; |
| 58 | public static final String EXTRA_ACTION_ID = "actionId"; |
| 59 | public static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode"; |
| Abhisek Devkota | aadbc73 | 2018-01-31 01:33:59 -0800 | [diff] [blame] | 60 | public static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; |
| 61 | public static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text"; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 62 | |
| cretin45 | c5e926d | 2015-06-17 13:56:09 -0700 | [diff] [blame] | 63 | public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled"; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 64 | public static final String KEY_SEND_METRICS = "send_metrics"; |
| 65 | public static final String DISABLE_NAV_KEYS = "disable_nav_keys"; |
| 66 | public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme"; |
| 67 | public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight"; |
| 68 | public static final String KEY_PRIVACY_GUARD = "privacy_guard_default"; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 69 | |
| d34d | 88aba00 | 2015-03-13 18:35:34 -0700 | [diff] [blame] | 70 | private static final String[] THEME_PACKAGES = { |
| 71 | "org.cyanogenmod.theme.chooser", |
| Joey Rizzoli | 52a78fd | 2016-12-29 17:28:02 +0100 | [diff] [blame] | 72 | "org.cyanogenmod.theme.chooser2", |
| d34d | 88aba00 | 2015-03-13 18:35:34 -0700 | [diff] [blame] | 73 | "com.cyngn.theme.chooser", |
| 74 | "com.cyngn.themestore" |
| 75 | }; |
| 76 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 77 | public static final int REQUEST_CODE_SETUP_WIFI = 0; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 78 | public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4; |
| dhacker29 | 218deb9 | 2015-04-23 22:54:36 -0400 | [diff] [blame] | 79 | public static final int REQUEST_CODE_SETUP_BLUETOOTH= 5; |
| d34d | b28f9c0 | 2015-07-07 17:30:20 -0700 | [diff] [blame] | 80 | public static final int REQUEST_CODE_SETUP_FINGERPRINT = 7; |
| Ricardo Cerqueira | 8331602 | 2016-08-10 12:33:05 +0100 | [diff] [blame] | 81 | public static final int REQUEST_CODE_SETUP_LOCKSCREEN = 9; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 82 | |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 83 | public static final int RADIO_READY_TIMEOUT = 10 * 1000; |
| 84 | |
| 85 | private boolean mIsRadioReady = false; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 86 | private boolean mIgnoreSimLocale = false; |
| cretin45 | 7710855 | 2015-05-07 16:21:10 -0700 | [diff] [blame] | 87 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 88 | private final Bundle mSettingsBundle = new Bundle(); |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 89 | private final Handler mHandler = new Handler(); |
| 90 | |
| 91 | private final Runnable mRadioTimeoutRunnable = new Runnable() { |
| 92 | @Override |
| 93 | public void run() { |
| 94 | mIsRadioReady = true; |
| 95 | } |
| 96 | }; |
| 97 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 98 | @Override |
| 99 | public void onCreate() { |
| 100 | super.onCreate(); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 101 | if (LOGV) { |
| 102 | Log.v(TAG, "onCreate()"); |
| 103 | } |
| 104 | NetworkMonitor.initInstance(this); |
| 105 | PhoneMonitor.initInstance(this); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 106 | SetupWizardUtils.disableComponentsForMissingFeatures(this); |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 107 | mHandler.postDelayed(mRadioTimeoutRunnable, SetupWizardApp.RADIO_READY_TIMEOUT); |
| 108 | } |
| 109 | |
| 110 | public boolean isRadioReady() { |
| 111 | return mIsRadioReady; |
| 112 | } |
| 113 | |
| 114 | public void setRadioReady(boolean radioReady) { |
| 115 | if (!mIsRadioReady && radioReady) { |
| 116 | mHandler.removeCallbacks(mRadioTimeoutRunnable); |
| 117 | } |
| 118 | mIsRadioReady = radioReady; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 119 | } |
| 120 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 121 | public boolean ignoreSimLocale() { |
| 122 | return mIgnoreSimLocale; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 123 | } |
| 124 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 125 | public void setIgnoreSimLocale(boolean ignoreSimLocale) { |
| 126 | mIgnoreSimLocale = ignoreSimLocale; |
| 127 | } |
| 128 | |
| 129 | public Bundle getSettingsBundle() { |
| 130 | return mSettingsBundle; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 131 | } |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 132 | } |