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

Commit 361aba38 authored by Toha's avatar Toha Committed by Steve Kondik
Browse files

Use actual storage type of sdcard/usb (1/2).

Change-Id: Icaf0d246ab3bdd0614c8bb7a22f8b2b95cbe9c7e
TODO: Provide drawable for usb storage (someone please).
parent 452cc3aa
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -300,6 +300,34 @@
    <string name="usb_media_removed">USB storage has been removed.</string>
    <string name="usb_media_shared">USB storage is currently in use by a computer.</string>

    <!-- SD card storage notification -->
    <string name="sd_ext_media_checking_notification_title">Preparing SD card</string>
    <string name="sd_ext_media_checking_notification_message">Checking SD card for errors.</string>
    <string name="sd_ext_media_nofs_notification_title">Blank SD card</string>
    <string name="sd_ext_media_nofs_notification_message">SD card is blank or has unsupported filesystem.</string>
    <string name="sd_ext_media_unmountable_notification_title">Damaged SD card</string>
    <string name="sd_ext_media_unmountable_notification_message">SD card is damaged. Try reformatting it.</string>
    <string name="sd_ext_media_badremoval_notification_title">SD card unexpectedly removed</string>
    <string name="sd_ext_media_badremoval_notification_message">Unmount SD card before removing to avoid data loss.</string>
    <string name="sd_ext_media_safe_unmount_notification_title">SD card safe to remove</string>
    <string name="sd_ext_media_safe_unmount_notification_message">You can safely remove SD card.</string>
    <string name="sd_ext_media_nomedia_notification_title">Removed SD card</string>
    <string name="sd_ext_media_nomedia_notification_message">SD card removed. Insert a new one.</string>

    <!-- USB storage notification -->
    <string name="usb_ext_media_checking_notification_title">Preparing USB storage</string>
    <string name="usb_ext_media_checking_notification_message">Checking USB storage for errors.</string>
    <string name="usb_ext_media_nofs_notification_title">Blank USB storage</string>
    <string name="usb_ext_media_nofs_notification_message">USB storage is blank or has unsupported filesystem.</string>
    <string name="usb_ext_media_unmountable_notification_title">Damaged USB storage</string>
    <string name="usb_ext_media_unmountable_notification_message">USB storage is damaged. Try reformatting it.</string>
    <string name="usb_ext_media_badremoval_notification_title">USB storage unexpectedly removed</string>
    <string name="usb_ext_media_badremoval_notification_message">Unmount USB storage before removing to avoid data loss.</string>
    <string name="usb_ext_media_safe_unmount_notification_title">USB storage safe to remove</string>
    <string name="usb_ext_media_safe_unmount_notification_message">You can safely remove USB storage.</string>
    <string name="usb_ext_media_nomedia_notification_title">Removed USB storage</string>
    <string name="usb_ext_media_nomedia_notification_message">USB storage removed. Insert new media.</string>

    <!-- LiveDisplay strings -->
    <string name="live_display_title" translatable="false">LiveDisplay</string>
    <string name="live_display_auto">Automatic</string>
+28 −0
Original line number Diff line number Diff line
@@ -278,6 +278,34 @@
    <java-symbol type="string" name="usb_media_removed" />
    <java-symbol type="string" name="usb_media_shared" />

    <!-- SD card storage notification -->
    <java-symbol type="string" name="sd_ext_media_badremoval_notification_message" />
    <java-symbol type="string" name="sd_ext_media_badremoval_notification_title" />
    <java-symbol type="string" name="sd_ext_media_checking_notification_message" />
    <java-symbol type="string" name="sd_ext_media_checking_notification_title" />
    <java-symbol type="string" name="sd_ext_media_nofs_notification_message" />
    <java-symbol type="string" name="sd_ext_media_nofs_notification_title" />
    <java-symbol type="string" name="sd_ext_media_nomedia_notification_message" />
    <java-symbol type="string" name="sd_ext_media_nomedia_notification_title" />
    <java-symbol type="string" name="sd_ext_media_safe_unmount_notification_message" />
    <java-symbol type="string" name="sd_ext_media_safe_unmount_notification_title" />
    <java-symbol type="string" name="sd_ext_media_unmountable_notification_message" />
    <java-symbol type="string" name="sd_ext_media_unmountable_notification_title" />

    <!-- USB storage notification -->
    <java-symbol type="string" name="usb_ext_media_badremoval_notification_message" />
    <java-symbol type="string" name="usb_ext_media_badremoval_notification_title" />
    <java-symbol type="string" name="usb_ext_media_checking_notification_message" />
    <java-symbol type="string" name="usb_ext_media_checking_notification_title" />
    <java-symbol type="string" name="usb_ext_media_nofs_notification_message" />
    <java-symbol type="string" name="usb_ext_media_nofs_notification_title" />
    <java-symbol type="string" name="usb_ext_media_nomedia_notification_message" />
    <java-symbol type="string" name="usb_ext_media_nomedia_notification_title" />
    <java-symbol type="string" name="usb_ext_media_safe_unmount_notification_message" />
    <java-symbol type="string" name="usb_ext_media_safe_unmount_notification_title" />
    <java-symbol type="string" name="usb_ext_media_unmountable_notification_message" />
    <java-symbol type="string" name="usb_ext_media_unmountable_notification_title" />

    <!-- LiveDisplay -->
    <java-symbol type="string" name="live_display_title" />
    <java-symbol type="string" name="live_display_hint" />
