下面列出了android.util.Slog#v ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void remove() {
synchronized (mService.mWindowMap) {
final long now = SystemClock.uptimeMillis();
if (mSizeMismatch && now - mShownTime < SIZE_MISMATCH_MINIMUM_TIME_MS) {
mHandler.postAtTime(this::remove, mShownTime + SIZE_MISMATCH_MINIMUM_TIME_MS);
if (DEBUG_STARTING_WINDOW) {
Slog.v(TAG, "Defer removing snapshot surface in " + (now - mShownTime) + "ms");
}
return;
}
}
try {
if (DEBUG_STARTING_WINDOW) Slog.v(TAG, "Removing snapshot surface");
mSession.remove(mWindow);
} catch (RemoteException e) {
// Local call.
}
}
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) {
if (DEBUG_BATCH) {
Slog.v(TAG, "Received TIME_TICK alarm; rescheduling");
}
synchronized (mLock) {
mLastTickReceived = System.currentTimeMillis();
}
scheduleTimeTickEvent();
} else if (intent.getAction().equals(Intent.ACTION_DATE_CHANGED)) {
// Since the kernel does not keep track of DST, we need to
// reset the TZ information at the beginning of each day
// based off of the current Zone gmt offset + userspace tracked
// daylight savings information.
TimeZone zone = TimeZone.getTimeZone(SystemProperties.get(TIMEZONE_PROPERTY));
int gmtOffset = zone.getOffset(System.currentTimeMillis());
setKernelTimezone(mNativeData, -(gmtOffset / 60000));
scheduleDateChangedEvent();
}
}
private void showEncryptionNotification(UserHandle user, CharSequence title,
CharSequence message, CharSequence detail, PendingIntent intent) {
if (DEBUG) Slog.v(TAG, "showing encryption notification, user: " + user.getIdentifier());
// Suppress all notifications on non-FBE devices for now
if (!StorageManager.isFileEncryptedNativeOrEmulated()) return;
Notification notification =
new Notification.Builder(mContext, SystemNotificationChannels.SECURITY)
.setSmallIcon(com.android.internal.R.drawable.ic_user_secure)
.setWhen(0)
.setOngoing(true)
.setTicker(title)
.setColor(mContext.getColor(
com.android.internal.R.color.system_notification_accent_color))
.setContentTitle(title)
.setContentText(message)
.setSubText(detail)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.setContentIntent(intent)
.build();
mNotificationManager.notifyAsUser(null, SystemMessage.NOTE_FBE_ENCRYPTED_NOTIFICATION,
notification, user);
}
/**
* Retrieve a target's full info, returning null if one does not exist.
*
* @param info info of the target to look up.
* @param tag If non-null, this will be used in a log message if the
* requested target does not exist.
*/
private AuthorityInfo getAuthorityLocked(EndPoint info, String tag) {
AccountAndUser au = new AccountAndUser(info.account, info.userId);
AccountInfo accountInfo = mAccounts.get(au);
if (accountInfo == null) {
if (tag != null) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Slog.v(TAG, tag + ": unknown account " + au);
}
}
return null;
}
AuthorityInfo authority = accountInfo.authorities.get(info.provider);
if (authority == null) {
if (tag != null) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Slog.v(TAG, tag + ": unknown provider " + info.provider);
}
}
return null;
}
return authority;
}
/**
* Validate bounds against orientation violations (if DEBUG_ORIENTATION_VIOLATIONS is set).
*
* @param bounds The bounds to be checked.
*/
private void checkBoundsForOrientationViolations(Rect bounds) {
// When using debug check that we are not violating the given constraints.
if (DEBUG_ORIENTATION_VIOLATIONS) {
if (mStartOrientationWasLandscape != (bounds.width() >= bounds.height())) {
Slog.e(TAG, "Orientation violation detected! should be "
+ (mStartOrientationWasLandscape ? "landscape" : "portrait")
+ " but is the other");
} else {
Slog.v(TAG, "new bounds size: " + bounds.width() + " x " + bounds.height());
}
if (mMinVisibleWidth > bounds.width() || mMinVisibleHeight > bounds.height()) {
Slog.v(TAG, "Minimum requirement violated: Width(min, is)=(" + mMinVisibleWidth
+ ", " + bounds.width() + ") Height(min,is)=("
+ mMinVisibleHeight + ", " + bounds.height() + ")");
}
if (mMaxVisibleSize.x < bounds.width() || mMaxVisibleSize.y < bounds.height()) {
Slog.v(TAG, "Maximum requirement violated: Width(min, is)=(" + mMaxVisibleSize.x
+ ", " + bounds.width() + ") Height(min,is)=("
+ mMaxVisibleSize.y + ", " + bounds.height() + ")");
}
}
}
public final void sendActivityResult(
IBinder token, String id, int requestCode,
int resultCode, Intent data) {
if (DEBUG_RESULTS) Slog.v(TAG, "sendActivityResult: id=" + id
+ " req=" + requestCode + " res=" + resultCode + " data=" + data);
ArrayList<ResultInfo> list = new ArrayList<ResultInfo>();
list.add(new ResultInfo(id, requestCode, resultCode, data));
mAppThread.scheduleSendResult(token, list);
}
/**
* Starts an animation on the container.
*
* @param anim The animation to run.
* @param hidden Whether our container is currently hidden. TODO This should use isVisible at
* some point but the meaning is too weird to work for all containers.
*/
void startAnimation(Transaction t, AnimationAdapter anim, boolean hidden) {
if (DEBUG_ANIM) Slog.v(TAG, "Starting animation on " + this + ": " + anim);
// TODO: This should use isVisible() but because isVisible has a really weird meaning at
// the moment this doesn't work for all animatable window containers.
mSurfaceAnimator.startAnimation(t, anim, hidden);
}
/**
* @return true if transition is not running and should not be skipped, false if transition is
* already running
*/
boolean prepareAppTransitionLocked(@TransitionType int transit, boolean alwaysKeepCurrent,
@TransitionFlags int flags, boolean forceOverride) {
if (DEBUG_APP_TRANSITIONS) Slog.v(TAG, "Prepare app transition:"
+ " transit=" + appTransitionToString(transit)
+ " " + this
+ " alwaysKeepCurrent=" + alwaysKeepCurrent
+ " Callers=" + Debug.getCallers(3));
final boolean allowSetCrashing = !isKeyguardTransit(mNextAppTransition)
&& transit == TRANSIT_CRASHING_ACTIVITY_CLOSE;
if (forceOverride || isKeyguardTransit(transit) || !isTransitionSet()
|| mNextAppTransition == TRANSIT_NONE || allowSetCrashing) {
setAppTransition(transit, flags);
}
// We never want to change from a Keyguard transit to a non-Keyguard transit, as our logic
// relies on the fact that we always execute a Keyguard transition after preparing one. We
// also don't want to change away from a crashing transition.
else if (!alwaysKeepCurrent && !isKeyguardTransit(mNextAppTransition)
&& mNextAppTransition != TRANSIT_CRASHING_ACTIVITY_CLOSE) {
if (transit == TRANSIT_TASK_OPEN && isTransitionEqual(TRANSIT_TASK_CLOSE)) {
// Opening a new task always supersedes a close for the anim.
setAppTransition(transit, flags);
} else if (transit == TRANSIT_ACTIVITY_OPEN
&& isTransitionEqual(TRANSIT_ACTIVITY_CLOSE)) {
// Opening a new activity always supersedes a close for the anim.
setAppTransition(transit, flags);
} else if (isTaskTransit(transit) && isActivityTransit(mNextAppTransition)) {
// Task animations always supersede activity animations, because if we have both, it
// usually means that activity transition were just trampoline activities.
setAppTransition(transit, flags);
}
}
boolean prepared = prepare();
if (isTransitionSet()) {
mService.mH.removeMessages(H.APP_TRANSITION_TIMEOUT);
mService.mH.sendEmptyMessageDelayed(H.APP_TRANSITION_TIMEOUT, APP_TRANSITION_TIMEOUT_MS);
}
return prepared;
}
/**
* Determines if the token has finished drawing. This should only be called from
* {@link DisplayContent#applySurfaceChangesTransaction}
*/
void updateAllDrawn() {
if (!allDrawn) {
// Number of drawn windows can be less when a window is being relaunched, wait for
// all windows to be launched and drawn for this token be considered all drawn.
final int numInteresting = mNumInterestingWindows;
// We must make sure that all present children have been considered (determined by
// {@link #allDrawnStatesConsidered}) before evaluating whether everything has been
// drawn.
if (numInteresting > 0 && allDrawnStatesConsidered()
&& mNumDrawnWindows >= numInteresting && !isRelaunching()) {
if (DEBUG_VISIBILITY) Slog.v(TAG, "allDrawn: " + this
+ " interesting=" + numInteresting + " drawn=" + mNumDrawnWindows);
allDrawn = true;
// Force an additional layout pass where
// WindowStateAnimator#commitFinishDrawingLocked() will call performShowLocked().
if (mDisplayContent != null) {
mDisplayContent.setLayoutNeeded();
}
mService.mH.obtainMessage(NOTIFY_ACTIVITY_DRAWN, token).sendToTarget();
// Notify the pinned stack upon all windows drawn. If there was an animation in
// progress then this signal will resume that animation.
final TaskStack pinnedStack = mDisplayContent.getPinnedStack();
if (pinnedStack != null) {
pinnedStack.onAllWindowsDrawn();
}
}
}
}
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case BROADCAST_INTENT_MSG: {
if (DEBUG_BROADCAST) Slog.v(
TAG_BROADCAST, "Received BROADCAST_INTENT_MSG");
processNextBroadcast(true);
} break;
case BROADCAST_TIMEOUT_MSG: {
synchronized (mService) {
broadcastTimeoutLocked(true);
}
} break;
}
}
private void startVendorIdStage() {
Slog.v(TAG, "Start [Vendor Id Stage]:" + mDevices.size());
mProcessedDeviceCount = 0;
mState = STATE_WAITING_FOR_VENDOR_ID;
checkAndProceedStage();
}
private final int register_intent_filter(F filter, Iterator<String> i,
ArrayMap<String, F[]> dest, String prefix) {
if (i == null) {
return 0;
}
int num = 0;
while (i.hasNext()) {
String name = i.next();
num++;
if (localLOGV) Slog.v(TAG, prefix + name);
addFilter(dest, name, filter);
}
return num;
}
@Override
public void onChange(boolean selfChange, Uri uri) {
if (DEBUG) {
Slog.v(TAG, "settings change " + uri);
}
if (mInjector.isBrightnessModeAutomatic(mContentResolver)) {
mBgHandler.obtainMessage(MSG_START_SENSOR_LISTENER).sendToTarget();
} else {
mBgHandler.obtainMessage(MSG_STOP_SENSOR_LISTENER).sendToTarget();
}
}
private LoadedApk getPackageInfo(ApplicationInfo aInfo, CompatibilityInfo compatInfo,
ClassLoader baseLoader, boolean securityViolation, boolean includeCode) {
synchronized (mPackages) {
WeakReference<LoadedApk> ref;
if (includeCode) {
ref = mPackages.get(aInfo.packageName);
} else {
ref = mResourcePackages.get(aInfo.packageName);
}
LoadedApk packageInfo = ref != null ? ref.get() : null;
if (packageInfo == null || (packageInfo.mResources != null
&& !packageInfo.mResources.getAssets().isUpToDate())) {
if (localLOGV) Slog.v(TAG, (includeCode ? "Loading code package "
: "Loading resource-only package ") + aInfo.packageName
+ " (in " + (mBoundApplication != null
? mBoundApplication.processName : null)
+ ")");
packageInfo =
new LoadedApk(this, aInfo, compatInfo, this, baseLoader,
securityViolation, includeCode &&
(aInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0);
if (includeCode) {
mPackages.put(aInfo.packageName,
new WeakReference<LoadedApk>(packageInfo));
} else {
mResourcePackages.put(aInfo.packageName,
new WeakReference<LoadedApk>(packageInfo));
}
}
return packageInfo;
}
}
private void logBatchesLocked(SimpleDateFormat sdf) {
ByteArrayOutputStream bs = new ByteArrayOutputStream(2048);
PrintWriter pw = new PrintWriter(bs);
final long nowRTC = System.currentTimeMillis();
final long nowELAPSED = SystemClock.elapsedRealtime();
final int NZ = mAlarmBatches.size();
for (int iz = 0; iz < NZ; iz++) {
Batch bz = mAlarmBatches.get(iz);
pw.append("Batch "); pw.print(iz); pw.append(": "); pw.println(bz);
dumpAlarmList(pw, bz.alarms, " ", nowELAPSED, nowRTC, sdf);
pw.flush();
Slog.v(TAG, bs.toString());
bs.reset();
}
}
/**
* Called when this Dream is stopped, either by external request or by calling finish(),
* before the window has been removed.
*/
public void onDreamingStopped() {
if (mDebug) Slog.v(TAG, "onDreamingStopped()");
// hook for subclasses
}
/**
* Dump camera usage events to log.
* Package-private
*/
void dumpUsageEvents() {
synchronized(mLock) {
// Randomize order of events so that it's not meaningful
Collections.shuffle(mCameraUsageHistory);
for (CameraUsageEvent e : mCameraUsageHistory) {
if (DEBUG) {
Slog.v(TAG, "Camera: " + e.mClientName + " used a camera facing " +
cameraFacingToString(e.mCameraFacing) + " for " +
e.getDuration() + " ms");
}
int subtype = 0;
switch(e.mCameraFacing) {
case ICameraServiceProxy.CAMERA_FACING_BACK:
subtype = MetricsEvent.CAMERA_BACK_USED;
break;
case ICameraServiceProxy.CAMERA_FACING_FRONT:
subtype = MetricsEvent.CAMERA_FRONT_USED;
break;
case ICameraServiceProxy.CAMERA_FACING_EXTERNAL:
subtype = MetricsEvent.CAMERA_EXTERNAL_USED;
break;
default:
continue;
}
LogMaker l = new LogMaker(MetricsEvent.ACTION_CAMERA_EVENT)
.setType(MetricsEvent.TYPE_ACTION)
.setSubtype(subtype)
.setLatency(e.getDuration())
.addTaggedData(MetricsEvent.FIELD_CAMERA_API_LEVEL, e.mAPILevel)
.setPackageName(e.mClientName);
mLogger.write(l);
}
mCameraUsageHistory.clear();
}
final long ident = Binder.clearCallingIdentity();
try {
CameraStatsJobService.schedule(mContext);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
private void enumerateUser(int userId) {
if (DEBUG) Slog.v(TAG, "Enumerating user(" + userId + ")");
boolean restricted = !hasPermission(MANAGE_FINGERPRINT);
startEnumerate(mToken, userId, null, restricted, true /* internal */);
}
private void onError(String msg) {
Slog.v(TAG, "Remote exception while " + msg);
}
private final void bumpServiceExecutingLocked(ServiceRecord r, boolean fg, String why) {
if (DEBUG_SERVICE) Slog.v(TAG_SERVICE, ">>> EXECUTING "
+ why + " of " + r + " in app " + r.app);
else if (DEBUG_SERVICE_EXECUTING) Slog.v(TAG_SERVICE_EXECUTING, ">>> EXECUTING "
+ why + " of " + r.shortName);
// For b/34123235: Services within the system server won't start until SystemServer
// does Looper.loop(), so we shouldn't try to start/bind to them too early in the boot
// process. However, since there's a little point of showing the ANR dialog in that case,
// let's suppress the timeout until PHASE_THIRD_PARTY_APPS_CAN_START.
//
// (Note there are multiple services start at PHASE_THIRD_PARTY_APPS_CAN_START too,
// which technically could also trigger this timeout if there's a system server
// that takes a long time to handle PHASE_THIRD_PARTY_APPS_CAN_START, but that shouldn't
// happen.)
boolean timeoutNeeded = true;
if ((mAm.mBootPhase < SystemService.PHASE_THIRD_PARTY_APPS_CAN_START)
&& (r.app != null) && (r.app.pid == android.os.Process.myPid())) {
Slog.w(TAG, "Too early to start/bind service in system_server: Phase=" + mAm.mBootPhase
+ " " + r.getComponentName());
timeoutNeeded = false;
}
long now = SystemClock.uptimeMillis();
if (r.executeNesting == 0) {
r.executeFg = fg;
ServiceState stracker = r.getTracker();
if (stracker != null) {
stracker.setExecuting(true, mAm.mProcessStats.getMemFactorLocked(), now);
}
if (r.app != null) {
r.app.executingServices.add(r);
r.app.execServicesFg |= fg;
if (timeoutNeeded && r.app.executingServices.size() == 1) {
scheduleServiceTimeoutLocked(r.app);
}
}
} else if (r.app != null && fg && !r.app.execServicesFg) {
r.app.execServicesFg = true;
if (timeoutNeeded) {
scheduleServiceTimeoutLocked(r.app);
}
}
r.executeFg |= fg;
r.executeNesting++;
r.executingStart = now;
}