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

Commit 5e8911a7 authored by kaiyiz's avatar kaiyiz Committed by Brint E. Kriebel
Browse files

DeskClock: Fix alarm name display abnormal when choose audio

Lack the handle to uri whose authority is document.

When we judge the uri is from document ,we obtain its name as
title for alarm name.

CRs-fixed: 662043

Change-Id: I588678ee8102adbe661a155e7650f7b50bb5b85e
parent fce93f2e
Loading
Loading
Loading
Loading
+19 −4
Original line number Original line Diff line number Diff line
@@ -113,6 +113,8 @@ public class AlarmClockFragment extends DeskClockFragment implements
    private static final String KEY_DELETE_CONFIRMATION = "deleteConfirmation";
    private static final String KEY_DELETE_CONFIRMATION = "deleteConfirmation";
    private static final String KEY_SELECT_SOURCE = "selectedSource";
    private static final String KEY_SELECT_SOURCE = "selectedSource";


    private static final String DOC_AUTHORITY = "com.android.providers.media.documents";

    private static final int REQUEST_CODE_RINGTONE = 1;
    private static final int REQUEST_CODE_RINGTONE = 1;
    private static final int REQUEST_CODE_PROFILE = 2;
    private static final int REQUEST_CODE_PROFILE = 2;
    private static final int REQUEST_CODE_EXTERN_AUDIO = 3;
    private static final int REQUEST_CODE_EXTERN_AUDIO = 3;
@@ -143,6 +145,8 @@ public class AlarmClockFragment extends DeskClockFragment implements
    private AlarmTimelineView mTimelineView;
    private AlarmTimelineView mTimelineView;
    private View mFooterView;
    private View mFooterView;


    private String mDisplayName;

    private Bundle mRingtoneTitleCache; // Key: ringtone uri, value: ringtone title
    private Bundle mRingtoneTitleCache; // Key: ringtone uri, value: ringtone title
    private ActionableToastBar mUndoBar;
    private ActionableToastBar mUndoBar;
    private View mUndoFrame;
    private View mUndoFrame;
@@ -1634,12 +1638,16 @@ public class AlarmClockFragment extends DeskClockFragment implements
                } else {
                } else {
                    if (isRingToneUriValid(uri)) {
                    if (isRingToneUriValid(uri)) {
                        // This is slow because a media player is created during Ringtone object creation.
                        // This is slow because a media player is created during Ringtone object creation.
                        if (uri.getAuthority().equals(DOC_AUTHORITY)) {
                            title = mDisplayName;
                        } else {
                            Ringtone ringTone = RingtoneManager.getRingtone(mContext, uri);
                            Ringtone ringTone = RingtoneManager.getRingtone(mContext, uri);
                            if (ringTone != null) {
                            if (ringTone != null) {
                                title = ringTone.getTitle(mContext);
                                title = ringTone.getTitle(mContext);
                            }
                            }
                        }
                        }
                    }
                    }
                }
                if (title != null) {
                if (title != null) {
                    mRingtoneTitleCache.putString(uri.toString(), title);
                    mRingtoneTitleCache.putString(uri.toString(), title);
                }
                }
@@ -1657,8 +1665,15 @@ public class AlarmClockFragment extends DeskClockFragment implements
                Cursor cursor = null;
                Cursor cursor = null;
                try {
                try {
                    cursor = mContext.getContentResolver().query(uri,
                    cursor = mContext.getContentResolver().query(uri,
                            new String[] {MediaStore.Audio.Media.TITLE}, null, null, null);
                            new String[] {
                                MediaStore.Audio.Media.TITLE,
                                MediaStore.Audio.Media.DISPLAY_NAME
                            }, null, null, null);
                    if (cursor != null && cursor.getCount() > 0) {
                    if (cursor != null && cursor.getCount() > 0) {
                        if (uri.getAuthority().equals(DOC_AUTHORITY)) {
                            cursor.moveToFirst();
                            mDisplayName = cursor.getString(1);
                        }
                        return true;
                        return true;
                    }
                    }
                } catch (Exception e) {
                } catch (Exception e) {