700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > android 关闭来电铃声 Android删除除自定义铃声后 来电铃声显示是一串数字

android 关闭来电铃声 Android删除除自定义铃声后 来电铃声显示是一串数字

时间:2020-06-09 14:42:54

相关推荐

android 关闭来电铃声 Android删除除自定义铃声后 来电铃声显示是一串数字

[DESCRIPTION]

1.设置--声音--手机铃声--添加铃声--自定义铃声--选择音乐文件为铃声

2.设置--声音--手机铃声--添加铃声--自定义铃声--进入Files音频--查看Ringtones列表,删除刚才设置的铃声

或者进入File Manager--Internal shared storage--Ringtones,删除刚才设置的铃声

[SOLUTION]

出现之前现象的原因是铃声不存在,加载的是apk的资源。如下修改可以将来电改成无声音,贵司也可以重新设置某个铃声,改成某个固定的铃声。

RingtoneManager.java

//add begin

public static boolean isRingtoneExist(Context context, Uri uri) {

if (uri == null) {

Log.e(TAG, "Check ringtone exist with null uri!");

return false;

}

boolean exist = false;

try {

AssetFileDescriptor fd = context.getContentResolver().openAssetFileDescriptor(uri, "r");

if (fd == null) {

exist = false;

} else {

fd.close();

exist = true;

}

} catch (FileNotFoundException e) {

e.printStackTrace();

exist = false;

} catch (IOException e) {

e.printStackTrace();

exist = true;

}

Log.d(TAG, uri + " is exist " + exist);

return exist;

}

}

//add end

/vendor/mediatek/proprietary/packages/services/Telecomm/src/com/android/server/telecom/RingtoneFactory.java

55 public Ringtone getRingtone(Call incomingCall) {

56 // Use the default ringtone of the work profile if the contact is a work profile contact.

57 Context userContext = isWorkContact(incomingCall) ?

58 getWorkProfileContextForUser(mCallsManager.getCurrentUserHandle()) :

59 getContextForUserHandle(mCallsManager.getCurrentUserHandle());

60 Uri ringtoneUri = incomingCall.getRingtone();

61 Ringtone ringtone = null;

62

63 if(ringtoneUri != null && userContext != null) {

64// Ringtone URI is explicitly specified. First, try to create a Ringtone with that.

65ringtone = RingtoneManager.getRingtone(userContext, ringtoneUri);

66 }

67 if(ringtone == null) {

68// Contact didn't specify ringtone or custom Ringtone creation failed. Get default

69// ringtone for user or profile.

70Context contextToUse = hasDefaultRingtoneForUser(userContext) ? userContext : mContext;

71Uri defaultRingtoneUri;

72if (UserManager.get(contextToUse).isUserUnlocked(contextToUse.getUserId())) {

73 defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(contextToUse,

74 RingtoneManager.TYPE_RINGTONE);

75} else {

76 defaultRingtoneUri = Settings.System.DEFAULT_RINGTONE_URI;

77}

//add begin

if(!RingtoneManager.isRingtoneExist(contextToUse,defaultRingtoneUri)){

RingtoneManager.setActualDefaultRingtoneUri(context,AudioManager.STREAM_RING,null);//可以设置希望的铃声

defaultRingtoneUri=null;

}

//add end

78if (defaultRingtoneUri == null) {

79 return null;

80}

81ringtone = RingtoneManager.getRingtone(contextToUse, defaultRingtoneUri);

82 }

83 if (ringtone != null) {

84ringtone.setStreamType(AudioManager.STREAM_RING);

85 }

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。