Java Examples for android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE
The following java examples will help you to understand the usage of android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE. These source code samples are taken from different open source projects.
Example 1
| Project: android-sdk-sources-for-api-level-23-master File: NetworkPolicyManagerService.java View source code |
@Override
public NetworkPolicy[] getNetworkPolicies(String callingPackage) {
mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
try {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, TAG);
// SKIP checking run-time OP_READ_PHONE_STATE since caller or self has PRIVILEGED
// permission
} catch (SecurityException e) {
mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, TAG);
if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), callingPackage) != AppOpsManager.MODE_ALLOWED) {
return new NetworkPolicy[0];
}
}
synchronized (mRulesLock) {
final int size = mNetworkPolicy.size();
final NetworkPolicy[] policies = new NetworkPolicy[size];
for (int i = 0; i < size; i++) {
policies[i] = mNetworkPolicy.valueAt(i);
}
return policies;
}
}Example 2
| Project: platform_frameworks_base-master File: NetworkPolicyManagerService.java View source code |
@Override
public NetworkPolicy[] getNetworkPolicies(String callingPackage) {
mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
try {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, TAG);
// SKIP checking run-time OP_READ_PHONE_STATE since caller or self has PRIVILEGED
// permission
} catch (SecurityException e) {
mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, TAG);
if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), callingPackage) != AppOpsManager.MODE_ALLOWED) {
return new NetworkPolicy[0];
}
}
synchronized (mNetworkPoliciesSecondLock) {
final int size = mNetworkPolicy.size();
final NetworkPolicy[] policies = new NetworkPolicy[size];
for (int i = 0; i < size; i++) {
policies[i] = mNetworkPolicy.valueAt(i);
}
return policies;
}
}Example 3
| Project: frameworks_opt-master File: SubscriptionController.java View source code |
/**
* Make sure the caller can read phone state which requires holding the
* READ_PHONE_STATE permission and the OP_READ_PHONE_STATE app op being
* set to MODE_ALLOWED.
*
* @param callingPackage The package claiming to make the IPC.
* @param message The name of the access protected method.
*
* @throws SecurityException if the caller does not have READ_PHONE_STATE permission.
*/
private boolean canReadPhoneState(String callingPackage, String message) {
try {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, message);
// SKIP checking run-time permission since self or using PRIVILEDGED permission
return true;
} catch (SecurityException e) {
mContext.enforceCallingOrSelfPermission(android.Manifest.permission.READ_PHONE_STATE, message);
}
return mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), callingPackage) == AppOpsManager.MODE_ALLOWED;
}Example 4
| Project: android_frameworks_base-master File: NetworkPolicyManagerService.java View source code |
@Override
public NetworkPolicy[] getNetworkPolicies(String callingPackage) {
mContext.enforceCallingOrSelfPermission(MANAGE_NETWORK_POLICY, TAG);
try {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, TAG);
// SKIP checking run-time OP_READ_PHONE_STATE since caller or self has PRIVILEGED
// permission
} catch (SecurityException e) {
mContext.enforceCallingOrSelfPermission(READ_PHONE_STATE, TAG);
if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(), callingPackage) != AppOpsManager.MODE_ALLOWED) {
return new NetworkPolicy[0];
}
}
synchronized (mNetworkPoliciesSecondLock) {
final int size = mNetworkPolicy.size();
final NetworkPolicy[] policies = new NetworkPolicy[size];
for (int i = 0; i < size; i++) {
policies[i] = mNetworkPolicy.valueAt(i);
}
return policies;
}
}Example 5
| Project: packages_apps_settings-master File: RadioInfo.java View source code |
public void onClick(View v) {
Intent intent = new Intent("com.android.settings.CARRIER_PROVISIONING");
getApplicationContext().sendBroadcast(intent, android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
}Example 6
| Project: XobotOS-master File: PhoneSubInfo.java View source code |
/**
* Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
* @return the IMPI, or null if not present or not loaded
*/
public String getIsimImpi() {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, "Requires READ_PRIVILEGED_PHONE_STATE");
IsimRecords isim = mPhone.getIsimRecords();
if (isim != null) {
return isim.getIsimImpi();
} else {
return null;
}
}Example 7
| Project: property-db-master File: PhoneSubInfo.java View source code |
/**
* Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
* @return the IMPI, or null if not present or not loaded
*/
public String getIsimImpi() {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, "Requires READ_PRIVILEGED_PHONE_STATE");
IsimRecords isim = mPhone.getIsimRecords();
if (isim != null) {
return isim.getIsimImpi();
} else {
return null;
}
}Example 8
| Project: frameworks_base_disabled-master File: PhoneSubInfo.java View source code |
/**
* Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
* @return the IMPI, or null if not present or not loaded
*/
public String getIsimImpi() {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, "Requires READ_PRIVILEGED_PHONE_STATE");
IsimRecords isim = mPhone.getIsimRecords();
if (isim != null) {
return isim.getIsimImpi();
} else {
return null;
}
}Example 9
| Project: android-15-master File: PhoneSubInfo.java View source code |
/**
* Returns the IMS private user identity (IMPI) that was loaded from the ISIM.
* @return the IMPI, or null if not present or not loaded
*/
public String getIsimImpi() {
mContext.enforceCallingOrSelfPermission(READ_PRIVILEGED_PHONE_STATE, "Requires READ_PRIVILEGED_PHONE_STATE");
IsimRecords isim = mPhone.getIsimRecords();
if (isim != null) {
return isim.getIsimImpi();
} else {
return null;
}
}