Java Code Examples for android.util.EventLog#writeEvent()

The following examples show how to use android.util.EventLog#writeEvent() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void maybeLogUpdateToEventLog(
    long durationMillis, Uri uri, String operation, String selection) {
    if (!ENABLE_CONTENT_SAMPLE) return;
    int samplePercent = samplePercentForDuration(durationMillis);
    if (samplePercent < 100) {
        synchronized (mRandom) {
            if (mRandom.nextInt(100) >= samplePercent) {
                return;
            }
        }
    }
    String blockingPackage = AppGlobals.getInitialPackage();
    EventLog.writeEvent(
        EventLogTags.CONTENT_UPDATE_SAMPLE,
        uri.toString(),
        operation,
        selection != null ? selection : "",
        durationMillis,
        blockingPackage != null ? blockingPackage : "",
        samplePercent);
}
 
Example 2
Source Project: android_9.0.0_r45   File: ProcessRecord.java    License: Apache License 2.0 6 votes vote down vote up
void kill(String reason, boolean noisy) {
    if (!killedByAm) {
        Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "kill");
        if (mService != null && (noisy || info.uid == mService.mCurOomAdjUid)) {
            mService.reportUidInfoMessageLocked(TAG,
                    "Killing " + toShortString() + " (adj " + setAdj + "): " + reason,
                    info.uid);
        }
        if (pid > 0) {
            EventLog.writeEvent(EventLogTags.AM_KILL, userId, pid, processName, setAdj, reason);
            Process.killProcessQuiet(pid);
            ActivityManagerService.killProcessGroup(uid, pid);
        } else {
            pendingStart = false;
        }
        if (!persistent) {
            killed = true;
            killedByAm = true;
        }
        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
    }
}
 
Example 3
private void collectBrightnessAdjustmentSample() {
    if (mBrightnessAdjustmentSamplePending) {
        mBrightnessAdjustmentSamplePending = false;
        if (mAmbientLuxValid && mScreenAutoBrightness >= 0) {
            if (DEBUG) {
                Slog.d(TAG, "Auto-brightness adjustment changed by user: " +
                        "lux=" + mAmbientLux + ", " +
                        "brightness=" + mScreenAutoBrightness + ", " +
                        "ring=" + mAmbientLightRingBuffer);
            }

            EventLog.writeEvent(EventLogTags.AUTO_BRIGHTNESS_ADJ,
                    mBrightnessAdjustmentSampleOldLux,
                    mBrightnessAdjustmentSampleOldBrightness,
                    mAmbientLux,
                    mScreenAutoBrightness);
        }
    }
}
 
Example 4
Source Project: android_9.0.0_r45   File: Task.java    License: Apache License 2.0 6 votes vote down vote up
@Override
void removeChild(AppWindowToken token) {
    if (!mChildren.contains(token)) {
        Slog.e(TAG, "removeChild: token=" + this + " not found.");
        return;
    }

    super.removeChild(token);

    if (mChildren.isEmpty()) {
        EventLog.writeEvent(WM_TASK_REMOVED, mTaskId, "removeAppToken: last token");
        if (mDeferRemoval) {
            removeIfPossible();
        }
    }
}
 
Example 5
public TaskWindowContainerController(int taskId, TaskWindowContainerListener listener,
        StackWindowController stackController, int userId, Rect bounds, int resizeMode,
        boolean supportsPictureInPicture, boolean toTop, boolean showForAllUsers,
        TaskDescription taskDescription, WindowManagerService service) {
    super(listener, service);
    mTaskId = taskId;
    mHandler = new H(new WeakReference<>(this), service.mH.getLooper());

    synchronized(mWindowMap) {
        if (DEBUG_STACK) Slog.i(TAG_WM, "TaskWindowContainerController: taskId=" + taskId
                + " stack=" + stackController + " bounds=" + bounds);

        final TaskStack stack = stackController.mContainer;
        if (stack == null) {
            throw new IllegalArgumentException("TaskWindowContainerController: invalid stack="
                    + stackController);
        }
        EventLog.writeEvent(WM_TASK_CREATED, taskId, stack.mStackId);
        final Task task = createTask(taskId, stack, userId, resizeMode,
                supportsPictureInPicture, taskDescription);
        final int position = toTop ? POSITION_TOP : POSITION_BOTTOM;
        // We only want to move the parents to the parents if we are creating this task at the
        // top of its stack.
        stack.addTask(task, position, showForAllUsers, toTop /* moveParents */);
    }
}
 
