Home | History | Annotate | Download | only in configui
      1 /*
      2  * Copyright (C) 2017 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.voicemail.impl.configui;
     18 
     19 import android.content.Intent;
     20 import android.preference.PreferenceActivity;
     21 import android.provider.VoicemailContract;
     22 import java.util.List;
     23 
     24 /** Activity launched by simulator->voicemail, provides debug features. */
     25 @SuppressWarnings("FragmentInjection") // not exported
     26 public class VoicemailSecretCodeActivity extends PreferenceActivity {
     27 
     28   private Header syncHeader;
     29 
     30   @Override
     31   public void onBuildHeaders(List<Header> target) {
     32     super.onBuildHeaders(target);
     33     syncHeader = new Header();
     34     syncHeader.title = "Sync";
     35     target.add(syncHeader);
     36 
     37     Header configOverride = new Header();
     38     configOverride.fragment = ConfigOverrideFragment.class.getName();
     39     configOverride.title = "VVM config override";
     40     target.add(configOverride);
     41   }
     42 
     43   @Override
     44   public void onHeaderClick(Header header, int position) {
     45     if (header == syncHeader) {
     46       Intent intent = new Intent(VoicemailContract.ACTION_SYNC_VOICEMAIL);
     47       intent.setPackage(getPackageName());
     48       sendBroadcast(intent);
     49       return;
     50     }
     51     super.onHeaderClick(header, position);
     52   }
     53 
     54   @Override
     55   protected boolean isValidFragment(String fragmentName) {
     56     return true;
     57   }
     58 }
     59