Search in sources :

Example 26 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by AOSPA.

the class SettingsHelper method setLocaleData.

/**
     * Sets the locale specified. Input data is the byte representation of a
     * BCP-47 language tag. For backwards compatibility, strings of the form
     * {@code ll_CC} are also accepted, where {@code ll} is a two letter language
     * code and {@code CC} is a two letter country code.
     *
     * @param data the locale string in bytes.
     */
void setLocaleData(byte[] data, int size) {
    // Check if locale was set by the user:
    Configuration conf = mContext.getResources().getConfiguration();
    // Don't change if user set it in the SetupWizard
    if (conf.userSetLocale)
        return;
    final String[] availableLocales = mContext.getAssets().getLocales();
    // Replace "_" with "-" to deal with older backups.
    String localeCode = new String(data, 0, size).replace('_', '-');
    Locale loc = null;
    for (int i = 0; i < availableLocales.length; i++) {
        if (availableLocales[i].equals(localeCode)) {
            loc = Locale.forLanguageTag(localeCode);
            break;
        }
    }
    // Couldn't find the saved locale in this version of the software
    if (loc == null)
        return;
    try {
        IActivityManager am = ActivityManagerNative.getDefault();
        Configuration config = am.getConfiguration();
        config.locale = loc;
        // indicate this isn't some passing default - the user wants this remembered
        config.userSetLocale = true;
        am.updateConfiguration(config);
    } catch (RemoteException e) {
    // Intentionally left blank
    }
}
Also used : Locale(java.util.Locale) Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 27 with IActivityManager

use of android.app.IActivityManager in project android_frameworks_base by AOSPA.

the class StrictMode method dropboxViolationAsync.

/**
     * In the common case, as set by conditionallyEnableDebugLogging,
     * we're just dropboxing any violations but not showing a dialog,
     * not loggging, and not killing the process.  In these cases we
     * don't need to do a synchronous call to the ActivityManager.
     * This is used by both per-thread and vm-wide violations when
     * applicable.
     */
private static void dropboxViolationAsync(final int violationMaskSubset, final ViolationInfo info) {
    int outstanding = sDropboxCallsInFlight.incrementAndGet();
    if (outstanding > 20) {
        // What's going on?  Let's not make make the situation
        // worse and just not log.
        sDropboxCallsInFlight.decrementAndGet();
        return;
    }
    if (LOG_V)
        Log.d(TAG, "Dropboxing async; in-flight=" + outstanding);
    new Thread("callActivityManagerForStrictModeDropbox") {

        public void run() {
            Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
            try {
                IActivityManager am = ActivityManagerNative.getDefault();
                if (am == null) {
                    Log.d(TAG, "No activity manager; failed to Dropbox violation.");
                } else {
                    am.handleApplicationStrictModeViolation(RuntimeInit.getApplicationObject(), violationMaskSubset, info);
                }
            } catch (RemoteException e) {
                if (e instanceof DeadObjectException) {
                // System process is dead; ignore
                } else {
                    Log.e(TAG, "RemoteException handling StrictMode violation", e);
                }
            }
            int outstanding = sDropboxCallsInFlight.decrementAndGet();
            if (LOG_V)
                Log.d(TAG, "Dropbox complete; in-flight=" + outstanding);
        }
    }.start();
}
Also used : ActivityThread(android.app.ActivityThread) IActivityManager(android.app.IActivityManager)

Example 28 with IActivityManager

use of android.app.IActivityManager in project platform_frameworks_base by android.

the class UserManagerService method runList.

private int runList(PrintWriter pw) throws RemoteException {
    final IActivityManager am = ActivityManagerNative.getDefault();
    final List<UserInfo> users = getUsers(false);
    if (users == null) {
        pw.println("Error: couldn't get users");
        return 1;
    } else {
        pw.println("Users:");
        for (int i = 0; i < users.size(); i++) {
            String running = am.isUserRunning(users.get(i).id, 0) ? " running" : "";
            pw.println("\t" + users.get(i).toString() + running);
        }
        return 0;
    }
}
Also used : UserInfo(android.content.pm.UserInfo) IActivityManager(android.app.IActivityManager)

Example 29 with IActivityManager

use of android.app.IActivityManager in project platform_frameworks_base by android.

the class Dpm method parseArgs.

private void parseArgs(boolean canHaveName) {
    String opt;
    while ((opt = nextOption()) != null) {
        if ("--user".equals(opt)) {
            String arg = nextArgRequired();
            if ("current".equals(arg) || "cur".equals(arg)) {
                mUserId = UserHandle.USER_CURRENT;
            } else {
                mUserId = parseInt(arg);
            }
            if (mUserId == UserHandle.USER_CURRENT) {
                IActivityManager activityManager = ActivityManagerNative.getDefault();
                try {
                    mUserId = activityManager.getCurrentUser().id;
                } catch (RemoteException e) {
                    e.rethrowAsRuntimeException();
                }
            }
        } else if (canHaveName && "--name".equals(opt)) {
            mName = nextArgRequired();
        } else {
            throw new IllegalArgumentException("Unknown option: " + opt);
        }
    }
    mComponent = parseComponentName(nextArgRequired());
}
Also used : RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 30 with IActivityManager

use of android.app.IActivityManager in project platform_frameworks_base by android.

the class PackageManagerService method sendPackageAddedForUser.

private void sendPackageAddedForUser(String packageName, boolean isSystem, int appId, int userId) {
    Bundle extras = new Bundle(1);
    extras.putInt(Intent.EXTRA_UID, UserHandle.getUid(userId, appId));
    sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName, extras, 0, null, null, new int[] { userId });
    try {
        IActivityManager am = ActivityManagerNative.getDefault();
        if (isSystem && am.isUserRunning(userId, 0)) {
            // The just-installed/enabled app is bundled on the system, so presumed
            // to be able to run automatically without needing an explicit launch.
            // Send it a BOOT_COMPLETED if it would ordinarily have gotten one.
            Intent bcIntent = new Intent(Intent.ACTION_BOOT_COMPLETED).addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES).setPackage(packageName);
            am.broadcastIntent(null, bcIntent, null, null, 0, null, null, null, android.app.AppOpsManager.OP_NONE, null, false, false, userId);
        }
    } catch (RemoteException e) {
        // shouldn't happen
        Slog.w(TAG, "Unable to bootstrap installed package", e);
    }
}
Also used : Bundle(android.os.Bundle) Intent(android.content.Intent) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Aggregations

IActivityManager (android.app.IActivityManager)112 RemoteException (android.os.RemoteException)93 Intent (android.content.Intent)23 IBinder (android.os.IBinder)20 Configuration (android.content.res.Configuration)15 UserHandle (android.os.UserHandle)14 ContentProviderHolder (android.app.IActivityManager.ContentProviderHolder)11 IContentProvider (android.content.IContentProvider)11 Binder (android.os.Binder)11 ActivityOptions (android.app.ActivityOptions)9 ActivityThread (android.app.ActivityThread)9 Context (android.content.Context)8 IntentSender (android.content.IntentSender)8 Point (android.graphics.Point)7 SpannableString (android.text.SpannableString)7 BroadcastReceiver (android.content.BroadcastReceiver)6 ComponentName (android.content.ComponentName)6 IMountService (android.os.storage.IMountService)6 IMountShutdownObserver (android.os.storage.IMountShutdownObserver)6 Locale (java.util.Locale)6