use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.
the class LocationManagerService method ensureFallbackFusedProviderPresentLocked.
private void ensureFallbackFusedProviderPresentLocked(ArrayList<String> pkgs) {
PackageManager pm = mContext.getPackageManager();
String systemPackageName = mContext.getPackageName();
ArrayList<HashSet<Signature>> sigSets = ServiceWatcher.getSignatureSets(mContext, pkgs);
List<ResolveInfo> rInfos = pm.queryIntentServicesAsUser(new Intent(FUSED_LOCATION_SERVICE_ACTION), PackageManager.GET_META_DATA, mCurrentUserId);
for (ResolveInfo rInfo : rInfos) {
String packageName = rInfo.serviceInfo.packageName;
// this list the standard provider binding logic won't bind to it.
try {
PackageInfo pInfo;
pInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES);
if (!ServiceWatcher.isSignatureMatch(pInfo.signatures, sigSets)) {
Log.w(TAG, packageName + " resolves service " + FUSED_LOCATION_SERVICE_ACTION + ", but has wrong signature, ignoring");
continue;
}
} catch (NameNotFoundException e) {
Log.e(TAG, "missing package: " + packageName);
continue;
}
// Get the version info
if (rInfo.serviceInfo.metaData == null) {
Log.w(TAG, "Found fused provider without metadata: " + packageName);
continue;
}
int version = rInfo.serviceInfo.metaData.getInt(ServiceWatcher.EXTRA_SERVICE_VERSION, -1);
if (version == 0) {
// Make sure it's in the system partition.
if ((rInfo.serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
if (D)
Log.d(TAG, "Fallback candidate not in /system: " + packageName);
continue;
}
// as a proxy for coreApp="true"
if (pm.checkSignatures(systemPackageName, packageName) != PackageManager.SIGNATURE_MATCH) {
if (D)
Log.d(TAG, "Fallback candidate not signed the same as system: " + packageName);
continue;
}
// Found a valid fallback.
if (D)
Log.d(TAG, "Found fallback provider: " + packageName);
return;
} else {
if (D)
Log.d(TAG, "Fallback candidate not version 0: " + packageName);
}
}
throw new IllegalStateException("Unable to find a fused location provider that is in the " + "system partition with version 0 and signed with the platform certificate. " + "Such a package is needed to provide a default fused location provider in the " + "event that no other fused location provider has been installed or is currently " + "available. For example, coreOnly boot mode when decrypting the data " + "partition. The fallback must also be marked coreApp=\"true\" in the manifest");
}
use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.
the class PermissionMonitor method startMonitoring.
// Intended to be called only once at startup, after the system is ready. Installs a broadcast
// receiver to monitor ongoing UID changes, so this shouldn't/needn't be called again.
public synchronized void startMonitoring() {
log("Monitoring");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_USER_ADDED);
intentFilter.addAction(Intent.ACTION_USER_REMOVED);
mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, intentFilter, null, null);
intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
intentFilter.addDataScheme("package");
mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, intentFilter, null, null);
List<PackageInfo> apps = mPackageManager.getInstalledPackages(GET_PERMISSIONS);
if (apps == null) {
loge("No apps");
return;
}
for (PackageInfo app : apps) {
int uid = app.applicationInfo != null ? app.applicationInfo.uid : -1;
if (uid < 0) {
continue;
}
boolean isNetwork = hasNetworkPermission(app);
boolean hasRestrictedPermission = hasRestrictedNetworkPermission(app);
if (isNetwork || hasRestrictedPermission) {
Boolean permission = mApps.get(uid);
// permissions, don't downgrade (i.e., if it's already SYSTEM, leave it as is).
if (permission == null || permission == NETWORK) {
mApps.put(uid, hasRestrictedPermission);
}
}
}
// exclude dying users
List<UserInfo> users = mUserManager.getUsers(true);
if (users != null) {
for (UserInfo user : users) {
mUsers.add(user.id);
}
}
log("Users: " + mUsers.size() + ", Apps: " + mApps.size());
update(mUsers, mApps, true);
}
use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.
the class PermissionMonitor method onAppAdded.
private synchronized void onAppAdded(String appName, int appUid) {
if (TextUtils.isEmpty(appName) || appUid < 0) {
loge("Invalid app in onAppAdded: " + appName + " | " + appUid);
return;
}
try {
PackageInfo app = mPackageManager.getPackageInfo(appName, GET_PERMISSIONS);
boolean isNetwork = hasNetworkPermission(app);
boolean hasRestrictedPermission = hasRestrictedNetworkPermission(app);
if (isNetwork || hasRestrictedPermission) {
Boolean permission = mApps.get(appUid);
// permissions, don't downgrade (i.e., if it's already SYSTEM, leave it as is).
if (permission == null || permission == NETWORK) {
mApps.put(appUid, hasRestrictedPermission);
Map<Integer, Boolean> apps = new HashMap<>();
apps.put(appUid, hasRestrictedPermission);
update(mUsers, apps, true);
}
}
} catch (NameNotFoundException e) {
loge("NameNotFoundException in onAppAdded: " + e);
}
}
use of android.content.pm.PackageInfo in project android_frameworks_base by ResurrectionRemix.
the class ClipboardService method addActiveOwnerLocked.
private final void addActiveOwnerLocked(int uid, String pkg) {
final IPackageManager pm = AppGlobals.getPackageManager();
final int targetUserHandle = UserHandle.getCallingUserId();
final long oldIdentity = Binder.clearCallingIdentity();
try {
PackageInfo pi = pm.getPackageInfo(pkg, 0, targetUserHandle);
if (pi == null) {
throw new IllegalArgumentException("Unknown package " + pkg);
}
if (!UserHandle.isSameApp(pi.applicationInfo.uid, uid)) {
throw new SecurityException("Calling uid " + uid + " does not own package " + pkg);
}
} catch (RemoteException e) {
// Can't happen; the package manager is in the same process
} finally {
Binder.restoreCallingIdentity(oldIdentity);
}
PerUserClipboard clipboard = getClipboard();
if (clipboard.primaryClip != null && !clipboard.activePermissionOwners.contains(pkg)) {
final int N = clipboard.primaryClip.getItemCount();
for (int i = 0; i < N; i++) {
grantItemLocked(clipboard.primaryClip.getItemAt(i), pkg, UserHandle.getUserId(uid));
}
clipboard.activePermissionOwners.add(pkg);
}
}
use of android.content.pm.PackageInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class HAFRAppChooserAdapter method getFilter.
@Override
public Filter getFilter() {
return new Filter() {
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
}
@Override
protected FilterResults performFiltering(CharSequence constraint) {
if (TextUtils.isEmpty(constraint)) {
// No filter implemented we return all the list
mTemporarylist = mInstalledAppInfo;
return new FilterResults();
}
ArrayList<PackageInfo> FilteredList = new ArrayList<PackageInfo>();
for (PackageInfo data : mInstalledAppInfo) {
final String filterText = constraint.toString().toLowerCase(Locale.ENGLISH);
try {
if (data.applicationInfo.loadLabel(mPackageManager).toString().toLowerCase(Locale.ENGLISH).contains(filterText)) {
FilteredList.add(data);
} else if (data.packageName.contains(filterText)) {
FilteredList.add(data);
}
} catch (Exception e) {
}
}
mTemporarylist = FilteredList;
return new FilterResults();
}
};
}
Aggregations