| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 The CyanogenMod Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.cyanogenmod.setupwizard; |
| 18 | |
| 19 | |
| 20 | import android.app.Application; |
| 21 | import android.app.StatusBarManager; |
| 22 | import android.content.Context; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 23 | import android.provider.Settings; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 24 | |
| cretin45 | 0d31b31 | 2015-03-09 14:49:31 -0700 | [diff] [blame^] | 25 | import com.cyanogenmod.setupwizard.util.SetupWizardUtils; |
| 26 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 27 | public class SetupWizardApp extends Application { |
| 28 | |
| 29 | public static final String TAG = SetupWizardApp.class.getSimpleName(); |
| 30 | // Leave this off for release |
| 31 | public static final boolean DEBUG = false; |
| 32 | |
| cretin45 | 48ca24e | 2015-01-19 14:29:43 -0800 | [diff] [blame] | 33 | public static final String ACTION_FINISHED = "com.cyanogenmod.setupwizard.SETUP_FINISHED"; |
| 34 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 35 | public static final String ACCOUNT_TYPE_GMS = "com.google"; |
| 36 | |
| 37 | public static final String ACTION_SETUP_WIFI = "com.android.net.wifi.SETUP_WIFI_NETWORK"; |
| 38 | |
| 39 | public static final String EXTRA_FIRST_RUN = "firstRun"; |
| 40 | public static final String EXTRA_ALLOW_SKIP = "allowSkip"; |
| 41 | public static final String EXTRA_AUTO_FINISH = "wifi_auto_finish_on_connect"; |
| cretin45 | 8913799 | 2015-01-22 14:17:05 -0800 | [diff] [blame] | 42 | public static final String EXTRA_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar"; |
| cretin45 | 30af327 | 2015-01-23 10:14:07 -0800 | [diff] [blame] | 43 | public static final String EXTRA_USE_IMMERSIVE = "useImmersiveMode"; |
| cretin45 | 3441abd | 2015-02-02 16:44:52 -0800 | [diff] [blame] | 44 | public static final String EXTRA_THEME = "theme"; |
| 45 | public static final String EXTRA_MATERIAL_LIGHT = "material_light"; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 46 | |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 47 | private static final String KEY_DETECT_CAPTIVE_PORTAL = "captive_portal_detection_enabled"; |
| 48 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 49 | public static final int REQUEST_CODE_SETUP_WIFI = 0; |
| cretin45 | 30af327 | 2015-01-23 10:14:07 -0800 | [diff] [blame] | 50 | public static final int REQUEST_CODE_SETUP_GMS= 1; |
| cretin45 | 3441abd | 2015-02-02 16:44:52 -0800 | [diff] [blame] | 51 | public static final int REQUEST_CODE_RESTORE_GMS= 2; |
| 52 | public static final int REQUEST_CODE_SETUP_CYANOGEN= 3; |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 53 | public static final int REQUEST_CODE_SETUP_CAPTIVE_PORTAL= 4; |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 54 | |
| 55 | private StatusBarManager mStatusBarManager; |
| 56 | |
| 57 | @Override |
| 58 | public void onCreate() { |
| 59 | super.onCreate(); |
| 60 | mStatusBarManager = (StatusBarManager)getSystemService(Context.STATUS_BAR_SERVICE); |
| cretin45 | 0d31b31 | 2015-03-09 14:49:31 -0700 | [diff] [blame^] | 61 | try { |
| 62 | // Since this is a new component, we need to disable here if the user |
| 63 | // has already been through setup on a previous version. |
| 64 | if (SetupWizardUtils.isGuestUser(this) |
| 65 | || Settings.Secure.getInt(getContentResolver(), |
| 66 | Settings.Secure.USER_SETUP_COMPLETE) == 1) { |
| 67 | SetupWizardUtils.disableSetupWizard(this); |
| 68 | } else { |
| 69 | disableCaptivePortalDetection(); |
| 70 | } |
| 71 | } catch (Settings.SettingNotFoundException e) { |
| 72 | // Continue with setup |
| 73 | disableCaptivePortalDetection(); |
| 74 | } |
| 75 | |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | public void disableStatusBar() { |
| 79 | mStatusBarManager.disable(StatusBarManager.DISABLE_EXPAND | StatusBarManager.DISABLE_NOTIFICATION_ALERTS |
| 80 | | StatusBarManager.DISABLE_NOTIFICATION_TICKER | StatusBarManager.DISABLE_RECENT | StatusBarManager.DISABLE_HOME |
| 81 | | StatusBarManager.DISABLE_SEARCH); |
| 82 | } |
| 83 | |
| 84 | public void enableStatusBar() { |
| 85 | mStatusBarManager.disable(StatusBarManager.DISABLE_NONE); |
| 86 | } |
| cretin45 | e001f97 | 2015-02-19 13:01:28 -0800 | [diff] [blame] | 87 | |
| 88 | public void disableCaptivePortalDetection() { |
| 89 | Settings.Global.putInt(getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 0); |
| 90 | } |
| 91 | |
| 92 | public void enableCaptivePortalDetection() { |
| 93 | Settings.Global.putInt(getContentResolver(), KEY_DETECT_CAPTIVE_PORTAL, 1); |
| 94 | } |
| cretin45 | 0328b87 | 2015-01-15 16:04:44 -0800 | [diff] [blame] | 95 | } |