Search in sources :

Example 16 with RemoteException

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

the class Wm method runDisplayOverscan.

private void runDisplayOverscan() throws Exception {
    String overscanStr = nextArgRequired();
    Rect rect = new Rect();
    int density;
    if ("reset".equals(overscanStr)) {
        rect.set(0, 0, 0, 0);
    } else {
        final Pattern FLATTENED_PATTERN = Pattern.compile("(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+)");
        Matcher matcher = FLATTENED_PATTERN.matcher(overscanStr);
        if (!matcher.matches()) {
            System.err.println("Error: bad rectangle arg: " + overscanStr);
            return;
        }
        rect.left = Integer.parseInt(matcher.group(1));
        rect.top = Integer.parseInt(matcher.group(2));
        rect.right = Integer.parseInt(matcher.group(3));
        rect.bottom = Integer.parseInt(matcher.group(4));
    }
    try {
        mWm.setOverscan(Display.DEFAULT_DISPLAY, rect.left, rect.top, rect.right, rect.bottom);
    } catch (RemoteException e) {
    }
}
Also used : Pattern(java.util.regex.Pattern) Rect(android.graphics.Rect) Matcher(java.util.regex.Matcher) RemoteException(android.os.RemoteException) Point(android.graphics.Point)

Example 17 with RemoteException

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

the class ChooseTypeAndAccountActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "ChooseTypeAndAccountActivity.onCreate(savedInstanceState=" + savedInstanceState + ")");
    }
    String message = null;
    try {
        IBinder activityToken = getActivityToken();
        mCallingUid = ActivityManagerNative.getDefault().getLaunchedFromUid(activityToken);
        mCallingPackage = ActivityManagerNative.getDefault().getLaunchedFromPackage(activityToken);
        if (mCallingUid != 0 && mCallingPackage != null) {
            Bundle restrictions = UserManager.get(this).getUserRestrictions(new UserHandle(UserHandle.getUserId(mCallingUid)));
            mDisallowAddAccounts = restrictions.getBoolean(UserManager.DISALLOW_MODIFY_ACCOUNTS, false);
        }
    } catch (RemoteException re) {
        // Couldn't figure out caller details
        Log.w(getClass().getSimpleName(), "Unable to get caller identity \n" + re);
    }
    // save some items we use frequently
    final Intent intent = getIntent();
    if (savedInstanceState != null) {
        mPendingRequest = savedInstanceState.getInt(KEY_INSTANCE_STATE_PENDING_REQUEST);
        mExistingAccounts = savedInstanceState.getParcelableArray(KEY_INSTANCE_STATE_EXISTING_ACCOUNTS);
        // Makes sure that any user selection is preserved across orientation changes.
        mSelectedAccountName = savedInstanceState.getString(KEY_INSTANCE_STATE_SELECTED_ACCOUNT_NAME);
        mSelectedAddNewAccount = savedInstanceState.getBoolean(KEY_INSTANCE_STATE_SELECTED_ADD_ACCOUNT, false);
        mAccounts = savedInstanceState.getParcelableArrayList(KEY_INSTANCE_STATE_ACCOUNT_LIST);
    } else {
        mPendingRequest = REQUEST_NULL;
        mExistingAccounts = null;
        // If the selected account as specified in the intent matches one in the list we will
        // show is as pre-selected.
        Account selectedAccount = (Account) intent.getParcelableExtra(EXTRA_SELECTED_ACCOUNT);
        if (selectedAccount != null) {
            mSelectedAccountName = selectedAccount.name;
        }
    }
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "selected account name is " + mSelectedAccountName);
    }
    mSetOfAllowableAccounts = getAllowableAccountSet(intent);
    mSetOfRelevantAccountTypes = getReleventAccountTypes(intent);
    mAlwaysPromptForAccount = intent.getBooleanExtra(EXTRA_ALWAYS_PROMPT_FOR_ACCOUNT, false);
    mDescriptionOverride = intent.getStringExtra(EXTRA_DESCRIPTION_TEXT_OVERRIDE);
}
Also used : IBinder(android.os.IBinder) Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 18 with RemoteException

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

the class Bmgr method doRestoreAll.

private void doRestoreAll(long token, HashSet<String> filter) {
    RestoreObserver observer = new RestoreObserver();
    try {
        boolean didRestore = false;
        mRestore = mBmgr.beginRestoreSession(null, null);
        if (mRestore == null) {
            System.err.println(BMGR_NOT_RUNNING_ERR);
            return;
        }
        RestoreSet[] sets = null;
        int err = mRestore.getAvailableRestoreSets(observer);
        if (err == 0) {
            observer.waitForCompletion();
            sets = observer.sets;
            if (sets != null) {
                for (RestoreSet s : sets) {
                    if (s.token == token) {
                        System.out.println("Scheduling restore: " + s.name);
                        if (filter == null) {
                            didRestore = (mRestore.restoreAll(token, observer) == 0);
                        } else {
                            String[] names = new String[filter.size()];
                            filter.toArray(names);
                            didRestore = (mRestore.restoreSome(token, observer, names) == 0);
                        }
                        break;
                    }
                }
            }
        }
        if (!didRestore) {
            if (sets == null || sets.length == 0) {
                System.out.println("No available restore sets; no restore performed");
            } else {
                System.out.println("No matching restore set token.  Available sets:");
                printRestoreSets(sets);
            }
        }
        // to complete before we can shut down the restore session safely
        if (didRestore) {
            observer.waitForCompletion();
        }
        // once the restore has finished, close down the session and we're done
        mRestore.endRestoreSession();
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(BMGR_NOT_RUNNING_ERR);
    }
}
Also used : IRestoreObserver(android.app.backup.IRestoreObserver) RestoreSet(android.app.backup.RestoreSet) RemoteException(android.os.RemoteException)

Example 19 with RemoteException

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

the class Bmgr method doListRestoreSets.

private void doListRestoreSets() {
    try {
        RestoreObserver observer = new RestoreObserver();
        int err = mRestore.getAvailableRestoreSets(observer);
        if (err != 0) {
            System.out.println("Unable to request restore sets");
        } else {
            observer.waitForCompletion();
            printRestoreSets(observer.sets);
        }
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(TRANSPORT_NOT_RUNNING_ERR);
    }
}
Also used : IRestoreObserver(android.app.backup.IRestoreObserver) RemoteException(android.os.RemoteException)

Example 20 with RemoteException

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

the class Activity method finish.

/**
     * Call this when your activity is done and should be closed.  The
     * ActivityResult is propagated back to whoever launched you via
     * onActivityResult().
     */
public void finish() {
    if (mParent == null) {
        int resultCode;
        Intent resultData;
        synchronized (this) {
            resultCode = mResultCode;
            resultData = mResultData;
        }
        if (false)
            Log.v(TAG, "Finishing self: token=" + mToken);
        try {
            if (resultData != null) {
                resultData.prepareToLeaveProcess();
            }
            if (ActivityManagerNative.getDefault().finishActivity(mToken, resultCode, resultData)) {
                mFinished = true;
            }
        } catch (RemoteException e) {
        // Empty
        }
    } else {
        mParent.finishFromChild(this);
    }
}
Also used : Intent(android.content.Intent) 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