• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 
17 package com.android.car.settings.common;
18 
19 import android.annotation.Nullable;
20 import android.content.Intent;
21 import android.net.Uri;
22 import android.os.Bundle;
23 import android.os.UserHandle;
24 import android.os.UserManager;
25 import android.provider.Settings;
26 import android.text.TextUtils;
27 
28 import androidx.fragment.app.Fragment;
29 
30 import com.android.car.settings.accounts.AccountSettingsFragment;
31 import com.android.car.settings.accounts.ChooseAccountFragment;
32 import com.android.car.settings.applications.ApplicationDetailsFragment;
33 import com.android.car.settings.applications.ApplicationsSettingsFragment;
34 import com.android.car.settings.applications.AppsAndNotificationsFragment;
35 import com.android.car.settings.applications.defaultapps.DefaultAutofillPickerFragment;
36 import com.android.car.settings.applications.specialaccess.ModifySystemSettingsFragment;
37 import com.android.car.settings.applications.specialaccess.NotificationAccessFragment;
38 import com.android.car.settings.applications.specialaccess.PremiumSmsAccessFragment;
39 import com.android.car.settings.applications.specialaccess.SpecialAccessSettingsFragment;
40 import com.android.car.settings.applications.specialaccess.UsageAccessFragment;
41 import com.android.car.settings.applications.specialaccess.WifiControlFragment;
42 import com.android.car.settings.bluetooth.BluetoothSettingsFragment;
43 import com.android.car.settings.datausage.DataUsageFragment;
44 import com.android.car.settings.datetime.DatetimeSettingsFragment;
45 import com.android.car.settings.display.DisplaySettingsFragment;
46 import com.android.car.settings.home.HomepageFragment;
47 import com.android.car.settings.inputmethod.KeyboardFragment;
48 import com.android.car.settings.language.LanguagePickerFragment;
49 import com.android.car.settings.language.LanguagesAndInputFragment;
50 import com.android.car.settings.location.LocationSettingsFragment;
51 import com.android.car.settings.network.MobileNetworkFragment;
52 import com.android.car.settings.network.MobileNetworkListFragment;
53 import com.android.car.settings.network.NetworkAndInternetFragment;
54 import com.android.car.settings.privacy.PrivacySettingsFragment;
55 import com.android.car.settings.quicksettings.QuickSettingFragment;
56 import com.android.car.settings.security.SecuritySettingsFragment;
57 import com.android.car.settings.sound.RingtonePickerFragment;
58 import com.android.car.settings.sound.SoundSettingsFragment;
59 import com.android.car.settings.storage.StorageSettingsFragment;
60 import com.android.car.settings.system.AboutSettingsFragment;
61 import com.android.car.settings.system.LegalInformationFragment;
62 import com.android.car.settings.system.ResetOptionsFragment;
63 import com.android.car.settings.system.SystemSettingsFragment;
64 import com.android.car.settings.tts.TextToSpeechOutputFragment;
65 import com.android.car.settings.units.UnitsSettingsFragment;
66 import com.android.car.settings.users.UserDetailsFragment;
67 import com.android.car.settings.users.UsersListFragment;
68 import com.android.car.settings.wifi.AddWifiFragment;
69 import com.android.car.settings.wifi.WifiSettingsFragment;
70 import com.android.car.settings.wifi.WifiTetherFragment;
71 import com.android.car.settings.wifi.preferences.WifiPreferencesFragment;
72 
73 /**
74  * Top level settings class, containing static instances of CarSettings activities.
75  */
76 public class CarSettingActivities {
77 
78     private static final Logger LOG = new Logger(CarSettingActivities.class);
79 
80     /**
81      * QuickSettings Activity.
82      */
83     public static class QuickSettingActivity extends BaseCarSettingsActivity {
84         @Nullable
85         @Override
getInitialFragment()86         protected Fragment getInitialFragment() {
87             return new QuickSettingFragment();
88         }
89     }
90 
91     /**
92      * Homepage Activity.
93      */
94     public static class HomepageActivity extends BaseCarSettingsActivity {
95         @Nullable
96         @Override
getInitialFragment()97         protected Fragment getInitialFragment() {
98             return new HomepageFragment();
99         }
100     }
101 
102     // Homepage sub-sections
103 
104     /**
105      * Display Settings Activity.
106      */
107     public static class DisplaySettingsActivity extends BaseCarSettingsActivity {
108         @Nullable
109         @Override
getInitialFragment()110         protected Fragment getInitialFragment() {
111             return new DisplaySettingsFragment();
112         }
113     }
114 
115     /**
116      * Sound Settings Activity.
117      */
118     public static class SoundSettingsActivity extends BaseCarSettingsActivity {
119         @Nullable
120         @Override
getInitialFragment()121         protected Fragment getInitialFragment() {
122             return new SoundSettingsFragment();
123         }
124     }
125 
126     /**
127      * Ringtone Picker Activity.
128      */
129     public static class RingtonePickerActivity extends BaseCarSettingsActivity {
130         @Nullable
131         @Override
getInitialFragment()132         protected Fragment getInitialFragment() {
133             Bundle args = getIntent().getExtras().deepCopy();
134             Fragment fragment = new RingtonePickerFragment();
135             fragment.setArguments(args);
136             return fragment;
137         }
138     }
139 
140     /**
141      * Network and Internet Activity.
142      */
143     public static class NetworkAndInternetActivity extends BaseCarSettingsActivity {
144         @Nullable
145         @Override
getInitialFragment()146         protected Fragment getInitialFragment() {
147             return new NetworkAndInternetFragment();
148         }
149     }
150 
151     /**
152      * Bluetooth Settings Activity.
153      */
154     public static class BluetoothSettingsActivity extends BaseCarSettingsActivity {
155         @Nullable
156         @Override
getInitialFragment()157         protected Fragment getInitialFragment() {
158             return new BluetoothSettingsFragment();
159         }
160     }
161 
162     /**
163      * Units Settings Activity.
164      */
165     public static class UnitsSettingsActivity extends BaseCarSettingsActivity {
166         @Nullable
167         @Override
getInitialFragment()168         protected Fragment getInitialFragment() {
169             return new UnitsSettingsFragment();
170         }
171     }
172 
173     /**
174      * Location Settings Activity.
175      */
176     public static class LocationSettingsActivity extends BaseCarSettingsActivity {
177         @Nullable
178         @Override
getInitialFragment()179         protected Fragment getInitialFragment() {
180             return new LocationSettingsFragment();
181         }
182     }
183 
184     /**
185      * Apps and Notifications Activity.
186      */
187     public static class AppsAndNotificationsActivity extends BaseCarSettingsActivity {
188         @Nullable
189         @Override
getInitialFragment()190         protected Fragment getInitialFragment() {
191             return new AppsAndNotificationsFragment();
192         }
193     }
194 
195     /**
196      * Datetime Settings Activity.
197      */
198     public static class DatetimeSettingsActivity extends BaseCarSettingsActivity {
199         @Nullable
200         @Override
getInitialFragment()201         protected Fragment getInitialFragment() {
202             return new DatetimeSettingsFragment();
203         }
204     }
205 
206     /**
207      * User Details Activity.
208      * The initial fragment shown is based on whether the current user is an admin.
209      */
210     public static class UserDetailsActivity extends BaseCarSettingsActivity {
211         @Nullable
212         @Override
getInitialFragment()213         protected Fragment getInitialFragment() {
214             UserManager userManager = UserManager.get(this);
215             if (userManager.isAdminUser()) {
216                 // Admins can see a full list of users in Settings.
217                 LOG.v("Creating UsersListFragment for admin user.");
218                 return new UsersListFragment();
219             } else {
220                 // Non-admins can only manage themselves in Settings.
221                 LOG.v("Creating UserDetailsFragment for non-admin.");
222                 return UserDetailsFragment.newInstance(UserHandle.myUserId());
223             }
224         }
225     }
226 
227     /**
228      * Account Settings Activity.
229      */
230     public static class AccountSettingsActivity extends BaseCarSettingsActivity {
231         @Nullable
232         @Override
getInitialFragment()233         protected Fragment getInitialFragment() {
234             return new AccountSettingsFragment();
235         }
236     }
237 
238     /**
239      * Privacy Settings Activity.
240      */
241     public static class PrivacySettingsActivity extends BaseCarSettingsActivity {
242         @Nullable
243         @Override
getInitialFragment()244         protected Fragment getInitialFragment() {
245             return new PrivacySettingsFragment();
246         }
247     }
248 
249     /**
250      * Storage Settings Activity.
251      */
252     public static class StorageSettingsActivity extends BaseCarSettingsActivity {
253         @Nullable
254         @Override
getInitialFragment()255         protected Fragment getInitialFragment() {
256             return new StorageSettingsFragment();
257         }
258     }
259 
260     /**
261      * Security Settings Activity.
262      */
263     public static class SecuritySettingsActivity extends BaseCarSettingsActivity {
264         @Nullable
265         @Override
getInitialFragment()266         protected Fragment getInitialFragment() {
267             return new SecuritySettingsFragment();
268         }
269     }
270 
271     /**
272      * System Settings Activity.
273      */
274     public static class SystemSettingsActivity extends BaseCarSettingsActivity {
275         @Nullable
276         @Override
getInitialFragment()277         protected Fragment getInitialFragment() {
278             return new SystemSettingsFragment();
279         }
280     }
281 
282     // Network & internet sub-sections
283 
284     /**
285      * Wifi Settings Activity.
286      */
287     public static class WifiSettingsActivity extends BaseCarSettingsActivity {
288         @Nullable
289         @Override
getInitialFragment()290         protected Fragment getInitialFragment() {
291             return new WifiSettingsFragment();
292         }
293     }
294 
295     /**
296      * Wifi Hotspot and Tethering Activity.
297      */
298     public static class WifiTetherActivity extends BaseCarSettingsActivity {
299         @Nullable
300         @Override
getInitialFragment()301         protected Fragment getInitialFragment() {
302             return new WifiTetherFragment();
303         }
304     }
305 
306     /**
307      * Mobile Network Activity.
308      */
309     public static class MobileNetworkActivity extends BaseCarSettingsActivity {
310         @Nullable
311         @Override
getInitialFragment()312         protected Fragment getInitialFragment() {
313             return MobileNetworkFragment.newInstance(
314                     getIntent().getIntExtra("network_sub_id", Integer.MIN_VALUE));
315         }
316     }
317 
318     /**
319      * Mobile Network List Activity.
320      */
321     public static class MobileNetworkListActivity extends BaseCarSettingsActivity {
322         @Nullable
323         @Override
getInitialFragment()324         protected Fragment getInitialFragment() {
325             return new MobileNetworkListFragment();
326         }
327     }
328 
329     /**
330      * Mobile Data Usage Activity.
331      */
332     public static class DataUsageActivity extends BaseCarSettingsActivity {
333         @Nullable
334         @Override
getInitialFragment()335         protected Fragment getInitialFragment() {
336             return new DataUsageFragment();
337         }
338     }
339 
340     // Apps & Notifications sub-sections
341 
342     /**
343      * Application Settings Activity.
344      */
345     public static class ApplicationsSettingsActivity extends BaseCarSettingsActivity {
346         @Nullable
347         @Override
getInitialFragment()348         protected Fragment getInitialFragment() {
349             return new ApplicationsSettingsFragment();
350         }
351     }
352 
353     /**
354      * Application Special Access Settings Activity.
355      */
356     public static class SpecialAccessSettingsActivity extends BaseCarSettingsActivity {
357         @Nullable
358         @Override
getInitialFragment()359         protected Fragment getInitialFragment() {
360             return new SpecialAccessSettingsFragment();
361         }
362     }
363 
364     // System sub-sections
365 
366     /**
367      * Languages and Input Activity.
368      */
369     public static class LanguagesAndInputActivity extends BaseCarSettingsActivity {
370         @Nullable
371         @Override
getInitialFragment()372         protected Fragment getInitialFragment() {
373             return new LanguagesAndInputFragment();
374         }
375     }
376 
377     /**
378      * About Settings Activity.
379      */
380     public static class AboutSettingsActivity extends BaseCarSettingsActivity {
381         @Nullable
382         @Override
getInitialFragment()383         protected Fragment getInitialFragment() {
384             return new AboutSettingsFragment();
385         }
386     }
387 
388     /**
389      * Legal Information Activity.
390      */
391     public static class LegalInformationActivity extends BaseCarSettingsActivity {
392         @Nullable
393         @Override
getInitialFragment()394         protected Fragment getInitialFragment() {
395             return new LegalInformationFragment();
396         }
397     }
398 
399     /**
400      * Reset Options Activity.
401      */
402     public static class ResetOptionsActivity extends BaseCarSettingsActivity {
403         @Nullable
404         @Override
getInitialFragment()405         protected Fragment getInitialFragment() {
406             return new ResetOptionsFragment();
407         }
408     }
409 
410     // Wi-fi sub-sections
411 
412     /**
413      * Add Wifi Network Activity.
414      */
415     public static class AddWifiActivity extends BaseCarSettingsActivity {
416         @Nullable
417         @Override
getInitialFragment()418         protected Fragment getInitialFragment() {
419             return new AddWifiFragment();
420         }
421     }
422 
423     /**
424      * Wifi Preferences Activity.
425      */
426     public static class WifiPreferencesActivity extends BaseCarSettingsActivity {
427         @Nullable
428         @Override
getInitialFragment()429         protected Fragment getInitialFragment() {
430             return new WifiPreferencesFragment();
431         }
432     }
433 
434     // App Info sub-sections
435 
436     /**
437      * Application Details Activity.
438      * Intent required to include package string as Settings.EXTRA_APP_PACKAGE extra.
439      */
440     public static class ApplicationsDetailsActivity extends BaseCarSettingsActivity {
441         @Nullable
442         @Override
getInitialFragment()443         protected Fragment getInitialFragment() {
444             Intent intent = getIntent();
445             String pkg = intent.getStringExtra(Settings.EXTRA_APP_PACKAGE);
446             if (TextUtils.isEmpty(pkg)) {
447                 LOG.w("No package provided for application detailed intent");
448                 Uri uri = intent.getData();
449                 if (uri == null) {
450                     LOG.w("No uri provided for application detailed intent");
451                     return null;
452                 }
453                 pkg = uri.getSchemeSpecificPart();
454             }
455             return ApplicationDetailsFragment.getInstance(pkg);
456         }
457     }
458 
459     // Special app access sub-section
460 
461     /**
462      * App Modify System Settings Access Activity.
463      */
464     public static class ModifySystemSettingsActivity extends BaseCarSettingsActivity {
465         @Nullable
466         @Override
getInitialFragment()467         protected Fragment getInitialFragment() {
468             return new ModifySystemSettingsFragment();
469         }
470     }
471 
472     /**
473      * App Notification Access Activity.
474      */
475     public static class NotificationAccessActivity extends BaseCarSettingsActivity {
476         @Nullable
477         @Override
getInitialFragment()478         protected Fragment getInitialFragment() {
479             return new NotificationAccessFragment();
480         }
481     }
482 
483     /**
484      * App Premium SMS Access Activity.
485      */
486     public static class PremiumSmsAccessActivity extends BaseCarSettingsActivity {
487         @Nullable
488         @Override
getInitialFragment()489         protected Fragment getInitialFragment() {
490             return new PremiumSmsAccessFragment();
491         }
492     }
493 
494     /**
495      * App Usage Access Activity.
496      */
497     public static class UsageAccessActivity extends BaseCarSettingsActivity {
498         @Nullable
499         @Override
getInitialFragment()500         protected Fragment getInitialFragment() {
501             return new UsageAccessFragment();
502         }
503     }
504 
505     /**
506      * App Wifi Control Access Activity.
507      */
508     public static class WifiControlActivity extends BaseCarSettingsActivity {
509         @Nullable
510         @Override
getInitialFragment()511         protected Fragment getInitialFragment() {
512             return new WifiControlFragment();
513         }
514     }
515 
516     // Account sub-section
517 
518     /**
519      * Choose Account Activity.
520      */
521     public static class ChooseAccountActivity extends BaseCarSettingsActivity {
522         @Nullable
523         @Override
getInitialFragment()524         protected Fragment getInitialFragment() {
525             return new ChooseAccountFragment();
526         }
527     }
528 
529     // Languages & input sub-section
530 
531     /**
532      * Language Picker Activity.
533      */
534     public static class LanguagePickerActivity extends BaseCarSettingsActivity {
535         @Nullable
536         @Override
getInitialFragment()537         protected Fragment getInitialFragment() {
538             return new LanguagePickerFragment();
539         }
540     }
541 
542     /**
543      * Default Autofill Picker Activity.
544      */
545     public static class DefaultAutofillPickerActivity extends BaseCarSettingsActivity {
546         @Nullable
547         @Override
getInitialFragment()548         protected Fragment getInitialFragment() {
549             return new DefaultAutofillPickerFragment();
550         }
551     }
552 
553     /**
554      * Keyboard Activity.
555      */
556     public static class KeyboardActivity extends BaseCarSettingsActivity {
557         @Nullable
558         @Override
getInitialFragment()559         protected Fragment getInitialFragment() {
560             return new KeyboardFragment();
561         }
562     }
563 
564     /**
565      * Text to Speech Output Activity.
566      */
567     public static class TextToSpeechOutputActivity extends BaseCarSettingsActivity {
568         @Nullable
569         @Override
getInitialFragment()570         protected Fragment getInitialFragment() {
571             return new TextToSpeechOutputFragment();
572         }
573     }
574 
575 }
576