Java Code Examples for android.util.Slog#wtf()

The following examples show how to use android.util.Slog#wtf() . 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 check out the related API usage on the sidebar.
Example 1
Source File: RecentTasks.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void syncPersistentTaskIdsLocked() {
    for (int i = mPersistedTaskIds.size() - 1; i >= 0; i--) {
        int userId = mPersistedTaskIds.keyAt(i);
        if (mUsersWithRecentsLoaded.get(userId)) {
            // Recents are loaded only after task ids are loaded. Therefore, the set of taskids
            // referenced here should not be null.
            mPersistedTaskIds.valueAt(i).clear();
        }
    }
    for (int i = mTasks.size() - 1; i >= 0; i--) {
        final TaskRecord task = mTasks.get(i);
        if (shouldPersistTaskLocked(task)) {
            // Set of persisted taskIds for task.userId should not be null here
            // TODO Investigate why it can happen. For now initialize with an empty set
            if (mPersistedTaskIds.get(task.userId) == null) {
                Slog.wtf(TAG, "No task ids found for userId " + task.userId + ". task=" + task
                        + " mPersistedTaskIds=" + mPersistedTaskIds);
                mPersistedTaskIds.put(task.userId, new SparseBooleanArray());
            }
            mPersistedTaskIds.get(task.userId).put(task.taskId, true);
        }
    }
}
 
Example 2
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Set a field in the crypto header.
 * @param field field to set
 * @param contents contents to set in field
 */
@Override
public void setField(String field, String contents) throws RemoteException {
    mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
        "no permission to access the crypt keeper");

    if (StorageManager.isFileEncryptedNativeOnly()) {
        // Not supported on FBE devices
        return;
    }

    try {
        mVold.fdeSetField(field, contents);
        return;
    } catch (Exception e) {
        Slog.wtf(TAG, e);
        return;
    }
}
 
Example 3
Source File: SystemServiceManager.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void unlockUser(final int userHandle) {
    Slog.i(TAG, "Calling onUnlockUser u" + userHandle);
    final int serviceLen = mServices.size();
    for (int i = 0; i < serviceLen; i++) {
        final SystemService service = mServices.get(i);
        Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "onUnlockUser "
                + service.getClass().getName());
        long time = SystemClock.elapsedRealtime();
        try {
            service.onUnlockUser(userHandle);
        } catch (Exception ex) {
            Slog.wtf(TAG, "Failure reporting unlock of user " + userHandle
                    + " to service " + service.getClass().getName(), ex);
        }
        warnIfTooLong(SystemClock.elapsedRealtime() - time, service, "onUnlockUser ");
        Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
    }
}
 
Example 4
Source File: ZygoteProcess.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Try connecting to the Zygote over and over again until we hit a time-out.
 * @param address The name of the socket to connect to.
 */
public static void waitForConnectionToZygote(LocalSocketAddress address) {
    for (int n = 20; n >= 0; n--) {
        try {
            final ZygoteState zs = ZygoteState.connect(address);
            zs.close();
            return;
        } catch (IOException ioe) {
            Log.w(LOG_TAG,
                    "Got error connecting to zygote, retrying. msg= " + ioe.getMessage());
        }

        try {
            Thread.sleep(1000);
        } catch (InterruptedException ie) {
        }
    }
    Slog.wtf(LOG_TAG, "Failed to connect to Zygote through socket " + address.getName());
}
 
Example 5
Source File: PackageDexOptimizer.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@GuardedBy("mInstallLock")
private void releaseWakeLockLI(final long acquireTime) {
    if (acquireTime < 0) {
        return;
    }
    try {
        if (mDexoptWakeLock.isHeld()) {
            mDexoptWakeLock.release();
        }
        final long duration = SystemClock.elapsedRealtime() - acquireTime;
        if (duration >= WAKELOCK_TIMEOUT_MS) {
            Slog.wtf(TAG, "WakeLock " + mDexoptWakeLock.getTag()
                    + " time out. Operation took " + duration + " ms. Thread: "
                    + Thread.currentThread().getName());
        }
    } catch (Exception e) {
        Slog.wtf(TAG, "Error while releasing " + mDexoptWakeLock.getTag() + " lock", e);
    }
}
 