+52 −27
Original line number Diff line number Diff line
@@ -28,10 +28,12 @@ import android.os.HandlerThread;
import android.os.UserHandle;
import android.os.storage.StorageEventListener;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.os.SystemProperties;
import android.provider.Settings;
import android.util.Log;

import com.android.internal.R;
import com.android.systemui.SystemUI;

public class StorageNotification extends SystemUI {
@@ -123,9 +125,19 @@ public class StorageNotification extends SystemUI {

    private void onStorageStateChangedAsync(String path, String oldState, String newState) {
        boolean isPrimary = mStorageManager.getPrimaryVolume().getPath().equals(path);
        boolean isUsbStorage = false;
        final StorageVolume[] storageVolumes = mStorageManager.getVolumeList();
        for (StorageVolume volume : storageVolumes) {
            if (volume.getPath().equals(path)) {
                if (volume.getDescriptionId() == R.string.storage_usb) {
                    isUsbStorage = true;
                }
                break;
            }
        }
        if (DEBUG) Log.i(TAG, String.format(
                "Media {%s} state changed from {%s} -> {%s} (primary = %b)", path, oldState,
                newState, isPrimary));
                "Media {%s} state changed from {%s} -> {%s} (primary = %b, usb storage = %b)",
                path, oldState, newState, isPrimary, isUsbStorage));
        if (newState.equals(Environment.MEDIA_SHARED)) {
            /*
             * Storage is now shared. Modify the UMS notification
@@ -134,19 +146,20 @@ public class StorageNotification extends SystemUI {
            Intent intent = new Intent();
            intent.setClass(mContext, com.android.systemui.usb.UsbStorageActivity.class);
            PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
            setUsbStorageNotification(
                    com.android.internal.R.string.usb_storage_stop_notification_title,
                    com.android.internal.R.string.usb_storage_stop_notification_message,
                    com.android.internal.R.drawable.stat_sys_warning, false, true, pi);
            setUsbStorageNotification(R.string.usb_storage_stop_notification_title,
                    R.string.usb_storage_stop_notification_message,
                    R.drawable.stat_sys_warning, false, true, pi);
        } else if (newState.equals(Environment.MEDIA_CHECKING)) {
            /*
             * Storage is now checking. Update media notification and disable
             * UMS notification.
             */
            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_checking_notification_title,
                    com.android.internal.R.string.ext_media_checking_notification_message,
                    com.android.internal.R.drawable.stat_notify_sdcard_prepare, true, false, null);
                    isUsbStorage ? R.string.usb_ext_media_checking_notification_title :
                            R.string.sd_ext_media_checking_notification_title,
                    isUsbStorage ? R.string.usb_ext_media_checking_notification_message :
                            R.string.sd_ext_media_checking_notification_message,
                    R.drawable.stat_notify_sdcard_prepare, true, false, null);
            updateUsbMassStorageNotification(false);
        } else if (newState.equals(Environment.MEDIA_MOUNTED)) {
            /*
@@ -176,9 +189,13 @@ public class StorageNotification extends SystemUI {
                     */
                    if (Environment.isExternalStorageRemovable()) {
                        setMediaStorageNotification(
                                com.android.internal.R.string.ext_media_safe_unmount_notification_title,
                                com.android.internal.R.string.ext_media_safe_unmount_notification_message,
                                com.android.internal.R.drawable.stat_notify_sdcard, true, true, null);
                                isUsbStorage ?
                                        R.string.usb_ext_media_safe_unmount_notification_title :
                                        R.string.sd_ext_media_safe_unmount_notification_title,
                                isUsbStorage ?
                                        R.string.usb_ext_media_safe_unmount_notification_message :
                                        R.string.sd_ext_media_safe_unmount_notification_message,
                                R.drawable.stat_notify_sdcard, true, true, null);
                    } else {
                        // This device does not have removable storage, so
                        // don't tell the user they can remove it.
@@ -206,9 +223,11 @@ public class StorageNotification extends SystemUI {
            PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);

            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_nofs_notification_title,
                    com.android.internal.R.string.ext_media_nofs_notification_message,
                    com.android.internal.R.drawable.stat_notify_sdcard_usb, true, false, pi);
                    isUsbStorage ? R.string.usb_ext_media_nofs_notification_title :
                            R.string.sd_ext_media_nofs_notification_title,
                    isUsbStorage ? R.string.usb_ext_media_nofs_notification_message :
                            R.string.sd_ext_media_nofs_notification_message,
                    R.drawable.stat_notify_sdcard_usb, true, false, pi);
            updateUsbMassStorageNotification(mUmsAvailable);
        } else if (newState.equals(Environment.MEDIA_UNMOUNTABLE)) {
            /*
@@ -222,9 +241,11 @@ public class StorageNotification extends SystemUI {
            PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);

            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_unmountable_notification_title,
                    com.android.internal.R.string.ext_media_unmountable_notification_message,
                    com.android.internal.R.drawable.stat_notify_sdcard_usb, true, false, pi);
                    isUsbStorage ? R.string.usb_ext_media_unmountable_notification_title :
                            R.string.sd_ext_media_unmountable_notification_title,
                    isUsbStorage ? R.string.usb_ext_media_unmountable_notification_message :
                            R.string.sd_ext_media_unmountable_notification_message,
                    R.drawable.stat_notify_sdcard_usb, true, false, pi);
            updateUsbMassStorageNotification(mUmsAvailable);
        } else if (newState.equals(Environment.MEDIA_REMOVED)) {
            /*
@@ -232,9 +253,11 @@ public class StorageNotification extends SystemUI {
             * and disable UMS notification if the removed storage is the primary storage.
             */
            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_nomedia_notification_title,
                    com.android.internal.R.string.ext_media_nomedia_notification_message,
                    com.android.internal.R.drawable.stat_notify_sdcard_usb,
                    isUsbStorage ? R.string.usb_ext_media_nomedia_notification_title :
                            R.string.sd_ext_media_nomedia_notification_title,
                    isUsbStorage ? R.string.usb_ext_media_nomedia_notification_message :
                            R.string.sd_ext_media_nomedia_notification_message,
                    R.drawable.stat_notify_sdcard_usb,
                    true, !isPrimary, null);
            updateUsbMassStorageNotification(isPrimary ? false : mUmsAvailable);
        } else if (newState.equals(Environment.MEDIA_BAD_REMOVAL)) {
@@ -243,9 +266,11 @@ public class StorageNotification extends SystemUI {
             * and disable UMS notification if the removed storage is the primary storage.
             */
            setMediaStorageNotification(
                    com.android.internal.R.string.ext_media_badremoval_notification_title,
                    com.android.internal.R.string.ext_media_badremoval_notification_message,
                    com.android.internal.R.drawable.stat_sys_warning,
                    isUsbStorage ? R.string.usb_ext_media_badremoval_notification_title :
                            R.string.sd_ext_media_badremoval_notification_title,
                    isUsbStorage ? R.string.usb_ext_media_badremoval_notification_message :
                            R.string.sd_ext_media_badremoval_notification_message,
                    R.drawable.stat_sys_warning,
                    true, true, null);
            updateUsbMassStorageNotification(isPrimary ? false : mUmsAvailable);
        } else {
@@ -265,9 +290,9 @@ public class StorageNotification extends SystemUI {

            PendingIntent pi = PendingIntent.getActivity(mContext, 0, intent, 0);
            setUsbStorageNotification(
                    com.android.internal.R.string.usb_storage_notification_title,
                    com.android.internal.R.string.usb_storage_notification_message,
                    com.android.internal.R.drawable.stat_sys_data_usb,
                    R.string.usb_storage_notification_title,
                    R.string.usb_storage_notification_message,
                    R.drawable.stat_sys_data_usb,
                    false, true, pi);
        } else {
            setUsbStorageNotification(0, 0, 0, false, false, null);