android.util.Slog#e ( )源码实例Demo

下面列出了android.util.Slog#e ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: TvInputManagerService.java
@Override
public void onTimeShiftCurrentPositionChanged(long timeMs) {
    synchronized (mLock) {
        if (DEBUG) {
            Slog.d(TAG, "onTimeShiftCurrentPositionChanged(timeMs=" + timeMs + ")");
        }
        if (mSessionState.session == null || mSessionState.client == null) {
            return;
        }
        try {
            mSessionState.client.onTimeShiftCurrentPositionChanged(timeMs,
                    mSessionState.seq);
        } catch (RemoteException e) {
            Slog.e(TAG, "error in onTimeShiftCurrentPositionChanged", e);
        }
    }
}
 
源代码2 项目: android_9.0.0_r45   文件: TvInputManagerService.java
@Override
public void startRecording(IBinder sessionToken, @Nullable Uri programUri, int userId) {
    final int callingUid = Binder.getCallingUid();
    final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
            userId, "startRecording");
    final long identity = Binder.clearCallingIdentity();
    try {
        synchronized (mLock) {
            try {
                getSessionLocked(sessionToken, callingUid, resolvedUserId).startRecording(
                        programUri);
            } catch (RemoteException | SessionNotFoundException e) {
                Slog.e(TAG, "error in startRecording", e);
            }
        }
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
 
源代码3 项目: android_9.0.0_r45   文件: TvInputManagerService.java
@Override
public void timeShiftEnablePositionTracking(IBinder sessionToken, boolean enable,
        int userId) {
    final int callingUid = Binder.getCallingUid();
    final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
            userId, "timeShiftEnablePositionTracking");
    final long identity = Binder.clearCallingIdentity();
    try {
        synchronized (mLock) {
            try {
                getSessionLocked(sessionToken, callingUid, resolvedUserId)
                        .timeShiftEnablePositionTracking(enable);
            } catch (RemoteException | SessionNotFoundException e) {
                Slog.e(TAG, "error in timeShiftEnablePositionTracking", e);
            }
        }
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
 
private void cancelAnimation(@ReorderMode int reorderMode, boolean runSynchronously,
        String reason) {
    if (DEBUG_RECENTS_ANIMATIONS) Slog.d(TAG, "cancelAnimation(): reason=" + reason
            + " runSynchronously=" + runSynchronously);
    synchronized (mService.getWindowManagerLock()) {
        if (mCanceled) {
            // We've already canceled the animation
            return;
        }
        mService.mH.removeCallbacks(mFailsafeRunnable);
        mCanceled = true;
        try {
            mRunner.onAnimationCanceled();
        } catch (RemoteException e) {
            Slog.e(TAG, "Failed to cancel recents animation", e);
        }
    }

    // Clean up and return to the previous app
    mCallbacks.onAnimationFinished(reorderMode, runSynchronously);
}
 
源代码5 项目: android_9.0.0_r45   文件: HdmiControlService.java
boolean invokeVendorCommandListenersOnControlStateChanged(boolean enabled, int reason) {
    synchronized (mLock) {
        if (mVendorCommandListenerRecords.isEmpty()) {
            return false;
        }
        for (VendorCommandListenerRecord record : mVendorCommandListenerRecords) {
            try {
                record.mListener.onControlStateChanged(enabled, reason);
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to notify control-state-changed to vendor handler", e);
            }
        }
        return true;
    }
}
 
源代码6 项目: android_9.0.0_r45   文件: PersistentConnection.java
@GuardedBy("mLock")
public final void bindInnerLocked(boolean resetBackoff) {
    unscheduleRebindLocked();

    if (mBound) {
        return;
    }
    mBound = true;

    if (resetBackoff) {
        // Note this is the only place we reset the backoff time.
        mNextBackoffMs = mRebindBackoffMs;
    }

    final Intent service = new Intent().setComponent(mComponentName);

    if (DEBUG) {
        Slog.d(mTag, "Attempting to connect to " + mComponentName);
    }

    final boolean success = mContext.bindServiceAsUser(service, mServiceConnection,
            Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
            mHandler, UserHandle.of(mUserId));

    if (!success) {
        Slog.e(mTag, "Binding: " + service.getComponent() + " u" + mUserId
                + " failed.");
    }
}
 
void setMatrix(SurfaceControl.Transaction t, float dsdx, float dtdx,
        float dtdy, float dsdy, boolean recoveringMemory) {
    final boolean matrixChanged = mLastDsdx != dsdx || mLastDtdx != dtdx ||
                                  mLastDtdy != dtdy || mLastDsdy != dsdy;
    if (!matrixChanged) {
        return;
    }

    mLastDsdx = dsdx;
    mLastDtdx = dtdx;
    mLastDtdy = dtdy;
    mLastDsdy = dsdy;

    try {
        if (SHOW_TRANSACTIONS) logSurface(
                "MATRIX [" + dsdx + "," + dtdx + "," + dtdy + "," + dsdy + "]", null);
        if (t == null) {
            mSurfaceControl.setMatrix(dsdx, dtdx, dtdy, dsdy);
        } else {
            t.setMatrix(mSurfaceControl, dsdx, dtdx, dtdy, dsdy);
        }
    } catch (RuntimeException e) {
        // If something goes wrong with the surface (such
        // as running out of memory), don't take down the
        // entire system.
        Slog.e(TAG, "Error setting matrix on surface surface" + title
                + " MATRIX [" + dsdx + "," + dtdx + "," + dtdy + "," + dsdy + "]", null);
        if (!recoveringMemory) {
            mAnimator.reclaimSomeSurfaceMemory("matrix", true);
        }
    }
}
 
源代码8 项目: android_9.0.0_r45   文件: MediaSessionRecord.java
public void pause(String packageName, int pid, int uid, ISessionControllerCallback caller) {
    try {
        mCb.onPause(packageName, pid, uid, caller);
    } catch (RemoteException e) {
        Slog.e(TAG, "Remote failure in pause.", e);
    }
}
 
public void adjustVolume(String id, int volume) {
    try {
        mProvider.adjustVolume(id, volume);
    } catch (RemoteException ex) {
        Slog.e(TAG, "Failed to deliver request to adjust display volume.", ex);
    }
}
 
源代码10 项目: android_9.0.0_r45   文件: RadioModule.java
public android.hardware.radio.ICloseHandle addAnnouncementListener(@NonNull int[] enabledTypes,
        @NonNull android.hardware.radio.IAnnouncementListener listener) throws RemoteException {
    ArrayList<Byte> enabledList = new ArrayList<>();
    for (int type : enabledTypes) {
        enabledList.add((byte)type);
    }

    MutableInt halResult = new MutableInt(Result.UNKNOWN_ERROR);
    Mutable<ICloseHandle> hwCloseHandle = new Mutable<>();
    IAnnouncementListener hwListener = new IAnnouncementListener.Stub() {
        public void onListUpdated(ArrayList<Announcement> hwAnnouncements)
                throws RemoteException {
            listener.onListUpdated(hwAnnouncements.stream().
                map(a -> Convert.announcementFromHal(a)).collect(Collectors.toList()));
        }
    };

    synchronized (mService) {
        mService.registerAnnouncementListener(enabledList, hwListener, (result, closeHnd) -> {
            halResult.value = result;
            hwCloseHandle.value = closeHnd;
        });
    }
    Convert.throwOnError("addAnnouncementListener", halResult.value);

    return new android.hardware.radio.ICloseHandle.Stub() {
        public void close() {
            try {
                hwCloseHandle.value.close();
            } catch (RemoteException ex) {
                Slog.e(TAG, "Failed closing announcement listener", ex);
            }
        }
    };
}
 
源代码11 项目: android_9.0.0_r45   文件: BrightnessTracker.java
private void writeAmbientBrightnessStats() {
    final AtomicFile writeTo = mInjector.getFile(AMBIENT_BRIGHTNESS_STATS_FILE);
    if (writeTo == null) {
        return;
    }
    FileOutputStream output = null;
    try {
        output = writeTo.startWrite();
        mAmbientBrightnessStatsTracker.writeStats(output);
        writeTo.finishWrite(output);
    } catch (IOException e) {
        writeTo.failWrite(output);
        Slog.e(TAG, "Failed to write ambient brightness stats.", e);
    }
}
 
源代码12 项目: android_9.0.0_r45   文件: TvRemoteService.java
private void openInputBridgeInternalLocked(TvRemoteProviderProxy provider, IBinder token,
                                           String name, int width, int height,
                                           int maxPointers) {
    if (DEBUG) {
        Slog.d(TAG, "openInputBridgeInternalLocked(), token: " + token + ", name: " + name +
                ", width: " + width + ", height: " + height + ", maxPointers: " + maxPointers);
    }

    try {
        //Create a new bridge, if one does not exist already
        if (mBridgeMap.containsKey(token)) {
            if (DEBUG) Slog.d(TAG, "RemoteBridge already exists");
            // Respond back with success.
            informInputBridgeConnected(token);
            return;
        }

        UinputBridge inputBridge = new UinputBridge(token, name, width, height, maxPointers);

        mBridgeMap.put(token, inputBridge);
        mProviderMap.put(token, provider);

        // Respond back with success.
        informInputBridgeConnected(token);

    } catch (IOException ioe) {
        Slog.e(TAG, "Cannot create device for " + name);
    }
}
 
源代码13 项目: android_9.0.0_r45   文件: PinnedStackController.java
private void notifyShelfVisibilityChanged(boolean shelfVisible, int shelfHeight) {
    if (mPinnedStackListener != null) {
        try {
            mPinnedStackListener.onShelfVisibilityChanged(shelfVisible, shelfHeight);
        } catch (RemoteException e) {
            Slog.e(TAG_WM, "Error delivering bounds changed event.", e);
        }
    }
}
 
源代码14 项目: android_9.0.0_r45   文件: LoadedApk.java
private AppComponentFactory createAppFactory(ApplicationInfo appInfo, ClassLoader cl) {
    if (appInfo.appComponentFactory != null && cl != null) {
        try {
            return (AppComponentFactory) cl.loadClass(appInfo.appComponentFactory)
                    .newInstance();
        } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
            Slog.e(TAG, "Unable to instantiate appComponentFactory", e);
        }
    }
    return AppComponentFactory.DEFAULT;
}
 
源代码15 项目: android_9.0.0_r45   文件: ActiveSourceHandler.java
static ActiveSourceHandler create(HdmiCecLocalDeviceTv source, IHdmiControlCallback callback) {
    if (source == null) {
        Slog.e(TAG, "Wrong arguments");
        return null;
    }
    return new ActiveSourceHandler(source, callback);
}
 
源代码16 项目: android_9.0.0_r45   文件: StatsCompanionService.java
@Override
public void onStart() {
    mStatsCompanionService = new StatsCompanionService(getContext());
    try {
        publishBinderService(Context.STATS_COMPANION_SERVICE, mStatsCompanionService);
        if (DEBUG) Slog.d(TAG, "Published " + Context.STATS_COMPANION_SERVICE);
    } catch (Exception e) {
        Slog.e(TAG, "Failed to publishBinderService", e);
    }
}
 
private void recoverBluetoothServiceFromError(boolean clearBle) {
    Slog.e(TAG, "recoverBluetoothServiceFromError");
    try {
        mBluetoothLock.readLock().lock();
        if (mBluetooth != null) {
            //Unregister callback object
            mBluetooth.unregisterCallback(mBluetoothCallback);
        }
    } catch (RemoteException re) {
        Slog.e(TAG, "Unable to unregister", re);
    } finally {
        mBluetoothLock.readLock().unlock();
    }

    SystemClock.sleep(500);

    // disable
    addActiveLog(BluetoothProtoEnums.ENABLE_DISABLE_REASON_START_ERROR,
            mContext.getPackageName(), false);
    handleDisable();

    waitForOnOff(false, true);

    sendBluetoothServiceDownCallback();

    try {
        mBluetoothLock.writeLock().lock();
        if (mBluetooth != null) {
            mBluetooth = null;
            // Unbind
            mContext.unbindService(mConnection);
        }
        mBluetoothGatt = null;
    } finally {
        mBluetoothLock.writeLock().unlock();
    }

    mHandler.removeMessages(MESSAGE_BLUETOOTH_STATE_CHANGE);
    mState = BluetoothAdapter.STATE_OFF;

    if (clearBle) {
        clearBleApps();
    }

    mEnable = false;

    if (mErrorRecoveryRetryCounter++ < MAX_ERROR_RESTART_RETRIES) {
        // Send a Bluetooth Restart message to reenable bluetooth
        Message restartMsg = mHandler.obtainMessage(MESSAGE_RESTART_BLUETOOTH_SERVICE);
        mHandler.sendMessageDelayed(restartMsg, ERROR_RESTART_TIME_MS);
    } else {
        // todo: notify user to power down and power up phone to make bluetooth work.
    }
}
 
private void requestPreparerTimeoutUiThread() {
    synchronized (mLock) {
        Slog.e(LOG_TAG, "AccessibilityRequestPreparer timed out");
        scheduleAllMessagesWaitingForRequestPreparerLocked();
    }
}
 
源代码19 项目: android_9.0.0_r45   文件: SyncOperation.java
/**
 * All fields are stored in a corresponding key in the persistable bundle.
 *
 * {@link #extras} is a Bundle and can contain parcelable objects. But only the type Account
 * is allowed {@link ContentResolver#validateSyncExtrasBundle(Bundle)} that can't be stored in
 * a PersistableBundle. For every value of type Account with key 'key', we store a
 * PersistableBundle containing account information at key 'ACCOUNT:key'. The Account object
 * can be reconstructed using this.
 *
 * We put a flag with key 'SyncManagerJob', to identify while reconstructing a sync operation
 * from a bundle whether the bundle actually contains information about a sync.
 * @return A persistable bundle containing all information to re-construct the sync operation.
 */
PersistableBundle toJobInfoExtras() {
    // This will be passed as extras bundle to a JobScheduler job.
    PersistableBundle jobInfoExtras = new PersistableBundle();

    PersistableBundle syncExtrasBundle = new PersistableBundle();
    for (String key: extras.keySet()) {
        Object value = extras.get(key);
        if (value instanceof Account) {
            Account account = (Account) value;
            PersistableBundle accountBundle = new PersistableBundle();
            accountBundle.putString("accountName", account.name);
            accountBundle.putString("accountType", account.type);
            // This is stored in jobInfoExtras so that we don't override a user specified
            // sync extra with the same key.
            jobInfoExtras.putPersistableBundle("ACCOUNT:" + key, accountBundle);
        } else if (value instanceof Long) {
            syncExtrasBundle.putLong(key, (Long) value);
        } else if (value instanceof Integer) {
            syncExtrasBundle.putInt(key, (Integer) value);
        } else if (value instanceof Boolean) {
            syncExtrasBundle.putBoolean(key, (Boolean) value);
        } else if (value instanceof Float) {
            syncExtrasBundle.putDouble(key, (double) (float) value);
        } else if (value instanceof Double) {
            syncExtrasBundle.putDouble(key, (Double) value);
        } else if (value instanceof String) {
            syncExtrasBundle.putString(key, (String) value);
        } else if (value == null) {
            syncExtrasBundle.putString(key, null);
        } else {
            Slog.e(TAG, "Unknown extra type.");
        }
    }
    jobInfoExtras.putPersistableBundle("syncExtras", syncExtrasBundle);

    jobInfoExtras.putBoolean("SyncManagerJob", true);

    jobInfoExtras.putString("provider", target.provider);
    jobInfoExtras.putString("accountName", target.account.name);
    jobInfoExtras.putString("accountType", target.account.type);
    jobInfoExtras.putInt("userId", target.userId);
    jobInfoExtras.putInt("owningUid", owningUid);
    jobInfoExtras.putString("owningPackage", owningPackage);
    jobInfoExtras.putInt("reason", reason);
    jobInfoExtras.putInt("source", syncSource);
    jobInfoExtras.putBoolean("allowParallelSyncs", allowParallelSyncs);
    jobInfoExtras.putInt("jobId", jobId);
    jobInfoExtras.putBoolean("isPeriodic", isPeriodic);
    jobInfoExtras.putInt("sourcePeriodicId", sourcePeriodicId);
    jobInfoExtras.putLong("periodMillis", periodMillis);
    jobInfoExtras.putLong("flexMillis", flexMillis);
    jobInfoExtras.putLong("expectedRuntime", expectedRuntime);
    jobInfoExtras.putInt("retries", retries);
    jobInfoExtras.putInt("syncExemptionFlag", syncExemptionFlag);
    return jobInfoExtras;
}
 
源代码20 项目: android_9.0.0_r45   文件: LockdownVpnTracker.java
/**
 * Watch for state changes to both active egress network, kicking off a VPN
 * connection when ready, or setting firewall rules once VPN is connected.
 */
private void handleStateChangedLocked() {

    final NetworkInfo egressInfo = mConnService.getActiveNetworkInfoUnfiltered();
    final LinkProperties egressProp = mConnService.getActiveLinkProperties();

    final NetworkInfo vpnInfo = mVpn.getNetworkInfo();
    final VpnConfig vpnConfig = mVpn.getLegacyVpnConfig();

    // Restart VPN when egress network disconnected or changed
    final boolean egressDisconnected = egressInfo == null
            || State.DISCONNECTED.equals(egressInfo.getState());
    final boolean egressChanged = egressProp == null
            || !TextUtils.equals(mAcceptedEgressIface, egressProp.getInterfaceName());

    final String egressTypeName = (egressInfo == null) ?
            null : ConnectivityManager.getNetworkTypeName(egressInfo.getType());
    final String egressIface = (egressProp == null) ?
            null : egressProp.getInterfaceName();
    Slog.d(TAG, "handleStateChanged: egress=" + egressTypeName +
            " " + mAcceptedEgressIface + "->" + egressIface);

    if (egressDisconnected || egressChanged) {
        mAcceptedEgressIface = null;
        mVpn.stopLegacyVpnPrivileged();
    }
    if (egressDisconnected) {
        hideNotification();
        return;
    }

    final int egressType = egressInfo.getType();
    if (vpnInfo.getDetailedState() == DetailedState.FAILED) {
        EventLogTags.writeLockdownVpnError(egressType);
    }

    if (mErrorCount > MAX_ERROR_COUNT) {
        showNotification(R.string.vpn_lockdown_error, R.drawable.vpn_disconnected);

    } else if (egressInfo.isConnected() && !vpnInfo.isConnectedOrConnecting()) {
        if (mProfile.isValidLockdownProfile()) {
            Slog.d(TAG, "Active network connected; starting VPN");
            EventLogTags.writeLockdownVpnConnecting(egressType);
            showNotification(R.string.vpn_lockdown_connecting, R.drawable.vpn_disconnected);

            mAcceptedEgressIface = egressProp.getInterfaceName();
            try {
                // Use the privileged method because Lockdown VPN is initiated by the system, so
                // no additional permission checks are necessary.
                mVpn.startLegacyVpnPrivileged(mProfile, KeyStore.getInstance(), egressProp);
            } catch (IllegalStateException e) {
                mAcceptedEgressIface = null;
                Slog.e(TAG, "Failed to start VPN", e);
                showNotification(R.string.vpn_lockdown_error, R.drawable.vpn_disconnected);
            }
        } else {
            Slog.e(TAG, "Invalid VPN profile; requires IP-based server and DNS");
            showNotification(R.string.vpn_lockdown_error, R.drawable.vpn_disconnected);
        }

    } else if (vpnInfo.isConnected() && vpnConfig != null) {
        final String iface = vpnConfig.interfaze;
        final List<LinkAddress> sourceAddrs = vpnConfig.addresses;

        if (TextUtils.equals(iface, mAcceptedIface)
              && sourceAddrs.equals(mAcceptedSourceAddr)) {
            return;
        }

        Slog.d(TAG, "VPN connected using iface=" + iface +
                ", sourceAddr=" + sourceAddrs.toString());
        EventLogTags.writeLockdownVpnConnected(egressType);
        showNotification(R.string.vpn_lockdown_connected, R.drawable.vpn_connected);

        final NetworkInfo clone = new NetworkInfo(egressInfo);
        augmentNetworkInfo(clone);
        mConnService.sendConnectedBroadcast(clone);
    }
}
 
 方法所在类