com.blankj.utilcode.util.DeviceUtils Java Examples

The following examples show how to use com.blankj.utilcode.util.DeviceUtils. 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: AppService.java    From V2EX with GNU General Public License v3.0 6 votes vote down vote up
public static void checkNotifycation(String errorLog,ResponseListener<String> responseListener){

        Map<String, String> form = new HashMap<String,String>(){{
            put("version", AppUtils.getAppVersionName() + AppUtils.getAppVersionCode());
            put("deviceModel", DeviceUtils.getModel());
            put("sdkVersion", String.valueOf(DeviceUtils.getSDKVersionCode()));
            put("screen",  ScreenUtils.getScreenDensity() +
                    " " + ScreenUtils.getScreenHeight() +
                    "x" + ScreenUtils.getScreenWidth());
            put("errorLog", errorLog);
        }};
        RetrofitManager.create(AppApi.class)
                .checkNotifycation(form)
                .compose(RxUtil.io2main())
                .subscribe(new RxObserver<JsonObject>() {
                    @Override
                    public void _onNext(JsonObject jsonObject) {

                    }
                });
    }
 
Example #2
Source File: DeviceActivity.java    From Android-UtilCode with Apache License 2.0 6 votes vote down vote up
@Override
public void onWidgetClick(View view) {
    switch (view.getId()) {
        case R.id.btn_shutdown:
            DeviceUtils.shutdown();
            break;
        case R.id.btn_reboot:
            DeviceUtils.reboot();
            break;
        case R.id.btn_reboot_to_recovery:
            DeviceUtils.reboot2Recovery();
            break;
        case R.id.btn_reboot_to_bootloader:
            DeviceUtils.reboot2Bootloader();
            break;
    }
}
 
Example #3
Source File: DeviceInfoItem.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
public static List<DeviceInfoItem> getAppInfoItems() {
    List<DeviceInfoItem> appInfoItems = new ArrayList<>();
    appInfoItems.add(new DeviceInfoItem(R.string.du_device_info_name, Build.MANUFACTURER + " " + Build.MODEL));
    appInfoItems.add(new DeviceInfoItem(R.string.du_device_info_android_version, DeviceUtils.getSDKVersionName() + " (" + DeviceUtils.getSDKVersionCode() + ")"));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        appInfoItems.add(new DeviceInfoItem(R.string.du_device_info_adb_enabled, String.valueOf(DeviceUtils.isAdbEnabled())));
    }
    appInfoItems.add(new DeviceInfoItem(R.string.du_device_info_support_abis, ArrayUtils.toString(DeviceUtils.getABIs())));
    appInfoItems.add(new DeviceInfoItem(R.string.du_device_info_screen_info, getScreenInfo()));
    appInfoItems.add(new DeviceInfoItem(R.string.du_device_info_open_development_settings_page, "", new OnClickListener() {
        @Override
        public void onClick(View v) {
            ActivityUtils.startActivity(new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS));
        }
    }));
    return appInfoItems;
}
 
Example #4
Source File: Retro.java    From Pixiv-Shaft with MIT License 5 votes vote down vote up
private static Request.Builder addHeader(Request.Builder before) {
        PixivHeaders pixivHeaders = new PixivHeaders();
        String osVersion = DeviceUtils.getSDKVersionName();
        String phoneName = DeviceUtils.getModel();
        before.addHeader("User-Agent", "PixivAndroidApp/5.0.175 (Android " + osVersion + "; " + phoneName + ")")
                .addHeader("Accept-Language", "zh_CN")
                .addHeader("X-Client-Time", pixivHeaders.getXClientTime())
                .addHeader("X-Client-Hash", pixivHeaders.getXClientHash());
//        if (addAuth && Shaft.sUserModel != null) {
//            before.addHeader("Authorization", Shaft.sUserModel.getResponse().getAccess_token());
//        }
        return before;
    }
 
