Search in sources :

Example 11 with ResultInfo

use of android.app.ResultInfo in project cornerstone by Onskreen.

the class ActivityStack method relaunchActivityLocked.

private final boolean relaunchActivityLocked(ActivityRecord r, int changes, boolean andResume) {
    List<ResultInfo> results = null;
    List<Intent> newIntents = null;
    if (andResume) {
        results = r.results;
        newIntents = r.newIntents;
    }
    if (DEBUG_SWITCH)
        Slog.v(TAG, "Relaunching: " + r + " with results=" + results + " newIntents=" + newIntents + " andResume=" + andResume);
    EventLog.writeEvent(andResume ? EventLogTags.AM_RELAUNCH_RESUME_ACTIVITY : EventLogTags.AM_RELAUNCH_ACTIVITY, System.identityHashCode(r), r.task.taskId, r.shortComponentName);
    r.startFreezingScreenLocked(r.app, 0);
    try {
        /**
             * Author: Onskreen
             * Date: 26/12/2011
             *
             * r.configuration contains all the changes.
             */
        if (DEBUG_SWITCH || DEBUG_STATES)
            Slog.i(TAG, (andResume ? "Relaunching to RESUMED " : "Relaunching to PAUSED ") + r);
        r.forceNewConfig = false;
        r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents, changes, !andResume, new Configuration(r.configuration));
    // Note: don't need to call pauseIfSleepingLocked() here, because
    // the caller will only pass in 'andResume' if this activity is
    // currently resumed, which implies we aren't sleeping.
    } catch (RemoteException e) {
        if (DEBUG_SWITCH || DEBUG_STATES)
            Slog.i(TAG, "Relaunch failed", e);
    }
    if (andResume) {
        r.results = null;
        r.newIntents = null;
        if (mMainStack || mCornerstoneStack || mCornerstonePanelStack) {
            mService.reportResumedActivityLocked(r);
        }
        r.state = ActivityState.RESUMED;
    } else {
        mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r);
        r.state = ActivityState.PAUSED;
    }
    return true;
}
Also used : Configuration(android.content.res.Configuration) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ResultInfo(android.app.ResultInfo) RemoteException(android.os.RemoteException)

Example 12 with ResultInfo

use of android.app.ResultInfo in project cornerstone by Onskreen.

the class ActivityStack method realStartActivityLocked.

