Search in sources :

Example 31 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.

the class ActivityManagerService method getRunningExternalApplications.

@Override
public List<ApplicationInfo> getRunningExternalApplications() {
    enforceNotIsolatedCaller("getRunningExternalApplications");
    List<ActivityManager.RunningAppProcessInfo> runningApps = getRunningAppProcesses();
    List<ApplicationInfo> retList = new ArrayList<ApplicationInfo>();
    if (runningApps != null && runningApps.size() > 0) {
        Set<String> extList = new HashSet<String>();
        for (ActivityManager.RunningAppProcessInfo app : runningApps) {
            if (app.pkgList != null) {
                for (String pkg : app.pkgList) {
                    extList.add(pkg);
                }
            }
        }
        IPackageManager pm = AppGlobals.getPackageManager();
        for (String pkg : extList) {
            try {
                ApplicationInfo info = pm.getApplicationInfo(pkg, 0, UserHandle.getCallingUserId());
                if ((info.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
                    retList.add(info);
                }
            } catch (RemoteException e) {
            }
        }
    }
    return retList;
}
Also used : IPackageManager(android.content.pm.IPackageManager) ArrayList(java.util.ArrayList) ApplicationInfo(android.content.pm.ApplicationInfo) ActivityManager(android.app.ActivityManager) RemoteException(android.os.RemoteException) HashSet(java.util.HashSet)

Example 32 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.

the class ActivityManagerService method getAppInfoForUser.

ApplicationInfo getAppInfoForUser(ApplicationInfo info, int userId) {
    if (info == null)
        return null;
    ApplicationInfo newInfo = new ApplicationInfo(info);
    newInfo.initForUser(userId);
    return newInfo;
}
Also used : ApplicationInfo(android.content.pm.ApplicationInfo)

Example 33 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.

the class ActivityManagerService method setSystemProcess.

public void setSystemProcess() {
    try {
        ServiceManager.addService(Context.ACTIVITY_SERVICE, this, true);
        ServiceManager.addService(ProcessStats.SERVICE_NAME, mProcessStats);
        ServiceManager.addService("meminfo", new MemBinder(this));
        ServiceManager.addService("gfxinfo", new GraphicsBinder(this));
        ServiceManager.addService("dbinfo", new DbBinder(this));
        if (MONITOR_CPU_USAGE) {
            ServiceManager.addService("cpuinfo", new CpuBinder(this));
        }
        ServiceManager.addService("permission", new PermissionController(this));
        ServiceManager.addService("processinfo", new ProcessInfoService(this));
        ApplicationInfo info = mContext.getPackageManager().getApplicationInfo("android", STOCK_PM_FLAGS | MATCH_SYSTEM_ONLY);
        mSystemThread.installSystemApplicationInfo(info, getClass().getClassLoader());
        synchronized (this) {
            ProcessRecord app = newProcessRecordLocked(info, info.processName, false, 0);
            app.persistent = true;
            app.pid = MY_PID;
            app.maxAdj = ProcessList.SYSTEM_ADJ;
            app.makeActive(mSystemThread.getApplicationThread(), mProcessStats);
            synchronized (mPidsSelfLocked) {
                mPidsSelfLocked.put(app.pid, app);
            }
            updateLruProcessLocked(app, false, null);
            updateOomAdjLocked();
        }
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Unable to find android system package", e);
    }
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) ApplicationInfo(android.content.pm.ApplicationInfo) IPermissionController(android.os.IPermissionController) IProcessInfoService(android.os.IProcessInfoService)

Example 34 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.

the class ActivityManagerService method systemReady.

public void systemReady(final Runnable goingCallback) {
    synchronized (this) {
        if (mSystemReady) {
            // by the SystemServer
            if (goingCallback != null) {
                goingCallback.run();
            }
            return;
        }
        mLocalDeviceIdleController = LocalServices.getService(DeviceIdleController.LocalService.class);
        // Make sure we have the current profile info, since it is needed for security checks.
        mUserController.onSystemReady();
        mRecentTasks.onSystemReadyLocked();
        mAppOpsService.systemReady();
        mSystemReady = true;
    }
    ArrayList<ProcessRecord> procsToKill = null;
    synchronized (mPidsSelfLocked) {
        for (int i = mPidsSelfLocked.size() - 1; i >= 0; i--) {
            ProcessRecord proc = mPidsSelfLocked.valueAt(i);
            if (!isAllowedWhileBooting(proc.info)) {
                if (procsToKill == null) {
                    procsToKill = new ArrayList<ProcessRecord>();
                }
                procsToKill.add(proc);
            }
        }
    }
    synchronized (this) {
        if (procsToKill != null) {
            for (int i = procsToKill.size() - 1; i >= 0; i--) {
                ProcessRecord proc = procsToKill.get(i);
                Slog.i(TAG, "Removing system update proc: " + proc);
                removeProcessLocked(proc, true, false, "system update done");
            }
        }
        // Now that we have cleaned up any update processes, we
        // are ready to start launching real processes and know that
        // we won't trample on them any more.
        mProcessesReady = true;
    }
    Slog.i(TAG, "System now ready");
    EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_AMS_READY, SystemClock.uptimeMillis());
    synchronized (this) {
        if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL) {
            ResolveInfo ri = mContext.getPackageManager().resolveActivity(new Intent(Intent.ACTION_FACTORY_TEST), STOCK_PM_FLAGS);
            CharSequence errorMsg = null;
            if (ri != null) {
                ActivityInfo ai = ri.activityInfo;
                ApplicationInfo app = ai.applicationInfo;
                if ((app.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                    mTopAction = Intent.ACTION_FACTORY_TEST;
                    mTopData = null;
                    mTopComponent = new ComponentName(app.packageName, ai.name);
                } else {
                    errorMsg = mContext.getResources().getText(com.android.internal.R.string.factorytest_not_system);
                }
            } else {
                errorMsg = mContext.getResources().getText(com.android.internal.R.string.factorytest_no_action);
            }
            if (errorMsg != null) {
                mTopAction = null;
                mTopData = null;
                mTopComponent = null;
                Message msg = Message.obtain();
                msg.what = SHOW_FACTORY_ERROR_UI_MSG;
                msg.getData().putCharSequence("msg", errorMsg);
                mUiHandler.sendMessage(msg);
            }
        }
    }
    retrieveSettings();
    final int currentUserId;
    synchronized (this) {
        currentUserId = mUserController.getCurrentUserIdLocked();
        readGrantedUriPermissionsLocked();
    }
    if (goingCallback != null)
        goingCallback.run();
    mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_RUNNING_START, Integer.toString(currentUserId), currentUserId);
    mBatteryStatsService.noteEvent(BatteryStats.HistoryItem.EVENT_USER_FOREGROUND_START, Integer.toString(currentUserId), currentUserId);
    mSystemServiceManager.startUser(currentUserId);
    synchronized (this) {
        // Only start up encryption-aware persistent apps; once user is
        // unlocked we'll come back around and start unaware apps
        startPersistentApps(PackageManager.MATCH_DIRECT_BOOT_AWARE);
        // Start up initial activity.
        mBooting = true;
        // Enable home activity for system user, so that the system can always boot
        if (UserManager.isSplitSystemUser()) {
            ComponentName cName = new ComponentName(mContext, SystemUserHomeActivity.class);
            try {
                AppGlobals.getPackageManager().setComponentEnabledSetting(cName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0, UserHandle.USER_SYSTEM);
            } catch (RemoteException e) {
                throw e.rethrowAsRuntimeException();
            }
        }
        startHomeActivityLocked(currentUserId, "systemReady");
        try {
            if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
                Slog.e(TAG, "UIDs on the system are inconsistent, you need to wipe your" + " data partition or your device will be unstable.");
                mUiHandler.obtainMessage(SHOW_UID_ERROR_UI_MSG).sendToTarget();
            }
        } catch (RemoteException e) {
        }
        if (!Build.isBuildConsistent()) {
            Slog.e(TAG, "Build fingerprint is not consistent, warning user");
            mUiHandler.obtainMessage(SHOW_FINGERPRINT_ERROR_UI_MSG).sendToTarget();
        }
        long ident = Binder.clearCallingIdentity();
        try {
            Intent intent = new Intent(Intent.ACTION_USER_STARTED);
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND);
            intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
            broadcastIntentLocked(null, null, intent, null, null, 0, null, null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, Process.SYSTEM_UID, currentUserId);
            intent = new Intent(Intent.ACTION_USER_STARTING);
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
            intent.putExtra(Intent.EXTRA_USER_HANDLE, currentUserId);
            broadcastIntentLocked(null, null, intent, null, new IIntentReceiver.Stub() {

                @Override
                public void performReceive(Intent intent, int resultCode, String data, Bundle extras, boolean ordered, boolean sticky, int sendingUser) throws RemoteException {
                }
            }, 0, null, null, new String[] { INTERACT_ACROSS_USERS }, AppOpsManager.OP_NONE, null, true, false, MY_PID, Process.SYSTEM_UID, UserHandle.USER_ALL);
        } catch (Throwable t) {
            Slog.wtf(TAG, "Failed sending first user broadcasts", t);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
        mStackSupervisor.resumeFocusedStackTopActivityLocked();
        mUserController.sendUserSwitchBroadcastsLocked(-1, currentUserId);
    }
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Message(android.os.Message) Bundle(android.os.Bundle) PersistableBundle(android.os.PersistableBundle) ApplicationInfo(android.content.pm.ApplicationInfo) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Point(android.graphics.Point) ResolveInfo(android.content.pm.ResolveInfo) IIntentReceiver(android.content.IIntentReceiver) ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 35 with ApplicationInfo

