Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d08fa02 authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "Pass the path to format to ExternalStorageFormatter." into gingerbread

parents 1dfd071e 1f752292
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

/**
 * This activity is shown to the user to confirm formatting of external media.
@@ -95,7 +96,13 @@ public class ExternalMediaFormatActivity extends AlertActivity implements Dialog
        if (which == POSITIVE_BUTTON) {
            Intent intent = new Intent(ExternalStorageFormatter.FORMAT_ONLY);
            intent.setComponent(ExternalStorageFormatter.COMPONENT_NAME);
            if (getIntent().hasExtra("path")) {
                String path = getIntent().getStringExtra("path");
                intent.putExtra("path", path);
                startService(intent);
            } else {
                Toast.makeText(this, "Invalid path: null", Toast.LENGTH_LONG).show();
            }
        }

        // No matter what, finish the activity
+16 −4
Original line number Diff line number Diff line
@@ -75,11 +75,13 @@ public class ExternalStorageFormatter extends Service

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        // We try to get the path from the intent
        // If it isn't set, we default to Environment.getExternalStorageDirectory()
        // We get the path from the intent and if it isn't set
        // we do not default to Environment.getExternalStoragePath()
        // because this can be the wrong sdcard in the case where
        // the device has more than one sdcard (as is becoming more
        // and more common). We will handle the null later when we
        // try to actually use the extStoragePath.
        extStoragePath = intent.getStringExtra("path");
        if (extStoragePath == null)
            extStoragePath = Environment.getExternalStorageDirectory().toString();
        if (FORMAT_AND_FACTORY_RESET.equals(intent.getAction())) {
            mFactoryReset = true;
        }
@@ -123,6 +125,11 @@ public class ExternalStorageFormatter extends Service
    public void onCancel(DialogInterface dialog) {
        IMountService mountService = getMountService();
        try {
            if (extStoragePath == null) {
                Toast.makeText(this, "Invalid path: null", Toast.LENGTH_LONG).show();
                stopSelf();
                return;
            }
            mountService.mountVolume(extStoragePath);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed talking with mount service", e);
@@ -141,6 +148,11 @@ public class ExternalStorageFormatter extends Service
    void updateProgressState() {
        String status = Environment.MEDIA_CHECKING;
        try {
            if (extStoragePath == null) {
                Toast.makeText(this, "Invalid path: null", Toast.LENGTH_LONG).show();
                stopSelf();
                return;
            }
            status = getMountService().getVolumeState(extStoragePath);
        } catch (RemoteException e) {
            Log.w(TAG, "Failed talking with mount service", e);
+2 −0
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ public class StorageNotification extends StorageEventListener {
             */
            Intent intent = new Intent();
            intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class);
            intent.putExtra("path", path);
            PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);

            setMediaStorageNotification(
@@ -217,6 +218,7 @@ public class StorageNotification extends StorageEventListener {
             */
            Intent intent = new Intent();
            intent.setClass(mContext, com.android.internal.app.ExternalMediaFormatActivity.class);
            intent.putExtra("path", path);
            PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);

            setMediaStorageNotification(