final boolean realStartActivityLocked(ActivityRecord r, ProcessRecord app, boolean andResume, boolean checkConfig) throws RemoteException {
    r.startFreezingScreenLocked(app, 0);
    mService.mWindowManager.setAppVisibility(r.appToken, true);
    /**
         * Author: Onskreen
         * Date: 26/12/2011
         *
         * Determine the WindowPanel specific config.
         */
    Configuration wpConfig = mService.mWindowManager.computeWindowPanelConfiguration(getWindowPanel());
    // schedule launch ticks to collect information about slow apps.
    r.startLaunchTickingLocked();
    // just restarting it anyway.
    if (checkConfig) {
        Configuration config = mService.mWindowManager.updateOrientationFromAppTokens(mService.mConfiguration, r.mayFreezeScreenLocked(app) ? r.appToken : null);
        mService.updateConfigurationLocked(config, r, false, false);
    }
    r.app = app;
    app.waitingToKill = null;
    if (localLOGV)
        Slog.v(TAG, "Launching: " + r);
    int idx = app.activities.indexOf(r);
    if (idx < 0) {
        app.activities.add(r);
    }
    mService.updateLruProcessLocked(app, true, true);
    try {
        if (app.thread == null) {
            throw new RemoteException();
        }
        List<ResultInfo> results = null;
        List<Intent> newIntents = null;
        if (andResume) {
            results = r.results;
            newIntents = r.newIntents;
        }
        if (DEBUG_SWITCH)
            Slog.v(TAG, "Launching: " + r + " icicle=" + r.icicle + " with results=" + results + " newIntents=" + newIntents + " andResume=" + andResume);
        if (andResume) {
            EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY, System.identityHashCode(r), r.task.taskId, r.shortComponentName);
        }
        if (r.isHomeActivity) {
            mService.mHomeProcess = app;
        }
        mService.ensurePackageDexOpt(r.intent.getComponent().getPackageName());
        r.sleeping = false;
        r.forceNewConfig = false;
        showAskCompatModeDialogLocked(r);
        r.compat = mService.compatibilityInfoForPackageLocked(r.info.applicationInfo);
        String profileFile = null;
        ParcelFileDescriptor profileFd = null;
        boolean profileAutoStop = false;
        if (mService.mProfileApp != null && mService.mProfileApp.equals(app.processName)) {
            if (mService.mProfileProc == null || mService.mProfileProc == app) {
                mService.mProfileProc = app;
                profileFile = mService.mProfileFile;
                profileFd = mService.mProfileFd;
                profileAutoStop = mService.mAutoStopProfiler;
            }
        }
        app.hasShownUi = true;
        app.pendingUiClean = true;
        if (profileFd != null) {
            try {
                profileFd = profileFd.dup();
            } catch (IOException e) {
                profileFd = null;
            }
        }
        /**
             * Author: Onskreen
             * Date: 26/12/2011
             *
             * Starting the activity with the wp specific activity instead of the default
             * AMS.mConfiguration.
             */
        app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken, System.identityHashCode(r), r.info, new Configuration(wpConfig), r.compat, r.icicle, results, newIntents, !andResume, mService.isNextTransitionForward(), profileFile, profileFd, profileAutoStop);
        if ((app.info.flags & ApplicationInfo.FLAG_CANT_SAVE_STATE) != 0) {
            // considered heavy-weight.
            if (app.processName.equals(app.info.packageName)) {
                if (mService.mHeavyWeightProcess != null && mService.mHeavyWeightProcess != app) {
                    Log.w(TAG, "Starting new heavy weight process " + app + " when already running " + mService.mHeavyWeightProcess);
                }
                mService.mHeavyWeightProcess = app;
                Message msg = mService.mHandler.obtainMessage(ActivityManagerService.POST_HEAVY_NOTIFICATION_MSG);
                msg.obj = r;
                mService.mHandler.sendMessage(msg);
            }
        }
    } catch (RemoteException e) {
        if (r.launchFailed) {
            // This is the second time we failed -- finish activity
            // and give up.
            Slog.e(TAG, "Second failure launching " + r.intent.getComponent().flattenToShortString() + ", giving up", e);
            mService.appDiedLocked(app, app.pid, app.thread);
            requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "2nd-crash");
            return false;
        }
        // This is the first time we failed -- restart process and
        // retry.
        app.activities.remove(r);
        throw e;
    }
    r.launchFailed = false;
    if (updateLRUListLocked(r)) {
        Slog.w(TAG, "Activity " + r + " being launched, but already in LRU list");
    }
    if (andResume) {
        // As part of the process of launching, ActivityThread also performs
        // a resume.
        r.state = ActivityState.RESUMED;
        if (DEBUG_STATES)
            Slog.v(TAG, "Moving to RESUMED: " + r + " (starting new instance)");
        r.stopped = false;
        mResumedActivity = r;
        r.task.touchActiveTime();
        if (mMainStack) {
            mService.addRecentTaskLocked(r.task);
        }
        completeResumeLocked(r);
        checkReadyForSleepLocked();
        if (DEBUG_SAVED_STATE)
            Slog.i(TAG, "Launch completed; removing icicle of " + r.icicle);
        r.icicle = null;
        r.haveState = false;
    } else {
        // other state.
        if (DEBUG_STATES)
            Slog.v(TAG, "Moving to STOPPED: " + r + " (starting in stopped state)");
        r.state = ActivityState.STOPPED;
        r.stopped = true;
    }
    // switch back to it faster and look better.
    if (mMainStack) {
        mService.startSetupActivityLocked();
    }
    return true;
}
Also used : Configuration(android.content.res.Configuration) Message(android.os.Message) ParcelFileDescriptor(android.os.ParcelFileDescriptor) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) IOException(java.io.IOException) RemoteException(android.os.RemoteException) ResultInfo(android.app.ResultInfo)

Example 13 with ResultInfo

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

the class ActivityStackSupervisor method realStartActivityLocked.