Example 6
WindowState computeFocusedWindow() {
    // While the keyguard is showing, we must focus anything besides the main display.
    // Otherwise we risk input not going to the keyguard when the user expects it to.
    final boolean forceDefaultDisplay = mService.isKeyguardShowingAndNotOccluded();

    for (int i = mChildren.size() - 1; i >= 0; i--) {
        final DisplayContent dc = mChildren.get(i);
        final WindowState win = dc.findFocusedWindow();
        if (win != null) {
            if (forceDefaultDisplay && !dc.isDefaultDisplay) {
                EventLog.writeEvent(0x534e4554, "71786287", win.mOwnerUid, "");
                continue;
            }
            return win;
        }
    }
    return null;
}
 
Example 7
private void logAppDisplayed(WindowingModeTransitionInfoSnapshot info) {
    if (info.type != TYPE_TRANSITION_WARM_LAUNCH && info.type != TYPE_TRANSITION_COLD_LAUNCH) {
        return;
    }

    EventLog.writeEvent(AM_ACTIVITY_LAUNCH_TIME,
            info.userId, info.activityRecordIdHashCode, info.launchedActivityShortComponentName,
            info.windowsDrawnDelayMs);

    StringBuilder sb = mStringBuilder;
    sb.setLength(0);
    sb.append("Displayed ");
    sb.append(info.launchedActivityShortComponentName);
    sb.append(": ");
    TimeUtils.formatDuration(info.windowsDrawnDelayMs, sb);
    Log.i(TAG, sb.toString());
}
 
Example 8
public final ActivityClientRecord performResumeActivity(IBinder token,
        boolean clearHide) {
    ActivityClientRecord r = mActivities.get(token);
    if (localLOGV) Slog.v(TAG, "Performing resume of " + r
            + " finished=" + r.activity.mFinished);
    if (r != null && !r.activity.mFinished) {
        if (clearHide) {
            r.hideForNow = false;
            r.activity.mStartedActivity = false;
        }
        try {
            if (r.pendingIntents != null) {
                deliverNewIntents(r, r.pendingIntents);
                r.pendingIntents = null;
            }
            if (r.pendingResults != null) {
                deliverResults(r, r.pendingResults);
                r.pendingResults = null;
            }
            r.activity.performResume();

            EventLog.writeEvent(LOG_ON_RESUME_CALLED,
                    r.activity.getComponentName().getClassName());

            r.paused = false;
            r.stopped = false;
            r.state = null;
        } catch (Exception e) {
            if (!mInstrumentation.onException(r.activity, e)) {
                throw new RuntimeException(
                    "Unable to resume activity "
                    + r.intent.getComponent().toShortString()
                    + ": " + e.toString(), e);
            }
        }
    }
    return r;
}
 
Example 9
Source Project: condom   File: CondomMiscTest.java    License: Apache License 2.0 5 votes vote down vote up
private static List<EventLog.Event> readNewEvents(final CondomCore.CondomEvent type) throws IOException {
	final List<EventLog.Event> events = new ArrayList<>();
	EventLog.readEvents(new int[] { EVENT_TAG_MARK, "Condom".hashCode() + type.ordinal() }, events);
	if (events.isEmpty()) return Collections.emptyList();
	for (int i = events.size() - 1; i >= 0; i --) {
		final EventLog.Event event = events.get(i);
		if (event.getTag() == EVENT_TAG_MARK) {
			EventLog.writeEvent(EVENT_TAG_MARK);
			return events.subList(i + 1, events.size());
		}
	}
	EventLog.writeEvent(EVENT_TAG_MARK);
	return events;
}
 
Example 10
Source Project: android_9.0.0_r45   File: Task.java    License: Apache License 2.0 5 votes vote down vote up
@Override
void removeImmediately() {
    if (DEBUG_STACK) Slog.i(TAG, "removeTask: removing taskId=" + mTaskId);
    EventLog.writeEvent(WM_TASK_REMOVED, mTaskId, "removeTask");
    mDeferRemoval = false;

    super.removeImmediately();
}
 
