Home | History | Annotate | Download | only in applications
      1 /*
      2  * Copyright (C) 2016 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 package com.android.settings.applications;
     17 
     18 import android.app.Fragment;
     19 import android.content.Intent;
     20 import android.os.Bundle;
     21 import android.view.LayoutInflater;
     22 import android.view.View;
     23 import android.view.ViewGroup;
     24 import android.widget.Button;
     25 
     26 import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
     27 import com.android.settings.R;
     28 import com.android.settings.SettingsPreferenceFragment;
     29 
     30 public class ConfirmConvertToFbe extends SettingsPreferenceFragment {
     31     static final String TAG = "ConfirmConvertToFBE";
     32 
     33     @Override
     34     public View onCreateView(LayoutInflater inflater, ViewGroup container,
     35                 Bundle savedInstanceState) {
     36         View rootView = inflater.inflate(R.layout.confirm_convert_fbe, null);
     37 
     38         final Button button = (Button) rootView.findViewById(R.id.button_confirm_convert_fbe);
     39         button.setOnClickListener(new View.OnClickListener() {
     40             public void onClick(View v) {
     41                 Intent intent = new Intent(Intent.ACTION_FACTORY_RESET);
     42                 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
     43                 intent.setPackage("android");
     44                 intent.putExtra(Intent.EXTRA_REASON, "convert_fbe");
     45                 getActivity().sendBroadcast(intent);
     46             }
     47         });
     48 
     49         return rootView;
     50     }
     51 
     52     @Override
     53     public int getMetricsCategory() {
     54         return MetricsEvent.CONVERT_FBE_CONFIRM;
     55     }
     56 }
     57