| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The CyanogenMod Project |
| Michael W | 29e7774 | 2021-03-17 22:47:01 +0100 | [diff] [blame] | 3 | * Copyright (C) 2017-2021 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 | |
| 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 | |
| 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(); |
| 33 | // Leave this off for release |
| 34 | public static final boolean DEBUG = false; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 35 | /* Verbose Logging */ |
| 36 | public static final boolean LOGV = Log.isLoggable(TAG, Log.VERBOSE); |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 37 | |
| Torsten Grote | da1355a | 2019-04-02 11:32:55 -0300 | [diff] [blame] | 38 | public static final String ACTION_SETUP_COMPLETE = "org.lineageos.setupwizard.LINEAGE_SETUP_COMPLETE"; |
| Michael Bestas | c83309e | 2018-02-03 17:42:13 +0200 | [diff] [blame] | 39 | public static final String ACTION_FINISHED = "org.lineageos.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"; |
| 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"; |
| Torsten Grote | fc026fc | 2019-09-04 15:58:07 -0300 | [diff] [blame] | 43 | public static final String ACTION_RESTORE_FROM_BACKUP = "com.stevesoltys.seedvault.RESTORE_BACKUP"; |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 44 | public static final String ACTION_EMERGENCY_DIAL = "com.android.phone.EmergencyDialer.DIAL"; |
| 45 | public static final String ACTION_NEXT = "com.android.wizard.NEXT"; |
| 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"; |
| 55 | 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] | 56 | |
| cretin45 | c5e926d | 2015-06-17 13:56:09 -0700 | [diff] [blame] | 57 | public static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled"; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 58 | public static final String KEY_SEND_METRICS = "send_metrics"; |
| 59 | public static final String DISABLE_NAV_KEYS = "disable_nav_keys"; |
| Timi | e90cf31 | 2020-12-23 13:28:00 +0100 | [diff] [blame] | 60 | public static final String ENABLE_RECOVERY_UPDATE = "enable_recovery_update"; |
| 61 | public static final String UPDATE_RECOVERY_PROP = "persist.vendor.recovery_update"; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 62 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 63 | public static final int REQUEST_CODE_SETUP_WIFI = 0; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 64 | public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4; |
| dhacker29 | 218deb9 | 2015-04-23 22:54:36 -0400 | [diff] [blame] | 65 | public static final int REQUEST_CODE_SETUP_BLUETOOTH= 5; |
| Chirayu Desai | e372bc0 | 2020-05-28 00:26:19 +0530 | [diff] [blame] | 66 | public static final int REQUEST_CODE_SETUP_BIOMETRIC = 7; |
| Ricardo Cerqueira | 8331602 | 2016-08-10 12:33:05 +0100 | [diff] [blame] | 67 | public static final int REQUEST_CODE_SETUP_LOCKSCREEN = 9; |
| Torsten Grote | fc026fc | 2019-09-04 15:58:07 -0300 | [diff] [blame] | 68 | public static final int REQUEST_CODE_RESTORE = 10; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 69 | |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 70 | public static final int RADIO_READY_TIMEOUT = 10 * 1000; |
| 71 | |
| 72 | private boolean mIsRadioReady = false; |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 73 | private boolean mIgnoreSimLocale = false; |
| cretin45 | 7710855 | 2015-05-07 16:21:10 -0700 | [diff] [blame] | 74 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 75 | private final Bundle mSettingsBundle = new Bundle(); |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 76 | private final Handler mHandler = new Handler(); |
| 77 | |
| Michael W | 2236d29 | 2018-07-15 15:09:20 +0200 | [diff] [blame] | 78 | private final Runnable mRadioTimeoutRunnable = () -> mIsRadioReady = true; |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 79 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 80 | @Override |
| 81 | public void onCreate() { |
| 82 | super.onCreate(); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 83 | if (LOGV) { |
| 84 | Log.v(TAG, "onCreate()"); |
| 85 | } |
| 86 | NetworkMonitor.initInstance(this); |
| 87 | PhoneMonitor.initInstance(this); |
| cretin45 | d4cea55 | 2016-04-25 11:00:04 -0700 | [diff] [blame] | 88 | SetupWizardUtils.disableComponentsForMissingFeatures(this); |
| Michael W | 29e7774 | 2021-03-17 22:47:01 +0100 | [diff] [blame] | 89 | SetupWizardUtils.setMobileDataEnabled(this, false); |
| cretin45 | f654deb | 2015-04-14 17:28:37 -0700 | [diff] [blame] | 90 | mHandler.postDelayed(mRadioTimeoutRunnable, SetupWizardApp.RADIO_READY_TIMEOUT); |
| 91 | } |
| 92 | |
| 93 | public boolean isRadioReady() { |
| 94 | return mIsRadioReady; |
| 95 | } |
| 96 | |
| 97 | public void setRadioReady(boolean radioReady) { |
| 98 | if (!mIsRadioReady && radioReady) { |
| 99 | mHandler.removeCallbacks(mRadioTimeoutRunnable); |
| 100 | } |
| 101 | mIsRadioReady = radioReady; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 102 | } |
| 103 | |
| cretin45 | 3593f03 | 2016-04-20 16:21:05 -0700 | [diff] [blame] | 104 | public boolean ignoreSimLocale() { |
| 105 | return mIgnoreSimLocale; |
| 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 void setIgnoreSimLocale(boolean ignoreSimLocale) { |
| 109 | mIgnoreSimLocale = ignoreSimLocale; |
| 110 | } |
| 111 | |
| 112 | public Bundle getSettingsBundle() { |
| 113 | return mSettingsBundle; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 114 | } |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 115 | } |