Example 6
Source File: GlobalSettingsToPropertiesMapper.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void setProperty(String key, String value) {
    // Check if need to clear the property
    if (value == null) {
        // It's impossible to remove system property, therefore we check previous value to
        // avoid setting an empty string if the property wasn't set.
        if (TextUtils.isEmpty(systemPropertiesGet(key))) {
            return;
        }
        value = "";
    }
    try {
        systemPropertiesSet(key, value);
    } catch (Exception e) {
        // Failure to set a property can be caused by SELinux denial. This usually indicates
        // that the property wasn't whitelisted in sepolicy.
        // No need to report it on all user devices, only on debug builds.
        if (Build.IS_DEBUGGABLE) {
            Slog.wtf(TAG, "Unable to set property " + key + " value '" + value + "'", e);
        } else {
            Slog.e(TAG, "Unable to set property " + key + " value '" + value + "'", e);
        }
    }
}
 
Example 7
Source File: NetworkWatchlistInstallReceiver.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void postInstall(Context context, Intent intent) {
    try {
        context.getSystemService(NetworkWatchlistManager.class).reloadWatchlist();
    } catch (Exception e) {
        // Network Watchlist is not available
        Slog.wtf("NetworkWatchlistInstallReceiver", "Unable to reload watchlist");
    }
}
 
Example 8
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void format(String volId) {
    enforcePermission(android.Manifest.permission.MOUNT_FORMAT_FILESYSTEMS);

    final VolumeInfo vol = findVolumeByIdOrThrow(volId);
    try {
        mVold.format(vol.id, "auto");
    } catch (Exception e) {
        Slog.wtf(TAG, e);
    }
}
 
Example 9
Source File: MultipathPolicyTracker.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void onChange(boolean selfChange, Uri uri) {
    if (!Settings.Global.getUriFor(NETWORK_DEFAULT_DAILY_MULTIPATH_QUOTA_BYTES)
            .equals(uri)) {
        Slog.wtf(TAG, "Unexpected settings observation: " + uri);
    }
    if (DBG) Slog.d(TAG, "Settings change: updating budgets.");
    updateAllMultipathBudgets();
}
 
Example 10
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Get the type of encryption used to encrypt the master key.
 * @return The type, one of the CRYPT_TYPE_XXX consts from StorageManager.
 */
@Override
public int getPasswordType() {
    mContext.enforceCallingOrSelfPermission(Manifest.permission.CRYPT_KEEPER,
        "no permission to access the crypt keeper");

    try {
        return mVold.fdeGetPasswordType();
    } catch (Exception e) {
        Slog.wtf(TAG, e);
        return -1;
    }
}
 
Example 11
Source File: SafeActivityOptions.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void setCallingPidForRemoteAnimationAdapter(ActivityOptions options, int callingPid) {
    final RemoteAnimationAdapter adapter = options.getRemoteAnimationAdapter();
    if (adapter == null) {
        return;
    }
    if (callingPid == Process.myPid()) {
        Slog.wtf(TAG, "Safe activity options constructed after clearing calling id");
        return;
    }
    adapter.setCallingPid(callingPid);
}
 
Example 12
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void onUnlockUser(int userId) {
    Slog.d(TAG, "onUnlockUser " + userId);

    // We purposefully block here to make sure that user-specific
    // staging area is ready so it's ready for zygote-forked apps to
    // bind mount against.
    try {
        mVold.onUserStarted(userId);
        mStoraged.onUserStarted(userId);
    } catch (Exception e) {
        Slog.wtf(TAG, e);
    }

    // Record user as started so newly mounted volumes kick off events
    // correctly, then synthesize events for any already-mounted volumes.
    synchronized (mLock) {
        for (int i = 0; i < mVolumes.size(); i++) {
            final VolumeInfo vol = mVolumes.valueAt(i);
            if (vol.isVisibleForRead(userId) && vol.isMountedReadable()) {
                final StorageVolume userVol = vol.buildStorageVolume(mContext, userId, false);
                mHandler.obtainMessage(H_VOLUME_BROADCAST, userVol).sendToTarget();

                final String envState = VolumeInfo.getEnvironmentForState(vol.getState());
                mCallbacks.notifyStorageStateChanged(userVol.getPath(), envState, envState);
            }
        }
        mSystemUnlockedUsers = ArrayUtils.appendInt(mSystemUnlockedUsers, userId);
    }
}
 
