Search in sources :

Example 36 with IActivityManager

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

the class LocalePicker method updateLocales.

/**
     * Requests the system to update the list of system locales.
     * Note that the system looks halted for a while during the Locale migration,
     * so the caller need to take care of it.
     */
public static void updateLocales(LocaleList locales) {
    try {
        final IActivityManager am = ActivityManagerNative.getDefault();
        final Configuration config = am.getConfiguration();
        config.setLocales(locales);
        config.userSetLocale = true;
        am.updatePersistentConfiguration(config);
        // Trigger the dirty bit for the Settings Provider.
        BackupManager.dataChanged("com.android.providers.settings");
    } catch (RemoteException e) {
    // Intentionally left blank
    }
}
Also used : Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 37 with IActivityManager

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

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 38 with IActivityManager

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

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 39 with IActivityManager

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

the class LocalePicker method updateLocales.

/**
     * Requests the system to update the list of system locales.
     * Note that the system looks halted for a while during the Locale migration,
     * so the caller need to take care of it.
     */
public static void updateLocales(LocaleList locales) {
    try {
        final IActivityManager am = ActivityManagerNative.getDefault();
        final Configuration config = am.getConfiguration();
        config.setLocales(locales);
        config.userSetLocale = true;
        am.updatePersistentConfiguration(config);
        // Trigger the dirty bit for the Settings Provider.
        BackupManager.dataChanged("com.android.providers.settings");
    } catch (RemoteException e) {
    // Intentionally left blank
    }
}
Also used : Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 40 with IActivityManager

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

the class SettingsCmd method run.

public void run() {
    boolean valid = false;
    String arg;
    try {
        while ((arg = nextArg()) != null) {
            if ("--user".equals(arg)) {
                if (mUser != -1) {
                    // --user specified more than once; invalid
                    break;
                }
                arg = nextArg();
                if ("current".equals(arg) || "cur".equals(arg)) {
                    mUser = UserHandle.USER_CURRENT;
                } else {
                    mUser = Integer.parseInt(arg);
                }
            } else if ("--cm".equals(arg)) {
                mUseCMSettingsProvider = true;
            } else if (mVerb == CommandVerb.UNSPECIFIED) {
                if ("get".equalsIgnoreCase(arg)) {
                    mVerb = CommandVerb.GET;
                } else if ("put".equalsIgnoreCase(arg)) {
                    mVerb = CommandVerb.PUT;
                } else if ("delete".equalsIgnoreCase(arg)) {
                    mVerb = CommandVerb.DELETE;
                } else if ("list".equalsIgnoreCase(arg)) {
                    mVerb = CommandVerb.LIST;
                } else {
                    // invalid
                    System.err.println("Invalid command: " + arg);
                    break;
                }
            } else if (mTable == null) {
                if (!"system".equalsIgnoreCase(arg) && !"secure".equalsIgnoreCase(arg) && !"global".equalsIgnoreCase(arg)) {
                    System.err.println("Invalid namespace '" + arg + "'");
                    // invalid
                    break;
                }
                mTable = arg.toLowerCase();
                if (mVerb == CommandVerb.LIST) {
                    valid = true;
                    break;
                }
            } else if (mVerb == CommandVerb.GET || mVerb == CommandVerb.DELETE) {
                mKey = arg;
                if (mNextArg >= mArgs.length) {
                    valid = true;
                } else {
                    System.err.println("Too many arguments");
                }
                break;
            } else if (mKey == null) {
                mKey = arg;
            // keep going; there's another PUT arg
            } else {
                // PUT, final arg
                mValue = arg;
                if (mNextArg >= mArgs.length) {
                    valid = true;
                } else {
                    System.err.println("Too many arguments");
                }
                break;
            }
        }
    } catch (Exception e) {
        valid = false;
    }
    if (valid) {
        try {
            IActivityManager activityManager = ActivityManagerNative.getDefault();
            if (mUser == UserHandle.USER_CURRENT) {
                mUser = activityManager.getCurrentUser().id;
            }
            if (mUser < 0) {
                mUser = UserHandle.USER_SYSTEM;
            }
            IContentProvider provider = null;
            IBinder token = new Binder();
            try {
                ContentProviderHolder holder = activityManager.getContentProviderExternal(mUseCMSettingsProvider ? CMSettings.AUTHORITY : Settings.AUTHORITY, UserHandle.USER_SYSTEM, token);
                if (holder == null) {
                    throw new IllegalStateException("Could not find settings provider");
                }
                provider = holder.provider;
                switch(mVerb) {
                    case GET:
                        System.out.println(getForUser(provider, mUser, mTable, mKey));
                        break;
                    case PUT:
                        putForUser(provider, mUser, mTable, mKey, mValue);
                        break;
                    case DELETE:
                        System.out.println("Deleted " + deleteForUser(provider, mUser, mTable, mKey) + " rows");
                        break;
                    case LIST:
                        for (String line : listForUser(provider, mUser, mTable)) {
                            System.out.println(line);
                        }
                        break;
                    default:
                        System.err.println("Unspecified command");
                        break;
                }
            } finally {
                if (provider != null) {
                    activityManager.removeContentProviderExternal("settings", token);
                }
            }
        } catch (Exception e) {
            System.err.println("Error while accessing settings provider");
            e.printStackTrace();
        }
    } else {
        printUsage();
    }
}
Also used : IBinder(android.os.IBinder) Binder(android.os.Binder) IBinder(android.os.IBinder) IContentProvider(android.content.IContentProvider) ContentProviderHolder(android.app.IActivityManager.ContentProviderHolder) 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