Merge "Replaced Slog by Slogf." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-04-07 16:35:53 +00:00
committed by Android (Google) Code Review
10 changed files with 392 additions and 386 deletions

View File

@@ -93,7 +93,6 @@ import android.util.ArraySet;
import android.util.EventLog;
import android.util.IntArray;
import android.util.Pair;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.util.proto.ProtoOutputStream;
@@ -110,6 +109,7 @@ import com.android.server.SystemServiceManager;
import com.android.server.am.UserState.KeyEvictedCallback;
import com.android.server.pm.UserManagerInternal;
import com.android.server.pm.UserManagerService;
import com.android.server.utils.Slogf;
import com.android.server.utils.TimingsTraceAndSlog;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowManagerService;
@@ -510,7 +510,7 @@ class UserController implements Handler.Callback {
elapsedTimeMs);
final long maxElapsedTimeMs = 120_000;
if (elapsedTimeMs > maxElapsedTimeMs) {
Slog.wtf("SystemServerTiming",
Slogf.wtf("SystemServerTiming",
"finishUserBoot took too long. elapsedTimeMs=" + elapsedTimeMs);
}
}
@@ -533,12 +533,12 @@ class UserController implements Handler.Callback {
final UserInfo parent = mInjector.getUserManager().getProfileParent(userId);
if (parent != null
&& isUserRunning(parent.id, ActivityManager.FLAG_AND_UNLOCKED)) {
Slog.d(TAG, "User " + userId + " (parent " + parent.id
Slogf.d(TAG, "User " + userId + " (parent " + parent.id
+ "): attempting unlock because parent is unlocked");
maybeUnlockUser(userId);
} else {
String parentId = (parent == null) ? "<null>" : String.valueOf(parent.id);
Slog.d(TAG, "User " + userId + " (parent " + parentId
Slogf.d(TAG, "User " + userId + " (parent " + parentId
+ "): delaying unlock because parent is locked");
}
} else {
@@ -587,7 +587,7 @@ class UserController implements Handler.Callback {
// Call onBeforeUnlockUser on a worker thread that allows disk I/O
FgThread.getHandler().post(() -> {
if (!StorageManager.isUserKeyUnlocked(userId)) {
Slog.w(TAG, "User key got locked unexpectedly, leaving user locked.");
Slogf.w(TAG, "User key got locked unexpectedly, leaving user locked.");
return;
}
mInjector.getUserManager().onBeforeUnlockUser(userId);
@@ -716,7 +716,7 @@ class UserController implements Handler.Callback {
Runnable initializeUser = () -> mInjector.getUserManager().makeInitialized(userInfo.id);
if (!userInfo.isInitialized()) {
Slog.d(TAG, "Initializing user #" + userId);
Slogf.d(TAG, "Initializing user #" + userId);
if (userInfo.preCreated) {
initializeUser.run();
} else if (userId != UserHandle.USER_SYSTEM) {
@@ -739,7 +739,7 @@ class UserController implements Handler.Callback {
}
if (userInfo.preCreated) {
Slog.i(TAG, "Stopping pre-created user " + userInfo.toFullString());
Slogf.i(TAG, "Stopping pre-created user " + userInfo.toFullString());
// Pre-created user was started right after creation so services could properly
// intialize it; it should be stopped right away as it's not really a "real" user.
stopUser(userInfo.id, /* force= */ true, /* allowDelayedLocking= */ false,
@@ -752,7 +752,7 @@ class UserController implements Handler.Callback {
mHandler.obtainMessage(USER_UNLOCKED_MSG, userId, 0).sendToTarget();
Slog.i(TAG, "Posting BOOT_COMPLETED user #" + userId);
Slogf.i(TAG, "Posting BOOT_COMPLETED user #" + userId);
// Do not report secondary users, runtime restarts or first boot/upgrade
if (userId == UserHandle.USER_SYSTEM
&& !mInjector.isRuntimeRestarted() && !mInjector.isFirstBootOrUpgrade()) {
@@ -777,7 +777,7 @@ class UserController implements Handler.Callback {
public void performReceive(Intent intent, int resultCode, String data,
Bundle extras, boolean ordered, boolean sticky, int sendingUser)
throws RemoteException {
Slog.i(UserController.TAG, "Finished processing BOOT_COMPLETED for u"
Slogf.i(UserController.TAG, "Finished processing BOOT_COMPLETED for u"
+ userId);
mBootCompleted = true;
}
@@ -863,11 +863,12 @@ class UserController implements Handler.Callback {
for (int i = 0; i < usersToStop.length; i++) {
int relatedUserId = usersToStop[i];
if ((UserHandle.USER_SYSTEM == relatedUserId) || isCurrentUserLU(relatedUserId)) {
if (DEBUG_MU) Slog.i(TAG, "stopUsersLocked cannot stop related user "
+ relatedUserId);
if (DEBUG_MU) {
Slogf.i(TAG, "stopUsersLocked cannot stop related user " + relatedUserId);
}
// We still need to stop the requested user if it's a force stop.
if (force) {
Slog.i(TAG,
Slogf.i(TAG,
"Force stop user " + userId + ". Related users will not be stopped");
stopSingleUserLU(userId, allowDelayedLocking, stopUserCallback,
keyEvictedCallback);
@@ -876,7 +877,7 @@ class UserController implements Handler.Callback {
return USER_OP_ERROR_RELATED_USERS_CANNOT_STOP;
}
}
if (DEBUG_MU) Slog.i(TAG, "stopUsersLocked usersToStop=" + Arrays.toString(usersToStop));
if (DEBUG_MU) Slogf.i(TAG, "stopUsersLocked usersToStop=" + Arrays.toString(usersToStop));
for (int userIdToStop : usersToStop) {
stopSingleUserLU(userIdToStop, allowDelayedLocking,
userIdToStop == userId ? stopUserCallback : null,
@@ -906,7 +907,7 @@ class UserController implements Handler.Callback {
private void stopSingleUserLU(final int userId, boolean allowDelayedLocking,
final IStopUserCallback stopUserCallback,
KeyEvictedCallback keyEvictedCallback) {
if (DEBUG_MU) Slog.i(TAG, "stopSingleUserLocked userId=" + userId);
if (DEBUG_MU) Slogf.i(TAG, "stopSingleUserLocked userId=" + userId);
final UserState uss = mStartedUsers.get(userId);
if (uss == null) { // User is not started
// If mDelayUserDataLocking is set and allowDelayedLocking is not set, we need to lock
@@ -917,7 +918,7 @@ class UserController implements Handler.Callback {
// and no further action is necessary.
if (mDelayUserDataLocking) {
if (allowDelayedLocking && keyEvictedCallback != null) {
Slog.wtf(TAG, "allowDelayedLocking set with KeyEvictedCallback, ignore it"
Slogf.wtf(TAG, "allowDelayedLocking set with KeyEvictedCallback, ignore it"
+ " and lock user:" + userId, new RuntimeException());
allowDelayedLocking = false;
}
@@ -1043,7 +1044,7 @@ class UserController implements Handler.Callback {
void finishUserStopped(UserState uss, boolean allowDelayedLocking) {
final int userId = uss.mHandle.getIdentifier();
if (DEBUG_MU) {
Slog.i(TAG, "finishUserStopped(%d): allowDelayedLocking=%b", userId,
Slogf.i(TAG, "finishUserStopped(%d): allowDelayedLocking=%b", userId,
allowDelayedLocking);
}
@@ -1067,7 +1068,7 @@ class UserController implements Handler.Callback {
mUserLru.remove(Integer.valueOf(userId));
updateStartedUserArrayLU();
if (allowDelayedLocking && !keyEvictedCallbacks.isEmpty()) {
Slog.wtf(TAG,
Slogf.wtf(TAG,
"Delayed locking enabled while KeyEvictedCallbacks not empty, userId:"
+ userId + " callbacks:" + keyEvictedCallbacks);
allowDelayedLocking = false;
@@ -1118,7 +1119,7 @@ class UserController implements Handler.Callback {
FgThread.getHandler().post(() -> {
synchronized (mLock) {
if (mStartedUsers.get(userId) != null) {
Slog.w(TAG, "User was restarted, skipping key eviction");
Slogf.w(TAG, "User was restarted, skipping key eviction");
return;
}
}
@@ -1156,10 +1157,10 @@ class UserController implements Handler.Callback {
if (totalUnlockedUsers > mMaxRunningUsers) { // should lock a user
userIdToLock = mLastActiveUsers.get(mLastActiveUsers.size() - 1);
mLastActiveUsers.remove(mLastActiveUsers.size() - 1);
Slog.i(TAG, "finishUserStopped, stopping user:" + userId
Slogf.i(TAG, "finishUserStopped, stopping user:" + userId
+ " lock user:" + userIdToLock);
} else {
Slog.i(TAG, "finishUserStopped, user:" + userId + ", skip locking");
Slogf.i(TAG, "finishUserStopped, user:" + userId + ", skip locking");
// do not lock
userIdToLock = UserHandle.USER_NULL;
}
@@ -1196,7 +1197,7 @@ class UserController implements Handler.Callback {
}
private void forceStopUser(@UserIdInt int userId, String reason) {
if (DEBUG_MU) Slog.i(TAG, "forceStopUser(%d): %s", userId, reason);
if (DEBUG_MU) Slogf.i(TAG, "forceStopUser(%d): %s", userId, reason);
mInjector.activityManagerForceStopPackage(userId, reason);
if (mInjector.getUserManager().isPreCreated(userId)) {
// Don't fire intent for precreated.
@@ -1227,7 +1228,7 @@ class UserController implements Handler.Callback {
* Stops the guest or ephemeral user if it has gone to the background.
*/
private void stopGuestOrEphemeralUserIfBackground(int oldUserId) {
if (DEBUG_MU) Slog.i(TAG, "Stop guest or ephemeral user if background: " + oldUserId);
if (DEBUG_MU) Slogf.i(TAG, "Stop guest or ephemeral user if background: " + oldUserId);
synchronized(mLock) {
UserState oldUss = mStartedUsers.get(oldUserId);
if (oldUserId == UserHandle.USER_SYSTEM || oldUserId == mCurrentUserId || oldUss == null
@@ -1265,7 +1266,7 @@ class UserController implements Handler.Callback {
void startProfiles() {
int currentUserId = getCurrentUserId();
if (DEBUG_MU) Slog.i(TAG, "startProfilesLocked");
if (DEBUG_MU) Slogf.i(TAG, "startProfilesLocked");
List<UserInfo> profiles = mInjector.getUserManager().getProfiles(
currentUserId, false /* enabledOnly */);
List<UserInfo> profilesToStart = new ArrayList<>(profiles.size());
@@ -1281,7 +1282,7 @@ class UserController implements Handler.Callback {
startUser(profilesToStart.get(i).id, /* foreground= */ false);
}
if (i < profilesToStartSize) {
Slog.w(TAG, "More profiles than MAX_RUNNING_USERS");
Slogf.w(TAG, "More profiles than MAX_RUNNING_USERS");
}
}
@@ -1309,7 +1310,7 @@ class UserController implements Handler.Callback {
}
if (!userInfo.isEnabled()) {
Slog.w(TAG, "Cannot start disabled profile #" + userId);
Slogf.w(TAG, "Cannot start disabled profile #" + userId);
return false;
}
@@ -1375,7 +1376,9 @@ class UserController implements Handler.Callback {
private boolean startUserInternal(@UserIdInt int userId, boolean foreground,
@Nullable IProgressListener unlockListener, @NonNull TimingsTraceAndSlog t) {
if (DEBUG_MU) Slog.i(TAG, "Starting user %d%s", userId, foreground ? " in foreground" : "");
if (DEBUG_MU) {
Slogf.i(TAG, "Starting user %d%s", userId, foreground ? " in foreground" : "");
}
EventLog.writeEvent(EventLogTags.UC_START_USER_INTERNAL, userId);
final int callingUid = Binder.getCallingUid();
@@ -1387,7 +1390,7 @@ class UserController implements Handler.Callback {
if (oldUserId == userId) {
final UserState state = getStartedUserState(userId);
if (state == null) {
Slog.wtf(TAG, "Current user has no UserState");
Slogf.wtf(TAG, "Current user has no UserState");
// continue starting.
} else {
if (userId == UserHandle.USER_SYSTEM && state.state == STATE_BOOTING) {
@@ -1417,16 +1420,16 @@ class UserController implements Handler.Callback {
t.traceEnd();
if (userInfo == null) {
Slog.w(TAG, "No user info for user #" + userId);
Slogf.w(TAG, "No user info for user #" + userId);
return false;
}
if (foreground && userInfo.isProfile()) {
Slog.w(TAG, "Cannot switch to User #" + userId + ": not a full user");
Slogf.w(TAG, "Cannot switch to User #" + userId + ": not a full user");
return false;
}
if (foreground && userInfo.preCreated) {
Slog.w(TAG, "Cannot start pre-created user #" + userId + " as foreground");
Slogf.w(TAG, "Cannot start pre-created user #" + userId + " as foreground");
return false;
}
@@ -1454,7 +1457,7 @@ class UserController implements Handler.Callback {
needStart = true;
updateUmState = true;
} else if (uss.state == UserState.STATE_SHUTDOWN && !isCallingOnHandlerThread()) {
Slog.i(TAG, "User #" + userId
Slogf.i(TAG, "User #" + userId
+ " is shutting down - will start after full stop");
mHandler.post(() -> startUser(userId, foreground, unlockListener));
t.traceEnd(); // updateStartedUserArrayStarting
@@ -1663,7 +1666,7 @@ class UserController implements Handler.Callback {
// We always want to unlock user storage, even user is not started yet
storageManager.unlockUserKey(userId, userInfo.serialNumber, token, secret);
} catch (RemoteException | RuntimeException e) {
Slog.w(TAG, "Failed to unlock: " + e.getMessage());
Slogf.w(TAG, "Failed to unlock: " + e.getMessage());
}
}
synchronized (mLock) {
@@ -1699,7 +1702,7 @@ class UserController implements Handler.Callback {
for (int testUserId : userIds) {
final UserInfo parent = mInjector.getUserManager().getProfileParent(testUserId);
if (parent != null && parent.id == userId && testUserId != userId) {
Slog.d(TAG, "User " + testUserId + " (parent " + parent.id
Slogf.d(TAG, "User " + testUserId + " (parent " + parent.id
+ "): attempting unlock because parent was just unlocked");
maybeUnlockUser(testUserId);
}
@@ -1714,25 +1717,25 @@ class UserController implements Handler.Callback {
int currentUserId = getCurrentUserId();
UserInfo targetUserInfo = getUserInfo(targetUserId);
if (targetUserId == currentUserId) {
Slog.i(TAG, "user #" + targetUserId + " is already the current user");
Slogf.i(TAG, "user #" + targetUserId + " is already the current user");
return true;
}
if (targetUserInfo == null) {
Slog.w(TAG, "No user info for user #" + targetUserId);
Slogf.w(TAG, "No user info for user #" + targetUserId);
return false;
}
if (!targetUserInfo.supportsSwitchTo()) {
Slog.w(TAG, "Cannot switch to User #" + targetUserId + ": not supported");
Slogf.w(TAG, "Cannot switch to User #" + targetUserId + ": not supported");
return false;
}
if (targetUserInfo.isProfile()) {
Slog.w(TAG, "Cannot switch to User #" + targetUserId + ": not a full user");
Slogf.w(TAG, "Cannot switch to User #" + targetUserId + ": not a full user");
return false;
}
boolean userSwitchUiEnabled;
synchronized (mLock) {
if (!mInitialized) {
Slog.e(TAG, "Cannot switch to User #" + targetUserId
Slogf.e(TAG, "Cannot switch to User #" + targetUserId
+ ": UserController not ready yet");
return false;
}
@@ -1809,13 +1812,13 @@ class UserController implements Handler.Callback {
boolean disallowRunInBg = hasRestriction || shouldStopBackgroundUsersOnSwitch();
if (!disallowRunInBg) {
if (DEBUG_MU) {
Slog.i(TAG, "stopBackgroundUsersIfEnforced() NOT stopping %d and related users",
oldUserId);
Slogf.i(TAG, "stopBackgroundUsersIfEnforced() NOT stopping %d and related "
+ "users", oldUserId);
}
return;
}
if (DEBUG_MU) {
Slog.i(TAG, "stopBackgroundUsersIfEnforced() stopping %d and related users",
Slogf.i(TAG, "stopBackgroundUsersIfEnforced() stopping %d and related users",
oldUserId);
}
stopUsersLU(oldUserId, /* force= */ false, /* allowDelayedLocking= */ true,
@@ -1825,7 +1828,7 @@ class UserController implements Handler.Callback {
private void timeoutUserSwitch(UserState uss, int oldUserId, int newUserId) {
synchronized (mLock) {
Slog.e(TAG, "User switch timeout: from " + oldUserId + " to " + newUserId);
Slogf.e(TAG, "User switch timeout: from " + oldUserId + " to " + newUserId);
mTimeoutUserSwitchCallbacks = mCurWaitingUserSwitchCallbacks;
mHandler.removeMessages(USER_SWITCH_CALLBACKS_TIMEOUT_MSG);
sendContinueUserSwitchLU(uss, oldUserId, newUserId);
@@ -1838,7 +1841,7 @@ class UserController implements Handler.Callback {
private void timeoutUserSwitchCallbacks(int oldUserId, int newUserId) {
synchronized (mLock) {
if (mTimeoutUserSwitchCallbacks != null && !mTimeoutUserSwitchCallbacks.isEmpty()) {
Slog.wtf(TAG, "User switch timeout: from " + oldUserId + " to " + newUserId
Slogf.wtf(TAG, "User switch timeout: from " + oldUserId + " to " + newUserId
+ ". Observers that didn't respond: " + mTimeoutUserSwitchCallbacks);
mTimeoutUserSwitchCallbacks = null;
}
@@ -1870,10 +1873,10 @@ class UserController implements Handler.Callback {
synchronized (mLock) {
long delay = SystemClock.elapsedRealtime() - dispatchStartedTime;
if (delay > USER_SWITCH_TIMEOUT_MS) {
Slog.e(TAG, "User switch timeout: observer " + name
Slogf.e(TAG, "User switch timeout: observer " + name
+ " sent result after " + delay + " ms");
} else if (delay > USER_SWITCH_WARNING_TIMEOUT_MS) {
Slog.w(TAG, "User switch slowed down by observer " + name
Slogf.w(TAG, "User switch slowed down by observer " + name
+ ": result sent after " + delay + " ms");
}
@@ -2091,7 +2094,7 @@ class UserController implements Handler.Callback {
}
}
String msg = builder.toString();
Slog.w(TAG, msg);
Slogf.w(TAG, msg);
throw new SecurityException(msg);
}
}
@@ -2318,7 +2321,7 @@ class UserController implements Handler.Callback {
+ Binder.getCallingPid()
+ ", uid=" + Binder.getCallingUid()
+ " requires " + INTERACT_ACROSS_USERS;
Slog.w(TAG, msg);
Slogf.w(TAG, msg);
throw new SecurityException(msg);
}
}
@@ -2421,7 +2424,7 @@ class UserController implements Handler.Callback {
+ "() from pid=" + Binder.getCallingPid()
+ ", uid=" + Binder.getCallingUid()
+ " requires " + permission;
Slog.w(TAG, msg);
Slogf.w(TAG, msg);
throw new SecurityException(msg);
}
}
@@ -2732,7 +2735,7 @@ class UserController implements Handler.Callback {
* journey so no need to create a new journey for user start.
*/
if (DEBUG_MU) {
Slog.d(TAG, journey + " not logged as it is expected to be part of "
Slogf.d(TAG, journey + " not logged as it is expected to be part of "
+ userJourneySession.mJourney);
}
return;
@@ -2755,7 +2758,7 @@ class UserController implements Handler.Callback {
}
if (DEBUG_MU) {
Slog.d(TAG,
Slogf.d(TAG,
"Starting a new journey: " + journey + " with session id: " + newSessionId);
}
@@ -2787,7 +2790,7 @@ class UserController implements Handler.Callback {
synchronized (mUserIdToUserJourneyMap) {
final UserJourneySession userJourneySession = mUserIdToUserJourneyMap.get(userId);
if (userJourneySession == null || userJourneySession.mSessionId == INVALID_SESSION_ID) {
Slog.w(TAG, "UserLifecycleEvent " + event
Slogf.w(TAG, "UserLifecycleEvent " + event
+ " received without an active userJourneySession.");
return;
}
@@ -2870,13 +2873,13 @@ class UserController implements Handler.Callback {
private volatile long mUnlockStarted;
@Override
public void onStarted(int id, Bundle extras) throws RemoteException {
Slog.d(TAG, "Started unlocking user " + id);
Slogf.d(TAG, "Started unlocking user " + id);
mUnlockStarted = SystemClock.uptimeMillis();
}
@Override
public void onProgress(int id, int progress, Bundle extras) throws RemoteException {
Slog.d(TAG, "Unlocking user " + id + " progress " + progress);
Slogf.d(TAG, "Unlocking user " + id + " progress " + progress);
}
@Override
@@ -3061,7 +3064,7 @@ class UserController implements Handler.Callback {
// config_customUserSwitchUi is set to true on Automotive as CarSystemUI is
// responsible to show the UI; OEMs should not change that, but if they do, we
// should at least warn the user...
Slog.w(TAG, "Showing user switch dialog on UserController, it could cause a race "
Slogf.w(TAG, "Showing user switch dialog on UserController, it could cause a race "
+ "condition if it's shown by CarSystemUI as well");
}
final Dialog d = new UserSwitchingDialog(mService, mService.mContext, fromUser,

View File

@@ -41,13 +41,13 @@ import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.TypedXmlPullParser;
import android.util.TypedXmlSerializer;
import com.android.internal.util.Preconditions;
import com.android.internal.util.XmlUtils;
import com.android.server.pm.UserRestrictionsUtils;
import com.android.server.utils.Slogf;
import org.xmlpull.v1.XmlPullParserException;
@@ -469,7 +469,7 @@ class ActiveAdmin {
try {
trustAgentInfo.options.saveToXml(out);
} catch (XmlPullParserException e) {
Slog.e(LOG_TAG, e, "Failed to save TrustAgent options");
Slogf.e(LOG_TAG, e, "Failed to save TrustAgent options");
}
out.endTag(null, TAG_TRUST_AGENT_COMPONENT_OPTIONS);
}
@@ -651,7 +651,7 @@ class ActiveAdmin {
String tag = parser.getName();
if (TAG_POLICIES.equals(tag)) {
if (shouldOverridePolicies) {
Slog.d(LOG_TAG, "Overriding device admin policies from XML.");
Slogf.d(LOG_TAG, "Overriding device admin policies from XML.");
info.readPoliciesFromXml(parser);
}
} else if (TAG_PASSWORD_QUALITY.equals(tag)) {
@@ -747,14 +747,14 @@ class ActiveAdmin {
if (type == TypedXmlPullParser.TEXT) {
shortSupportMessage = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing text when loading short support message");
Slogf.w(LOG_TAG, "Missing text when loading short support message");
}
} else if (TAG_LONG_SUPPORT_MESSAGE.equals(tag)) {
type = parser.next();
if (type == TypedXmlPullParser.TEXT) {
longSupportMessage = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing text when loading long support message");
Slogf.w(LOG_TAG, "Missing text when loading long support message");
}
} else if (TAG_PARENT_ADMIN.equals(tag)) {
Preconditions.checkState(!isParent);
@@ -767,7 +767,7 @@ class ActiveAdmin {
if (type == TypedXmlPullParser.TEXT) {
organizationName = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing text when loading organization name");
Slogf.w(LOG_TAG, "Missing text when loading organization name");
}
} else if (TAG_IS_LOGOUT_ENABLED.equals(tag)) {
isLogoutEnabled = parser.getAttributeBoolean(null, ATTR_VALUE, false);
@@ -776,14 +776,14 @@ class ActiveAdmin {
if (type == TypedXmlPullParser.TEXT) {
startUserSessionMessage = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing text when loading start session message");
Slogf.w(LOG_TAG, "Missing text when loading start session message");
}
} else if (TAG_END_USER_SESSION_MESSAGE.equals(tag)) {
type = parser.next();
if (type == TypedXmlPullParser.TEXT) {
endUserSessionMessage = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing text when loading end session message");
Slogf.w(LOG_TAG, "Missing text when loading end session message");
}
} else if (TAG_CROSS_PROFILE_CALENDAR_PACKAGES.equals(tag)) {
mCrossProfileCalendarPackages = readPackageList(parser, tag);
@@ -822,14 +822,14 @@ class ActiveAdmin {
if (type == TypedXmlPullParser.TEXT) {
mOrganizationId = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing Organization ID.");
Slogf.w(LOG_TAG, "Missing Organization ID.");
}
} else if (TAG_ENROLLMENT_SPECIFIC_ID.equals(tag)) {
type = parser.next();
if (type == TypedXmlPullParser.TEXT) {
mEnrollmentSpecificId = parser.getText();
} else {
Slog.w(LOG_TAG, "Missing Enrollment-specific ID.");
Slogf.w(LOG_TAG, "Missing Enrollment-specific ID.");
}
} else if (TAG_ADMIN_CAN_GRANT_SENSORS_PERMISSIONS.equals(tag)) {
mAdminCanGrantSensorsPermissions = parser.getAttributeBoolean(null, ATTR_VALUE,
@@ -838,7 +838,7 @@ class ActiveAdmin {
mUsbDataSignalingEnabled = parser.getAttributeBoolean(null, ATTR_VALUE,
USB_DATA_SIGNALING_ENABLED_DEFAULT);
} else {
Slog.w(LOG_TAG, "Unknown admin tag: %s", tag);
Slogf.w(LOG_TAG, "Unknown admin tag: %s", tag);
XmlUtils.skipCurrentTag(parser);
}
}
@@ -860,10 +860,10 @@ class ActiveAdmin {
if (packageName != null) {
result.add(packageName);
} else {
Slog.w(LOG_TAG, "Package name missing under %s", outerTag);
Slogf.w(LOG_TAG, "Package name missing under %s", outerTag);
}
} else {
Slog.w(LOG_TAG, "Unknown tag under %s: ", tag, outerTag);
Slogf.w(LOG_TAG, "Unknown tag under %s: ", tag, outerTag);
}
}
return result;
@@ -884,7 +884,7 @@ class ActiveAdmin {
if (tag.equals(tagDAM)) {
result.add(parser.getAttributeValue(null, ATTR_VALUE));
} else {
Slog.e(LOG_TAG, "Expected tag %s but found %s", tag, tagDAM);
Slogf.e(LOG_TAG, "Expected tag %s but found %s", tag, tagDAM);
}
}
}
@@ -906,7 +906,7 @@ class ActiveAdmin {
final TrustAgentInfo trustAgentInfo = getTrustAgentInfo(parser, tag);
result.put(component, trustAgentInfo);
} else {
Slog.w(LOG_TAG, "Unknown tag under %s: %s", tag, tagDAM);
Slogf.w(LOG_TAG, "Unknown tag under %s: %s", tag, tagDAM);
}
}
return result;
@@ -926,7 +926,7 @@ class ActiveAdmin {
if (TAG_TRUST_AGENT_COMPONENT_OPTIONS.equals(tagDAM)) {
result.options = PersistableBundle.restoreFromXml(parser);
} else {
Slog.w(LOG_TAG, "Unknown tag under %s: %s", tag, tagDAM);
Slogf.w(LOG_TAG, "Unknown tag under %s: %s", tag, tagDAM);
}
}
return result;

View File

@@ -35,11 +35,11 @@ import android.provider.Settings;
import android.security.Credentials;
import android.security.KeyChain;
import android.security.KeyChain.KeyChainConnection;
import android.util.Slog;
import com.android.internal.R;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.server.utils.Slogf;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -79,16 +79,16 @@ public class CertificateMonitor {
X509Certificate cert = parseCert(certBuffer);
pemCert = Credentials.convertToPem(cert);
} catch (CertificateException | IOException ce) {
Slog.e(LOG_TAG, "Problem converting cert", ce);
Slogf.e(LOG_TAG, "Problem converting cert", ce);
return null;
}
try (KeyChainConnection keyChainConnection = mInjector.keyChainBindAsUser(userHandle)) {
return keyChainConnection.getService().installCaCertificate(pemCert);
} catch (RemoteException e) {
Slog.e(LOG_TAG, "installCaCertsToKeyChain(): ", e);
Slogf.e(LOG_TAG, "installCaCertsToKeyChain(): ", e);
} catch (InterruptedException e1) {
Slog.w(LOG_TAG, "installCaCertsToKeyChain(): ", e1);
Slogf.w(LOG_TAG, "installCaCertsToKeyChain(): ", e1);
Thread.currentThread().interrupt();
}
return null;
@@ -100,9 +100,9 @@ public class CertificateMonitor {
keyChainConnection.getService().deleteCaCertificate(aliases[i]);
}
} catch (RemoteException e) {
Slog.e(LOG_TAG, "from CaCertUninstaller: ", e);
Slogf.e(LOG_TAG, "from CaCertUninstaller: ", e);
} catch (InterruptedException ie) {
Slog.w(LOG_TAG, "CaCertUninstaller: ", ie);
Slogf.w(LOG_TAG, "CaCertUninstaller: ", ie);
Thread.currentThread().interrupt();
}
}
@@ -147,7 +147,7 @@ public class CertificateMonitor {
try {
installedCerts = getInstalledCaCertificates(userHandle);
} catch (RemoteException | RuntimeException e) {
Slog.e(LOG_TAG, e, "Could not retrieve certificates from KeyChain service for user %d",
Slogf.e(LOG_TAG, e, "Could not retrieve certificates from KeyChain service for user %d",
userId);
return;
}
@@ -170,7 +170,7 @@ public class CertificateMonitor {
try {
userContext = mInjector.createContextAsUser(userHandle);
} catch (PackageManager.NameNotFoundException e) {
Slog.e(LOG_TAG, e, "Create context as %s failed", userHandle);
Slogf.e(LOG_TAG, e, "Create context as %s failed", userHandle);
return null;
}

View File

@@ -27,13 +27,13 @@ import android.content.pm.ServiceInfo;
import android.os.Handler;
import android.os.IBinder;
import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.SparseArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.BackgroundThread;
import com.android.server.am.PersistentConnection;
import com.android.server.appbinding.AppBindingUtils;
import com.android.server.utils.Slogf;
/**
* Manages connections to persistent services in owner packages.
@@ -114,7 +114,8 @@ public class DeviceAdminServiceController {
final ServiceInfo service = findService(packageName, userId);
if (service == null) {
if (DEBUG) {
Slog.d(TAG, "Owner package %s on u%d has no service.", packageName, userId);
Slogf.d(TAG, "Owner package %s on u%d has no service.", packageName,
userId);
}
disconnectServiceOnUserLocked(userId, actionForLog);
return;
@@ -127,14 +128,14 @@ public class DeviceAdminServiceController {
// would have died at this point due to a package update. So we disconnect
// anyway and re-connect.
if (DEBUG) {
Slog.d("Disconnecting from existing service connection.", packageName,
Slogf.d("Disconnecting from existing service connection.", packageName,
userId);
}
disconnectServiceOnUserLocked(userId, actionForLog);
}
if (DEBUG) {
Slog.d("Owner package %s on u%d has service %s for %s", packageName, userId,
Slogf.d("Owner package %s on u%d has service %s for %s", packageName, userId,
service.getComponentName().flattenToShortString(), actionForLog);
}
@@ -168,7 +169,7 @@ public class DeviceAdminServiceController {
final DevicePolicyServiceConnection conn = mConnections.get(userId);
if (conn != null) {
if (DEBUG) {
Slog.d(TAG, "Stopping service for u%d if already running for %s.", userId,
Slogf.d(TAG, "Stopping service for u%d if already running for %s.", userId,
actionForLog);
}
conn.unbind();

View File

@@ -17,7 +17,8 @@ package com.android.server.devicepolicy;
import android.util.IndentingPrintWriter;
import android.util.KeyValueListParser;
import android.util.Slog;
import com.android.server.utils.Slogf;
import java.util.concurrent.TimeUnit;
@@ -99,7 +100,7 @@ public class DevicePolicyConstants {
} catch (IllegalArgumentException e) {
// Failed to parse the settings string, log this and move on
// with defaults.
Slog.e(TAG, "Bad device policy settings: %s", settings);
Slogf.e(TAG, "Bad device policy settings: %s", settings);
}
long dasDiedServiceReconnectBackoffSec = parser.getLong(

View File

@@ -27,13 +27,13 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DebugUtils;
import android.util.IndentingPrintWriter;
import android.util.Slog;
import android.util.TypedXmlPullParser;
import android.util.TypedXmlSerializer;
import android.util.Xml;
import com.android.internal.util.JournaledFile;
import com.android.internal.util.XmlUtils;
import com.android.server.utils.Slogf;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
@@ -183,7 +183,7 @@ class DevicePolicyData {
try {
chooseForWrite = file.chooseForWrite();
if (VERBOSE_LOG) {
Slog.v(TAG, "Storing data for user %d on %s ", policyData.mUserId, chooseForWrite);
Slogf.v(TAG, "Storing data for user %d on %s ", policyData.mUserId, chooseForWrite);
}
stream = new FileOutputStream(chooseForWrite, false);
TypedXmlSerializer out = Xml.resolveSerializer(stream);
@@ -195,7 +195,7 @@ class DevicePolicyData {
policyData.mRestrictionsProvider.flattenToString());
}
if (policyData.mUserSetupComplete) {
if (VERBOSE_LOG) Slog.v(TAG, "setting %s to true", ATTR_SETUP_COMPLETE);
if (VERBOSE_LOG) Slogf.v(TAG, "setting %s to true", ATTR_SETUP_COMPLETE);
out.attributeBoolean(null, ATTR_SETUP_COMPLETE, true);
}
if (policyData.mPaired) {
@@ -216,7 +216,7 @@ class DevicePolicyData {
if (policyData.mFactoryResetFlags != 0) {
if (VERBOSE_LOG) {
Slog.v(TAG, "Storing factory reset flags for user %d: %s", policyData.mUserId,
Slogf.v(TAG, "Storing factory reset flags for user %d: %s", policyData.mUserId,
factoryResetFlagsToString(policyData.mFactoryResetFlags));
}
out.attributeInt(null, ATTR_FACTORY_RESET_FLAGS, policyData.mFactoryResetFlags);
@@ -382,7 +382,7 @@ class DevicePolicyData {
file.commit();
return true;
} catch (XmlPullParserException | IOException e) {
Slog.w(TAG, e, "failed writing file %s", chooseForWrite);
Slogf.w(TAG, e, "failed writing file %s", chooseForWrite);
try {
if (stream != null) {
stream.close();
@@ -404,7 +404,7 @@ class DevicePolicyData {
ComponentName ownerComponent) {
FileInputStream stream = null;
File file = journaledFile.chooseForRead();
if (VERBOSE_LOG) Slog.v(TAG, "Loading data for user %d from %s", policy.mUserId, file);
if (VERBOSE_LOG) Slogf.v(TAG, "Loading data for user %d from %s", policy.mUserId, file);
boolean needsRewrite = false;
try {
stream = new FileInputStream(file);
@@ -428,7 +428,7 @@ class DevicePolicyData {
}
String userSetupComplete = parser.getAttributeValue(null, ATTR_SETUP_COMPLETE);
if (Boolean.toString(true).equals(userSetupComplete)) {
if (VERBOSE_LOG) Slog.v(TAG, "setting mUserSetupComplete to true");
if (VERBOSE_LOG) Slogf.v(TAG, "setting mUserSetupComplete to true");
policy.mUserSetupComplete = true;
}
String paired = parser.getAttributeValue(null, ATTR_DEVICE_PAIRED);
@@ -452,7 +452,7 @@ class DevicePolicyData {
policy.mFactoryResetFlags = parser.getAttributeInt(null, ATTR_FACTORY_RESET_FLAGS, 0);
if (VERBOSE_LOG) {
Slog.v(TAG, "Restored factory reset flags for user %d: %s", policy.mUserId,
Slogf.v(TAG, "Restored factory reset flags for user %d: %s", policy.mUserId,
factoryResetFlagsToString(policy.mFactoryResetFlags));
}
policy.mFactoryResetReason = parser.getAttributeValue(null, ATTR_FACTORY_RESET_REASON);
@@ -486,7 +486,7 @@ class DevicePolicyData {
policy.mAdminMap.put(ap.info.getComponent(), ap);
}
} catch (RuntimeException e) {
Slog.w(TAG, e, "Failed loading admin %s", name);
Slogf.w(TAG, e, "Failed loading admin %s", name);
}
} else if ("delegation".equals(tag)) {
// Parse delegation info.
@@ -558,7 +558,7 @@ class DevicePolicyData {
policy.mAppsSuspended =
parser.getAttributeBoolean(null, ATTR_VALUE, false);
} else {
Slog.w(TAG, "Unknown tag: %s", tag);
Slogf.w(TAG, "Unknown tag: %s", tag);
XmlUtils.skipCurrentTag(parser);
}
}
@@ -566,7 +566,7 @@ class DevicePolicyData {
// Don't be noisy, this is normal if we haven't defined any policies.
} catch (NullPointerException | NumberFormatException | XmlPullParserException | IOException
| IndexOutOfBoundsException e) {
Slog.w(TAG, e, "failed parsing %s", file);
Slogf.w(TAG, e, "failed parsing %s", file);
}
try {
if (stream != null) {
@@ -590,7 +590,7 @@ class DevicePolicyData {
}
}
if (!haveOwner) {
Slog.w(TAG, "Previous password owner %s no longer active; disabling",
Slogf.w(TAG, "Previous password owner %s no longer active; disabling",
mPasswordOwner);
mPasswordOwner = -1;
}

View File

@@ -26,10 +26,10 @@ import android.os.RemoteException;
import android.os.UserManager;
import android.os.storage.StorageManager;
import android.service.persistentdata.PersistentDataBlockManager;
import android.util.Slog;
import com.android.internal.os.IResultReceiver;
import com.android.internal.util.Preconditions;
import com.android.server.utils.Slogf;
import java.io.IOException;
import java.util.Objects;
@@ -68,16 +68,16 @@ public final class FactoryResetter {
IResultReceiver receiver = new IResultReceiver.Stub() {
@Override
public void send(int resultCode, Bundle resultData) throws RemoteException {
Slog.i(TAG, "Factory reset confirmed by %s, proceeding", mSafetyChecker);
Slogf.i(TAG, "Factory reset confirmed by %s, proceeding", mSafetyChecker);
try {
factoryResetInternalUnchecked();
} catch (IOException e) {
// Shouldn't happen
Slog.wtf(TAG, e, "IOException calling underlying systems");
Slogf.wtf(TAG, e, "IOException calling underlying systems");
}
}
};
Slog.i(TAG, "Delaying factory reset until %s confirms", mSafetyChecker);
Slogf.i(TAG, "Delaying factory reset until %s confirms", mSafetyChecker);
mSafetyChecker.onFactoryReset(receiver);
return false;
}
@@ -112,7 +112,7 @@ public final class FactoryResetter {
}
private void factoryResetInternalUnchecked() throws IOException {
Slog.i(TAG, "factoryReset(): reason=%s, shutdown=%b, force=%b, wipeEuicc=%b, "
Slogf.i(TAG, "factoryReset(): reason=%s, shutdown=%b, force=%b, wipeEuicc=%b, "
+ "wipeAdoptableStorage=%b, wipeFRP=%b", mReason, mShutdown, mForce, mWipeEuicc,
mWipeAdoptableStorage, mWipeFactoryResetProtection);
@@ -125,15 +125,15 @@ public final class FactoryResetter {
PersistentDataBlockManager manager = mContext
.getSystemService(PersistentDataBlockManager.class);
if (manager != null) {
Slog.w(TAG, "Wiping factory reset protection");
Slogf.w(TAG, "Wiping factory reset protection");
manager.wipe();
} else {
Slog.w(TAG, "No need to wipe factory reset protection");
Slogf.w(TAG, "No need to wipe factory reset protection");
}
}
if (mWipeAdoptableStorage) {
Slog.w(TAG, "Wiping adoptable storage");
Slogf.w(TAG, "Wiping adoptable storage");
StorageManager sm = mContext.getSystemService(StorageManager.class);
sm.wipeAdoptableDisks();
}

View File

@@ -39,13 +39,13 @@ import android.text.TextUtils;
import android.util.ArraySet;
import android.util.IndentingPrintWriter;
import android.util.Log;
import android.util.Slog;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.IAccessibilityManager;
import android.view.inputmethod.InputMethodInfo;
import com.android.internal.R;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.utils.Slogf;
import java.util.ArrayList;
import java.util.Arrays;
@@ -109,7 +109,7 @@ public final class PersonalAppsSuspensionHelper {
}
if (Log.isLoggable(LOG_TAG, Log.INFO)) {
Slog.i(LOG_TAG, "Packages subject to suspension: %s", String.join(",", result));
Slogf.i(LOG_TAG, "Packages subject to suspension: %s", String.join(",", result));
}
return result.toArray(new String[0]);
}
@@ -123,7 +123,7 @@ public final class PersonalAppsSuspensionHelper {
for (final ResolveInfo resolveInfo : matchingActivities) {
if (resolveInfo.activityInfo == null
|| TextUtils.isEmpty(resolveInfo.activityInfo.packageName)) {
Slog.wtf(LOG_TAG, "Could not find package name for launcher app %s", resolveInfo);
Slogf.wtf(LOG_TAG, "Could not find package name for launcher app %s", resolveInfo);
continue;
}
final String packageName = resolveInfo.activityInfo.packageName;
@@ -134,7 +134,7 @@ public final class PersonalAppsSuspensionHelper {
result.add(packageName);
}
} catch (PackageManager.NameNotFoundException e) {
Slog.e(LOG_TAG, "Could not find application info for launcher app: %s",
Slogf.e(LOG_TAG, "Could not find application info for launcher app: %s",
packageName);
}
}

View File

@@ -45,11 +45,11 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.text.format.DateUtils;
import android.util.Pair;
import android.util.Slog;
import com.android.internal.R;
import com.android.internal.messages.nano.SystemMessageProto.SystemMessage;
import com.android.internal.notification.SystemNotificationChannels;
import com.android.server.utils.Slogf;
import java.io.FileNotFoundException;
import java.lang.annotation.Retention;
@@ -135,7 +135,7 @@ public class RemoteBugreportManager {
if (targetInfo != null) {
dialogIntent.setComponent(targetInfo.getComponentName());
} else {
Slog.wtf(LOG_TAG, "Failed to resolve intent for remote bugreport dialog");
Slogf.wtf(LOG_TAG, "Failed to resolve intent for remote bugreport dialog");
}
// Simple notification clicks are immutable
@@ -191,7 +191,7 @@ public class RemoteBugreportManager {
public boolean requestBugreport() {
if (mRemoteBugreportServiceIsActive.get()
|| (mService.getDeviceOwnerRemoteBugreportUriAndHash() != null)) {
Slog.d(LOG_TAG, "Remote bugreport wasn't started because there's already one running.");
Slogf.d(LOG_TAG, "Remote bugreport wasn't started because there's already one running");
return false;
}
@@ -208,7 +208,7 @@ public class RemoteBugreportManager {
return true;
} catch (RemoteException re) {
// should never happen
Slog.e(LOG_TAG, "Failed to make remote calls to start bugreportremote service", re);
Slogf.e(LOG_TAG, "Failed to make remote calls to start bugreportremote service", re);
return false;
} finally {
mInjector.binderRestoreCallingIdentity(callingIdentity);
@@ -222,7 +222,7 @@ public class RemoteBugreportManager {
mContext.registerReceiver(mRemoteBugreportFinishedReceiver, filterFinished);
} catch (IntentFilter.MalformedMimeTypeException e) {
// should never happen, as setting a constant
Slog.w(LOG_TAG, e, "Failed to set type %s", BUGREPORT_MIMETYPE);
Slogf.w(LOG_TAG, e, "Failed to set type %s", BUGREPORT_MIMETYPE);
}
final IntentFilter filterConsent = new IntentFilter();
filterConsent.addAction(ACTION_BUGREPORT_SHARING_DECLINED);