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

Commit 1280ef18 authored by Toha's avatar Toha Committed by Abhisek Devkota
Browse files

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

Change-Id: Icaf0d246ab3bdd0614c8bb7a22f8b2b95cbe9c7e
TODO: Provide drawable for usb storage (someone please).
parent 96350ea7
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2014 The CyanogenMod Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <public type="string" name="storage_internal" id="0x01040018" />
    <public type="string" name="storage_sd_card" id="0x01040019" />
    <public type="string" name="storage_usb" id="0x0104001a" />
</resources>
+28 −0
Original line number Diff line number Diff line
@@ -233,4 +233,32 @@

    <!-- USB OTG notification message -->
    <string name="usb_storage_notification_manage_message">Tap to manage</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>
</resources>
+32 −0
Original line number Diff line number Diff line
@@ -2037,4 +2037,36 @@
  <!-- USB OTG Notification -->
  <java-symbol type="string" name="usb_storage_notification_manage_message" />

  <!-- Used for storage notification -->
  <java-symbol type="string" name="storage_internal" />
  <java-symbol type="string" name="storage_sd_card" />
  <java-symbol type="string" name="storage_usb" />

  <!-- 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" />
</resources>
+51 −27
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.provider.Settings;
import android.util.Log;

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

public class StorageNotification extends SystemUI {
    private static final String TAG = "StorageNotification";
@@ -125,9 +126,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
@@ -136,19 +147,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)) {
            /*
@@ -179,9 +191,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.
@@ -209,9 +225,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)) {
            /*
@@ -225,9 +243,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)) {
            /*
@@ -235,9 +255,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)) {
@@ -246,9 +268,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 {
@@ -292,9 +316,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);