Search in sources :

Example 56 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class DevicePolicyManagerService method notifyPendingSystemUpdate.

@Override
public void notifyPendingSystemUpdate(long updateReceivedTime) {
    mContext.enforceCallingOrSelfPermission(permission.NOTIFY_PENDING_SYSTEM_UPDATE, "Only the system update service can broadcast update information");
    if (UserHandle.getCallingUserId() != UserHandle.USER_SYSTEM) {
        Slog.w(LOG_TAG, "Only the system update service in the system user " + "can broadcast update information.");
        return;
    }
    Intent intent = new Intent(DeviceAdminReceiver.ACTION_NOTIFY_PENDING_SYSTEM_UPDATE);
    intent.putExtra(DeviceAdminReceiver.EXTRA_SYSTEM_UPDATE_RECEIVED_TIME, updateReceivedTime);
    synchronized (this) {
        final String deviceOwnerPackage = mOwners.hasDeviceOwner() ? mOwners.getDeviceOwnerComponent().getPackageName() : null;
        if (deviceOwnerPackage == null) {
            return;
        }
        final UserHandle deviceOwnerUser = new UserHandle(mOwners.getDeviceOwnerUserId());
        ActivityInfo[] receivers = null;
        try {
            receivers = mContext.getPackageManager().getPackageInfo(deviceOwnerPackage, PackageManager.GET_RECEIVERS).receivers;
        } catch (NameNotFoundException e) {
            Log.e(LOG_TAG, "Cannot find device owner package", e);
        }
        if (receivers != null) {
            long ident = mInjector.binderClearCallingIdentity();
            try {
                for (int i = 0; i < receivers.length; i++) {
                    if (permission.BIND_DEVICE_ADMIN.equals(receivers[i].permission)) {
                        intent.setComponent(new ComponentName(deviceOwnerPackage, receivers[i].name));
                        mContext.sendBroadcastAsUser(intent, deviceOwnerUser);
                    }
                }
            } finally {
                mInjector.binderRestoreCallingIdentity(ident);
            }
        }
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) UserHandle(android.os.UserHandle) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) ComponentName(android.content.ComponentName) ParcelableString(com.android.internal.util.ParcelableString)

Example 57 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class DevicePolicyManagerService method findAdmin.

public DeviceAdminInfo findAdmin(ComponentName adminName, int userHandle, boolean throwForMissiongPermission) {
    if (!mHasFeature) {
        return null;
    }
    enforceFullCrossUsersPermission(userHandle);
    ActivityInfo ai = null;
    try {
        ai = mIPackageManager.getReceiverInfo(adminName, PackageManager.GET_META_DATA | PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS | PackageManager.MATCH_DIRECT_BOOT_AWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE, userHandle);
    } catch (RemoteException e) {
    // shouldn't happen.
    }
    if (ai == null) {
        throw new IllegalArgumentException("Unknown admin: " + adminName);
    }
    if (!permission.BIND_DEVICE_ADMIN.equals(ai.permission)) {
        final String message = "DeviceAdminReceiver " + adminName + " must be protected with " + permission.BIND_DEVICE_ADMIN;
        Slog.w(LOG_TAG, message);
        if (throwForMissiongPermission && ai.applicationInfo.targetSdkVersion > Build.VERSION_CODES.M) {
            throw new IllegalArgumentException(message);
        }
    }
    try {
        return new DeviceAdminInfo(mContext, ai);
    } catch (XmlPullParserException | IOException e) {
        Slog.w(LOG_TAG, "Bad device admin requested for user=" + userHandle + ": " + adminName, e);
        return null;
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) DeviceAdminInfo(android.app.admin.DeviceAdminInfo) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) ParcelableString(com.android.internal.util.ParcelableString) IOException(java.io.IOException) RemoteException(android.os.RemoteException)

Example 58 with ActivityInfo

use of android.content.pm.ActivityInfo in project android_frameworks_base by ResurrectionRemix.

the class NetworkScorerAppManagerTest method buildResolveInfo.

