use of android.app.IActivityManager.WaitResult in project android_frameworks_base by ParanoidAndroid.
the class KeyguardActivityLauncher method startActivityForCurrentUser.
private void startActivityForCurrentUser(final Intent intent, final Bundle options, Handler worker, final Runnable onStarted) {
final UserHandle user = new UserHandle(UserHandle.USER_CURRENT);
if (worker == null || onStarted == null) {
getContext().startActivityAsUser(intent, options, user);
return;
}
// if worker + onStarted are supplied, run blocking activity launch call in the background
worker.post(new Runnable() {
@Override
public void run() {
try {
WaitResult result = ActivityManagerNative.getDefault().startActivityAndWait(null, /*caller*/
null, /*caller pkg*/
intent, intent.resolveTypeIfNeeded(getContext().getContentResolver()), null, /*resultTo*/
null, /*resultWho*/
0, /*requestCode*/
Intent.FLAG_ACTIVITY_NEW_TASK, null, /*profileFile*/
null, /*profileFd*/
options, user.getIdentifier());
if (DEBUG)
Log.d(TAG, String.format("waitResult[%s,%s,%s,%s] at %s", result.result, result.thisTime, result.totalTime, result.who, SystemClock.uptimeMillis()));
} catch (RemoteException e) {
Log.w(TAG, "Error starting activity", e);
return;
}
try {
onStarted.run();
} catch (Throwable t) {
Log.w(TAG, "Error running onStarted callback", t);
}
}
});
}
use of android.app.IActivityManager.WaitResult in project android_frameworks_base by ParanoidAndroid.
the class AppLaunch method startApp.
private long startApp(String appName, boolean forceStopBeforeLaunch) throws NameNotFoundException, RemoteException {
Log.i(TAG, "Starting " + appName);
Intent startIntent = mNameToIntent.get(appName);
if (startIntent == null) {
Log.w(TAG, "App does not exist: " + appName);
mResult.putString(mNameToResultKey.get(appName), "App does not exist");
return -1;
}
AppLaunchRunnable runnable = new AppLaunchRunnable(startIntent, forceStopBeforeLaunch);
Thread t = new Thread(runnable);
t.start();
try {
t.join(JOIN_TIMEOUT);
} catch (InterruptedException e) {
// ignore
}
WaitResult result = runnable.getResult();
// * or in case of no force stop, result is not TASK_TO_FRONT either
if (t.isAlive() || (result != null && ((result.result != ActivityManager.START_SUCCESS) && (!forceStopBeforeLaunch && result.result != ActivityManager.START_TASK_TO_FRONT)))) {
Log.w(TAG, "Assuming app " + appName + " crashed.");
reportError(appName, mNameToProcess.get(appName));
return -1;
}
return result.thisTime;
}
use of android.app.IActivityManager.WaitResult in project android_frameworks_base by ResurrectionRemix.
the class ActivityStackSupervisor method reportTaskToFrontNoLaunch.
void reportTaskToFrontNoLaunch(ActivityRecord r) {
boolean changed = false;
for (int i = mWaitingActivityLaunched.size() - 1; i >= 0; i--) {
WaitResult w = mWaitingActivityLaunched.remove(i);
if (w.who == null) {
changed = true;
// Set result to START_TASK_TO_FRONT so that startActivityMayWait() knows that
// the starting activity ends up moving another activity to front, and it should
// wait for this new activity to become visible instead.
// Do not modify other fields.
w.result = START_TASK_TO_FRONT;
}
}
if (changed) {
mService.notifyAll();
}
}
use of android.app.IActivityManager.WaitResult in project android_frameworks_base by ResurrectionRemix.
the class ActivityStackSupervisor method reportActivityLaunchedLocked.
void reportActivityLaunchedLocked(boolean timeout, ActivityRecord r, long thisTime, long totalTime) {
boolean changed = false;
for (int i = mWaitingActivityLaunched.size() - 1; i >= 0; i--) {
WaitResult w = mWaitingActivityLaunched.remove(i);
if (w.who == null) {
changed = true;
w.timeout = timeout;
if (r != null) {
w.who = new ComponentName(r.info.packageName, r.info.name);
}
w.thisTime = thisTime;
w.totalTime = totalTime;
// Do not modify w.result.
}
}
if (changed) {
mService.notifyAll();
}
}
use of android.app.IActivityManager.WaitResult in project android_frameworks_base by ResurrectionRemix.
the class ActivityStackSupervisor method sendWaitingVisibleReportLocked.
void sendWaitingVisibleReportLocked(ActivityRecord r) {
boolean changed = false;
for (int i = mWaitingActivityVisible.size() - 1; i >= 0; i--) {
WaitResult w = mWaitingActivityVisible.get(i);
if (w.who == null) {
changed = true;
w.timeout = false;
if (r != null) {
w.who = new ComponentName(r.info.packageName, r.info.name);
}
w.totalTime = SystemClock.uptimeMillis() - w.thisTime;
w.thisTime = w.totalTime;
}
}
if (changed) {
mService.notifyAll();
}
}
Aggregations