final boolean realStartActivityLocked(ActivityRecord r, ProcessRecord app, boolean andResume, boolean checkConfig) throws RemoteException {
    if (!allPausedActivitiesComplete()) {
        // the paused state because they will first be resumed then paused on the client side.
        if (DEBUG_SWITCH || DEBUG_PAUSE || DEBUG_STATES)
            Slog.v(TAG_PAUSE, "realStartActivityLocked: Skipping start of r=" + r + " some activities pausing...");
        return false;
    }
    if (andResume) {
        r.startFreezingScreenLocked(app, 0);
        mWindowManager.setAppVisibility(r.appToken, true);
        // schedule launch ticks to collect information about slow apps.
        r.startLaunchTickingLocked();
    }
    // just restarting it anyway.
    if (checkConfig) {
        Configuration config = mWindowManager.updateOrientationFromAppTokens(mService.mConfiguration, r.mayFreezeScreenLocked(app) ? r.appToken : null);
        // Deferring resume here because we're going to launch new activity shortly.
        // We don't want to perform a redundant launch of the same record while ensuring
        // configurations and trying to resume top activity of focused stack.
        mService.updateConfigurationLocked(config, r, false, true);
    }
    r.app = app;
    app.waitingToKill = null;
    r.launchCount++;
    r.lastLaunchTime = SystemClock.uptimeMillis();
    if (DEBUG_ALL)
        Slog.v(TAG, "Launching: " + r);
    int idx = app.activities.indexOf(r);
    if (idx < 0) {
        app.activities.add(r);
    }
    mService.updateLruProcessLocked(app, true, null);
    mService.updateOomAdjLocked();
    final TaskRecord task = r.task;
    if (task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE || task.mLockTaskAuth == LOCK_TASK_AUTH_LAUNCHABLE_PRIV) {
        setLockTaskModeLocked(task, LOCK_TASK_MODE_LOCKED, "mLockTaskAuth==LAUNCHABLE", false);
    }
    final ActivityStack stack = task.stack;
    try {
        if (app.thread == null) {
            throw new RemoteException();
        }
        List<ResultInfo> results = null;
        List<ReferrerIntent> newIntents = null;
        if (andResume) {
            results = r.results;
            newIntents = r.newIntents;
        }
        if (DEBUG_SWITCH)
            Slog.v(TAG_SWITCH, "Launching: " + r + " icicle=" + r.icicle + " with results=" + results + " newIntents=" + newIntents + " andResume=" + andResume);
        if (andResume) {
            EventLog.writeEvent(EventLogTags.AM_RESTART_ACTIVITY, r.userId, System.identityHashCode(r), task.taskId, r.shortComponentName);
        }
        if (r.isHomeActivity()) {
            // Home process is the root process of the task.
            mService.mHomeProcess = task.mActivities.get(0).app;
        }
        mService.notifyPackageUse(r.intent.getComponent().getPackageName(), PackageManager.NOTIFY_PACKAGE_USE_ACTIVITY);
        r.sleeping = false;
        r.forceNewConfig = false;
        mService.showUnsupportedZoomDialogIfNeededLocked(r);
        mService.showAskCompatModeDialogLocked(r);
        r.compat = mService.compatibilityInfoForPackageLocked(r.info.applicationInfo);
        ProfilerInfo profilerInfo = null;
        if (mService.mProfileApp != null && mService.mProfileApp.equals(app.processName)) {
            if (mService.mProfileProc == null || mService.mProfileProc == app) {
                mService.mProfileProc = app;
                final String profileFile = mService.mProfileFile;
                if (profileFile != null) {
                    ParcelFileDescriptor profileFd = mService.mProfileFd;
                    if (profileFd != null) {
                        try {
                            profileFd = profileFd.dup();
                        } catch (IOException e) {
                            if (profileFd != null) {
                                try {
                                    profileFd.close();
                                } catch (IOException o) {
                                }
                                profileFd = null;
                            }
                        }
                    }
                    profilerInfo = new ProfilerInfo(profileFile, profileFd, mService.mSamplingInterval, mService.mAutoStopProfiler);
                }
            }
        }
        if (andResume) {
            app.hasShownUi = true;
            app.pendingUiClean = true;
        }
        app.forceProcessStateUpTo(mService.mTopProcessState);
        app.thread.scheduleLaunchActivity(new Intent(r.intent), r.appToken, System.identityHashCode(r), r.info, new Configuration(mService.mConfiguration), new Configuration(task.mOverrideConfig), r.compat, r.launchedFromPackage, task.voiceInteractor, app.repProcState, r.icicle, r.persistentState, results, newIntents, !andResume, mService.isNextTransitionForward(), profilerInfo);
        if ((app.info.privateFlags & ApplicationInfo.PRIVATE_FLAG_CANT_SAVE_STATE) != 0) {
            // considered heavy-weight.
            if (app.processName.equals(app.info.packageName)) {
                if (mService.mHeavyWeightProcess != null && mService.mHeavyWeightProcess != app) {
                    Slog.w(TAG, "Starting new heavy weight process " + app + " when already running " + mService.mHeavyWeightProcess);
                }
                mService.mHeavyWeightProcess = app;
                Message msg = mService.mHandler.obtainMessage(ActivityManagerService.POST_HEAVY_NOTIFICATION_MSG);
                msg.obj = r;
                mService.mHandler.sendMessage(msg);
            }
        }
    } catch (RemoteException e) {
        if (r.launchFailed) {
            // This is the second time we failed -- finish activity
            // and give up.
            Slog.e(TAG, "Second failure launching " + r.intent.getComponent().flattenToShortString() + ", giving up", e);
            mService.appDiedLocked(app);
            stack.requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null, "2nd-crash", false);
            return false;
        }
        // This is the first time we failed -- restart process and
        // retry.
        app.activities.remove(r);
        throw e;
    }
    r.launchFailed = false;
    if (stack.updateLRUListLocked(r)) {
        Slog.w(TAG, "Activity " + r + " being launched, but already in LRU list");
    }
    if (andResume) {
        // As part of the process of launching, ActivityThread also performs
        // a resume.
        stack.minimalResumeActivityLocked(r);
    } else {
        // current icicle and other state.
        if (DEBUG_STATES)
            Slog.v(TAG_STATES, "Moving to PAUSED: " + r + " (starting in paused state)");
        r.state = PAUSED;
    }
    // switch back to it faster and look better.
    if (isFocusedStack(stack)) {
        mService.startSetupActivityLocked();
    }
    // their client may have activities.
    if (r.app != null) {
        mService.mServices.updateServiceConnectionActivitiesLocked(r.app);
    }
    return true;
}
Also used : ProfilerInfo(android.app.ProfilerInfo) Configuration(android.content.res.Configuration) ReferrerIntent(com.android.internal.content.ReferrerIntent) Message(android.os.Message) ReferrerIntent(com.android.internal.content.ReferrerIntent) Intent(android.content.Intent) IOException(java.io.IOException) ParcelFileDescriptor(android.os.ParcelFileDescriptor) RemoteException(android.os.RemoteException) ResultInfo(android.app.ResultInfo)