private ResolveInfoHolder buildResolveInfo(String packageName, int packageUid, boolean hasReceiverPermission, boolean hasScorePermission, boolean hasConfigActivity, boolean hasServiceInfo) throws Exception {
    Mockito.when(mMockPm.checkPermission(permission.SCORE_NETWORKS, packageName)).thenReturn(hasScorePermission ? PackageManager.PERMISSION_GRANTED : PackageManager.PERMISSION_DENIED);
    ResolveInfo resolveInfo = new ResolveInfo();
    resolveInfo.activityInfo = new ActivityInfo();
    resolveInfo.activityInfo.packageName = packageName;
    resolveInfo.activityInfo.applicationInfo = new ApplicationInfo();
    resolveInfo.activityInfo.applicationInfo.uid = packageUid;
    if (hasReceiverPermission) {
        resolveInfo.activityInfo.permission = permission.BROADCAST_NETWORK_PRIVILEGED;
    }
    ResolveInfo configActivityInfo = null;
    if (hasConfigActivity) {
        configActivityInfo = new ResolveInfo();
        configActivityInfo.activityInfo = new ActivityInfo();
        configActivityInfo.activityInfo.name = ".ConfigActivity";
    }
    ResolveInfo serviceInfo = null;
    if (hasServiceInfo) {
        serviceInfo = new ResolveInfo();
        serviceInfo.serviceInfo = new ServiceInfo();
        serviceInfo.serviceInfo.name = ".ScoringService";
    }
    return new ResolveInfoHolder(resolveInfo, configActivityInfo, serviceInfo);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ServiceInfo(android.content.pm.ServiceInfo) ActivityInfo(android.content.pm.ActivityInfo) ApplicationInfo(android.content.pm.ApplicationInfo)

Example 59 with ActivityInfo

use of android.content.pm.ActivityInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class HomeSettings method buildHomeActivitiesList.

private void buildHomeActivitiesList() {
    ArrayList<ResolveInfo> homeActivities = new ArrayList<ResolveInfo>();
    ComponentName currentDefaultHome = mPm.getHomeActivities(homeActivities);
    Context context = getPrefContext();
    mCurrentHome = null;
    mPrefGroup.removeAll();
    mPrefs = new ArrayList<HomeAppPreference>();
    mHomeComponentSet = new ComponentName[homeActivities.size()];
    int prefIndex = 0;
    boolean supportManagedProfilesExtra = getActivity().getIntent().getBooleanExtra(EXTRA_SUPPORT_MANAGED_PROFILES, false);
    boolean mustSupportManagedProfile = hasManagedProfile() || supportManagedProfilesExtra;
    for (int i = 0; i < homeActivities.size(); i++) {
        final ResolveInfo candidate = homeActivities.get(i);
        final ActivityInfo info = candidate.activityInfo;
        ComponentName activityName = new ComponentName(info.packageName, info.name);
        mHomeComponentSet[i] = activityName;
        try {
            Drawable icon = info.loadIcon(mPm);
            CharSequence name = info.loadLabel(mPm);
            HomeAppPreference pref;
            if (mustSupportManagedProfile && !launcherHasManagedProfilesFeature(candidate)) {
                pref = new HomeAppPreference(context, activityName, prefIndex, icon, name, this, info, false, /* not enabled */
                getResources().getString(R.string.home_work_profile_not_supported));
            } else {
                pref = new HomeAppPreference(context, activityName, prefIndex, icon, name, this, info, true, /* enabled */
                null);
            }
            mPrefs.add(pref);
            mPrefGroup.addPreference(pref);
            if (activityName.equals(currentDefaultHome)) {
                mCurrentHome = pref;
            }
            prefIndex++;
        } catch (Exception e) {
            Log.v(TAG, "Problem dealing with activity " + activityName, e);
        }
    }
    if (mCurrentHome != null) {
        if (mCurrentHome.isEnabled()) {
            getActivity().setResult(Activity.RESULT_OK);
        }
        new Handler().post(new Runnable() {

            public void run() {
                mCurrentHome.setChecked(true);
            }
        });
    }
}
Also used : Context(android.content.Context) ActivityInfo(android.content.pm.ActivityInfo) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) ResolveInfo(android.content.pm.ResolveInfo) ComponentName(android.content.ComponentName)

Example 60 with ActivityInfo

use of android.content.pm.ActivityInfo in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ManageAccountsSettings method isSafeIntent.

/**
     * Determines if the supplied Intent is safe. A safe intent is one that is
     * will launch a exported=true activity or owned by the same uid as the
     * authenticator supplying the intent.
     */
private boolean isSafeIntent(PackageManager pm, Intent intent) {
    AuthenticatorDescription authDesc = mAuthenticatorHelper.getAccountTypeDescription(mAccountType);
    ResolveInfo resolveInfo = pm.resolveActivity(intent, 0);
    if (resolveInfo == null) {
        return false;
    }
    ActivityInfo resolvedActivityInfo = resolveInfo.activityInfo;
    ApplicationInfo resolvedAppInfo = resolvedActivityInfo.applicationInfo;
    try {
        ApplicationInfo authenticatorAppInf = pm.getApplicationInfo(authDesc.packageName, 0);
        return resolvedActivityInfo.exported || resolvedAppInfo.uid == authenticatorAppInf.uid;
    } catch (NameNotFoundException e) {
        Log.e(TAG, "Intent considered unsafe due to exception.", e);
        return false;
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) AuthenticatorDescription(android.accounts.AuthenticatorDescription) ActivityInfo(android.content.pm.ActivityInfo) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo)

Aggregations

ActivityInfo (android.content.pm.ActivityInfo)886 ResolveInfo (android.content.pm.ResolveInfo)360 Intent (android.content.Intent)339 ComponentName (android.content.ComponentName)324 PackageManager (android.content.pm.PackageManager)215 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)141 ArrayList (java.util.ArrayList)139 ApplicationInfo (android.content.pm.ApplicationInfo)115 Test (org.junit.Test)113 RemoteException (android.os.RemoteException)82 Bundle (android.os.Bundle)68 PendingIntent (android.app.PendingIntent)62 Drawable (android.graphics.drawable.Drawable)61 IOException (java.io.IOException)60 PackageInfo (android.content.pm.PackageInfo)59 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)54 XmlResourceParser (android.content.res.XmlResourceParser)43 Point (android.graphics.Point)35 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)34 Context (android.content.Context)33