Java Code Examples for com.android.internal.util.DumpUtils#checkDumpPermission()

The following examples show how to use com.android.internal.util.DumpUtils#checkDumpPermission() . 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: StatsCompanionService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, writer)) return;

    synchronized (sStatsdLock) {
        writer.println("Number of configuration files deleted: " + mDeletedFiles.size());
        if (mDeletedFiles.size() > 0) {
            writer.println("  timestamp, deleted file name");
        }
        long lastBootMillis =
                SystemClock.currentThreadTimeMillis() - SystemClock.elapsedRealtime();
        for (Long elapsedMillis : mDeletedFiles.keySet()) {
            long deletionMillis = lastBootMillis + elapsedMillis;
            writer.println("  " + deletionMillis + ", " + mDeletedFiles.get(elapsedMillis));
        }
    }
}
 
Example 2
Source File: CommonTimeManagementService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    if (!mDetectedAtStartup) {
        pw.println("Native Common Time service was not detected at startup.  " +
                   "Service is unavailable");
        return;
    }

    synchronized (mLock) {
        pw.println("Current Common Time Management Service Config:");
        pw.println(String.format("  Native service     : %s",
                                 (null == mCTConfig) ? "reconnecting"
                                                     : "alive"));
        pw.println(String.format("  Bound interface    : %s",
                                 (null == mCurIface ? "unbound" : mCurIface)));
        pw.println(String.format("  Allow WiFi         : %s", ALLOW_WIFI ? "yes" : "no"));
        pw.println(String.format("  Allow Auto Disable : %s", AUTO_DISABLE ? "yes" : "no"));
        pw.println(String.format("  Server Priority    : %d", mEffectivePrio));
        pw.println(String.format("  No iface timeout   : %d", NO_INTERFACE_TIMEOUT));
    }
}
 
Example 3
Source File: PowerManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override // Binder call
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    final long ident = Binder.clearCallingIdentity();

    boolean isDumpProto = false;
    for (String arg : args) {
        if (arg.equals("--proto")) {
            isDumpProto = true;
        }
    }
    try {
        if (isDumpProto) {
            dumpProto(fd);
        } else {
            dumpInternal(pw);
        }
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
Example 4
Source File: CountryDetectorService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unused")
@Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, fout)) return;
    if (!DEBUG) return;
    try {
        final Printer p = new PrintWriterPrinter(fout);
        p.println("CountryDetectorService state:");
        p.println("  Number of listeners=" + mReceivers.keySet().size());
        if (mCountryDetector == null) {
            p.println("  ComprehensiveCountryDetector not initialized");
        } else {
            p.println("  " + mCountryDetector.toString());
        }
    } catch (Exception e) {
        Slog.e(TAG, "Failed to dump CountryDetectorService: ", e);
    }
}
 
Example 5
Source File: DreamManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override // Binder call
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
    final long ident = Binder.clearCallingIdentity();
    try {
        dumpInternal(pw);
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
Example 6
Source File: NetworkTimeUpdateService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
    pw.print("PollingIntervalMs: ");
    TimeUtils.formatDuration(mPollingIntervalMs, pw);
    pw.print("\nPollingIntervalShorterMs: ");
    TimeUtils.formatDuration(mPollingIntervalShorterMs, pw);
    pw.println("\nTryAgainTimesMax: " + mTryAgainTimesMax);
    pw.print("TimeErrorThresholdMs: ");
    TimeUtils.formatDuration(mTimeErrorThresholdMs, pw);
    pw.println("\nTryAgainCounter: " + mTryAgainCounter);
    pw.println("NTP cache age: " + mTime.getCacheAge());
    pw.println("NTP cache certainty: " + mTime.getCacheCertainty());
    pw.println();
}
 
Example 7
Source File: FingerprintService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override // Binder call
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    final long ident = Binder.clearCallingIdentity();
    try {
        if (args.length > 0 && "--proto".equals(args[0])) {
            dumpProto(fd);
        } else {
            dumpInternal(pw);
        }
    } finally {
        Binder.restoreCallingIdentity(ident);
    }
}
 
Example 8
Source File: StatusBarManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    synchronized (mLock) {
        pw.println("  mDisabled1=0x" + Integer.toHexString(mDisabled1));
        pw.println("  mDisabled2=0x" + Integer.toHexString(mDisabled2));
        final int N = mDisableRecords.size();
        pw.println("  mDisableRecords.size=" + N);
        for (int i=0; i<N; i++) {
            DisableRecord tok = mDisableRecords.get(i);
            pw.println("    [" + i + "] " + tok);
        }
        pw.println("  mCurrentUserId=" + mCurrentUserId);
        pw.println("  mIcons=");
        for (String slot : mIcons.keySet()) {
            pw.println("    ");
            pw.print(slot);
            pw.print(" -> ");
            final StatusBarIcon icon = mIcons.get(slot);
            pw.print(icon);
            if (!TextUtils.isEmpty(icon.contentDescription)) {
                pw.print(" \"");
                pw.print(icon.contentDescription);
                pw.print("\"");
            }
            pw.println();
        }
    }
}
 
