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

Commit 4366b565 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Storage accessors; persist nickname, flags.

Move to using new public accessors on DiskInfo and VolumeInfo.

Persist nickname changes, and remember when user has initialized a
public volume.  Also skip the migration part of storage wizard until
it's implemented.

Bug: 19993667
Change-Id: I642fb43afb95380fddd48a1dad438e87b06454da
parent 2949a4ab
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
        final StorageManager storage = getActivity().getSystemService(StorageManager.class);
        final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
        mVolume = storage.findVolumeById(volumeId);
        mDisk = storage.findDiskById(mVolume.diskId);
        mDisk = storage.findDiskById(mVolume.getDiskId());

        final View view = inflater.inflate(R.layout.storage_internal_format, container, false);
        final TextView body = (TextView) view.findViewById(R.id.body);
@@ -65,7 +65,7 @@ public class PrivateVolumeFormatConfirm extends InstrumentedFragment {
        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(getActivity(), StorageWizardFormatProgress.class);
            intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
            intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
            intent.putExtra(StorageWizardFormatProgress.EXTRA_FORMAT_PUBLIC, true);
            startActivity(intent);
            getActivity().finish();
+15 −14
Original line number Diff line number Diff line
@@ -121,13 +121,13 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
        mVolume = mStorageManager.findVolumeById(mVolumeId);

        Preconditions.checkNotNull(mVolume);
        Preconditions.checkState(mVolume.type == VolumeInfo.TYPE_PRIVATE);
        Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);

        addPreferencesFromResource(R.xml.device_info_storage_volume);

        // Find the emulated shared storage layered above this private volume
        mSharedVolume = mStorageManager.findVolumeById(
                mVolume.id.replace("private", "emulated"));
                mVolume.getId().replace("private", "emulated"));

        mMeasure = new StorageMeasurement(context, mVolume, mSharedVolume);
        mMeasure.setReceiver(mReceiver);
@@ -168,7 +168,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {

        screen.removeAll();

        if (mVolume.state != VolumeInfo.STATE_MOUNTED) {
        if (mVolume.getState() != VolumeInfo.STATE_MOUNTED) {
            return;
        }

@@ -202,7 +202,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
            }
        }

        final File file = new File(mVolume.path);
        final File file = mVolume.getPath();
        mTotalSize = file.getTotalSpace();
        mAvailSize = file.getFreeSpace();

@@ -272,15 +272,15 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {

        // Actions live in menu for non-internal private volumes; they're shown
        // as preference items for public volumes.
        if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(mVolume.id)) {
        if (VolumeInfo.ID_PRIVATE_INTERNAL.equals(mVolume.getId())) {
            rename.setVisible(false);
            mount.setVisible(false);
            unmount.setVisible(false);
            format.setVisible(false);
        } else {
            rename.setVisible(mVolume.type == VolumeInfo.TYPE_PRIVATE);
            mount.setVisible(mVolume.state == VolumeInfo.STATE_UNMOUNTED);
            unmount.setVisible(mVolume.state == VolumeInfo.STATE_MOUNTED);
            rename.setVisible(mVolume.getType() == VolumeInfo.TYPE_PRIVATE);
            mount.setVisible(mVolume.getState() == VolumeInfo.STATE_UNMOUNTED);
            unmount.setVisible(mVolume.getState() == VolumeInfo.STATE_MOUNTED);
            format.setVisible(true);
        }

@@ -300,12 +300,12 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
                new MountTask(context, mVolume).execute();
                return true;
            case R.id.storage_unmount:
                args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.id);
                args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
                startFragment(this, PrivateVolumeUnmountConfirm.class.getCanonicalName(),
                        R.string.storage_menu_unmount, 0, args);
                return true;
            case R.id.storage_format:
                args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.id);
                args.putString(VolumeInfo.EXTRA_VOLUME_ID, mVolume.getId());
                startFragment(this, PrivateVolumeFormatConfirm.class.getCanonicalName(),
                        R.string.storage_menu_format, 0, args);
                return true;