Example 14 with ResultInfo

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

the class ActivityStack method sendActivityResultLocked.

void sendActivityResultLocked(int callingUid, ActivityRecord r, String resultWho, int requestCode, int resultCode, Intent data) {
    if (callingUid > 0) {
        mService.grantUriPermissionFromIntentLocked(callingUid, r.packageName, data, r.getUriPermissionsLocked(), r.userId);
    }
    if (DEBUG_RESULTS)
        Slog.v(TAG, "Send activity result to " + r + " : who=" + resultWho + " req=" + requestCode + " res=" + resultCode + " data=" + data);
    if (mResumedActivity == r && r.app != null && r.app.thread != null) {
        try {
            ArrayList<ResultInfo> list = new ArrayList<ResultInfo>();
            list.add(new ResultInfo(resultWho, requestCode, resultCode, data));
            r.app.thread.scheduleSendResult(r.appToken, list);
            return;
        } catch (Exception e) {
            Slog.w(TAG, "Exception thrown sending result to " + r, e);
        }
    }
    r.addResultLocked(null, resultWho, requestCode, resultCode, data);
}
Also used : ArrayList(java.util.ArrayList) ResultInfo(android.app.ResultInfo) RemoteException(android.os.RemoteException)

Example 15 with ResultInfo

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

