E DatabaseUtils: android.content.OperationApplicationException: App op not allowed
E DatabaseUtils: at android.content.ContentProvider$Transport.applyBatch(ContentProvider.java:310)
E DatabaseUtils: at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:192)
E DatabaseUtils: at android.os.Binder.execTransact(Binder.java:565)
W System.err: android.content.OperationApplicationException: App op not allowed
V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@cdc72b7
V BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@55aca24
W System.err: at android.database.DatabaseUtils.readExceptionWithOperationApplicationExceptionFromParcel(DatabaseUtils.java:156)
W System.err: at android.content.ContentProviderProxy.applyBatch(ContentProviderNative.java:520)
W System.err: at android.content.ContentProviderClient.applyBatch(ContentProviderClient.java:438)
/frameworks/base/core/java/android/content/ContentProvider.java
private void enforceFilePermission(String callingPkg, Uri uri, String mode,
IBinder callerToken) throws FileNotFoundException, SecurityException {
if (mode != null && mode.indexOf('w') != -1) {
if (enforceWritePermission(callingPkg, uri, callerToken)
!= AppOpsManager.MODE_ALLOWED) {
throw new FileNotFoundException("App op not allowed");
}
} else {
if (enforceReadPermission(callingPkg, uri, callerToken)
!= AppOpsManager.MODE_ALLOWED) {
throw new FileNotFoundException("App op not allowed");
}
}
}
//验证读权限
private int enforceReadPermission(String callingPkg, Uri uri, IBinder callerToken)
throws SecurityException {
final int mode = enforceReadPermissionInner(uri, callingPkg, callerToken);
if (mode != MODE_ALLOWED) {
return mode;
}
if (mReadOp != AppOpsManager.OP_NONE) {
return mAppOpsManager.noteProxyOp(mReadOp, callingPkg);
}
return AppOpsManager.MODE_ALLOWED;
}
//验证写权限
private int enforceWritePermission(String callingPkg, Uri uri, IBinder callerToken)
throws SecurityException {
final int mode = enforceWritePermissionInner(uri, callingPkg, callerToken);
if (mode != MODE_ALLOWED) {
return mode;
}
if (mWriteOp != AppOpsManager.OP_NONE) {
return mAppOpsManager.noteProxyOp(mWriteOp, callingPkg);
}
return AppOpsManager.MODE_ALLOWED;
}
}
@Override
public ContentProviderResult[] applyBatch(String callingPkg,
ArrayList operations)
throws OperationApplicationException {
int numOperations = operations.size();
final int[] userIds = new int[numOperations];
for (int i = 0; i < numOperations; i++) {
ContentProviderOperation operation = operations.get(i);
Uri uri = operation.getUri();
validateIncomingUri(uri);
userIds[i] = getUserIdFromUri(uri);
if (userIds[i] != UserHandle.USER_CURRENT) {
// Removing the user id from the uri.
operation = new ContentProviderOperation(operation, true);
operations.set(i, operation);
}
if (operation.isReadOperation()) {
if (enforceReadPermission(callingPkg, uri, null)
!= AppOpsManager.MODE_ALLOWED) {
throw new OperationApplicationException("App op not allowed", 0);
}
}
if (operation.isWriteOperation()) {
if (enforceWritePermission(callingPkg, uri, null)
!= AppOpsManager.MODE_ALLOWED) {
throw new OperationApplicationException("App op not allowed", 0);
}
}
}
final String original = setCallingPackage(callingPkg);
try {
ContentProviderResult[] results = ContentProvider.this.applyBatch(operations);
if (results != null) {
for (int i = 0; i < results.length ; i++) {
if (userIds[i] != UserHandle.USER_CURRENT) {
// Adding the userId to the uri.
results[i] = new ContentProviderResult(results[i], userIds[i]);
}
}
}
return results;
} finally {
setCallingPackage(original);
}
}
// smsApplication
private static final String BACKUP_PACKAGE_NAME = "com.android.backup";
private static final String PHONE_PACKAGE_NAME = "com.android.phone";
private static final String BLUETOOTH_PACKAGE_NAME = "com.android.bluetooth";
private static SmsApplicationData getApplication(Context context, boolean updateIfNeeded,
int userId) {
....
....
assignWriteSmsPermissionToSystemApp(context, packageManager, appOps,
BACKUP_PACKAGE_NAME);
...
...
}
private static void setDefaultApplicationInternal(String packageName, Context context,
int userId) {
....
....
assignWriteSmsPermissionToSystemApp(context, packageManager, appOps,
BLUETOOTH_PACKAGE_NAME);
....
....
}
设置的地方
TelephonyProvider/src/com/android/providers/telephony/SmsProvider.java
public boolean onCreate() {
setAppOps(AppOpsManager.OP_READ_SMS, AppOpsManager.OP_WRITE_SMS);
mOpenHelper = MmsSmsDatabaseHelper.getInstance(getContext());
setIccColumns();
return true;
}