Example #5
Source File: RomUtils.java    From FloatWindow with Apache License 2.0 5 votes vote down vote up
public static String getDeviceManufacture() {
    if (isMiuiRom()) {
        return "小米";
    }
    if (isHuaweiRom()) {
        return "华为";
    }
    if (isVivoRom()) {
        return ROM_VIVO;
    }
    if (isOppoRom()) {
        return ROM_OPPO;
    }
    if (isMeizuRom()) {
        return "魅族";
    }
    if (isSmartisanRom()) {
        return "锤子";
    }
    if (is360Rom()) {
        return "奇酷";
    }
    if (isLetvRom()) {
        return "乐视";
    }
    if (isLenovoRom()) {
        return "联想";
    }
    if (isZTERom()) {
        return "中兴";
    }
    if (isCoolPadRom()) {
        return "酷派";
    }
    return DeviceUtils.getManufacturer();
}
 
Example #6
Source File: AppHealthInfoUtil.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
/**
 * 设置基本信息
 *
 * @param caseName   用例名称
 * @param testPerson 测试人员名字
 */
void setBaseInfo(String caseName, String testPerson) {
    AppHealthInfo.BaseInfoBean baseInfoBean = new AppHealthInfo.BaseInfoBean();
    baseInfoBean.setTestPerson(testPerson);
    baseInfoBean.setCaseName(caseName);
    baseInfoBean.setAppName(AppUtils.getAppName());
    baseInfoBean.setAppVersion(AppUtils.getAppVersionName());
    baseInfoBean.setDokitVersion(BuildConfig.DOKIT_VERSION);
    baseInfoBean.setPlatform("Android");
    baseInfoBean.setPhoneMode(DeviceUtils.getModel());
    baseInfoBean.setTime(TimeUtils.getNowString());
    baseInfoBean.setSystemVersion(DeviceUtils.getSDKVersionName());
    baseInfoBean.setpId("" + DokitConstant.PRODUCT_ID);
    mAppHealthInfo.setBaseInfo(baseInfoBean);
}
 
Example #7
Source File: DataPickBean.java    From DoraemonKit with Apache License 2.0 5 votes vote down vote up
DataPickBean() {
    //初始化基础数据
    this.pId = DokitConstant.PRODUCT_ID;
    this.appName = AppUtils.getAppName();
    this.appId = AppUtils.getAppPackageName();
    this.dokitVersion = BuildConfig.DOKIT_VERSION;
    this.platform = "Android";
    this.phoneMode = DeviceUtils.getModel();
    this.time = "" + TimeUtils.getNowMills();
    this.systemVersion = DeviceUtils.getSDKVersionName();
    this.language = Locale.getDefault().getDisplayLanguage();
}
 
Example #8
Source File: RomUtils.java    From FloatWindow with Apache License 2.0 5 votes vote down vote up
public static String getDeviceManufacture() {
    if (isMiuiRom()) {
        return "小米";
    }
    if (isHuaweiRom()) {
        return "华为";
    }
    if (isVivoRom()) {
        return ROM_VIVO;
    }
    if (isOppoRom()) {
        return ROM_OPPO;
    }
    if (isMeizuRom()) {
        return "魅族";
    }
    if (isSmartisanRom()) {
        return "锤子";
    }
    if (is360Rom()) {
        return "奇酷";
    }
    if (isLetvRom()) {
        return "乐视";
    }
    if (isLenovoRom()) {
        return "联想";
    }
    if (isZTERom()) {
        return "中兴";
    }
    if (isCoolPadRom()) {
        return "酷派";
    }
    return DeviceUtils.getManufacturer();
}
 
Example #9
Source File: DeviceActivity.java    From Android-UtilCode with Apache License 2.0 5 votes vote down vote up
@Override
public void initView(Bundle savedInstanceState, View view) {
    findViewById(R.id.btn_shutdown).setOnClickListener(this);
    findViewById(R.id.btn_reboot).setOnClickListener(this);
    findViewById(R.id.btn_reboot_to_recovery).setOnClickListener(this);
    findViewById(R.id.btn_reboot_to_bootloader).setOnClickListener(this);
    TextView tvAboutDevice = (TextView) findViewById(R.id.tv_about_device);
    tvAboutDevice.setText("isRoot: " + DeviceUtils.isDeviceRooted()
            + "\ngetSDKVersion: " + DeviceUtils.getSDKVersion()
            + "\ngetAndroidID: " + DeviceUtils.getAndroidID()
            + "\ngetMacAddress: " + DeviceUtils.getMacAddress()
            + "\ngetManufacturer: " + DeviceUtils.getManufacturer()
            + "\ngetModel: " + DeviceUtils.getModel()
    );
}
 