Example 13
Source File: TaskSnapshotPersister.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
File getBitmapFile(int taskId, int userId) {
    // Full sized bitmaps are disabled on low ram devices
    if (DISABLE_FULL_SIZED_BITMAPS) {
        Slog.wtf(TAG, "This device does not support full sized resolution bitmaps.");
        return null;
    }
    return new File(getDirectory(userId), taskId + BITMAP_EXTENSION);
}
 
Example 14
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void finalize() throws Throwable {
    try {
        if (mReferenceCount != 0) {
            Slog.wtf(TAG, "Suspend blocker \"" + mName
                    + "\" was finalized without being released!");
            mReferenceCount = 0;
            nativeReleaseSuspendBlocker(mName);
            Trace.asyncTraceEnd(Trace.TRACE_TAG_POWER, mTraceName, 0);
        }
    } finally {
        super.finalize();
    }
}
 
Example 15
Source File: StorageManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void lockUserKey(int userId) {
    enforcePermission(android.Manifest.permission.STORAGE_INTERNAL);

    try {
        mVold.lockUserKey(userId);
    } catch (Exception e) {
        Slog.wtf(TAG, e);
        return;
    }

    synchronized (mLock) {
        mLocalUnlockedUsers = ArrayUtils.removeInt(mLocalUnlockedUsers, userId);
    }
}
 
Example 16
Source File: IpSecService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void systemReady() {
    if (isNetdAlive()) {
        Slog.d(TAG, "IpSecService is ready");
    } else {
        Slog.wtf(TAG, "IpSecService not ready: failed to connect to NetD Native Service!");
    }
}
 
Example 17
Source File: AlarmManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private void setLocked(int type, long when) {
    if (mNativeData != 0) {
        // The kernel never triggers alarms with negative wakeup times
        // so we ensure they are positive.
        long alarmSeconds, alarmNanoseconds;
        if (when < 0) {
            alarmSeconds = 0;
            alarmNanoseconds = 0;
        } else {
            alarmSeconds = when / 1000;
            alarmNanoseconds = (when % 1000) * 1000 * 1000;
        }

        final int result = set(mNativeData, type, alarmSeconds, alarmNanoseconds);
        if (result != 0) {
            final long nowElapsed = SystemClock.elapsedRealtime();
            Slog.wtf(TAG, "Unable to set kernel alarm, now=" + nowElapsed
                    + " type=" + type + " when=" + when
                    + " @ (" + alarmSeconds + "," + alarmNanoseconds
                    + "), ret = " + result + " = " + Os.strerror(result));
        }
    } else {
        Message msg = Message.obtain();
        msg.what = ALARM_EVENT;

        mHandler.removeMessages(ALARM_EVENT);
        mHandler.sendMessageAtTime(msg, when);
    }
}
 
Example 18
Source File: ClipboardService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
        throws RemoteException {
    try {
        return super.onTransact(code, data, reply, flags);
    } catch (RuntimeException e) {
        if (!(e instanceof SecurityException)) {
            Slog.wtf("clipboard", "Exception: ", e);
        }
        throw e;
    }

}
 
