Search in sources :

Example 1 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class AccountManager method getAuthToken.

/**
     * Gets an auth token of the specified type for a particular account,
     * prompting the user for credentials if necessary.  This method is
     * intended for applications running in the foreground where it makes
     * sense to ask the user directly for a password.
     *
     * <p>If a previously generated auth token is cached for this account and
     * type, then it is returned.  Otherwise, if a saved password is
     * available, it is sent to the server to generate a new auth token.
     * Otherwise, the user is prompted to enter a password.
     *
     * <p>Some authenticators have auth token <em>types</em>, whose value
     * is authenticator-dependent.  Some services use different token types to
     * access different functionality -- for example, Google uses different auth
     * tokens to access Gmail and Google Calendar for the same account.
     *
     * <p>This method may be called from any thread, but the returned
     * {@link AccountManagerFuture} must not be used on the main thread.
     *
     * <p>This method requires the caller to hold the permission
     * {@link android.Manifest.permission#USE_CREDENTIALS}.
     *
     * @param account The account to fetch an auth token for
     * @param authTokenType The auth token type, an authenticator-dependent
     *     string token, must not be null
     * @param options Authenticator-specific options for the request,
     *     may be null or empty
     * @param activity The {@link Activity} context to use for launching a new
     *     authenticator-defined sub-Activity to prompt the user for a password
     *     if necessary; used only to call startActivity(); must not be null.
     * @param callback Callback to invoke when the request completes,
     *     null for no callback
     * @param handler {@link Handler} identifying the callback thread,
     *     null for the main thread
     * @return An {@link AccountManagerFuture} which resolves to a Bundle with
     *     at least the following fields:
     * <ul>
     * <li> {@link #KEY_ACCOUNT_NAME} - the name of the account you supplied
     * <li> {@link #KEY_ACCOUNT_TYPE} - the type of the account
     * <li> {@link #KEY_AUTHTOKEN} - the auth token you wanted
     * </ul>
     *
     * (Other authenticator-specific values may be returned.)  If an auth token
     * could not be fetched, {@link AccountManagerFuture#getResult()} throws:
     * <ul>
     * <li> {@link AuthenticatorException} if the authenticator failed to respond
     * <li> {@link OperationCanceledException} if the operation is canceled for
     *      any reason, incluidng the user canceling a credential request
     * <li> {@link IOException} if the authenticator experienced an I/O problem
     *      creating a new auth token, usually because of network trouble
     * </ul>
     * If the account is no longer present on the device, the return value is
     * authenticator-dependent.  The caller should verify the validity of the
     * account before requesting an auth token.
     */
public AccountManagerFuture<Bundle> getAuthToken(final Account account, final String authTokenType, final Bundle options, final Activity activity, AccountManagerCallback<Bundle> callback, Handler handler) {
    if (account == null)
        throw new IllegalArgumentException("account is null");
    if (authTokenType == null)
        throw new IllegalArgumentException("authTokenType is null");
    final Bundle optionsIn = new Bundle();
    if (options != null) {
        optionsIn.putAll(options);
    }
    optionsIn.putString(KEY_ANDROID_PACKAGE_NAME, mContext.getPackageName());
    return new AmsTask(activity, handler, callback) {

        public void doWork() throws RemoteException {
            mService.getAuthToken(mResponse, account, authTokenType, false, /* notifyOnAuthFailure */
            true, /* expectActivityLaunch */
            optionsIn);
        }
    }.start();
}
Also used : Bundle(android.os.Bundle) RemoteException(android.os.RemoteException)

Example 2 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class Bmgr method doRestorePackage.

private void doRestorePackage(String pkg) {
    try {
        mRestore = mBmgr.beginRestoreSession(pkg, null);
        if (mRestore == null) {
            System.err.println(BMGR_NOT_RUNNING_ERR);
            return;
        }
        RestoreObserver observer = new RestoreObserver();
        int err = mRestore.restorePackage(pkg, observer);
        if (err == 0) {
            // Off and running -- wait for the restore to complete
            observer.waitForCompletion();
        } else {
            System.err.println("Unable to restore package " + pkg);
        }
        // And finally shut down the session
        mRestore.endRestoreSession();
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(BMGR_NOT_RUNNING_ERR);
    }
}
Also used : IRestoreObserver(android.app.backup.IRestoreObserver) RemoteException(android.os.RemoteException)

Example 3 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class Ime method runList.

/**
     * Execute the list sub-command.
     */
