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