@@ -428,7 +428,7 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
    private final StorageEventListener mStorageListener = new StorageEventListener() {
        @Override
        public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
            if (Objects.equals(mVolume.id, vol.id)) {
            if (Objects.equals(mVolume.getId(), vol.getId())) {
                mVolume = vol;
                refresh();
            }
@@ -462,8 +462,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
            final View view = dialogInflater.inflate(R.layout.dialog_edittext, null, false);
            final EditText nickname = (EditText) view.findViewById(R.id.edittext);

            if (!TextUtils.isEmpty(vol.nickname)) {
                nickname.setText(vol.nickname);
            if (!TextUtils.isEmpty(vol.getNickname())) {
                nickname.setText(vol.getNickname());
            } else {
                nickname.setText(storageManager.getBestVolumeDescription(vol));
            }
@@ -475,7 +475,8 @@ public class PrivateVolumeSettings extends SettingsPreferenceFragment {
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO: persist the edited nickname!
                            // TODO: move to background thread
                            storageManager.setVolumeNickname(volId, nickname.getText().toString());
                        }
                    });
            builder.setNegativeButton(R.string.cancel, null);
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class PrivateVolumeUnmountConfirm extends InstrumentedFragment {
        final StorageManager storage = getActivity().getSystemService(StorageManager.class);
        final String volumeId = getArguments().getString(VolumeInfo.EXTRA_VOLUME_ID);
        mVolume = storage.findVolumeById(volumeId);
        mDisk = storage.findDiskById(mVolume.id);
        mDisk = storage.findDiskById(mVolume.getId());

        final View view = inflater.inflate(R.layout.storage_internal_unmount, container, false);
        final TextView body = (TextView) view.findViewById(R.id.body);
+10 −10
Original line number Diff line number Diff line
@@ -91,12 +91,12 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
        }

        Preconditions.checkNotNull(mVolume);
        Preconditions.checkState(mVolume.type == VolumeInfo.TYPE_PUBLIC);
        Preconditions.checkState(mVolume.getType() == VolumeInfo.TYPE_PUBLIC);

        mDisk = mStorageManager.findDiskById(mVolume.diskId);
        mDisk = mStorageManager.findDiskById(mVolume.getDiskId());
        Preconditions.checkNotNull(mDisk);

        mVolumeId = mVolume.id;
        mVolumeId = mVolume.getId();

        addPreferencesFromResource(R.xml.device_info_storage_volume);

@@ -118,24 +118,24 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {

        screen.removeAll();

        if (mVolume.state == VolumeInfo.STATE_MOUNTED) {
        if (mVolume.getState() == VolumeInfo.STATE_MOUNTED) {
            screen.addPreference(mGraph);
            screen.addPreference(mTotal);
            screen.addPreference(mAvailable);
        }

        if (mVolume.state == VolumeInfo.STATE_UNMOUNTED) {
        if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
            screen.addPreference(mMount);
        }
        if (mVolume.state == VolumeInfo.STATE_MOUNTED) {
        if (mVolume.getState() == VolumeInfo.STATE_MOUNTED) {
            screen.addPreference(mUnmount);
        }
        screen.addPreference(mFormat);
        if ((mDisk.flags & DiskInfo.FLAG_ADOPTABLE) != 0) {
        if (mDisk.isAdoptable()) {
            screen.addPreference(mFormatInternal);
        }

        final File file = new File(mVolume.path);
        final File file = mVolume.getPath();
        mTotalSize = file.getTotalSpace();
        mAvailSize = file.getFreeSpace();

@@ -200,7 +200,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
            new FormatTask(context, mVolume).execute();
        } else if (pref == mFormatInternal) {
            final Intent intent = new Intent(context, StorageWizardFormatConfirm.class);
            intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.id);
            intent.putExtra(DiskInfo.EXTRA_DISK_ID, mDisk.getId());
            startActivity(intent);
        }

@@ -210,7 +210,7 @@ public class PublicVolumeSettings extends SettingsPreferenceFragment {
    private final StorageEventListener mStorageListener = new StorageEventListener() {
        @Override
        public void onVolumeStateChanged(VolumeInfo vol, int oldState, int newState) {
            if (Objects.equals(mVolume.id, vol.id)) {
            if (Objects.equals(mVolume.getId(), vol.getId())) {
                mVolume = vol;
                refresh();
            }
+4 −4
Original line number Diff line number Diff line
@@ -345,7 +345,7 @@ public class StorageMeasurement {
        final Message finished = mMeasurementHandler.obtainMessage(MeasurementHandler.MSG_COMPLETED,
                details);

        if (mSharedVolume != null && mSharedVolume.state == VolumeInfo.STATE_MOUNTED) {
        if (mSharedVolume != null && mSharedVolume.getState() == VolumeInfo.STATE_MOUNTED) {
            final File basePath = mSharedVolume.getPathForUser(currentUser);

            // Measure media types for emulated storage, or for primary physical
@@ -359,7 +359,7 @@ public class StorageMeasurement {
            // Measure misc files not counted under media
            details.miscSize = measureMisc(imcs, basePath);

            if (mSharedVolume.type == VolumeInfo.TYPE_EMULATED) {
            if (mSharedVolume.getType() == VolumeInfo.TYPE_EMULATED) {
                // Measure total emulated storage of all users; internal apps data
                // will be spliced in later
                for (UserInfo user : users) {
@@ -371,14 +371,14 @@ public class StorageMeasurement {
        }

        // Measure all apps hosted on this volume for all users
        if (mVolume.type == VolumeInfo.TYPE_PRIVATE) {
        if (mVolume.getType() == VolumeInfo.TYPE_PRIVATE) {
            final List<ApplicationInfo> apps = packageManager.getInstalledApplications(
                    PackageManager.GET_UNINSTALLED_PACKAGES
                    | PackageManager.GET_DISABLED_COMPONENTS);

            final List<ApplicationInfo> volumeApps = new ArrayList<>();
            for (ApplicationInfo app : apps) {
                if (Objects.equals(app.volumeUuid, mVolume.fsUuid)) {
                if (Objects.equals(app.volumeUuid, mVolume.getFsUuid())) {
                    volumeApps.add(app);
                }
            }
Loading