the class ActivityStack method relaunchActivityLocked.

private void relaunchActivityLocked(ActivityRecord r, int changes, boolean andResume, boolean preserveWindow) {
    if (mService.mSuppressResizeConfigChanges && preserveWindow) {
        r.configChangeFlags = 0;
        return;
    }
    List<ResultInfo> results = null;
    List<ReferrerIntent> newIntents = null;
    if (andResume) {
        results = r.results;
        newIntents = r.newIntents;
    }
    if (DEBUG_SWITCH)
        Slog.v(TAG_SWITCH, "Relaunching: " + r + " with results=" + results + " newIntents=" + newIntents + " andResume=" + andResume + " preserveWindow=" + preserveWindow);
    EventLog.writeEvent(andResume ? EventLogTags.AM_RELAUNCH_RESUME_ACTIVITY : EventLogTags.AM_RELAUNCH_ACTIVITY, r.userId, System.identityHashCode(r), r.task.taskId, r.shortComponentName);
    r.startFreezingScreenLocked(r.app, 0);
    mStackSupervisor.removeChildActivityContainers(r);
    try {
        if (DEBUG_SWITCH || DEBUG_STATES)
            Slog.i(TAG_SWITCH, "Moving to " + (andResume ? "RESUMED" : "PAUSED") + " Relaunching " + r + " callers=" + Debug.getCallers(6));
        r.forceNewConfig = false;
        mStackSupervisor.activityRelaunchingLocked(r);
        r.app.thread.scheduleRelaunchActivity(r.appToken, results, newIntents, changes, !andResume, new Configuration(mService.mConfiguration), new Configuration(r.task.mOverrideConfig), preserveWindow);
    // Note: don't need to call pauseIfSleepingLocked() here, because
    // the caller will only pass in 'andResume' if this activity is
    // currently resumed, which implies we aren't sleeping.
    } catch (RemoteException e) {
        if (DEBUG_SWITCH || DEBUG_STATES)
            Slog.i(TAG_SWITCH, "Relaunch failed", e);
    }
    if (andResume) {
        if (DEBUG_STATES) {
            Slog.d(TAG_STATES, "Resumed after relaunch " + r);
        }
        r.state = ActivityState.RESUMED;
        // code in resumeTopActivityInnerLocked to complete the resume might be skipped.
        if (!r.visible || r.stopped) {
            mWindowManager.setAppVisibility(r.appToken, true);
            completeResumeLocked(r);
        } else {
            r.results = null;
            r.newIntents = null;
        }
        mService.showUnsupportedZoomDialogIfNeededLocked(r);
        mService.showAskCompatModeDialogLocked(r);
    } else {
        mHandler.removeMessages(PAUSE_TIMEOUT_MSG, r);
        r.state = ActivityState.PAUSED;
    }
    r.configChangeFlags = 0;
    r.deferRelaunchUntilPaused = false;
    r.preserveWindowOnDeferredRelaunch = false;
}
Also used : ReferrerIntent(com.android.internal.content.ReferrerIntent) Configuration(android.content.res.Configuration) ResultInfo(android.app.ResultInfo) RemoteException(android.os.RemoteException)

Aggregations

ResultInfo (android.app.ResultInfo)26 RemoteException (android.os.RemoteException)26 Configuration (android.content.res.Configuration)19 ReferrerIntent (com.android.internal.content.ReferrerIntent)15 Intent (android.content.Intent)14 IOException (java.io.IOException)9 Message (android.os.Message)7 ParcelFileDescriptor (android.os.ParcelFileDescriptor)7 ArrayList (java.util.ArrayList)7 ActivityOptions (android.app.ActivityOptions)5 ProfilerInfo (android.app.ProfilerInfo)5 Point (android.graphics.Point)5 Bundle (android.os.Bundle)5 PersistableBundle (android.os.PersistableBundle)5 PendingIntent (android.app.PendingIntent)4 BoostFramework (android.util.BoostFramework)1