@@ -454,7 +454,7 @@ private void waitForReady() {
454454 }
455455 }
456456
457- private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver () {
457+ private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver () {
458458 @ Override
459459 public void onReceive (Context context , Intent intent ) {
460460 String action = intent .getAction ();
@@ -484,7 +484,7 @@ public void run() {
484484 synchronized (mVolumeStates ) {
485485 Set <String > keys = mVolumeStates .keySet ();
486486 count = keys .size ();
487- paths = ( String []) keys .toArray (new String [count ]);
487+ paths = keys .toArray (new String [count ]);
488488 states = new String [count ];
489489 for (int i = 0 ; i < count ; i ++) {
490490 states [i ] = mVolumeStates .get (paths [i ]);
@@ -1761,6 +1761,37 @@ public void unmountObb(String filename, boolean force, IObbActionListener token,
17611761 Slog .i (TAG , "Send to OBB handler: " + action .toString ());
17621762 }
17631763
1764+ @ Override
1765+ public int getEncryptionState () {
1766+ mContext .enforceCallingOrSelfPermission (Manifest .permission .CRYPT_KEEPER ,
1767+ "no permission to access the crypt keeper" );
1768+
1769+ waitForReady ();
1770+
1771+ try {
1772+ ArrayList <String > rsp = mConnector .doCommand ("cryptfs cryptocomplete" );
1773+ String [] tokens = rsp .get (0 ).split (" " );
1774+
1775+ if (tokens == null || tokens .length != 2 ) {
1776+ // Unexpected.
1777+ Slog .w (TAG , "Unexpected result from cryptfs cryptocomplete" );
1778+ return ENCRYPTION_STATE_ERROR_UNKNOWN ;
1779+ }
1780+
1781+ return Integer .parseInt (tokens [1 ]);
1782+
1783+ } catch (NumberFormatException e ) {
1784+ // Bad result - unexpected.
1785+ Slog .w (TAG , "Unable to parse result from cryptfs cryptocomplete" );
1786+ return ENCRYPTION_STATE_ERROR_UNKNOWN ;
1787+ } catch (NativeDaemonConnectorException e ) {
1788+ // Something bad happened.
1789+ Slog .w (TAG , "Error in communicating with cryptfs in validating" );
1790+ return ENCRYPTION_STATE_ERROR_UNKNOWN ;
1791+ }
1792+ }
1793+
1794+ @ Override
17641795 public int decryptStorage (String password ) {
17651796 if (TextUtils .isEmpty (password )) {
17661797 throw new IllegalArgumentException ("password cannot be empty" );
@@ -2090,7 +2121,7 @@ abstract class ObbAction {
20902121 public void execute (ObbActionHandler handler ) {
20912122 try {
20922123 if (DEBUG_OBB )
2093- Slog .i (TAG , "Starting to execute action: " + this . toString ());
2124+ Slog .i (TAG , "Starting to execute action: " + toString ());
20942125 mRetries ++;
20952126 if (mRetries > MAX_RETRIES ) {
20962127 Slog .w (TAG , "Failed to invoke remote methods on default container service. Giving up" );
@@ -2147,7 +2178,7 @@ protected void sendNewStatusOrIgnore(int status) {
21472178 }
21482179
21492180 class MountObbAction extends ObbAction {
2150- private String mKey ;
2181+ private final String mKey ;
21512182
21522183 MountObbAction (ObbState obbState , String key ) {
21532184 super (obbState );
@@ -2258,7 +2289,7 @@ public String toString() {
22582289 }
22592290
22602291 class UnmountObbAction extends ObbAction {
2261- private boolean mForceUnmount ;
2292+ private final boolean mForceUnmount ;
22622293
22632294 UnmountObbAction (ObbState obbState , boolean force ) {
22642295 super (obbState );
0 commit comments