Example 11
Source Project: android_9.0.0_r45   File: Notifier.java    License: Apache License 2.0 5 votes vote down vote up
private void sendGoToSleepBroadcast() {
    if (DEBUG) {
        Slog.d(TAG, "Sending go to sleep broadcast.");
    }

    if (mActivityManagerInternal.isSystemReady()) {
        mContext.sendOrderedBroadcastAsUser(mScreenOffIntent, UserHandle.ALL, null,
                mGoToSleepBroadcastDone, mHandler, 0, null, null);
    } else {
        EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_STOP, 3, 1);
        sendNextBroadcast();
    }
}
 
Example 12
Source Project: android_9.0.0_r45   File: SyncManager.java    License: Apache License 2.0 5 votes vote down vote up
public void stopSyncEvent(long rowId, SyncOperation syncOperation, String resultMessage,
        int upstreamActivity, int downstreamActivity, long elapsedTime) {
    EventLog.writeEvent(2720,
            syncOperation.toEventLog(SyncStorageEngine.EVENT_STOP));
    mSyncStorageEngine.stopSyncEvent(rowId, elapsedTime,
            resultMessage, downstreamActivity, upstreamActivity);
}
 
Example 13
Source Project: android_9.0.0_r45   File: TaskStack.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Overridden version of {@link TaskStack#positionChildAt(int, Task, boolean)}. Used in
 * {@link TaskStack#addTask(Task, int, boolean showForAllUsers, boolean)}, as it can receive
 * showForAllUsers param from {@link AppWindowToken} instead of {@link Task#showForAllUsers()}.
 */
private void positionChildAt(int position, Task child, boolean includingParents,
        boolean showForAllUsers) {
    final int targetPosition = findPositionForTask(child, position, showForAllUsers,
            false /* addingNew */);
    super.positionChildAt(targetPosition, child, includingParents);

    // Log positioning.
    if (DEBUG_TASK_MOVEMENT)
        Slog.d(TAG_WM, "positionTask: task=" + this + " position=" + position);

    final int toTop = targetPosition == mChildren.size() - 1 ? 1 : 0;
    EventLog.writeEvent(EventLogTags.WM_TASK_MOVED, child.mTaskId, toTop, targetPosition);
}
 
Example 14
InputBindResult startInputUncheckedLocked(ClientState cs,
        IInputContext inputContext, EditorInfo attribute, int controlFlags) {
    // If no method is currently selected, do nothing.
    if (mCurMethodId == null) {
        return mNoBinding;
    }

    if (mCurClient != cs) {
        // Was the keyguard locked when switching over to the new client?
        mCurClientInKeyguard = isKeyguardLocked();
        // If the client is changing, we need to switch over to the new
        // one.
        unbindCurrentClientLocked();
        if (DEBUG) Slog.v(TAG, "switching to client: client = "
                + cs.client.asBinder() + " keyguard=" + mCurClientInKeyguard);

        // If the screen is on, inform the new client it is active
        if (mScreenOn) {
            executeOrSendMessage(cs.client, mCaller.obtainMessageIO(
                    MSG_SET_ACTIVE, mScreenOn ? 1 : 0, cs));
        }
    }

    // Bump up the sequence for this client and attach it.
    mCurSeq++;
    if (mCurSeq <= 0) mCurSeq = 1;
    mCurClient = cs;
    mCurInputContext = inputContext;
    mCurAttribute = attribute;

    // Check if the input method is changing.
    if (mCurId != null && mCurId.equals(mCurMethodId)) {
        if (cs.curSession != null) {
            // Fast case: if we are already connected to the input method,
            // then just return it.
            return attachNewInputLocked(
                    (controlFlags&InputMethodManager.CONTROL_START_INITIAL) != 0);
        }
        if (mHaveConnection) {
            if (mCurMethod != null) {
                // Return to client, and we will get back with it when
                // we have had a session made for it.
                requestClientSessionLocked(cs);
                return new InputBindResult(null, null, mCurId, mCurSeq);
            } else if (SystemClock.uptimeMillis()
                    < (mLastBindTime+TIME_TO_RECONNECT)) {
                // In this case we have connected to the service, but
                // don't yet have its interface.  If it hasn't been too
                // long since we did the connection, we'll return to
                // the client and wait to get the service interface so
                // we can report back.  If it has been too long, we want
                // to fall through so we can try a disconnect/reconnect
                // to see if we can get back in touch with the service.
                return new InputBindResult(null, null, mCurId, mCurSeq);
            } else {
                EventLog.writeEvent(EventLogTags.IMF_FORCE_RECONNECT_IME,
                        mCurMethodId, SystemClock.uptimeMillis()-mLastBindTime, 0);
            }
        }
    }

    return startInputInnerLocked();
}
 
Example 15
private void maybeLogQueryToEventLog(
        long durationMillis, Uri uri, String[] projection, @Nullable Bundle queryArgs) {
    if (!ENABLE_CONTENT_SAMPLE) return;
    int samplePercent = samplePercentForDuration(durationMillis);
    if (samplePercent < 100) {
        synchronized (mRandom) {
            if (mRandom.nextInt(100) >= samplePercent) {
                return;
            }
        }
    }

    // Ensure a non-null bundle.
    queryArgs = (queryArgs != null) ? queryArgs : Bundle.EMPTY;

    StringBuilder projectionBuffer = new StringBuilder(100);
    if (projection != null) {
        for (int i = 0; i < projection.length; ++i) {
            // Note: not using a comma delimiter here, as the
            // multiple arguments to EventLog.writeEvent later
            // stringify with a comma delimiter, which would make
            // parsing uglier later.
            if (i != 0) projectionBuffer.append('/');
            projectionBuffer.append(projection[i]);
        }
    }

    // ActivityThread.currentPackageName() only returns non-null if the
    // current thread is an application main thread.  This parameter tells
    // us whether an event loop is blocked, and if so, which app it is.
    String blockingPackage = AppGlobals.getInitialPackage();

    EventLog.writeEvent(
        EventLogTags.CONTENT_QUERY_SAMPLE,
        uri.toString(),
        projectionBuffer.toString(),
        queryArgs.getString(QUERY_ARG_SQL_SELECTION, ""),
        queryArgs.getString(QUERY_ARG_SQL_SORT_ORDER, ""),
        durationMillis,
        blockingPackage != null ? blockingPackage : "",
        samplePercent);
}
 
Example 16
void relaunchActivityLocked(boolean andResume, boolean preserveWindow) {
    if (service.mSuppressResizeConfigChanges && preserveWindow) {
        configChangeFlags = 0;
        return;
    }

    List<ResultInfo> pendingResults = null;
    List<ReferrerIntent> pendingNewIntents = null;
    if (andResume) {
        pendingResults = results;
        pendingNewIntents = newIntents;
    }
    if (DEBUG_SWITCH) Slog.v(TAG_SWITCH,
            "Relaunching: " + this + " with results=" + pendingResults
                    + " newIntents=" + pendingNewIntents + " andResume=" + andResume
                    + " preserveWindow=" + preserveWindow);
    EventLog.writeEvent(andResume ? AM_RELAUNCH_RESUME_ACTIVITY
                    : AM_RELAUNCH_ACTIVITY, userId, System.identityHashCode(this),
            task.taskId, shortComponentName);

    startFreezingScreenLocked(app, 0);

    try {
        if (DEBUG_SWITCH || DEBUG_STATES) Slog.i(TAG_SWITCH,
                "Moving to " + (andResume ? "RESUMED" : "PAUSED") + " Relaunching " + this
                        + " callers=" + Debug.getCallers(6));
        forceNewConfig = false;
        mStackSupervisor.activityRelaunchingLocked(this);
        final ClientTransactionItem callbackItem = ActivityRelaunchItem.obtain(pendingResults,
                pendingNewIntents, configChangeFlags,
                new MergedConfiguration(service.getGlobalConfiguration(),
                        getMergedOverrideConfiguration()),
                preserveWindow);
        final ActivityLifecycleItem lifecycleItem;
        if (andResume) {
            lifecycleItem = ResumeActivityItem.obtain(service.isNextTransitionForward());
        } else {
            lifecycleItem = PauseActivityItem.obtain();
        }
        final ClientTransaction transaction = ClientTransaction.obtain(app.thread, appToken);
        transaction.addCallback(callbackItem);
        transaction.setLifecycleStateRequest(lifecycleItem);
        service.getLifecycleManager().scheduleTransaction(transaction);
        // Note: don't need to call pauseIfSleepingLocked() here, because the caller will only
        // request resume 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 " + this);
        }
        results = null;
        newIntents = null;
        service.getAppWarningsLocked().onResumeActivity(this);
        service.showAskCompatModeDialogLocked(this);
    } else {
        service.mHandler.removeMessages(PAUSE_TIMEOUT_MSG, this);
        setState(PAUSED, "relaunchActivityLocked");
    }

    configChangeFlags = 0;
    deferRelaunchUntilPaused = false;
    preserveWindowOnDeferredRelaunch = false;
}
 
Example 17
private void maybeLogQueryToEventLog(
        long durationMillis, Uri uri, String[] projection, @Nullable Bundle queryArgs) {
    if (!ENABLE_CONTENT_SAMPLE) return;
    int samplePercent = samplePercentForDuration(durationMillis);
    if (samplePercent < 100) {
        synchronized (mRandom) {
            if (mRandom.nextInt(100) >= samplePercent) {
                return;
            }
        }
    }

    // Ensure a non-null bundle.
    queryArgs = (queryArgs != null) ? queryArgs : Bundle.EMPTY;

    StringBuilder projectionBuffer = new StringBuilder(100);
    if (projection != null) {
        for (int i = 0; i < projection.length; ++i) {
            // Note: not using a comma delimiter here, as the
            // multiple arguments to EventLog.writeEvent later
            // stringify with a comma delimiter, which would make
            // parsing uglier later.
            if (i != 0) projectionBuffer.append('/');
            projectionBuffer.append(projection[i]);
        }
    }

    // ActivityThread.currentPackageName() only returns non-null if the
    // current thread is an application main thread.  This parameter tells
    // us whether an event loop is blocked, and if so, which app it is.
    String blockingPackage = AppGlobals.getInitialPackage();

    EventLog.writeEvent(
        EventLogTags.CONTENT_QUERY_SAMPLE,
        uri.toString(),
        projectionBuffer.toString(),
        queryArgs.getString(QUERY_ARG_SQL_SELECTION, ""),
        queryArgs.getString(QUERY_ARG_SQL_SORT_ORDER, ""),
        durationMillis,
        blockingPackage != null ? blockingPackage : "",
        samplePercent);
}
 
Example 18
private void maybeLogQueryToEventLog(
        long durationMillis, Uri uri, String[] projection, @Nullable Bundle queryArgs) {
    if (!ENABLE_CONTENT_SAMPLE) return;
    int samplePercent = samplePercentForDuration(durationMillis);
    if (samplePercent < 100) {
        synchronized (mRandom) {
            if (mRandom.nextInt(100) >= samplePercent) {
                return;
            }
        }
    }

    // Ensure a non-null bundle.
    queryArgs = (queryArgs != null) ? queryArgs : Bundle.EMPTY;

    StringBuilder projectionBuffer = new StringBuilder(100);
    if (projection != null) {
        for (int i = 0; i < projection.length; ++i) {
            // Note: not using a comma delimiter here, as the
            // multiple arguments to EventLog.writeEvent later
            // stringify with a comma delimiter, which would make
            // parsing uglier later.
            if (i != 0) projectionBuffer.append('/');
            projectionBuffer.append(projection[i]);
        }
    }

    // ActivityThread.currentPackageName() only returns non-null if the
    // current thread is an application main thread.  This parameter tells
    // us whether an event loop is blocked, and if so, which app it is.
    String blockingPackage = AppGlobals.getInitialPackage();

    EventLog.writeEvent(
        EventLogTags.CONTENT_QUERY_SAMPLE,
        uri.toString(),
        projectionBuffer.toString(),
        queryArgs.getString(QUERY_ARG_SQL_SELECTION, ""),
        queryArgs.getString(QUERY_ARG_SQL_SORT_ORDER, ""),
        durationMillis,
        blockingPackage != null ? blockingPackage : "",
        samplePercent);
}
 
Example 19
Source Project: android_9.0.0_r45   File: Notifier.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_DONE, 1,
            SystemClock.uptimeMillis() - mBroadcastStartTime, 1);
    sendNextBroadcast();
}
 
Example 20
Source Project: android_9.0.0_r45   File: Notifier.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    EventLog.writeEvent(EventLogTags.POWER_SCREEN_BROADCAST_DONE, 0,
            SystemClock.uptimeMillis() - mBroadcastStartTime, 1);
    sendNextBroadcast();
}