use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.
the class RestrictedLockUtils method checkIfUninstallBlocked.
public static EnforcedAdmin checkIfUninstallBlocked(Context context, String packageName, int userId) {
EnforcedAdmin allAppsControlDisallowedAdmin = checkIfRestrictionEnforced(context, UserManager.DISALLOW_APPS_CONTROL, userId);
if (allAppsControlDisallowedAdmin != null) {
return allAppsControlDisallowedAdmin;
}
EnforcedAdmin allAppsUninstallDisallowedAdmin = checkIfRestrictionEnforced(context, UserManager.DISALLOW_UNINSTALL_APPS, userId);
if (allAppsUninstallDisallowedAdmin != null) {
return allAppsUninstallDisallowedAdmin;
}
IPackageManager ipm = AppGlobals.getPackageManager();
try {
if (ipm.getBlockUninstallForUser(packageName, userId)) {
return getProfileOrDeviceOwner(context, userId);
}
} catch (RemoteException e) {
// Nothing to do
}
return null;
}
use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.
the class AccountManagerService method checkUidPermission.
private boolean checkUidPermission(String permission, int uid, String opPackageName) {
final long identity = Binder.clearCallingIdentity();
try {
IPackageManager pm = ActivityThread.getPackageManager();
if (pm.checkUidPermission(permission, uid) != PackageManager.PERMISSION_GRANTED) {
return false;
}
final int opCode = AppOpsManager.permissionToOpCode(permission);
return (opCode == AppOpsManager.OP_NONE || mAppOpsManager.noteOpNoThrow(opCode, uid, opPackageName) == AppOpsManager.MODE_ALLOWED);
} catch (RemoteException e) {
/* ignore - local call */
} finally {
Binder.restoreCallingIdentity(identity);
}
return false;
}
use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.
the class IntentFirewall method logIntent.
private static void logIntent(int intentType, Intent intent, int callerUid, String resolvedType) {
// The component shouldn't be null, but let's double check just to be safe
ComponentName cn = intent.getComponent();
String shortComponent = null;
if (cn != null) {
shortComponent = cn.flattenToShortString();
}
String callerPackages = null;
int callerPackageCount = 0;
IPackageManager pm = AppGlobals.getPackageManager();
if (pm != null) {
try {
String[] callerPackagesArray = pm.getPackagesForUid(callerUid);
if (callerPackagesArray != null) {
callerPackageCount = callerPackagesArray.length;
callerPackages = joinPackages(callerPackagesArray);
}
} catch (RemoteException ex) {
Slog.e(TAG, "Remote exception while retrieving packages", ex);
}
}
EventLogTags.writeIfwIntentMatched(intentType, shortComponent, callerUid, callerPackageCount, callerPackages, intent.getAction(), resolvedType, intent.getDataString(), intent.getFlags());
}
use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.
the class CardEmulation method getInstance.
/**
* Helper to get an instance of this class.
*
* @param adapter A reference to an NfcAdapter object.
* @return
*/
public static synchronized CardEmulation getInstance(NfcAdapter adapter) {
if (adapter == null)
throw new NullPointerException("NfcAdapter is null");
Context context = adapter.getContext();
if (context == null) {
Log.e(TAG, "NfcAdapter context is null.");
throw new UnsupportedOperationException();
}
if (!sIsInitialized) {
IPackageManager pm = ActivityThread.getPackageManager();
if (pm == null) {
Log.e(TAG, "Cannot get PackageManager");
throw new UnsupportedOperationException();
}
try {
if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION, 0)) {
Log.e(TAG, "This device does not support card emulation");
throw new UnsupportedOperationException();
}
} catch (RemoteException e) {
Log.e(TAG, "PackageManager query failed.");
throw new UnsupportedOperationException();
}
sIsInitialized = true;
}
CardEmulation manager = sCardEmus.get(context);
if (manager == null) {
// Get card emu service
INfcCardEmulation service = adapter.getCardEmulationService();
if (service == null) {
Log.e(TAG, "This device does not implement the INfcCardEmulation interface.");
throw new UnsupportedOperationException();
}
manager = new CardEmulation(context, service);
sCardEmus.put(context, manager);
}
return manager;
}
use of android.content.pm.IPackageManager in project android_frameworks_base by crdroidandroid.
the class RetailDemoModeService method isDemoLauncherDisabled.
boolean isDemoLauncherDisabled() {
int enabledState = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
try {
final IPackageManager iPm = AppGlobals.getPackageManager();
final String demoLauncherComponent = getContext().getString(R.string.config_demoModeLauncherComponent);
enabledState = iPm.getComponentEnabledSetting(ComponentName.unflattenFromString(demoLauncherComponent), mCurrentUserId);
} catch (RemoteException re) {
Slog.e(TAG, "Error retrieving demo launcher enabled setting", re);
}
return enabledState == PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
Aggregations