2 * Copyright (C) 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.settings;
19 import android.app.Activity;
20 import android.app.Fragment;
21 import android.app.StatusBarManager;
22 import android.content.Context;
23 import android.content.Intent;
24 import android.os.Bundle;
25 import android.os.Handler;
26 import android.os.IBinder;
27 import android.os.ServiceManager;
28 import android.os.storage.IMountService;
29 import android.util.Log;
30 import android.view.LayoutInflater;
31 import android.view.View;
32 import android.view.ViewGroup;
33 import android.widget.Button;
35 public class CryptKeeperConfirm extends Fragment {
37 public static class Blank extends Activity {
38 private Handler mHandler = new Handler();
41 public void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
44 setContentView(R.layout.crypt_keeper_blank);
46 if (Utils.isMonkeyRunning()) {
50 StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
51 sbm.disable(StatusBarManager.DISABLE_EXPAND
52 | StatusBarManager.DISABLE_NOTIFICATION_ICONS
53 | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
54 | StatusBarManager.DISABLE_SYSTEM_INFO
55 | StatusBarManager.DISABLE_NAVIGATION
56 | StatusBarManager.DISABLE_BACK);
58 // Post a delayed message in 700 milliseconds to enable encryption.
59 // NOTE: The animation on this activity is set for 500 milliseconds
60 // I am giving it a little extra time to complete.
61 mHandler.postDelayed(new Runnable() {
63 IBinder service = ServiceManager.getService("mount");
64 if (service == null) {
65 Log.e("CryptKeeper", "Failed to find the mount service");
70 IMountService mountService = IMountService.Stub.asInterface(service);
72 Bundle args = getIntent().getExtras();
73 mountService.encryptStorage(args.getString("password"));
74 } catch (Exception e) {
75 Log.e("CryptKeeper", "Error while encrypting...", e);
82 private View mContentView;
83 private Button mFinalButton;
84 private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
86 public void onClick(View v) {
87 if (Utils.isMonkeyRunning()) {
91 Intent intent = new Intent(getActivity(), Blank.class);
92 intent.putExtras(getArguments());
94 startActivity(intent);
98 private void establishFinalConfirmationState() {
99 mFinalButton = (Button) mContentView.findViewById(R.id.execute_encrypt);
100 mFinalButton.setOnClickListener(mFinalClickListener);
104 public View onCreateView(LayoutInflater inflater, ViewGroup container,
105 Bundle savedInstanceState) {
106 mContentView = inflater.inflate(R.layout.crypt_keeper_confirm, null);
107 establishFinalConfirmationState();