1 /*
2  * Copyright (C) 2021 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.tv.settings.accounts;
18 
19 import static com.android.tv.settings.accounts.AccountsUtil.ACCOUNTS_BASIC_MODE_FRAGMENT;
20 import static com.android.tv.settings.accounts.AccountsUtil.ACCOUNTS_FRAGMENT_DEFAULT;
21 import static com.android.tv.settings.accounts.AccountsUtil.ACCOUNTS_FRAGMENT_RESTRICTED;
22 import static com.android.tv.settings.accounts.AccountsUtil.ACCOUNTS_SLICE_FRAGMENT;
23 import static com.android.tv.settings.accounts.AccountsUtil.ACCOUNTS_SYSTEM_INTENT;
24 
25 import android.annotation.Nullable;
26 import android.app.Activity;
27 import android.content.Intent;
28 import android.os.Bundle;
29 
30 /** Activity for launching actual account settings activities. */
31 public class AccountsTrampolineActivity extends Activity {
32 
33     private static final String ACTION_ACCOUNTS = "com.android.tv.settings.ACCOUNTS";
34 
35     @Override
onCreate(@ullable Bundle savedInstanceState)36     protected void onCreate(@Nullable Bundle savedInstanceState) {
37         super.onCreate(savedInstanceState);
38 
39         startActivity(getActivityToStart());
40         finish();
41     }
42 
getActivityToStart()43     private Intent getActivityToStart() {
44         @AccountsUtil.AccountsFragmentType int frag = AccountsUtil.getAccountsFragmentToLaunch(
45                 this);
46         switch(frag) {
47             case ACCOUNTS_SLICE_FRAGMENT:
48                 return new Intent(this, AccountSliceActivity.class);
49             case ACCOUNTS_SYSTEM_INTENT:
50                 return new Intent(ACTION_ACCOUNTS);
51             case ACCOUNTS_FRAGMENT_RESTRICTED:
52             case ACCOUNTS_FRAGMENT_DEFAULT:
53             case ACCOUNTS_BASIC_MODE_FRAGMENT:
54             default:
55                 Intent intent = new Intent(this, AccountsActivity.class);
56                 intent.putExtra(AccountsActivity.EXTRA_FRAGMENT_TYPE, frag);
57                 return intent;
58         }
59     }
60 }
61