use of android.content.pm.ApplicationInfo in project platform_frameworks_base by android.

the class NetworkPolicyManagerService method addDefaultRestrictBackgroundWhitelistUidsUL.

private boolean addDefaultRestrictBackgroundWhitelistUidsUL(int userId) {
    final SystemConfig sysConfig = SystemConfig.getInstance();
    final PackageManager pm = mContext.getPackageManager();
    final ArraySet<String> allowDataUsage = sysConfig.getAllowInDataUsageSave();
    boolean changed = false;
    for (int i = 0; i < allowDataUsage.size(); i++) {
        final String pkg = allowDataUsage.valueAt(i);
        if (LOGD)
            Slog.d(TAG, "checking restricted background whitelisting for package " + pkg + " and user " + userId);
        final ApplicationInfo app;
        try {
            app = pm.getApplicationInfoAsUser(pkg, PackageManager.MATCH_SYSTEM_ONLY, userId);
        } catch (PackageManager.NameNotFoundException e) {
            if (LOGD)
                Slog.d(TAG, "No ApplicationInfo for package " + pkg);
            // Ignore it - some apps on allow-in-data-usage-save are optional.
            continue;
        }
        if (!app.isPrivilegedApp()) {
            Slog.e(TAG, "addDefaultRestrictBackgroundWhitelistUidsUL(): " + "skipping non-privileged app  " + pkg);
            continue;
        }
        final int uid = UserHandle.getUid(userId, app.uid);
        mDefaultRestrictBackgroundWhitelistUids.append(uid, true);
        if (LOGD)
            Slog.d(TAG, "Adding uid " + uid + " (user " + userId + ") to default restricted " + "background whitelist. Revoked status: " + mRestrictBackgroundWhitelistRevokedUids.get(uid));
        if (!mRestrictBackgroundWhitelistRevokedUids.get(uid)) {
            if (LOGD)
                Slog.d(TAG, "adding default package " + pkg + " (uid " + uid + " for user " + userId + ") to restrict background whitelist");
            mRestrictBackgroundWhitelistUids.append(uid, true);
            changed = true;
        }
    }
    return changed;
}
Also used : SystemConfig(com.android.server.SystemConfig) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ApplicationInfo(android.content.pm.ApplicationInfo) NetworkPolicyManager.uidRulesToString(android.net.NetworkPolicyManager.uidRulesToString)

Aggregations

ApplicationInfo (android.content.pm.ApplicationInfo)921 PackageManager (android.content.pm.PackageManager)345 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)274 RemoteException (android.os.RemoteException)204 Intent (android.content.Intent)103 ArrayList (java.util.ArrayList)98 IPackageManager (android.content.pm.IPackageManager)96 IOException (java.io.IOException)80 PackageInfo (android.content.pm.PackageInfo)79 ResolveInfo (android.content.pm.ResolveInfo)72 File (java.io.File)64 ComponentName (android.content.ComponentName)52 Context (android.content.Context)51 Bundle (android.os.Bundle)50 PendingIntent (android.app.PendingIntent)45 Drawable (android.graphics.drawable.Drawable)43 UserInfo (android.content.pm.UserInfo)40 ActivityInfo (android.content.pm.ActivityInfo)35 ServiceInfo (android.content.pm.ServiceInfo)35 Resources (android.content.res.Resources)33