No need to use PermissionChecker to check own permission
PermissionChecker is only needed to handle the case when you check a
permission for a different app.
Test: Built
Merged-In: Iebfaaf1d9ff7f789c8883515f584463719edb941
Change-Id: Iebfaaf1d9ff7f789c8883515f584463719edb941
(cherry picked from commit 827bba88eba65ac5855f495f812797bbf8fb92b9)
diff --git a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
index 345253a..fb3677e 100644
--- a/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
+++ b/src/com/android/cellbroadcastservice/CellBroadcastHandler.java
@@ -16,7 +16,6 @@
package com.android.cellbroadcastservice;
-import static android.content.PermissionChecker.PERMISSION_GRANTED;
import static android.provider.Settings.Secure.CMAS_ADDITIONAL_BROADCAST_PKG;
import android.Manifest;
@@ -27,7 +26,7 @@
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
-import android.content.PermissionChecker;
+import android.content.pm.PackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
@@ -37,6 +36,7 @@
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.os.Process;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Telephony;
@@ -384,8 +384,8 @@
}
private boolean hasPermission(String permission) {
- return PermissionChecker.checkCallingOrSelfPermissionForDataDelivery(mContext,
- permission) == PERMISSION_GRANTED;
+ return mContext.checkPermission(permission, Process.myPid(), Process.myUid())
+ == PackageManager.PERMISSION_GRANTED;
}
private final LocationListener mLocationListener = new LocationListener() {