當前位置: 首頁>>代碼示例>>Java>>正文


Java Hood類代碼示例

本文整理匯總了Java中at.favre.lib.hood.Hood的典型用法代碼示例。如果您正苦於以下問題:Java Hood類的具體用法?Java Hood怎麽用?Java Hood使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Hood類屬於at.favre.lib.hood包,在下文中一共展示了Hood類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: asEntryList

import at.favre.lib.hood.Hood; //導入依賴的package包/類
@Override
public List<PageEntry<?>> asEntryList() {
    if (entries.isEmpty() && errorMessage == null) {
        return Collections.emptyList();
    }

    List<PageEntry<?>> entriesOut = new ArrayList<>(entries.size() + 1);
    if (header != null) {
        entriesOut.add(Hood.get().createHeaderEntry(header));
    }
    if (errorMessage != null) {
        entriesOut.add(Hood.get().createMessageEntry(errorMessage));
    }

    entriesOut.addAll(entries);

    return entriesOut;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:19,代碼來源:DefaultSection.java

示例2: setPageData

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Sets the page data (required to for the ui to show anything)
 *
 * @param pages
 */
public void setPageData(@NonNull Pages pages) {
    this.viewPager.setAdapter(new DebugViewPageAdapter(viewPager, pages, zebraColor));
    this.pages = Hood.ext().createUnmodifiablePages(pages);

    if (pages.getConfig().autoLog) {
        pages.logPages();
    }

    setupAutoRefresh(pages);

    if (!(getContext() instanceof HoodController)) {
        pages.log("activity does not implement IHoodDebugController - some features might not work");
    }

    if (pages.getAll().size() <= 1 || !pages.getConfig().showPagesIndicator) {
        tabs.setVisibility(GONE);
    } else {
        tabs.setVisibility(VISIBLE);
    }
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:26,代碼來源:HoodDebugPageView.java

示例3: createDetailedDeviceInfo

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Additional device info
 *
 * @param activity can be null, but will just return an empty list
 * @return list of page-entries
 */
public static List<PageEntry<?>> createDetailedDeviceInfo(@Nullable final Activity activity) {
    List<PageEntry<?>> entries = new ArrayList<>();
    if (activity != null) {
        DisplayMetrics metrics = new DisplayMetrics();
        activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
        entries.add(Hood.get().createPropertyEntry("dpi", "x" + metrics.density + "/" + metrics.densityDpi + "dpi"));
        entries.add(Hood.get().createPropertyEntry("resolution", metrics.heightPixels + "x" + metrics.widthPixels));
        entries.add(Hood.get().createPropertyEntry("locale/timezone", new DynamicValue<String>() {
            @Override
            public String getValue() {
                return HoodUtil.getCurrentLocale(activity).toString() + "/" + TimeZone.getDefault().getDisplayName();
            }
        }));
        entries.add(Hood.get().createPropertyEntry("uptime", new DynamicValue<String>() {
            @Override
            public String getValue() {
                return HoodUtil.millisToDaysHoursMinString(SystemClock.elapsedRealtime());
            }
        }));
        entries.add(Hood.get().createPropertyEntry("android-id", Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID)));
    }
    return entries;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:30,代碼來源:DefaultProperties.java

示例4: createStaticFieldsInfo

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Traverses the static fields of given arbitrary class. Will create an entry for each non-null
 * static public field. Ignores "serialVersionUID".
 * <p>
 * NOTE: this uses reflection to traverse to class, so if you want to keep it after proguard, use
 * a keep rule like:
 * <p>
 * <pre>
 *     -keep public class your.package.name.BuildConfig { public *;}
 * </pre>
 *
 * @param clazz the BuildConfig.java class you want the info
 * @return list of page-entries
 */
public static List<PageEntry<?>> createStaticFieldsInfo(Class<?> clazz) {
    List<PageEntry<?>> entries = new ArrayList<>();

    Field[] declaredFields = clazz.getDeclaredFields();
    for (Field field : declaredFields) {
        if (Modifier.isStatic(field.getModifiers()))
            try {
                String key = field.getName();
                String value = String.valueOf(field.get(null));

                if (key != null && !key.equals("serialVersionUID") &&
                        value != null && !value.equals("null") && !value.trim().isEmpty()) {
                    entries.add(Hood.get().createPropertyEntry(key, String.valueOf(field.get(null))));
                }
            } catch (Exception e) {
                Timber.w("could not get field from class (" + field + ")");
            }
    }

    return entries;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:36,代碼來源:DefaultProperties.java

示例5: createSectionRuntimePermissions

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Returns for each provided permission a page-entry containing the current dynamic state (granted, denied, etc.) including click
 * actions to request the permission.
 *
 * @param activity           can be null, but will just return an empty list
 * @param androidPermissions see {@link android.Manifest.permission}
 * @return the section containing header, entries etc.
 */
public static Section.HeaderSection createSectionRuntimePermissions(@Nullable final Activity activity, List<String> androidPermissions) {
    Section.ModifiableHeaderSection section = Hood.ext().createSection("Permissions");

    if (activity != null && !androidPermissions.isEmpty()) {
        for (final String perm : androidPermissions) {
            section.add(Hood.get().createPropertyEntry(perm.replace("android.permission.", ""), new DynamicValue<String>() {
                @Override
                public String getValue() {
                    return TypeTranslators.translatePermissionState(PermissionTranslator.getPermissionStatus(activity, perm));
                }
            }, Hood.ext().createOnClickActionAskPermission(perm, activity), false));
        }
    }
    return section;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:24,代碼來源:DefaultProperties.java

示例6: createSystemFeatureInfo

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Convince feature to add state of multiple system features.
 * Uses {@link PackageManager#hasSystemFeature(String)} call.
 * <p>
 * See https://developer.android.com/guide/topics/manifest/uses-feature-element.html#features-reference for
 * available system features.
 *
 * @param context               can be null, but will just return an empty list
 * @param labelSystemFeatureMap a map which has ui labels as key and android system feature string
 *                              (as returned as name by {@link PackageManager#getSystemAvailableFeatures()}) as value
 * @return list of page-entries (one for each map entry)
 */
public static List<PageEntry<?>> createSystemFeatureInfo(@Nullable Context context, Map<CharSequence, String> labelSystemFeatureMap) {
    List<PageEntry<?>> entries = new ArrayList<>();
    if (context != null) {

        for (Map.Entry<CharSequence, String> entry : labelSystemFeatureMap.entrySet()) {
            boolean supported;
            if (entry.getValue().matches("^-?\\d+$")) {
                final ConfigurationInfo configurationInfo = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE)).getDeviceConfigurationInfo();
                supported = configurationInfo.reqGlEsVersion >= Integer.valueOf(entry.getValue());
            } else {
                supported = context.getPackageManager().hasSystemFeature(entry.getValue());
            }
            entries.add(Hood.get().createPropertyEntry(entry.getKey(), String.valueOf(supported)));
        }
    }
    return entries;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:30,代碼來源:DefaultProperties.java

示例7: createSectionStrictMode

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Adds info for current {@link StrictMode} config. Currently only shows the bitmask used to
 * store the policies states. Unfortunately there is not much public API to examine StrictMode
 *
 * @return section
 */
public static Section.HeaderSection createSectionStrictMode() {
    Section.ModifiableHeaderSection section = Hood.ext().createSection("StrictMode");
    section.add(Hood.get().createPropertyEntry("thread-policy", new DynamicValue<String>() {
        @Override
        public String getValue() {
            return String.valueOf(StrictMode.getThreadPolicy());
        }
    }, true));
    section.add(Hood.get().createPropertyEntry("vm-policy", new DynamicValue<String>() {
        @Override
        public String getValue() {
            return StrictMode.getVmPolicy().toString();
        }
    }, true));
    return section;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:23,代碼來源:DefaultProperties.java

示例8: createSectionSourceControlAndCI

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Convenience to create a CI and source control section. Pass everything you want and keep the rest null.
 *
 * @param scmRev      git hash e.g. "git log -1 --format=%H"
 * @param scmBranch   git branch e.g. "git rev-parse --abbrev-ref HEAD"
 * @param ciBuildId   build number
 * @param ciBuildJob  job name
 * @param ciBuildTime time on ci server
 * @return the section containing all the data
 */
public static Section.HeaderSection createSectionSourceControlAndCI(@Nullable String scmRev, @Nullable String scmBranch, @Nullable String scmCommitDate,
                                                                    @Nullable String ciBuildId, @Nullable String ciBuildJob, @Nullable String ciBuildTime) {
    Section.ModifiableHeaderSection section = Hood.ext().createSection("Source Control & CI");
    if (scmBranch != null) {
        section.add(Hood.get().createPropertyEntry("scm-branch", scmBranch));
    }
    if (scmRev != null) {
        section.add(Hood.get().createPropertyEntry("scm-rev", scmRev));
    }
    if (scmCommitDate != null) {
        section.add(Hood.get().createPropertyEntry("scm-date", scmCommitDate));
    }
    if (ciBuildJob != null) {
        section.add(Hood.get().createPropertyEntry("ci-job", ciBuildJob));
    }
    if (ciBuildId != null) {
        section.add(Hood.get().createPropertyEntry("ci-build-id", ciBuildId));
    }
    if (ciBuildTime != null) {
        section.add(Hood.get().createPropertyEntry("ci-build-time", ciBuildTime));
    }
    return section;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:34,代碼來源:DefaultProperties.java

示例9: createTransferStatSection

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Creates a section showing some stats from {@link TrafficStats} showing tx/rx bytes and packages
 * of tagged sockets from boot until now.
 *
 * @param uids optional uid to get rx/tx bytes and packages
 * @return section
 */
public static Section.HeaderSection createTransferStatSection(int... uids) {
    Section.ModifiableHeaderSection section = Hood.ext().createSection("Traffic Stats");

    if (uids != null) {
        for (int uid : uids) {
            section.add(createTxRxdSection("Socket " + uid, TrafficStats.getUidTxBytes(uid), TrafficStats.getUidTxPackets(uid),
                    TrafficStats.getUidRxBytes(uid), TrafficStats.getUidRxPackets(uid)));
        }
    }
    section.add(createTxRxdSection("Mobile", TrafficStats.getMobileTxBytes(), TrafficStats.getMobileTxPackets(),
            TrafficStats.getMobileRxBytes(), TrafficStats.getMobileRxPackets()));
    section.add(createTxRxdSection("Total", TrafficStats.getTotalTxBytes(), TrafficStats.getTotalTxPackets(),
            TrafficStats.getTotalRxBytes(), TrafficStats.getTotalRxPackets()));

    return section;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:24,代碼來源:DefaultProperties.java

示例10: createTxRxdSection

import at.favre.lib.hood.Hood; //導入依賴的package包/類
private static List<PageEntry<?>> createTxRxdSection(String name, final long txBytes,
                                                     final long txPackets, final long rxBytes, final long rxPackets) {
    List<PageEntry<?>> list = new LinkedList<>();
    list.add(Hood.get().createPropertyEntry(name + " TX", new DynamicValue<String>() {
        @Override
        public String getValue() {
            return txBytes == TrafficStats.UNSUPPORTED ? "UNSUPPORTED" : txPackets + " pkt / " + HoodUtil.humanReadableByteCount(txBytes, false);
        }
    }));
    list.add(Hood.get().createPropertyEntry(name + " RCVD", new DynamicValue<String>() {
        @Override
        public String getValue() {
            return rxPackets == TrafficStats.UNSUPPORTED ? "UNSUPPORTED" : rxPackets + " pkt / " + HoodUtil.humanReadableByteCount(rxBytes, false);
        }
    }));
    return list;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:18,代碼來源:DefaultProperties.java

示例11: createPmServiceInfo

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Lists all defined services with additional meta-data
 *
 * @param packageInfo from {@link PackageManager#getPackageInfo(String, int)} requiring {@link PackageManager#GET_SERVICES} flag
 * @return list of services
 */
public static List<PageEntry<?>> createPmServiceInfo(@NonNull PackageInfo packageInfo) {
    List<PageEntry<?>> entries = new ArrayList<>();
    if (packageInfo.services != null) {
        for (ServiceInfo service : packageInfo.services) {
            if (service != null) {
                entries.add(Hood.get().createPropertyEntry(service.name,
                        "exported: " + service.exported + "\n" +
                                "enabled: " + service.enabled + "\n" +
                                "flags: " + service.exported + "\n" +
                                "process: " + service.processName + "\n" +
                                "req-permission: " + service.permission + "\n", true));
            }
        }
    }
    return entries;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:23,代碼來源:PackageInfoAssembler.java

示例12: createPmProviderInfo

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Lists all defined providers with additional meta-data
 *
 * @param packageInfo from {@link PackageManager#getPackageInfo(String, int)} requiring {@link PackageManager#GET_PROVIDERS} flag
 * @return entries
 */
public static List<PageEntry<?>> createPmProviderInfo(@NonNull PackageInfo packageInfo) {
    List<PageEntry<?>> entries = new ArrayList<>();
    if (packageInfo.providers != null) {
        for (ProviderInfo provider : packageInfo.providers) {
            if (provider != null) {
                entries.add(Hood.get().createPropertyEntry(provider.name,
                        "exported: " + provider.exported + "\n" +
                                "enabled: " + provider.enabled + "\n" +
                                "authorities: " + provider.authority + "\n" +
                                "multi-process: " + provider.multiprocess + "\n" +
                                "read-perm: " + provider.readPermission + "\n" +
                                "write-perm: " + provider.writePermission + "\n", true));
            }
        }
    }
    return entries;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:24,代碼來源:PackageInfoAssembler.java

示例13: createPmSignatureHashInfo

import at.favre.lib.hood.Hood; //導入依賴的package包/類
/**
 * Creates page-entries for all the apks signatures and shows sh256 hash of it
 *
 * @param packageInfo  from {@link PackageManager#getPackageInfo(String, int)} requiring {@link PackageManager#GET_SIGNATURES} flag
 * @param refSha256Map a map of key: name of signature and value: first x digits of sha256 hash of signature; used for adding name to specific signature (i.e. "debug key")
 * @return entries
 */
public static List<PageEntry<?>> createPmSignatureHashInfo(@NonNull PackageInfo packageInfo, @NonNull Map<String, String> refSha256Map) {
    List<PageEntry<?>> entries = new ArrayList<>();
    try {
        for (Signature signature : packageInfo.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(signature.toByteArray());

            String sha256 = HoodUtil.byteToHex(md.digest());
            String key = "apk-signature-sha256";
            for (Map.Entry<String, String> refEntry : refSha256Map.entrySet()) {
                if (sha256.toLowerCase().startsWith(refEntry.getValue().toLowerCase())) {
                    key += " (" + refEntry.getKey() + ")";
                }
            }
            entries.add(Hood.get().createPropertyEntry(key, sha256, true));
        }
    } catch (Exception e) {
        throw new IllegalStateException("could not create hash", e);
    }
    return entries;
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:29,代碼來源:PackageInfoAssembler.java

示例14: testPagesEqualsLogic

import at.favre.lib.hood.Hood; //導入依賴的package包/類
@Test
public void testPagesEqualsLogic() throws Exception {
    Pages defaultPages = DebugPages.Factory.create(Config.newBuilder().build());
    Page page1a = DebugPage.Factory.create(defaultPages, "one");
    Page page1b = DebugPage.Factory.create(defaultPages, "two");

    assertNotSame(page1a, page1b);

    Page page2a = DebugPage.Factory.create(DebugPages.Factory.create(Config.newBuilder().setAutoRefresh(true).build()), "same");
    Page page2b = DebugPage.Factory.create(DebugPages.Factory.create(Config.newBuilder().setAutoRefresh(false).build()), "same");

    assertNotSame(page2a, page2b);

    Page page3a = DebugPage.Factory.create(defaultPages, "same");
    Page page3b = DebugPage.Factory.create(defaultPages, "same");

    page3a.add(Hood.get().createPropertyEntry("key", "value"));
    assertNotSame(page3a, page3b);
    page3b.add(Hood.get().createPropertyEntry("key_a", "value_a"));
    assertNotSame(page3a, page3b);

    Page page4a = DebugPage.Factory.create(defaultPages, "one");
    Page page4b = DebugPage.Factory.create(defaultPages, "one");
    assertEquals(page4a, page4b);
}
 
開發者ID:patrickfav,項目名稱:under-the-hood,代碼行數:26,代碼來源:DebugPageTest.java

示例15: onCreate

import at.favre.lib.hood.Hood; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    navigationView = findViewById(R.id.navigationView);

    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setElevation(getResources().getDimension(R.dimen.toolbar_elevation));
    initDrawer();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setTaskDescription(new ActivityManager.TaskDescription(getString(R.string.app_name), BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher), getResources().getColor(R.color.color_primary_dark)));
    }

    if (savedInstanceState == null) {
        selectView(R.id.navigation_item_1);
    } else {
        currentFragmentTag = savedInstanceState.getString(ARG_VISIBLE_FRAGMENT_TAG);
    }

    control = Hood.ext().registerShakeToOpenDebugActivity(this, PopHoodActivity.createIntent(this, DebugActivity.class));
}
 
開發者ID:patrickfav,項目名稱:BlurTestAndroid,代碼行數:24,代碼來源:MainActivity.java


注:本文中的at.favre.lib.hood.Hood類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。