Example 9
Source File: NetworkScoreService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void dump(final FileDescriptor fd, final PrintWriter writer, final String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, writer)) return;
    final long token = Binder.clearCallingIdentity();
    try {
        NetworkScorerAppData currentScorer = mNetworkScorerAppManager.getActiveScorer();
        if (currentScorer == null) {
            writer.println("Scoring is disabled.");
            return;
        }
        writer.println("Current scorer: " + currentScorer);

        sendCacheUpdateCallback(new BiConsumer<INetworkScoreCache, Object>() {
            @Override
            public void accept(INetworkScoreCache networkScoreCache, Object cookie) {
                try {
                    TransferPipe.dumpAsync(networkScoreCache.asBinder(), fd, args);
                } catch (IOException | RemoteException e) {
                    writer.println("Failed to dump score cache: " + e);
                }
            }
        }, getScoreCacheLists());

        synchronized (mServiceConnectionLock) {
            if (mServiceConnection != null) {
                mServiceConnection.dump(fd, writer, args);
            } else {
                writer.println("ScoringServiceConnection: null");
            }
        }
        writer.flush();
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example 10
Source File: DisplayManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override // Binder call
public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    final long token = Binder.clearCallingIdentity();
    try {
        dumpInternal(pw);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example 11
Source File: HdmiControlService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, final PrintWriter writer, String[] args) {
    if (!DumpUtils.checkDumpPermission(getContext(), TAG, writer)) return;
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");

    pw.println("mHdmiControlEnabled: " + mHdmiControlEnabled);
    pw.println("mProhibitMode: " + mProhibitMode);
    if (mCecController != null) {
        pw.println("mCecController: ");
        pw.increaseIndent();
        mCecController.dump(pw);
        pw.decreaseIndent();
    }

    pw.println("mMhlController: ");
    pw.increaseIndent();
    mMhlController.dump(pw);
    pw.decreaseIndent();

    pw.println("mPortInfo: ");
    pw.increaseIndent();
    for (HdmiPortInfo hdmiPortInfo : mPortInfo) {
        pw.println("- " + hdmiPortInfo);
    }
    pw.decreaseIndent();
    pw.println("mPowerStatus: " + mPowerStatus);
}
 
Example 12
Source File: SearchManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
    synchronized (mSearchables) {
        for (int i = 0; i < mSearchables.size(); i++) {
            ipw.print("\nUser: "); ipw.println(mSearchables.keyAt(i));
            ipw.increaseIndent();
            mSearchables.valueAt(i).dump(fd, ipw, args);
            ipw.decreaseIndent();
        }
    }
}
 
Example 13
Source File: MediaProjectionManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override // Binder call
public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
    final long token = Binder.clearCallingIdentity();
    try {
        MediaProjectionManagerService.this.dump(pw);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example 14
Source File: UiModeManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) return;
    dumpImpl(pw);
}
 
Example 15
Source File: NetworkWatchlistService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
    mConfig.dump(fd, pw, args);
}
 
Example 16
Source File: UpdateLockService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
    mLocks.dump(pw);
}
 
Example 17
Source File: NetworkManagementService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    pw.println("NetworkManagementService NativeDaemonConnector Log:");
    mConnector.dump(fd, pw, args);
    pw.println();

    pw.print("Bandwidth control enabled: "); pw.println(mBandwidthControlEnabled);
    pw.print("mMobileActivityFromRadio="); pw.print(mMobileActivityFromRadio);
            pw.print(" mLastPowerStateFromRadio="); pw.println(mLastPowerStateFromRadio);
    pw.print("mNetworkActive="); pw.println(mNetworkActive);

    synchronized (mQuotaLock) {
        pw.print("Active quota ifaces: "); pw.println(mActiveQuotas.toString());
        pw.print("Active alert ifaces: "); pw.println(mActiveAlerts.toString());
        pw.print("Data saver mode: "); pw.println(mDataSaverMode);
        synchronized (mRulesLock) {
            dumpUidRuleOnQuotaLocked(pw, "blacklist", mUidRejectOnMetered);
            dumpUidRuleOnQuotaLocked(pw, "whitelist", mUidAllowOnMetered);
        }
    }

    synchronized (mRulesLock) {
        dumpUidFirewallRule(pw, "", mUidFirewallRules);

        pw.print("UID firewall standby chain enabled: "); pw.println(
                getFirewallChainState(FIREWALL_CHAIN_STANDBY));
        dumpUidFirewallRule(pw, FIREWALL_CHAIN_NAME_STANDBY, mUidFirewallStandbyRules);

        pw.print("UID firewall dozable chain enabled: "); pw.println(
                getFirewallChainState(FIREWALL_CHAIN_DOZABLE));
        dumpUidFirewallRule(pw, FIREWALL_CHAIN_NAME_DOZABLE, mUidFirewallDozableRules);

        pw.println("UID firewall powersave chain enabled: " +
                getFirewallChainState(FIREWALL_CHAIN_POWERSAVE));
        dumpUidFirewallRule(pw, FIREWALL_CHAIN_NAME_POWERSAVE, mUidFirewallPowerSaveRules);
    }

    synchronized (mIdleTimerLock) {
        pw.println("Idle timers:");
        for (HashMap.Entry<String, IdleTimerParams> ent : mActiveIdleTimers.entrySet()) {
            pw.print("  "); pw.print(ent.getKey()); pw.println(":");
            IdleTimerParams params = ent.getValue();
            pw.print("    timeout="); pw.print(params.timeout);
            pw.print(" type="); pw.print(params.type);
            pw.print(" networkCount="); pw.println(params.networkCount);
        }
    }

    pw.print("Firewall enabled: "); pw.println(mFirewallEnabled);
    pw.print("Netd service status: " );
    if (mNetdService == null) {
        pw.println("disconnected");
    } else {
        try {
            final boolean alive = mNetdService.isAlive();
            pw.println(alive ? "alive": "dead");
        } catch (RemoteException e) {
            pw.println("unreachable");
        }
    }
}
 
