Make AppOpsManager#permissionToOp API public

We need this API to implement permission checker API
in the support lib that takes into account both app
ops and permissions.

bug:21277214

Change-Id: I684fc002bb71ec5e1cd2994098faa0d2036297ac
diff --git a/api/current.txt b/api/current.txt
index 3e0a1b3..308ac424 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -3880,6 +3880,7 @@
     method public void finishOp(java.lang.String, int, java.lang.String);
     method public int noteOp(java.lang.String, int, java.lang.String);
     method public int noteOpNoThrow(java.lang.String, int, java.lang.String);
+    method public static java.lang.String permissionToOp(java.lang.String);
     method public int startOp(java.lang.String, int, java.lang.String);
     method public int startOpNoThrow(java.lang.String, int, java.lang.String);
     method public void startWatchingMode(java.lang.String, java.lang.String, android.app.AppOpsManager.OnOpChangedListener);
@@ -3888,12 +3889,32 @@
     field public static final int MODE_DEFAULT = 3; // 0x3
     field public static final int MODE_ERRORED = 2; // 0x2
     field public static final int MODE_IGNORED = 1; // 0x1
+    field public static final java.lang.String OPSTR_ADD_VOICEMAIL = "android:add_voicemail";
+    field public static final java.lang.String OPSTR_BODY_SENSORS = "android:body_sensors";
+    field public static final java.lang.String OPSTR_CALL_PHONE = "android:call_phone";
+    field public static final java.lang.String OPSTR_CAMERA = "android:camera";
     field public static final java.lang.String OPSTR_COARSE_LOCATION = "android:coarse_location";
     field public static final java.lang.String OPSTR_FINE_LOCATION = "android:fine_location";
     field public static final java.lang.String OPSTR_GET_USAGE_STATS = "android:get_usage_stats";
     field public static final java.lang.String OPSTR_MOCK_LOCATION = "android:mock_location";
     field public static final java.lang.String OPSTR_MONITOR_HIGH_POWER_LOCATION = "android:monitor_location_high_power";
     field public static final java.lang.String OPSTR_MONITOR_LOCATION = "android:monitor_location";