private void runList() {
    String opt;
    boolean all = false;
    boolean brief = false;
    while ((opt = nextOption()) != null) {
        if (opt.equals("-a")) {
            all = true;
        } else if (opt.equals("-s")) {
            brief = true;
        } else {
            System.err.println("Error: Unknown option: " + opt);
            showUsage();
            return;
        }
    }
    List<InputMethodInfo> methods;
    if (!all) {
        try {
            methods = mImm.getEnabledInputMethodList();
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(IMM_NOT_RUNNING_ERR);
            return;
        }
    } else {
        try {
            methods = mImm.getInputMethodList();
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(IMM_NOT_RUNNING_ERR);
            return;
        }
    }
    if (methods != null) {
        Printer pr = new PrintStreamPrinter(System.out);
        for (int i = 0; i < methods.size(); i++) {
            InputMethodInfo imi = methods.get(i);
            if (brief) {
                System.out.println(imi.getId());
            } else {
                System.out.println(imi.getId() + ":");
                imi.dump(pr, "  ");
            }
        }
    }
}
Also used : PrintStreamPrinter(android.util.PrintStreamPrinter) RemoteException(android.os.RemoteException) PrintStreamPrinter(android.util.PrintStreamPrinter) Printer(android.util.Printer) InputMethodInfo(android.view.inputmethod.InputMethodInfo)

Example 4 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class Pm method runSetEnabledSetting.

private void runSetEnabledSetting(int state) {
    int userId = 0;
    String option = nextOption();
    if (option != null && option.equals("--user")) {
        String optionData = nextOptionData();
        if (optionData == null || !isNumber(optionData)) {
            System.err.println("Error: no USER_ID specified");
            showUsage();
            return;
        } else {
            userId = Integer.parseInt(optionData);
        }
    }
    String pkg = nextArg();
    if (pkg == null) {
        System.err.println("Error: no package or component specified");
        showUsage();
        return;
    }
    ComponentName cn = ComponentName.unflattenFromString(pkg);
    if (cn == null) {
        try {
            mPm.setApplicationEnabledSetting(pkg, state, 0, userId, "shell:" + android.os.Process.myUid());
            System.err.println("Package " + pkg + " new state: " + enabledSettingToString(mPm.getApplicationEnabledSetting(pkg, userId)));
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(PM_NOT_RUNNING_ERR);
        }
    } else {
        try {
            mPm.setComponentEnabledSetting(cn, state, 0, userId);
            System.err.println("Component " + cn.toShortString() + " new state: " + enabledSettingToString(mPm.getComponentEnabledSetting(cn, userId)));
        } catch (RemoteException e) {
            System.err.println(e.toString());
            System.err.println(PM_NOT_RUNNING_ERR);
        }
    }
}
Also used : ComponentName(android.content.ComponentName) RemoteException(android.os.RemoteException)

Example 5 with RemoteException

use of android.os.RemoteException in project android_frameworks_base by ParanoidAndroid.

the class Pm method getResources.

private Resources getResources(PackageItemInfo pii) {
    Resources res = mResourceCache.get(pii.packageName);
    if (res != null)
        return res;
    try {
        ApplicationInfo ai = mPm.getApplicationInfo(pii.packageName, 0, 0);
        AssetManager am = new AssetManager();
        am.addAssetPath(ai.publicSourceDir);
        res = new Resources(am, null, null);
        mResourceCache.put(pii.packageName, res);
        return res;
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(PM_NOT_RUNNING_ERR);
        return null;
    }
}
Also used : AssetManager(android.content.res.AssetManager) ApplicationInfo(android.content.pm.ApplicationInfo) Resources(android.content.res.Resources) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)4527 Intent (android.content.Intent)595 IBinder (android.os.IBinder)480 Bundle (android.os.Bundle)461 Point (android.graphics.Point)423 IOException (java.io.IOException)381 PendingIntent (android.app.PendingIntent)274 ComponentName (android.content.ComponentName)265 ArrayList (java.util.ArrayList)248 ApplicationInfo (android.content.pm.ApplicationInfo)190 IPackageManager (android.content.pm.IPackageManager)190 Message (android.os.Message)184 Uri (android.net.Uri)157 UserHandle (android.os.UserHandle)154 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)151 Cursor (android.database.Cursor)150 Configuration (android.content.res.Configuration)133 UserInfo (android.content.pm.UserInfo)129 AndroidRuntimeException (android.util.AndroidRuntimeException)128 ParcelFileDescriptor (android.os.ParcelFileDescriptor)126