Example 19
Source File: DexManager.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void notifyDexLoadInternal(ApplicationInfo loadingAppInfo,
        List<String> classLoaderNames, List<String> classPaths, String loaderIsa,
        int loaderUserId) {
    if (classLoaderNames.size() != classPaths.size()) {
        Slog.wtf(TAG, "Bad call to noitfyDexLoad: args have different size");
        return;
    }
    if (classLoaderNames.isEmpty()) {
        Slog.wtf(TAG, "Bad call to notifyDexLoad: class loaders list is empty");
        return;
    }
    if (!PackageManagerServiceUtils.checkISA(loaderIsa)) {
        Slog.w(TAG, "Loading dex files " + classPaths + " in unsupported ISA: " +
                loaderIsa + "?");
        return;
    }

    // The classpath is represented as a list of dex files separated by File.pathSeparator.
    String[] dexPathsToRegister = classPaths.get(0).split(File.pathSeparator);

    // Encode the class loader contexts for the dexPathsToRegister.
    String[] classLoaderContexts = DexoptUtils.processContextForDexLoad(
            classLoaderNames, classPaths);

    int dexPathIndex = 0;
    for (String dexPath : dexPathsToRegister) {
        // Find the owning package name.
        DexSearchResult searchResult = getDexPackage(loadingAppInfo, dexPath, loaderUserId);

        if (DEBUG) {
            Slog.i(TAG, loadingAppInfo.packageName
                + " loads from " + searchResult + " : " + loaderUserId + " : " + dexPath);
        }

        if (searchResult.mOutcome != DEX_SEARCH_NOT_FOUND) {
            // TODO(calin): extend isUsedByOtherApps check to detect the cases where
            // different apps share the same runtime. In that case we should not mark the dex
            // file as isUsedByOtherApps. Currently this is a safe approximation.
            boolean isUsedByOtherApps = !loadingAppInfo.packageName.equals(
                    searchResult.mOwningPackageName);
            boolean primaryOrSplit = searchResult.mOutcome == DEX_SEARCH_FOUND_PRIMARY ||
                    searchResult.mOutcome == DEX_SEARCH_FOUND_SPLIT;

            if (primaryOrSplit && !isUsedByOtherApps) {
                // If the dex file is the primary apk (or a split) and not isUsedByOtherApps
                // do not record it. This case does not bring any new usable information
                // and can be safely skipped.
                continue;
            }

            // Record dex file usage. If the current usage is a new pattern (e.g. new secondary,
            // or UsedBytOtherApps), record will return true and we trigger an async write
            // to disk to make sure we don't loose the data in case of a reboot.

            // A null classLoaderContexts means that there are unsupported class loaders in the
            // chain.
            String classLoaderContext = classLoaderContexts == null
                    ? PackageDexUsage.UNSUPPORTED_CLASS_LOADER_CONTEXT
                    : classLoaderContexts[dexPathIndex];
            if (mPackageDexUsage.record(searchResult.mOwningPackageName,
                    dexPath, loaderUserId, loaderIsa, isUsedByOtherApps, primaryOrSplit,
                    loadingAppInfo.packageName, classLoaderContext)) {
                mPackageDexUsage.maybeWriteAsync();
            }
        } else {
            // If we can't find the owner of the dex we simply do not track it. The impact is
            // that the dex file will not be considered for offline optimizations.
            if (DEBUG) {
                Slog.i(TAG, "Could not find owning package for dex file: " + dexPath);
            }
        }
        dexPathIndex++;
    }
}
 
Example 20
Source File: DropBoxManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Extracts metadata from an existing on-disk log filename.
 *
 * Note when a filename is not recognizable, it will create an instance that
 * {@link #hasFile()} would return false on, and also remove the file.
 *
 * @param file name of existing log file
 * @param blockSize to use for space accounting
 */
public EntryFile(File file, int blockSize) {

    boolean parseFailure = false;

    String name = file.getName();
    int flags = 0;
    String tag = null;
    long millis = 0;

    final int at = name.lastIndexOf('@');
    if (at < 0) {
        parseFailure = true;
    } else {
        tag = Uri.decode(name.substring(0, at));
        if (name.endsWith(".gz")) {
            flags |= DropBoxManager.IS_GZIPPED;
            name = name.substring(0, name.length() - 3);
        }
        if (name.endsWith(".lost")) {
            flags |= DropBoxManager.IS_EMPTY;
            name = name.substring(at + 1, name.length() - 5);
        } else if (name.endsWith(".txt")) {
            flags |= DropBoxManager.IS_TEXT;
            name = name.substring(at + 1, name.length() - 4);
        } else if (name.endsWith(".dat")) {
            name = name.substring(at + 1, name.length() - 4);
        } else {
            parseFailure = true;
        }
        if (!parseFailure) {
            try {
                millis = Long.parseLong(name);
            } catch (NumberFormatException e) {
                parseFailure = true;
            }
        }
    }
    if (parseFailure) {
        Slog.wtf(TAG, "Invalid filename: " + file);

        // Remove the file and return an empty instance.
        file.delete();
        this.tag = null;
        this.flags = DropBoxManager.IS_EMPTY;
        this.timestampMillis = 0;
        this.blocks = 0;
        return;
    }

    this.blocks = (int) ((file.length() + blockSize - 1) / blockSize);
    this.tag = TextUtils.safeIntern(tag);
    this.flags = flags;
    this.timestampMillis = millis;
}