blob: 4ac4be4b2094d42babe10ab4a559aacd069c9976 [file] [log] [blame]
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -08001/*
2 * Copyright (C) 2014 The Android Open Source 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
17package com.android.settings;
18
Fan Zhang60f01072016-10-13 16:53:41 -070019import android.app.ActionBar;
Matthew Fritze7ac78f22016-10-03 13:26:07 -070020import android.app.ActivityManager;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080021import android.content.BroadcastReceiver;
Fabrice Di Megliod25314d2014-03-21 19:24:43 -070022import android.content.ComponentName;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080023import android.content.Context;
24import android.content.Intent;
25import android.content.IntentFilter;
26import android.content.SharedPreferences;
27import android.content.pm.ActivityInfo;
28import android.content.pm.PackageManager;
29import android.content.pm.PackageManager.NameNotFoundException;
pastychangfefc6682019-03-21 19:42:39 +080030import android.content.res.Resources.Theme;
Jason Monkfd2c7222015-12-02 15:38:38 -050031import android.os.AsyncTask;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080032import android.os.Bundle;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080033import android.os.UserHandle;
34import android.os.UserManager;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080035import android.text.TextUtils;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080036import android.util.Log;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080037import android.view.View;
Fabrice Di Meglio59a40552014-05-23 16:46:50 -070038import android.view.ViewGroup;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080039import android.widget.Button;
Fan Zhang4c26da92017-09-08 15:29:54 -070040
Fan Zhang60243e62018-08-03 09:13:53 -070041import androidx.annotation.Nullable;
42import androidx.annotation.VisibleForTesting;
43import androidx.fragment.app.Fragment;
44import androidx.fragment.app.FragmentManager;
45import androidx.fragment.app.FragmentTransaction;
46import androidx.localbroadcastmanager.content.LocalBroadcastManager;
47import androidx.preference.Preference;
48import androidx.preference.PreferenceFragmentCompat;
49import androidx.preference.PreferenceManager;
50
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080051import com.android.internal.util.ArrayUtils;
Jason Monk4da79e02015-09-10 10:54:36 -040052import com.android.settings.Settings.WifiSettingsActivity;
Fan Zhanga8cac7a2017-10-11 16:44:41 -070053import com.android.settings.applications.manageapplications.ManageApplications;
Chandan Nath4d626f62019-03-12 10:52:53 +000054import com.android.settings.backup.BackupSettingsHelper;
55import com.android.settings.backup.UserBackupSettingsActivity;
Fan Zhangaf32e722018-07-17 10:12:30 -070056import com.android.settings.core.OnActivityResultListener;
tmfangd97fba52018-06-14 14:48:35 +080057import com.android.settings.core.SettingsBaseActivity;
Fan Zhang615563d2018-02-15 15:19:33 -080058import com.android.settings.core.SubSettingLauncher;
Fan Zhanga3e8f5c2016-12-01 09:52:10 -080059import com.android.settings.core.gateway.SettingsGateway;
Fan Zhanga96a2d82016-09-27 17:51:11 -070060import com.android.settings.dashboard.DashboardFeatureProvider;
Fan Zhang21526c12018-09-06 15:44:26 -070061import com.android.settings.homepage.TopLevelSettings;
Fan Zhanga96a2d82016-09-27 17:51:11 -070062import com.android.settings.overlay.FeatureFactory;
Fan Zhang4fcd5ed2017-03-10 12:25:35 -080063import com.android.settings.wfd.WifiDisplaySettings;
Fabrice Di Meglio41937762014-05-13 19:51:59 -070064import com.android.settings.widget.SwitchBar;
Fan Zhang7cf99f52018-02-16 10:37:37 -080065import com.android.settingslib.core.instrumentation.Instrumentable;
Leif Hendrik Wilden28dee1f2018-01-11 10:15:36 -080066import com.android.settingslib.core.instrumentation.SharedPreferencesLogger;
Tony Mantler3d84d562017-07-31 10:48:55 -070067import com.android.settingslib.development.DevelopmentSettingsEnabler;
Jason Monk4da79e02015-09-10 10:54:36 -040068import com.android.settingslib.drawer.DashboardCategory;
Fan Zhang4c26da92017-09-08 15:29:54 -070069
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080070import java.util.ArrayList;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080071import java.util.List;
72
tmfangd97fba52018-06-14 14:48:35 +080073
74public class SettingsActivity extends SettingsBaseActivity
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080075 implements PreferenceManager.OnPreferenceTreeClickListener,
tmfang27c84de2018-06-28 11:39:05 +080076 PreferenceFragmentCompat.OnPreferenceStartFragmentCallback,
Fan Zhangff4da232017-11-09 14:07:23 -080077 ButtonBarHandler, FragmentManager.OnBackStackChangedListener {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080078
Fan Zhang22230502018-03-27 14:14:13 -070079 private static final String LOG_TAG = "SettingsActivity";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080080
81 // Constants for state save/restore
Fabrice Di Meglio769630c2014-04-24 14:48:48 -070082 private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -080083
84 /**
85 * When starting this activity, the invoking Intent can contain this extra
86 * string to specify which fragment should be initially displayed.
87 * <p/>Starting from Key Lime Pie, when this argument is passed in, the activity
88 * will call isValidFragment() to confirm that the fragment class name is valid for this
89 * activity.
90 */
91 public static final String EXTRA_SHOW_FRAGMENT = ":settings:show_fragment";
92
93 /**
94 * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
95 * this extra can also be specified to supply a Bundle of arguments to pass
96 * to that fragment when it is instantiated during the initial creation
97 * of the activity.
98 */
99 public static final String EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args";
100
101 /**
Fabrice Di Meglioc1457322014-04-04 19:07:50 -0700102 * Fragment "key" argument passed thru {@link #EXTRA_SHOW_FRAGMENT_ARGUMENTS}
103 */
104 public static final String EXTRA_FRAGMENT_ARG_KEY = ":settings:fragment_args_key";
105
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800106 // extras that allow any preference activity to be launched as part of a wizard
107
108 // show Back and Next buttons? takes boolean parameter
109 // Back will then return RESULT_CANCELED and Next RESULT_OK
110 protected static final String EXTRA_PREFS_SHOW_BUTTON_BAR = "extra_prefs_show_button_bar";
111
112 // add a Skip button?
113 private static final String EXTRA_PREFS_SHOW_SKIP = "extra_prefs_show_skip";
114
115 // specify custom text for the Back or Next buttons, or cause a button to not appear
116 // at all by setting it to null
117 protected static final String EXTRA_PREFS_SET_NEXT_TEXT = "extra_prefs_set_next_text";
118 protected static final String EXTRA_PREFS_SET_BACK_TEXT = "extra_prefs_set_back_text";
119
120 /**
121 * When starting this activity and using {@link #EXTRA_SHOW_FRAGMENT},
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700122 * those extra can also be specify to supply the title or title res id to be shown for
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800123 * that fragment.
124 */
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700125 public static final String EXTRA_SHOW_FRAGMENT_TITLE = ":settings:show_fragment_title";
Alexandra Gherghina62464b82014-08-11 12:40:13 +0100126 /**
127 * The package name used to resolve the title resource id.
128 */
129 public static final String EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME =
130 ":settings:show_fragment_title_res_package_name";
Fabrice Di Meglio61a1fec2014-08-13 16:22:38 -0700131 public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID =
132 ":settings:show_fragment_title_resid";
Fabrice Di Meglio61a1fec2014-08-13 16:22:38 -0700133
134 public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING =
135 ":settings:show_fragment_as_subsetting";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800136
Jason Monk30695812015-11-17 09:01:08 -0500137 public static final String META_DATA_KEY_FRAGMENT_CLASS =
Fan Zhangf11c8852018-02-06 14:21:01 -0800138 "com.android.settings.FRAGMENT_CLASS";
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800139
140 private static final String EXTRA_UI_OPTIONS = "settings:ui_options";
141
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800142 private String mFragmentClass;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800143
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800144 private CharSequence mInitialTitle;
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700145 private int mInitialTitleResId;
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800146
Tony Mantler3d84d562017-07-31 10:48:55 -0700147 private BroadcastReceiver mDevelopmentSettingsListener;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800148
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800149 private boolean mBatteryPresent = true;
150 private BroadcastReceiver mBatteryInfoReceiver = new BroadcastReceiver() {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800151 @Override
152 public void onReceive(Context context, Intent intent) {
153 String action = intent.getAction();
154 if (Intent.ACTION_BATTERY_CHANGED.equals(action)) {
155 boolean batteryPresent = Utils.isBatteryPresent(intent);
156
157 if (mBatteryPresent != batteryPresent) {
158 mBatteryPresent = batteryPresent;
Jason Monk4da79e02015-09-10 10:54:36 -0400159 updateTilesList();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800160 }
161 }
162 }
163 };
164
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700165 private SwitchBar mSwitchBar;
166
167 private Button mNextButton;
Fabrice Di Meglio3d35ec72014-06-06 12:13:29 -0700168
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700169 private ViewGroup mContent;
170
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700171 // Categories
Fan Zhanga3e8f5c2016-12-01 09:52:10 -0800172 private ArrayList<DashboardCategory> mCategories = new ArrayList<>();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800173
Fan Zhanga96a2d82016-09-27 17:51:11 -0700174 private DashboardFeatureProvider mDashboardFeatureProvider;
Jim Miller0698a212014-10-16 19:49:07 -0700175
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700176 public SwitchBar getSwitchBar() {
177 return mSwitchBar;
178 }
179
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800180 @Override
tmfang27c84de2018-06-28 11:39:05 +0800181 public boolean onPreferenceStartFragment(PreferenceFragmentCompat caller, Preference pref) {
Fan Zhang7cf99f52018-02-16 10:37:37 -0800182 new SubSettingLauncher(this)
183 .setDestination(pref.getFragment())
184 .setArguments(pref.getExtras())
185 .setSourceMetricsCategory(caller instanceof Instrumentable
186 ? ((Instrumentable) caller).getMetricsCategory()
187 : Instrumentable.METRICS_CATEGORY_UNKNOWN)
hjchangliaoe86eec02018-05-02 13:01:07 +0800188 .setTitleRes(-1)
Fan Zhang7cf99f52018-02-16 10:37:37 -0800189 .launch();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800190 return true;
191 }
192
193 @Override
Jason Monk39b46742015-09-10 15:52:51 -0400194 public boolean onPreferenceTreeClick(Preference preference) {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800195 return false;
196 }
197
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800198 @Override
Jason Monk31c7c322016-01-20 14:41:52 -0500199 public SharedPreferences getSharedPreferences(String name, int mode) {
200 if (name.equals(getPackageName() + "_preferences")) {
Leif Hendrik Wilden28dee1f2018-01-11 10:15:36 -0800201 return new SharedPreferencesLogger(this, getMetricsTag(),
202 FeatureFactory.getFactory(this).getMetricsFeatureProvider());
Jason Monk31c7c322016-01-20 14:41:52 -0500203 }
204 return super.getSharedPreferences(name, mode);
205 }
206
Jason Monke4ebcd12016-02-21 09:37:41 -0500207 private String getMetricsTag() {
208 String tag = getClass().getName();
209 if (getIntent() != null && getIntent().hasExtra(EXTRA_SHOW_FRAGMENT)) {
210 tag = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
211 }
212 if (tag.startsWith("com.android.settings.")) {
213 tag = tag.replace("com.android.settings.", "");
214 }
215 return tag;
216 }
217
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700218 @Override
219 protected void onCreate(Bundle savedState) {
Fabrice Di Meglio0d643fd2014-06-16 20:11:27 -0700220 super.onCreate(savedState);
Fan Zhang22230502018-03-27 14:14:13 -0700221 Log.d(LOG_TAG, "Starting onCreate");
Jason Monkfd2c7222015-12-02 15:38:38 -0500222 long startTime = System.currentTimeMillis();
Matthew Fritze0ed37c32016-10-24 10:12:49 -0700223
224 final FeatureFactory factory = FeatureFactory.getFactory(this);
225
226 mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
Matthew Fritze0ed37c32016-10-24 10:12:49 -0700227
Fabrice Di Meglio0d643fd2014-06-16 20:11:27 -0700228 // Should happen before any call to getIntent()
229 getMetaData();
230
231 final Intent intent = getIntent();
232 if (intent.hasExtra(EXTRA_UI_OPTIONS)) {
233 getWindow().setUiOptions(intent.getIntExtra(EXTRA_UI_OPTIONS, 0));
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800234 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800235
Fabrice Di Meglioda8baba2014-06-10 17:12:51 -0700236 // Getting Intent properties can only be done after the super.onCreate(...)
Fabrice Di Meglio0d643fd2014-06-16 20:11:27 -0700237 final String initialFragmentName = intent.getStringExtra(EXTRA_SHOW_FRAGMENT);
Fabrice Di Meglioda8baba2014-06-10 17:12:51 -0700238
Fabrice Di Meglio61a1fec2014-08-13 16:22:38 -0700239 // This is a "Sub Settings" when:
240 // - this is a real SubSettings
241 // - or :settings:show_fragment_as_subsetting is passed to the Intent
Jorim Jaggi4dfcb822015-04-29 17:21:32 -0700242 final boolean isSubSettings = this instanceof SubSettings ||
Fabrice Di Meglio61a1fec2014-08-13 16:22:38 -0700243 intent.getBooleanExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, false);
244
Fan Zhang92f1e942017-01-21 10:07:26 -0800245 // If this is a sub settings, then apply the SubSettings Theme for the ActionBar content
246 // insets
Fabrice Di Meglio61a1fec2014-08-13 16:22:38 -0700247 if (isSubSettings) {
Fan Zhang92f1e942017-01-21 10:07:26 -0800248 setTheme(R.style.Theme_SubSettings);
Fabrice Di Meglioda8baba2014-06-10 17:12:51 -0700249 }
250
Fan Zhang4df9bfa2019-02-22 13:53:09 -0800251 setContentView(R.layout.settings_main_prefs);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800252
Andrew Sappersteina2dd9972017-06-25 13:51:08 -0700253 mContent = findViewById(R.id.main_content);
Fabrice Di Meglio59a40552014-05-23 16:46:50 -0700254
tmfang27c84de2018-06-28 11:39:05 +0800255 getSupportFragmentManager().addOnBackStackChangedListener(this);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800256
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700257 if (savedState != null) {
Fabrice Di Meglio1800a9f2014-04-03 19:31:07 -0700258 // We are restarting from a previous saved state; used that to initialize, instead
259 // of starting fresh.
Fabrice Di Meglio0d643fd2014-06-16 20:11:27 -0700260 setTitleFromIntent(intent);
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800261
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700262 ArrayList<DashboardCategory> categories =
263 savedState.getParcelableArrayList(SAVE_KEY_CATEGORIES);
264 if (categories != null) {
Fabrice Di Meglio5f995722014-05-19 19:51:31 -0700265 mCategories.clear();
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700266 mCategories.addAll(categories);
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700267 setTitleFromBackStack();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800268 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800269 } else {
Fan Zhang8e14ca02018-11-27 13:06:44 -0800270 launchSettingFragment(initialFragmentName, intent);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800271 }
272
Doris Ling882bef32018-07-31 14:04:44 -0700273 final boolean deviceProvisioned = Utils.isDeviceProvisioned(this);
Andrew Sapperstein048f6fb2017-05-28 12:20:10 -0700274
Fan Zhang4df9bfa2019-02-22 13:53:09 -0800275 final ActionBar actionBar = getActionBar();
Andrew Sappersteina2dd9972017-06-25 13:51:08 -0700276 if (actionBar != null) {
Tony Make226b382018-03-02 18:23:35 +0000277 actionBar.setDisplayHomeAsUpEnabled(deviceProvisioned);
278 actionBar.setHomeButtonEnabled(deviceProvisioned);
Fan Zhang4df9bfa2019-02-22 13:53:09 -0800279 actionBar.setDisplayShowTitleEnabled(true);
Fabrice Di Megliod8aec082014-05-20 10:49:50 -0700280 }
Andrew Sappersteina2dd9972017-06-25 13:51:08 -0700281 mSwitchBar = findViewById(R.id.switch_bar);
Jason Monke4ebcd12016-02-21 09:37:41 -0500282 if (mSwitchBar != null) {
283 mSwitchBar.setMetricsTag(getMetricsTag());
284 }
Fabrice Di Meglio41937762014-05-13 19:51:59 -0700285
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800286 // see if we should show Back/Next buttons
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800287 if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_BUTTON_BAR, false)) {
288
Fabrice Di Megliod2b64f32014-05-20 12:55:15 -0700289 View buttonBar = findViewById(R.id.button_bar);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800290 if (buttonBar != null) {
291 buttonBar.setVisibility(View.VISIBLE);
292
Fan Zhange994d462018-12-04 12:43:14 -0800293 Button backButton = findViewById(R.id.back_button);
294 backButton.setOnClickListener(v -> {
295 setResult(RESULT_CANCELED, null);
296 finish();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800297 });
Fan Zhange994d462018-12-04 12:43:14 -0800298 Button skipButton = findViewById(R.id.skip_button);
299 skipButton.setOnClickListener(v -> {
300 setResult(RESULT_OK, null);
301 finish();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800302 });
Fan Zhange994d462018-12-04 12:43:14 -0800303 mNextButton = findViewById(R.id.next_button);
304 mNextButton.setOnClickListener(v -> {
305 setResult(RESULT_OK, null);
306 finish();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800307 });
308
309 // set our various button parameters
310 if (intent.hasExtra(EXTRA_PREFS_SET_NEXT_TEXT)) {
311 String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_NEXT_TEXT);
312 if (TextUtils.isEmpty(buttonText)) {
313 mNextButton.setVisibility(View.GONE);
Fan Zhangf11c8852018-02-06 14:21:01 -0800314 } else {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800315 mNextButton.setText(buttonText);
316 }
317 }
318 if (intent.hasExtra(EXTRA_PREFS_SET_BACK_TEXT)) {
319 String buttonText = intent.getStringExtra(EXTRA_PREFS_SET_BACK_TEXT);
320 if (TextUtils.isEmpty(buttonText)) {
321 backButton.setVisibility(View.GONE);
Fan Zhangf11c8852018-02-06 14:21:01 -0800322 } else {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800323 backButton.setText(buttonText);
324 }
325 }
326 if (intent.getBooleanExtra(EXTRA_PREFS_SHOW_SKIP, false)) {
327 skipButton.setVisibility(View.VISIBLE);
328 }
329 }
330 }
Fabrice Di Meglioceb335f2014-07-23 16:25:30 -0700331
Fan Zhangefba6b42017-02-07 17:40:59 -0800332 if (DEBUG_TIMING) {
333 Log.d(LOG_TAG, "onCreate took " + (System.currentTimeMillis() - startTime) + " ms");
334 }
Fabrice Di Meglioceb335f2014-07-23 16:25:30 -0700335 }
336
Fan Zhangaf32e722018-07-17 10:12:30 -0700337 @Override
pastychangfefc6682019-03-21 19:42:39 +0800338 protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
339 theme.applyStyle(R.style.SetupWizardPartnerResource, true);
340 super.onApplyThemeResource(theme, resid, first);
341 }
342
343 @Override
Fan Zhangaf32e722018-07-17 10:12:30 -0700344 protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
345 super.onActivityResult(requestCode, resultCode, data);
346 final List<Fragment> fragments = getSupportFragmentManager().getFragments();
347 if (fragments != null) {
348 for (Fragment fragment : fragments) {
349 if (fragment instanceof OnActivityResultListener) {
350 fragment.onActivityResult(requestCode, resultCode, data);
351 }
352 }
353 }
354 }
355
Doris Lingcb69baf2017-02-23 17:50:03 -0800356 @VisibleForTesting
Fan Zhang8e14ca02018-11-27 13:06:44 -0800357 void launchSettingFragment(String initialFragmentName, Intent intent) {
358 if (initialFragmentName != null) {
Doris Lingcb69baf2017-02-23 17:50:03 -0800359 setTitleFromIntent(intent);
360
361 Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
Fan Zhang39d9d7c2019-01-23 16:38:24 -0800362 switchToFragment(initialFragmentName, initialArguments, true,
363 mInitialTitleResId, mInitialTitle);
Doris Lingcb69baf2017-02-23 17:50:03 -0800364 } else {
Andrew Sapperstein048f6fb2017-05-28 12:20:10 -0700365 // Show search icon as up affordance if we are displaying the main Dashboard
Doris Lingcb69baf2017-02-23 17:50:03 -0800366 mInitialTitleResId = R.string.dashboard_title;
Fan Zhang39d9d7c2019-01-23 16:38:24 -0800367 switchToFragment(TopLevelSettings.class.getName(), null /* args */, false,
368 mInitialTitleResId, mInitialTitle);
Doris Lingcb69baf2017-02-23 17:50:03 -0800369 }
370 }
371
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700372 private void setTitleFromIntent(Intent intent) {
Fan Zhang22230502018-03-27 14:14:13 -0700373 Log.d(LOG_TAG, "Starting to set activity title");
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700374 final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
375 if (initialTitleResId > 0) {
376 mInitialTitle = null;
377 mInitialTitleResId = initialTitleResId;
Alexandra Gherghina62464b82014-08-11 12:40:13 +0100378
379 final String initialTitleResPackageName = intent.getStringExtra(
380 EXTRA_SHOW_FRAGMENT_TITLE_RES_PACKAGE_NAME);
381 if (initialTitleResPackageName != null) {
382 try {
383 Context authContext = createPackageContextAsUser(initialTitleResPackageName,
384 0 /* flags */, new UserHandle(UserHandle.myUserId()));
385 mInitialTitle = authContext.getResources().getText(mInitialTitleResId);
386 setTitle(mInitialTitle);
387 mInitialTitleResId = -1;
388 return;
389 } catch (NameNotFoundException e) {
390 Log.w(LOG_TAG, "Could not find package" + initialTitleResPackageName);
391 }
392 } else {
393 setTitle(mInitialTitleResId);
394 }
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700395 } else {
396 mInitialTitleResId = -1;
397 final String initialTitle = intent.getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE);
398 mInitialTitle = (initialTitle != null) ? initialTitle : getTitle();
399 setTitle(mInitialTitle);
400 }
Fan Zhang22230502018-03-27 14:14:13 -0700401 Log.d(LOG_TAG, "Done setting title");
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700402 }
403
Fabrice Di Meglioc95be4f2014-03-07 12:57:38 -0800404 @Override
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800405 public void onBackStackChanged() {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700406 setTitleFromBackStack();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800407 }
408
Fan Zhang28691572016-03-23 15:31:08 -0700409 private void setTitleFromBackStack() {
tmfang27c84de2018-06-28 11:39:05 +0800410 final int count = getSupportFragmentManager().getBackStackEntryCount();
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700411
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800412 if (count == 0) {
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700413 if (mInitialTitleResId > 0) {
414 setTitle(mInitialTitleResId);
415 } else {
416 setTitle(mInitialTitle);
417 }
Fan Zhang28691572016-03-23 15:31:08 -0700418 return;
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800419 }
Fabrice Di Megliob643cbf2014-03-10 12:18:39 -0700420
tmfang27c84de2018-06-28 11:39:05 +0800421 FragmentManager.BackStackEntry bse = getSupportFragmentManager().
422 getBackStackEntryAt(count - 1);
Fabrice Di Meglio8eb3f0f2014-02-27 15:51:46 -0800423 setTitleFromBackStackEntry(bse);
424 }
425
426 private void setTitleFromBackStackEntry(FragmentManager.BackStackEntry bse) {
427 final CharSequence title;
428 final int titleRes = bse.getBreadCrumbTitleRes();
429 if (titleRes > 0) {
430 title = getText(titleRes);
431 } else {
432 title = bse.getBreadCrumbTitle();
433 }
434 if (title != null) {
435 setTitle(title);
436 }
Fabrice Di Meglio5529d292014-02-11 19:52:28 -0800437 }
438
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800439 @Override
440 protected void onSaveInstanceState(Bundle outState) {
441 super.onSaveInstanceState(outState);
Matthew Fritze7d48ae82017-03-23 08:59:15 -0700442 saveState(outState);
443 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800444
Matthew Fritze7d48ae82017-03-23 08:59:15 -0700445 /**
446 * For testing purposes to avoid crashes from final variables in Activity's onSaveInstantState.
447 */
448 @VisibleForTesting
449 void saveState(Bundle outState) {
Fabrice Di Meglio769630c2014-04-24 14:48:48 -0700450 if (mCategories.size() > 0) {
451 outState.putParcelableArrayList(SAVE_KEY_CATEGORIES, mCategories);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800452 }
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800453 }
454
455 @Override
Jason Monk39b46742015-09-10 15:52:51 -0400456 protected void onResume() {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800457 super.onResume();
458
Tony Mantler3d84d562017-07-31 10:48:55 -0700459 mDevelopmentSettingsListener = new BroadcastReceiver() {
460 @Override
461 public void onReceive(Context context, Intent intent) {
462 updateTilesList();
463 }
464 };
465 LocalBroadcastManager.getInstance(this).registerReceiver(mDevelopmentSettingsListener,
466 new IntentFilter(DevelopmentSettingsEnabler.DEVELOPMENT_SETTINGS_CHANGED_ACTION));
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800467
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800468 registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
Fabrice Di Meglioa3270762014-04-16 16:54:56 -0700469
Jason Monk4da79e02015-09-10 10:54:36 -0400470 updateTilesList();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800471 }
472
473 @Override
Jason Monk39b46742015-09-10 15:52:51 -0400474 protected void onPause() {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800475 super.onPause();
Tony Mantler3d84d562017-07-31 10:48:55 -0700476 LocalBroadcastManager.getInstance(this).unregisterReceiver(mDevelopmentSettingsListener);
477 mDevelopmentSettingsListener = null;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800478 unregisterReceiver(mBatteryInfoReceiver);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800479 }
480
481 @Override
jackqdyulei6c355f52017-03-01 17:37:23 -0800482 public void setTaskDescription(ActivityManager.TaskDescription taskDescription) {
Sunny Goyal3c846752018-07-03 11:39:00 -0700483 taskDescription.setIcon(R.drawable.ic_launcher_settings);
jackqdyulei6c355f52017-03-01 17:37:23 -0800484 super.setTaskDescription(taskDescription);
485 }
486
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800487 protected boolean isValidFragment(String fragmentName) {
488 // Almost all fragments are wrapped in this,
489 // except for a few that have their own activities.
Fan Zhanga3e8f5c2016-12-01 09:52:10 -0800490 for (int i = 0; i < SettingsGateway.ENTRY_FRAGMENTS.length; i++) {
491 if (SettingsGateway.ENTRY_FRAGMENTS[i].equals(fragmentName)) return true;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800492 }
493 return false;
494 }
495
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800496 @Override
497 public Intent getIntent() {
498 Intent superIntent = super.getIntent();
499 String startingFragment = getStartingFragmentClass(superIntent);
500 // This is called from super.onCreate, isMultiPane() is not yet reliable
501 // Do not use onIsHidingHeaders either, which relies itself on this method
502 if (startingFragment != null) {
503 Intent modIntent = new Intent(superIntent);
504 modIntent.putExtra(EXTRA_SHOW_FRAGMENT, startingFragment);
Fan Zhange8666c62018-03-02 11:01:15 -0800505 Bundle args = superIntent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800506 if (args != null) {
507 args = new Bundle(args);
508 } else {
509 args = new Bundle();
510 }
511 args.putParcelable("intent", superIntent);
Kenny Guyac1e20e2014-06-24 14:34:14 +0100512 modIntent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800513 return modIntent;
514 }
515 return superIntent;
516 }
517
518 /**
519 * Checks if the component name in the intent is different from the Settings class and
520 * returns the class name to load as a fragment.
521 */
522 private String getStartingFragmentClass(Intent intent) {
523 if (mFragmentClass != null) return mFragmentClass;
524
525 String intentClass = intent.getComponent().getClassName();
526 if (intentClass.equals(getClass().getName())) return null;
527
Fan Zhanga8cac7a2017-10-11 16:44:41 -0700528 if ("com.android.settings.RunningServices".equals(intentClass)
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800529 || "com.android.settings.applications.StorageUse".equals(intentClass)) {
530 // Old names of manage apps.
Fan Zhanga8cac7a2017-10-11 16:44:41 -0700531 intentClass = ManageApplications.class.getName();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800532 }
533
534 return intentClass;
535 }
536
537 /**
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800538 * Called by a preference panel fragment to finish itself.
539 *
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800540 * @param resultCode Optional result code to send back to the original
Fan Zhangf11c8852018-02-06 14:21:01 -0800541 * launching fragment.
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800542 * @param resultData Optional result data to send back to the original
Fan Zhangf11c8852018-02-06 14:21:01 -0800543 * launching fragment.
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800544 */
Fan Zhang47854c22018-02-19 13:54:09 -0800545 public void finishPreferencePanel(int resultCode, Intent resultData) {
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800546 setResult(resultCode, resultData);
Fabrice Di Meglio58146c22014-06-26 16:20:26 -0700547 finish();
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800548 }
549
550 /**
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700551 * Switch to a specific Fragment with taking care of validation, Title and BackStack
552 */
553 private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate,
Fan Zhang39d9d7c2019-01-23 16:38:24 -0800554 int titleResId, CharSequence title) {
Fan Zhang22230502018-03-27 14:14:13 -0700555 Log.d(LOG_TAG, "Switching to fragment " + fragmentName);
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700556 if (validate && !isValidFragment(fragmentName)) {
557 throw new IllegalArgumentException("Invalid fragment for this activity: "
558 + fragmentName);
559 }
560 Fragment f = Fragment.instantiate(this, fragmentName, args);
tmfang27c84de2018-06-28 11:39:05 +0800561 FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Anna Galusza6b1e9db2016-03-30 17:25:36 -0700562 transaction.replace(R.id.main_content, f);
Fabrice Di Meglioa9e77992014-06-09 12:52:24 -0700563 if (titleResId > 0) {
564 transaction.setBreadCrumbTitle(titleResId);
565 } else if (title != null) {
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700566 transaction.setBreadCrumbTitle(title);
567 }
568 transaction.commitAllowingStateLoss();
tmfang27c84de2018-06-28 11:39:05 +0800569 getSupportFragmentManager().executePendingTransactions();
Fan Zhang22230502018-03-27 14:14:13 -0700570 Log.d(LOG_TAG, "Executed frag manager pendingTransactions");
Fabrice Di Megliod25314d2014-03-21 19:24:43 -0700571 return f;
572 }
573
Jason Monk4da79e02015-09-10 10:54:36 -0400574 private void updateTilesList() {
Jason Monkfd2c7222015-12-02 15:38:38 -0500575 // Generally the items that are will be changing from these updates will
576 // not be in the top list of tiles, so run it in the background and the
tmfangd97fba52018-06-14 14:48:35 +0800577 // SettingsBaseActivity will pick up on the updates automatically.
Jason Monkfd2c7222015-12-02 15:38:38 -0500578 AsyncTask.execute(new Runnable() {
579 @Override
580 public void run() {
581 doUpdateTilesList();
582 }
583 });
584 }
585
586 private void doUpdateTilesList() {
Jason Monk4da79e02015-09-10 10:54:36 -0400587 PackageManager pm = getPackageManager();
Xiaohui Chen44879a32015-07-22 13:53:22 -0700588 final UserManager um = UserManager.get(this);
589 final boolean isAdmin = um.isAdminUser();
Fan Zhangaeb94f02017-07-05 13:46:04 -0700590 boolean somethingChanged = false;
Fan Zhang22230502018-03-27 14:14:13 -0700591 final String packageName = getPackageName();
592 final StringBuilder changedList = new StringBuilder();
593 somethingChanged = setTileEnabled(changedList,
Fan Zhangaeb94f02017-07-05 13:46:04 -0700594 new ComponentName(packageName, WifiSettingsActivity.class.getName()),
595 pm.hasSystemFeature(PackageManager.FEATURE_WIFI), isAdmin) || somethingChanged;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700596
Fan Zhang22230502018-03-27 14:14:13 -0700597 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Fan Zhanga6986e72017-03-08 09:24:45 -0800598 Settings.BluetoothSettingsActivity.class.getName()),
Fan Zhangaeb94f02017-07-05 13:46:04 -0700599 pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin)
600 || somethingChanged;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700601
Rajeev Kumar4a5e3dc2017-07-18 19:21:34 -0700602 // Enable DataUsageSummaryActivity if the data plan feature flag is turned on otherwise
603 // enable DataPlanUsageSummaryActivity.
Fan Zhang22230502018-03-27 14:14:13 -0700604 somethingChanged = setTileEnabled(changedList,
Fan Zhang3ed55b12018-02-07 13:50:09 -0800605 new ComponentName(packageName, Settings.DataUsageSummaryActivity.class.getName()),
Rajeev Kumar4a5e3dc2017-07-18 19:21:34 -0700606 Utils.isBandwidthControlEnabled() /* enabled */,
607 isAdmin) || somethingChanged;
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700608
Fan Zhang22230502018-03-27 14:14:13 -0700609 somethingChanged = setTileEnabled(changedList,
jackqdyulei76ba0f72017-11-17 14:14:51 -0800610 new ComponentName(packageName,
611 Settings.ConnectedDeviceDashboardActivity.class.getName()),
Jerry Zhang40bd5702018-02-23 14:43:58 -0800612 !UserManager.isDeviceInDemoMode(this) /* enabled */,
jackqdyulei76ba0f72017-11-17 14:14:51 -0800613 isAdmin) || somethingChanged;
614
Fan Zhang22230502018-03-27 14:14:13 -0700615 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Fan Zhanga6986e72017-03-08 09:24:45 -0800616 Settings.PowerUsageSummaryActivity.class.getName()),
Lei Yu68ffee12018-03-26 14:31:57 -0700617 mBatteryPresent, isAdmin) || somethingChanged;
Jason Monk4da79e02015-09-10 10:54:36 -0400618
Fan Zhang22230502018-03-27 14:14:13 -0700619 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Eric Schwarzenbach98998a22018-02-06 15:57:01 -0800620 Settings.DataUsageSummaryActivity.class.getName()),
Fan Zhangcd21cb82018-06-11 09:28:02 -0700621 Utils.isBandwidthControlEnabled(), isAdmin)
Eric Schwarzenbach98998a22018-02-06 15:57:01 -0800622 || somethingChanged;
623
Fan Zhang22230502018-03-27 14:14:13 -0700624 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Fan Zhanga6986e72017-03-08 09:24:45 -0800625 Settings.UserSettingsActivity.class.getName()),
Jason Monk4da79e02015-09-10 10:54:36 -0400626 UserHandle.MU_ENABLED && UserManager.supportsMultipleUsers()
Fan Zhangaeb94f02017-07-05 13:46:04 -0700627 && !Utils.isMonkeyRunning(), isAdmin)
628 || somethingChanged;
Jason Monk4da79e02015-09-10 10:54:36 -0400629
Tony Mantler3d84d562017-07-31 10:48:55 -0700630 final boolean showDev = DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(this)
Fan Zhang831f6302017-11-22 13:07:50 -0800631 && !Utils.isMonkeyRunning();
Fan Zhang22230502018-03-27 14:14:13 -0700632 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Fan Zhang4c26da92017-09-08 15:29:54 -0700633 Settings.DevelopmentSettingsDashboardActivity.class.getName()),
Christine Franks986d02f2018-04-23 11:19:57 -0700634 showDev, isAdmin)
Fan Zhangaeb94f02017-07-05 13:46:04 -0700635 || somethingChanged;
Dan Sandler12c4ba42016-03-28 11:13:40 -0400636
Chandan Nath4d626f62019-03-12 10:52:53 +0000637 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Chandan Nathf94033d2019-04-24 18:58:50 +0100638 UserBackupSettingsActivity.class.getName()), true, isAdmin)
Chandan Nath4d626f62019-03-12 10:52:53 +0000639 || somethingChanged;
640
Fan Zhang22230502018-03-27 14:14:13 -0700641 somethingChanged = setTileEnabled(changedList, new ComponentName(packageName,
Fan Zhang4fcd5ed2017-03-10 12:25:35 -0800642 Settings.WifiDisplaySettingsActivity.class.getName()),
Fan Zhangaeb94f02017-07-05 13:46:04 -0700643 WifiDisplaySettings.isAvailable(this), isAdmin)
644 || somethingChanged;
Fan Zhang4fcd5ed2017-03-10 12:25:35 -0800645
Jason Monk4da79e02015-09-10 10:54:36 -0400646 if (UserHandle.MU_ENABLED && !isAdmin) {
Fan Zhanga6986e72017-03-08 09:24:45 -0800647
Jason Monk4da79e02015-09-10 10:54:36 -0400648 // When on restricted users, disable all extra categories (but only the settings ones).
Fan Zhang78ab9f92017-02-27 16:10:05 -0800649 final List<DashboardCategory> categories = mDashboardFeatureProvider.getAllCategories();
Fan Zhanga6986e72017-03-08 09:24:45 -0800650 synchronized (categories) {
651 for (DashboardCategory category : categories) {
Fan Zhang7c8f8a02017-03-17 12:54:24 -0700652 final int tileCount = category.getTilesCount();
653 for (int i = 0; i < tileCount; i++) {
Fan Zhang3506b742018-08-07 13:52:52 -0700654 final ComponentName component = category.getTile(i)
655 .getIntent().getComponent();
Fan Zhanga6986e72017-03-08 09:24:45 -0800656 final String name = component.getClassName();
657 final boolean isEnabledForRestricted = ArrayUtils.contains(
Christine Franks986d02f2018-04-23 11:19:57 -0700658 SettingsGateway.SETTINGS_FOR_RESTRICTED, name);
Fan Zhanga6986e72017-03-08 09:24:45 -0800659 if (packageName.equals(component.getPackageName())
660 && !isEnabledForRestricted) {
Fan Zhang22230502018-03-27 14:14:13 -0700661 somethingChanged =
662 setTileEnabled(changedList, component, false, isAdmin)
663 || somethingChanged;
Fan Zhanga6986e72017-03-08 09:24:45 -0800664 }
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700665 }
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700666 }
Fabrice Di Meglio63bbb8e2014-04-23 16:44:30 -0700667 }
668 }
Doris Ling26bf0032016-06-15 18:16:09 -0700669
Fan Zhang224caad2017-01-06 11:42:48 -0800670 // Final step, refresh categories.
Fan Zhangaeb94f02017-07-05 13:46:04 -0700671 if (somethingChanged) {
Fan Zhang22230502018-03-27 14:14:13 -0700672 Log.d(LOG_TAG, "Enabled state changed for some tiles, reloading all categories "
673 + changedList.toString());
Fan Zhangaeb94f02017-07-05 13:46:04 -0700674 updateCategories();
675 } else {
676 Log.d(LOG_TAG, "No enabled state changed, skipping updateCategory call");
677 }
Jason Monk2ebc8a02015-02-13 15:23:19 -0500678 }
679
Fan Zhangaeb94f02017-07-05 13:46:04 -0700680 /**
681 * @return whether or not the enabled state actually changed.
682 */
Fan Zhang22230502018-03-27 14:14:13 -0700683 private boolean setTileEnabled(StringBuilder changedList, ComponentName component,
684 boolean enabled, boolean isAdmin) {
Jason Monk5862c1e2016-06-07 14:02:33 -0400685 if (UserHandle.MU_ENABLED && !isAdmin && getPackageName().equals(component.getPackageName())
Fan Zhang9ec45362017-01-10 11:55:45 -0800686 && !ArrayUtils.contains(SettingsGateway.SETTINGS_FOR_RESTRICTED,
687 component.getClassName())) {
Jason Monk4da79e02015-09-10 10:54:36 -0400688 enabled = false;
689 }
Fan Zhang22230502018-03-27 14:14:13 -0700690 boolean changed = setTileEnabled(component, enabled);
691 if (changed) {
692 changedList.append(component.toShortString()).append(",");
693 }
694 return changed;
Jason Monk2ebc8a02015-02-13 15:23:19 -0500695 }
696
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800697 private void getMetaData() {
698 try {
699 ActivityInfo ai = getPackageManager().getActivityInfo(getComponentName(),
700 PackageManager.GET_META_DATA);
701 if (ai == null || ai.metaData == null) return;
Fabrice Di Meglio263bcc82014-01-17 19:17:58 -0800702 mFragmentClass = ai.metaData.getString(META_DATA_KEY_FRAGMENT_CLASS);
703 } catch (NameNotFoundException nnfe) {
704 // No recovery
705 Log.d(LOG_TAG, "Cannot get Metadata for: " + getComponentName().toString());
706 }
707 }
708
709 // give subclasses access to the Next button
710 public boolean hasNextButton() {
711 return mNextButton != null;
712 }
713
714 public Button getNextButton() {
715 return mNextButton;
716 }
Andrew Sapperstein048f6fb2017-05-28 12:20:10 -0700717}