Example 18
Source File: TelephonyRegistry.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");

    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    synchronized (mRecords) {
        final int recordCount = mRecords.size();
        pw.println("last known state:");
        pw.increaseIndent();
        for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
            pw.println("Phone Id=" + i);
            pw.increaseIndent();
            pw.println("mCallState=" + mCallState[i]);
            pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]);
            pw.println("mServiceState=" + mServiceState[i]);
            pw.println("mVoiceActivationState= " + mVoiceActivationState[i]);
            pw.println("mDataActivationState= " + mDataActivationState[i]);
            pw.println("mUserMobileDataState= " + mUserMobileDataState[i]);
            pw.println("mSignalStrength=" + mSignalStrength[i]);
            pw.println("mMessageWaiting=" + mMessageWaiting[i]);
            pw.println("mCallForwarding=" + mCallForwarding[i]);
            pw.println("mDataActivity=" + mDataActivity[i]);
            pw.println("mDataConnectionState=" + mDataConnectionState[i]);
            pw.println("mCellLocation=" + mCellLocation[i]);
            pw.println("mCellInfo=" + mCellInfo.get(i));
            pw.decreaseIndent();
        }
        pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState);
        pw.println("mPreciseCallState=" + mPreciseCallState);
        pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);
        pw.println("mRingingCallState=" + mRingingCallState);
        pw.println("mForegroundCallState=" + mForegroundCallState);
        pw.println("mBackgroundCallState=" + mBackgroundCallState);
        pw.println("mVoLteServiceState=" + mVoLteServiceState);

        pw.decreaseIndent();

        pw.println("local logs:");
        pw.increaseIndent();
        mLocalLog.dump(fd, pw, args);
        pw.decreaseIndent();
        pw.println("registrations: count=" + recordCount);
        pw.increaseIndent();
        for (Record r : mRecords) {
            pw.println(r);
        }
        pw.decreaseIndent();
    }
}
 
Example 19
Source File: Tethering.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
    // Binder.java closes the resource for us.
    @SuppressWarnings("resource")
    final IndentingPrintWriter pw = new IndentingPrintWriter(writer, "  ");
    if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;

    pw.println("Tethering:");
    pw.increaseIndent();

    pw.println("Configuration:");
    pw.increaseIndent();
    final TetheringConfiguration cfg = mConfig;
    cfg.dump(pw);
    pw.decreaseIndent();

    synchronized (mPublicSync) {
        pw.println("Tether state:");
        pw.increaseIndent();
        for (int i = 0; i < mTetherStates.size(); i++) {
            final String iface = mTetherStates.keyAt(i);
            final TetherState tetherState = mTetherStates.valueAt(i);
            pw.print(iface + " - ");

            switch (tetherState.lastState) {
                case IControlsTethering.STATE_UNAVAILABLE:
                    pw.print("UnavailableState");
                    break;
                case IControlsTethering.STATE_AVAILABLE:
                    pw.print("AvailableState");
                    break;
                case IControlsTethering.STATE_TETHERED:
                    pw.print("TetheredState");
                    break;
                case IControlsTethering.STATE_LOCAL_ONLY:
                    pw.print("LocalHotspotState");
                    break;
                default:
                    pw.print("UnknownState");
                    break;
            }
            pw.println(" - lastError = " + tetherState.lastError);
        }
        pw.println("Upstream wanted: " + upstreamWanted());
        pw.println("Current upstream interface(s): " + mCurrentUpstreamIfaceSet);
        pw.decreaseIndent();
    }

    pw.println("Hardware offload:");
    pw.increaseIndent();
    mOffloadController.dump(pw);
    pw.decreaseIndent();

    pw.println("Log:");
    pw.increaseIndent();
    if (argsContain(args, SHORT_ARG)) {
        pw.println("<log removed for brevity>");
    } else {
        mLog.dump(fd, pw, args);
    }
    pw.decreaseIndent();

    pw.decreaseIndent();
}
 
Example 20
Source File: WebViewUpdateService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) return;
    WebViewUpdateService.this.mImpl.dumpState(pw);
}