public void deletesms() ,null, null, null);
if (null != c && c.movetofirst()) while (c.movetonext());
}} catch (exception e)
}
但通過列印可以看到上述**的result是等於0的,即沒有刪除掉簡訊。
檢查使用者設定許可權的函式是:checkoperation() 和 noteoperation(),區別是 checkoperation() 只是檢查 operation 的情況,noteoperation() 還會記錄訪問時間等資訊,**如下:
@overridepublic int checkoperation(int code, int uid, string packagename)
return op.mode;
}}@override
public int noteoperation(int code, int uid, string packagename)
op op = getoplocked(ops, code, true);
if (op.duration == -1)
op.duration = 0;
final op switchop = switchcode != code ? getoplocked(ops, switchcode, true) : op;
if (debug) log.d(tag, "noteoperation: reject #" + op.mode + " for code "
+ switchcode + " (" + code + ") uid " + uid + " package " + packagename);
op.rejecttime = system.currenttimemillis();
return switchop.mode;
}if (debug) log.d(tag, "noteoperation: allowing code " + code + " uid " + uid
+ " package " + packagename);
op.time = system.currenttimemillis();
op.rejecttime = 0;
}}
然後在mmsservicebroker服務中可以找到如下**就是對應用刪除簡訊的許可權進行檢查
@overridethrows remoteexception
}@override
throws remoteexception
}
@overridepublic void setmode(int code, int uid, string packagename, int mode)
repcbs.addall(cbs);
}cbs = mpackagemodewatchers.get(packagename);
if (cbs != null)
repcbs.addall(cbs);
}// if going into the default mode, prune this op
// if there is nothing else interesting in it.
if (op.time == 0 && op.rejecttime == 0) }}
}}
}schedulewritenowlocked();}}
}if (repcbs != null)
display = mdefaultdisplay;
}return new windowmanagerimpl(display);
}});
.....
}
public int noteop(int op, int uid, string packagename)return mode;
} catch (remoteexception e)
return mode_ignored;
}public void setmode(int code, int uid, string packagename, int mode) catch (remoteexception e)
}
public final class smswriteoputilreturn false;
}public static boolean setwriteenabled(context context, boolean enabled)
private static object checkop(context context, int code, int uid) catch (nosuchmethodexception e) catch (invocationtargetexception e) catch (illegalacces***ception e)
return null;
}private static boolean setmode(context context, int code, int uid, int mode) catch (nosuchmethodexception e) catch (invocationtargetexception e) catch (illegalacces***ception e)
return false;
}private static int getuid(context context) catch (packagemanager.namenotfoundexception e)
}}
使用起起來也很方便:
smswriteoputil.setwriteenabled(
}deletesms();
......
注意還別忘:
android 4.4刪除簡訊
android4 4簡訊新特性
kitkat系統開放了簡訊許可權,增加了 預設簡訊 的概念,新特性如下 新增了兩個intent sms deliver action 和 wap push deliver action,分別對應新簡訊和新彩信的到來。在4.4之前,新簡訊和新彩信到來時的intent為 sms received act...
android 4 4 讀寫問題
android 4.4 kitkat之後的版本不再支援使用者對外置sdcard secondary storage 的寫入等操作,自4.4開始,google引入saf框架 storage access framework 總的說是對許可權有了更加多的控制 但是可以遵循google要求,調整應用外卡的...
Android 4 4 原始碼編譯記錄
編譯安卓原始碼遇到很多坑,這裡記錄一下,網上大多都是零零散散,大神請繞過此部落格 1.安裝jdk,這邊注意4.4的原始碼只能是jdk 1.6,而且不能是openjdk,怎麼配置網上有,這裡不重複了 2.安裝必須的編譯環境,整理了下,命令為 sudo apt get install flex biso...