1117      * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}:
1118      * indicating that encryption is not supported.
1119      */
1120     public static final int ENCRYPTION_STATUS_UNSUPPORTED = 0;
1122     /**
1123      * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}:
1124      * indicating that encryption is supported, but is not currently active.
1125      */
1126     public static final int ENCRYPTION_STATUS_INACTIVE = 1;
1128     /**
1129      * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}:
1130      * indicating that encryption is not currently active, but is currently
1131      * being activated.  This is only reported by devices that support
1132      * encryption of data and only when the storage is currently
1133      * undergoing a process of becoming encrypted.  A device that must reboot and/or wipe data
1134      * to become encrypted will never return this value.
1135      */
1136     public static final int ENCRYPTION_STATUS_ACTIVATING = 2;
1138     /**
1139      * Result code for {@link #setStorageEncryption} and {@link #getStorageEncryptionStatus}:
1140      * indicating that encryption is active.
1141      */
1142     public static final int ENCRYPTION_STATUS_ACTIVE = 3;
2023     /**
2024      * Hook to low-levels:  Reporting the current status of encryption.
2025      * @return A value such as {@link DevicePolicyManager#ENCRYPTION_STATUS_UNSUPPORTED} or
2026      * {@link DevicePolicyManager#ENCRYPTION_STATUS_INACTIVE} or
2027      * {@link DevicePolicyManager#ENCRYPTION_STATUS_ACTIVE}.
2028      */
2029     private int getEncryptionStatus() {
2030         String status = SystemProperties.get("ro.crypto.state", "unsupported");
2031         if ("encrypted".equalsIgnoreCase(status)) {
2032             return DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE;
2033         } else if ("unencrypted".equalsIgnoreCase(status)) {
2034             return DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE;
2035         } else {
2036             return DevicePolicyManager.ENCRYPTION_STATUS_UNSUPPORTED;
2037         }
2038     }
http://osxr.org/android/source/frameworks/base/services/java/com/android/server/DevicePolicyManagerService.java#2029
2005     /**
2006      * Get the current encryption status of the device.
2007      */
2008     public int getStorageEncryptionStatus() {
2009         return getEncryptionStatus();
2010     }
http://osxr.org/android/source/packages/apps/Settings/src/com/android/settings/SecuritySettings.java#0145
0140         // Add options for device encryption
0141         DevicePolicyManager dpm =
0142                 (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
0144         if (UserId.myUserId() == 0) {
0145             switch (dpm.getStorageEncryptionStatus()) {
0146             case DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE:
0147                 // The device is currently encrypted.
0148                 addPreferencesFromResource(R.xml.security_settings_encrypted);
0149                 break;
0150             case DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE:
0151                 // This device supports encryption but isn't encrypted.
0152                 addPreferencesFromResource(R.xml.security_settings_unencrypted);
0153                 break;
0154             }
0155         }
0019 import android.app.Activity;
0020 import android.app.Fragment;
0021 import android.app.StatusBarManager;
0022 import android.content.Context;
0023 import android.content.Intent;
0024 import android.os.Bundle;
0025 import android.os.Handler;
0026 import android.os.IBinder;
0027 import android.os.ServiceManager;
0028 import android.os.storage.IMountService;
0029 import android.util.Log;
0030 import android.view.LayoutInflater;
0031 import android.view.View;
0032 import android.view.ViewGroup;
0033 import android.widget.Button;
0035 public class CryptKeeperConfirm extends Fragment {
0037     public static class Blank extends Activity {
0038         private Handler mHandler = new Handler();
0040         @Override
0041         public void onCreate(Bundle savedInstanceState) {
0042             super.onCreate(savedInstanceState);
0044             setContentView(R.layout.crypt_keeper_blank);
0046             if (Utils.isMonkeyRunning()) {
0047                 finish();
0048             }
0050             StatusBarManager sbm = (StatusBarManager) getSystemService(Context.STATUS_BAR_SERVICE);
0051             sbm.disable(StatusBarManager.DISABLE_EXPAND
0052                     | StatusBarManager.DISABLE_NOTIFICATION_ICONS
0053                     | StatusBarManager.DISABLE_NOTIFICATION_ALERTS
0054                     | StatusBarManager.DISABLE_SYSTEM_INFO
0055                     | StatusBarManager.DISABLE_HOME
0056                     | StatusBarManager.DISABLE_RECENT
0057                     | StatusBarManager.DISABLE_BACK);
0059             // Post a delayed message in 700 milliseconds to enable encryption.
0060             // NOTE: The animation on this activity is set for 500 milliseconds
0061             // I am giving it a little extra time to complete.
0062             mHandler.postDelayed(new Runnable() {
0063                 public void run() {
0064                     IBinder service = ServiceManager.getService("mount");
0065                     if (service == null) {
0066                         Log.e("CryptKeeper", "Failed to find the mount service");
0067                         finish();
0068                         return;
0069                     }
0071                     IMountService mountService = IMountService.Stub.asInterface(service);
0072                     try {
0073                         Bundle args = getIntent().getExtras();
0074                         mountService.encryptStorage(args.getString("password"));
0075                     } catch (Exception e) {
0076                         Log.e("CryptKeeper", "Error while encrypting...", e);
0077                     }
0078                 }
0079             }, 700);
0080         }
0081     }
0083     private View mContentView;
0084     private Button mFinalButton;
0085     private Button.OnClickListener mFinalClickListener = new Button.OnClickListener() {
0087         public void onClick(View v) {
0088             if (Utils.isMonkeyRunning()) {
0089                 return;
0090             }
0092             Intent intent = new Intent(getActivity(), Blank.class);
0093             intent.putExtras(getArguments());
0095             startActivity(intent);
0096         }
0097     };
0099     private void establishFinalConfirmationState() {
0100         mFinalButton = (Button) mContentView.findViewById(R.id.execute_encrypt);
0101         mFinalButton.setOnClickListener(mFinalClickListener);
0102     }
0104     @Override
0105     public View onCreateView(LayoutInflater inflater, ViewGroup container,
0106             Bundle savedInstanceState) {
0107         mContentView = inflater.inflate(R.layout.crypt_keeper_confirm, null);
0108         establishFinalConfirmationState();
0109         return mContentView;
0110     }
0111 }
public int encryptStorage(String password) throws RemoteException {
0629                 Parcel _data = Parcel.obtain();
0630                 Parcel _reply = Parcel.obtain();
0631                 int _result;
0632                 try {
0633                     _data.writeInterfaceToken(DESCRIPTOR);
0634                     _data.writeString(password);
0635                     mRemote.transact(Stub.TRANSACTION_encryptStorage, _data, _reply, 0);
0636                     _reply.readException();
0637                     _result = _reply.readInt();
0638                 } finally {
0639                     _reply.recycle();
0640                     _data.recycle();
0641                 }
0642                 return _result;
0643             }
https://blog.csdn.net/nei504293736/article/details/51913749 2016年07月14日 23:30:30三3⃣️阅读数:3739更多 个人分类:工作中遇到的问题 在android6.0 系统 设置 -- 安全 界面中有一个选项是【 手机 加密 】,如下图 在android原生 系统 中该选项显示是:已 加密 ,但在小米,华为等 手机 上该选项并是一...
功能 能够用来 加密 手机 上的全部数据,包含 Google 帐户、应用数据、音乐和其它媒体信息、已下载的信息等。假设运行了 加密 操作,您每次开机时都必须输入数字 PIN 或password。 请注意,上述 PIN 或password与您在未 加密 状态下解锁 手机 时所用的同样,无法单独 设置 。 警告: 加密 操作无法撤消...
在android6.0 系统 设置 -- 安全 界面中有一个选项是【 手机 加密 】,如下图 在android原生 系统 中该选项显示是:已 加密 ,但在小米,华为等 手机 上该选项并是一定是显示:已 加密 ,因为google把该选项的权限放给了各 手机 厂家,各 手机 厂家可以根据自己的要求是否要默认 加密 手机 ,如果 手机 加密 了(即显示 手机 加密 )用户是不办法取消的, 一客户要求 手机 出厂后 手机 默认不 加密 ,因为之前没有处理这问题,在