| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The CyanogenMod Project |
| Timi Rautamäki | e83f9e1 | 2022-03-16 13:21:30 +0000 | [diff] [blame^] | 3 | * Copyright (C) 2017-2022 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 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 18 | package org.lineageos.setupwizard; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 19 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 20 | import android.app.Application; |
| Artem Borisov | fbf886e | 2020-12-07 13:43:19 +0000 | [diff] [blame] | 21 | import android.app.StatusBarManager; |
| 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 | |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 26 | import org.lineageos.setupwizard.util.NetworkMonitor; |
| 27 | import org.lineageos.setupwizard.util.PhoneMonitor; |
| 28 | import org.lineageos.setupwizard.util.SetupWizardUtils; |
| cretin45 | 0d31b31 | 2015-03-09 14:49:31 -0700 | [diff] [blame] | 29 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 30 | public class SetupWizardApp extends Application { |
| 31 | |
| 32 | public static final String TAG = SetupWizardApp.class.getSimpleName(); |
| Michael Bestas | b7b34b9 | 2021-08-25 19:13:30 +0300 | [diff] [blame] | 33 | // Verbose logging |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 34 | public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE); |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 35 | |
| Timi Rautamäki | f6dbf84 | 2021-08-24 19:19:25 +0000 | [diff] [blame] | 36 | public static final String ACTION_ACCESSIBILITY_SETTINGS = |
| 37 | "android.settings.ACCESSIBILITY_SETTINGS_FOR_SUW"; |
| Michael Bestas | b7b34b9 | 2021-08-25 19:13:30 +0300 | [diff] [blame] | 38 | public static final String ACTION_SETUP_COMPLETE = |
| 39 | "org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE"; |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 40 | public static final String ACTION_FINISHED = "org.lineageos.setupwizard.SETUP_FINISHED"; |
| Michael Bestas | 334cd1b | 2021-10-09 01:55:56 +0300 | [diff] [blame] | 41 | public static final String ACTION_SETUP_NETWORK = "android.settings.NETWORK_PROVIDER_SETUP"; |
| Chirayu Desai | e372bc0 | 2020-05-28 00:26:19 +0530 | [diff] [blame] | 42 | public static final String ACTION_SETUP_BIOMETRIC = "android.settings.BIOMETRIC_ENROLL"; |
| Ricardo Cerqueira | 8331602 | 2016-08-10 12:33:05 +0100 | [diff] [blame] | 43 | public static final String ACTION_SETUP_LOCKSCREEN = "com.android.settings.SETUP_LOCK_SCREEN"; |
| Michael Bestas | b7b34b9 | 2021-08-25 19:13:30 +0300 | [diff] [blame] | 44 | public static final String ACTION_RESTORE_FROM_BACKUP = |
| 45 | "com.stevesoltys.seedvault.RESTORE_BACKUP"; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 46 | public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL"; |
| 47 | public static final String ACTION_NEXT = "com.android.wizard.NEXT"; |
| 48 | public static final String ACTION_LOAD = "com.android.wizard.LOAD"; |
| 49 | |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 50 | public static final String EXTRA_HAS_MULTIPLE_USERS = "hasMultipleUsers"; |
| d34d | b28f9c0 | 2015-07-07 17:30:20 -0700 | [diff] [blame] | 51 | public static final String EXTRA_TITLE = "title"; |
| 52 | public static final String EXTRA_DETAILS = "details"; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 53 | public static final String EXTRA_SCRIPT_URI = "scriptUri"; |
| 54 | public static final String EXTRA_ACTION_ID = "actionId"; |
| 55 | public static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode"; |
| Abhisek Devkota | aadbc73 | 2018-01-31 01:33:59 -0800 | [diff] [blame] | 56 | public static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; |
| Michael Bestas | b3789b8 | 2021-08-24 02:01:57 +0300 | [diff] [blame] | 57 | public static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip"; |
| Timi Rautamäki | 40215f6 | 2021-11-03 11:53:10 +0000 | [diff] [blame] | 58 | public static final String EXTRA_PREFS_SHOW_SKIP_TV = "extra_show_skip_network"; |
| Abhisek Devkota | aadbc73 | 2018-01-31 01:33:59 -0800 | [diff] [blame] | 59 | public static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text"; |
| Michael Bestas | b3789b8 | 2021-08-24 02:01:57 +0300 | [diff] [blame] | 60 | public static final String EXTRA_ENABLE_NEXT_ON_CONNECT = "wifi_enable_next_on_connect"; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 61 | |
| cretin45 | c5e926d | 2015-06-17 13:56:09 -0700 | [diff] [blame] | 62 | public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled"; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 63 | public static final String KEY_SEND_METRICS = "send_metrics"; |
| 64 | public static final String DISABLE_NAV_KEYS = "disable_nav_keys"; |
| Timi | e90cf31 | 2020-12-23 13:28:00 +0100 | [diff] [blame] | 65 | public static final String ENABLE_RECOVERY_UPDATE = "enable_recovery_update"; |
| 66 | public static final String UPDATE_RECOVERY_PROP = "persist.vendor.recovery_update"; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 67 | |
| Timi Rautamäki | e83f9e1 | 2022-03-16 13:21:30 +0000 | [diff] [blame^] | 68 | public static final String NAVIGATION_OPTION_KEY = "navigation_option"; |
| 69 | |
| Michael Bestas | 334cd1b | 2021-10-09 01:55:56 +0300 | [diff] [blame] | 70 | public static final int REQUEST_CODE_SETUP_NETWORK = 0; |
| Michael Bestas | b7b34b9 | 2021-08-25 19:13:30 +0300 | [diff] [blame] | 71 | public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL = 4; |
| 72 | public static final int REQUEST_CODE_SETUP_BLUETOOTH = 5; |
| Chirayu Desai | e372bc0 | 2020-05-28 00:26:19 +0530 | [diff] [blame] | 73 | public static final int REQUEST_CODE_SETUP_BIOMETRIC = 7; |
| Ricardo Cerqueira | 8331602 | 2016-08-10 12:33:05 +0100 | [diff] [blame] | 74 | public static final int REQUEST_CODE_SETUP_LOCKSCREEN = 9; |
| Torsten Grote | fc026fc | 2019-09-04 15:58:07 -0300 | [diff] [blame] | 75 | public static final int REQUEST_CODE_RESTORE = 10; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 76 | |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 77 | public static final int RADIO_READY_TIMEOUT = 10 * 1000; |
| 78 | |
| Artem Borisov | fbf886e | 2020-12-07 13:43:19 +0000 | [diff] [blame] | 79 | private static StatusBarManager sStatusBarManager; |
| 80 | |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 81 | private boolean mIsRadioReady = false; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 82 | private boolean mIgnoreSimLocale = false; |
| cretin45 | 7710855 | 2015-05-07 16:21:10 -0700 | [diff] [blame] | 83 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 84 | private final Bundle mSettingsBundle = new Bundle(); |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 85 | private final Handler mHandler = new Handler(); |
| 86 | |
| Michael Bestas | b7b34b9 | 2021-08-25 19:13:30 +0300 | [diff] [blame] | 87 | private final Runnable mRadioTimeoutRunnable = () -> mIsRadioReady = true; |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 88 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 89 | @Override |
| 90 | public void onCreate() { |
| 91 | super.onCreate(); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 92 | if (LOGV) { |
| 93 | Log.v(TAG, "onCreate()"); |
| 94 | } |
| 95 | NetworkMonitor.initInstance(this); |
| 96 | PhoneMonitor.initInstance(this); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 97 | SetupWizardUtils.disableComponentsForMissingFeatures(this); |
| Michael W | 29e7774 | 2021-03-17 22:47:01 +0100 | [diff] [blame] | 98 | SetupWizardUtils.setMobileDataEnabled(this, false); |
| Artem Borisov | fbf886e | 2020-12-07 13:43:19 +0000 | [diff] [blame] | 99 | sStatusBarManager = SetupWizardUtils.disableStatusBar(this); |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 100 | mHandler.postDelayed(mRadioTimeoutRunnable, SetupWizardApp.RADIO_READY_TIMEOUT); |
| 101 | } |
| 102 | |
| Artem Borisov | fbf886e | 2020-12-07 13:43:19 +0000 | [diff] [blame] | 103 | public static StatusBarManager getStatusBarManager() { |
| 104 | return sStatusBarManager; |
| 105 | } |
| 106 | |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 107 | public boolean isRadioReady() { |
| 108 | return mIsRadioReady; |
| 109 | } |
| 110 | |
| 111 | public void setRadioReady(boolean radioReady) { |
| 112 | if (!mIsRadioReady && radioReady) { |
| 113 | mHandler.removeCallbacks(mRadioTimeoutRunnable); |
| 114 | } |
| 115 | mIsRadioReady = radioReady; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 116 | } |
| 117 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 118 | public boolean ignoreSimLocale() { |
| 119 | return mIgnoreSimLocale; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 120 | } |
| 121 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 122 | public void setIgnoreSimLocale(boolean ignoreSimLocale) { |
| 123 | mIgnoreSimLocale = ignoreSimLocale; |
| 124 | } |
| 125 | |
| 126 | public Bundle getSettingsBundle() { |
| 127 | return mSettingsBundle; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 128 | } |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 129 | } |