+    field public static final java.lang.String OPSTR_READ_CALENDAR = "android:read_calendar";
+    field public static final java.lang.String OPSTR_READ_CALL_LOG = "android:read_call_log";
+    field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
+    field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
+    field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
+    field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
+    field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";
+    field public static final java.lang.String OPSTR_RECEIVE_SMS = "android:receive_sms";
+    field public static final java.lang.String OPSTR_RECEIVE_WAP_PUSH = "android:receive_wap_push";
+    field public static final java.lang.String OPSTR_RECORD_AUDIO = "android:record_audio";
+    field public static final java.lang.String OPSTR_SEND_SMS = "android:send_sms";
+    field public static final java.lang.String OPSTR_USE_FINGERPRINT = "android:use_fingerprint";
+    field public static final java.lang.String OPSTR_USE_SIP = "android:use_sip";
+    field public static final java.lang.String OPSTR_WRITE_CALENDAR = "android:write_calendar";
+    field public static final java.lang.String OPSTR_WRITE_CALL_LOG = "android:write_call_log";
+    field public static final java.lang.String OPSTR_WRITE_CONTACTS = "android:write_contacts";
   }
 
   public static abstract interface AppOpsManager.OnOpChangedListener {
diff --git a/api/system-current.txt b/api/system-current.txt
index a61b9fb53..ded7f0a 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3984,12 +3984,32 @@
     field public static final int MODE_ERRORED = 2; // 0x2
     field public static final int MODE_IGNORED = 1; // 0x1
     field public static final java.lang.String OPSTR_ACTIVATE_VPN = "android:activate_vpn";
+    field public static final java.lang.String OPSTR_ADD_VOICEMAIL = "android:add_voicemail";
+    field public static final java.lang.String OPSTR_BODY_SENSORS = "android:body_sensors";
+    field public static final java.lang.String OPSTR_CALL_PHONE = "android:call_phone";
+    field public static final java.lang.String OPSTR_CAMERA = "android:camera";
     field public static final java.lang.String OPSTR_COARSE_LOCATION = "android:coarse_location";
     field public static final java.lang.String OPSTR_FINE_LOCATION = "android:fine_location";
     field public static final java.lang.String OPSTR_GET_USAGE_STATS = "android:get_usage_stats";
     field public static final java.lang.String OPSTR_MOCK_LOCATION = "android:mock_location";
     field public static final java.lang.String OPSTR_MONITOR_HIGH_POWER_LOCATION = "android:monitor_location_high_power";
     field public static final java.lang.String OPSTR_MONITOR_LOCATION = "android:monitor_location";
+    field public static final java.lang.String OPSTR_READ_CALENDAR = "android:read_calendar";
+    field public static final java.lang.String OPSTR_READ_CALL_LOG = "android:read_call_log";
+    field public static final java.lang.String OPSTR_READ_CELL_BROADCASTS = "android:read_cell_broadcasts";
+    field public static final java.lang.String OPSTR_READ_CONTACTS = "android:read_contacts";
+    field public static final java.lang.String OPSTR_READ_PHONE_STATE = "android:read_phone_state";
+    field public static final java.lang.String OPSTR_READ_SMS = "android:read_sms";
+    field public static final java.lang.String OPSTR_RECEIVE_MMS = "android:receive_mms";
+    field public static final java.lang.String OPSTR_RECEIVE_SMS = "android:receive_sms";
+    field public static final java.lang.String OPSTR_RECEIVE_WAP_PUSH = "android:receive_wap_push";
+    field public static final java.lang.String OPSTR_RECORD_AUDIO = "android:record_audio";
+    field public static final java.lang.String OPSTR_SEND_SMS = "android:send_sms";
+    field public static final java.lang.String OPSTR_USE_FINGERPRINT = "android:use_fingerprint";
+    field public static final java.lang.String OPSTR_USE_SIP = "android:use_sip";
+    field public static final java.lang.String OPSTR_WRITE_CALENDAR = "android:write_calendar";
+    field public static final java.lang.String OPSTR_WRITE_CALL_LOG = "android:write_call_log";
+    field public static final java.lang.String OPSTR_WRITE_CONTACTS = "android:write_contacts";
   }
 
   public static abstract interface AppOpsManager.OnOpChangedListener {
diff --git a/core/java/android/app/AppOpsManager.java b/core/java/android/app/AppOpsManager.java
index e728971..8a61ec6 100644
--- a/core/java/android/app/AppOpsManager.java
+++ b/core/java/android/app/AppOpsManager.java
@@ -250,64 +250,64 @@
     @SystemApi
     public static final String OPSTR_ACTIVATE_VPN
             = "android:activate_vpn";
-    /** @hide Allows an application to read the user's contacts data. */
+    /** Allows an application to read the user's contacts data. */
     public static final String OPSTR_READ_CONTACTS
             = "android:read_contacts";
-    /** @hide Allows an application to write to the user's contacts data. */
+    /** Allows an application to write to the user's contacts data. */
     public static final String OPSTR_WRITE_CONTACTS
             = "android:write_contacts";
-    /** @hide Allows an application to read the user's call log. */
+    /** Allows an application to read the user's call log. */
     public static final String OPSTR_READ_CALL_LOG
             = "android:read_call_log";
-    /** @hide Allows an application to write to the user's call log. */
+    /** Allows an application to write to the user's call log. */
     public static final String OPSTR_WRITE_CALL_LOG
             = "android:write_call_log";
-    /** @hide Allows an application to read the user's calendar data. */
+    /** Allows an application to read the user's calendar data. */
     public static final String OPSTR_READ_CALENDAR
             = "android:read_calendar";
-    /** @hide Allows an application to write to the user's calendar data. */
+    /** Allows an application to write to the user's calendar data. */
     public static final String OPSTR_WRITE_CALENDAR
             = "android:write_calendar";
-    /** @hide Allows an application to initiate a phone call. */
+    /** Allows an application to initiate a phone call. */
     public static final String OPSTR_CALL_PHONE
             = "android:call_phone";
-    /** @hide Allows an application to read SMS messages. */
+    /** Allows an application to read SMS messages. */
     public static final String OPSTR_READ_SMS
             = "android:read_sms";
-    /** @hide Allows an application to receive SMS messages. */
+    /** Allows an application to receive SMS messages. */
     public static final String OPSTR_RECEIVE_SMS
             = "android:receive_sms";
-    /** @hide Allows an application to receive MMS messages. */
+    /** Allows an application to receive MMS messages. */
     public static final String OPSTR_RECEIVE_MMS
             = "android:receive_mms";
-    /** @hide Allows an application to receive WAP push messages. */
+    /** Allows an application to receive WAP push messages. */
     public static final String OPSTR_RECEIVE_WAP_PUSH
             = "android:receive_wap_push";
-    /** @hide Allows an application to send SMS messages. */
+    /** Allows an application to send SMS messages. */
     public static final String OPSTR_SEND_SMS
             = "android:send_sms";
-    /** @hide Required to be able to access the camera device. */
+    /** Required to be able to access the camera device. */
     public static final String OPSTR_CAMERA
             = "android:camera";
-    /** @hide Required to be able to access the microphone device. */
+    /** Required to be able to access the microphone device. */
     public static final String OPSTR_RECORD_AUDIO
             = "android:record_audio";
-    /** @hide Required to access phone state related information. */
+    /** Required to access phone state related information. */
     public static final String OPSTR_READ_PHONE_STATE
             = "android:read_phone_state";
-    /** @hide Required to access phone state related information. */
+    /** Required to access phone state related information. */
     public static final String OPSTR_ADD_VOICEMAIL
             = "android:add_voicemail";
-    /** @hide Access APIs for SIP calling over VOIP or WiFi */
+    /** Access APIs for SIP calling over VOIP or WiFi */
     public static final String OPSTR_USE_SIP
             = "android:use_sip";
-    /** @hide Use the fingerprint API. */
+    /** Use the fingerprint API. */
     public static final String OPSTR_USE_FINGERPRINT
             = "android:use_fingerprint";
-    /** @hide Access to body sensors such as heart rate, etc. */
+    /** Access to body sensors such as heart rate, etc. */
     public static final String OPSTR_BODY_SENSORS
             = "android:body_sensors";
-    /** @hide Read previously received cell broadcast messages. */
+    /** Read previously received cell broadcast messages. */
     public static final String OPSTR_READ_CELL_BROADCASTS
             = "android:read_cell_broadcasts";
     /** Inject mock location into the system. */
@@ -1217,10 +1217,7 @@
      *
      * @param permission The permission.
      * @return The app op associated with the permission or null.
-     *
-     * @hide
      */
-    @SystemApi
     public static String permissionToOp(String permission) {
         final Integer opCode = sPermToOp.get(permission);
         if (opCode == null) {