Example #10
Source File: FeedbackPresenter.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private Feedback getFeedback(String content,String contact){
    Feedback feedback=new Feedback();
    feedback.setContent(content);
    feedback.setContact(contact);
    feedback.setSdk(DeviceUtils.getSDKVersion());
    feedback.setVersion(AppUtils.getAppVersionName());
    return feedback;
}
 
Example #11
Source File: BasicInfoUtils.java    From QPM with Apache License 2.0 4 votes vote down vote up
public static List<InfoItem> getBaseInfo(Context context) {
    List<InfoItem> result = new ArrayList<>();
    // 基本信息
    result.add(new InfoItem("基本信息"));
    result.add(new InfoItem("是否ROOT", DeviceUtils.isDeviceRooted() ? "是" : "否"));
    result.add(new InfoItem("SDK版本", String.valueOf(DeviceUtils.getSDKVersionName())));
    result.add(new InfoItem("发布版本", Build.VERSION.RELEASE));
    result.add(new InfoItem("AndroidId", DeviceUtils.getAndroidID()));
    result.add(new InfoItem("设备厂商", DeviceUtils.getManufacturer()));
    result.add(new InfoItem("设备类型", DeviceUtils.getModel()));
    result.add(new InfoItem("产品型号", Build.PRODUCT));
    result.add(new InfoItem("主板型号", Build.BOARD));
    result.add(new InfoItem("显示型号", Build.DISPLAY));
    result.add(new InfoItem("序列号", Build.SERIAL));
    try{
        result.add(new InfoItem("IMEI", PhoneUtils.getIMEI()));
        result.add(new InfoItem("IMSI", PhoneUtils.getIMSI()));
    } catch (SecurityException e){
        //用户可能手动拒绝权限
    }
    result.add(new InfoItem("OCCID", getOCCID()));
    result.add(new InfoItem("SIM卡", PhoneUtils.isSimCardReady() ? "有" : "无"));

    // 网络相关
    result.add(new InfoItem("网络信息"));
    result.add(new InfoItem("Wifi名称", getWifiName(context)));
    result.add(new InfoItem("IP地址", NetworkUtils.getIPAddress(true)));
    result.add(new InfoItem("Mac地址", DeviceUtils.getMacAddress()));
    result.add(new InfoItem("运营商", NetworkUtils.getNetworkOperatorName()));
    result.add(new InfoItem("网络状态", getNetworkType()));
    result.add(new InfoItem("系统UA", System.getProperty("http.agent")));
    result.add(new InfoItem("聚美UA", getJMUserAgent(context)));

    //屏幕信息
    result.add(new InfoItem("屏幕信息"));
    result.add(new InfoItem("分辨率", getScreenSize(context)));
    result.add(new InfoItem("真实分辨率", ScreenUtils.getScreenWidth() + "x" + ScreenUtils.getScreenHeight()));
    result.add(new InfoItem("像素密度", String.valueOf(ScreenUtils.getScreenDensity())));
    result.add(new InfoItem("像素密度dp", String.valueOf(ScreenUtils.getScreenDensityDpi())));
    result.add(new InfoItem("屏幕尺寸", String.valueOf(getScreenInch(context) + "英寸")));

    // 硬件信息
    result.add(new InfoItem("硬件信息"));
    result.add(new InfoItem("CPU架构", getCPUType()));
    result.add(new InfoItem("CPU核数", String.valueOf(Runtime.getRuntime().availableProcessors())));
    result.add(new InfoItem("总内存", transferByte2MB(Runtime.getRuntime().totalMemory())));
    result.add(new InfoItem("最大内存", transferByte2MB(Runtime.getRuntime().maxMemory())));
    result.add(new InfoItem("剩余内存", transferByte2MB(Runtime.getRuntime().freeMemory())));
    result.add(new InfoItem("硬件信息", Build.HARDWARE));

    return result;
}