version:
update:2020.09.07 fix:去掉不需要显示的toast,增加高德地图定位,增加更新设备获取详细信息 add:
This commit is contained in:
@@ -88,8 +88,8 @@ android {
|
|||||||
}
|
}
|
||||||
newl {
|
newl {
|
||||||
flavorDimensions "default"
|
flavorDimensions "default"
|
||||||
versionCode 150
|
versionCode 153
|
||||||
versionName "1.0.5"
|
versionName "1.0.8"
|
||||||
/*********************************极光推送************************************/
|
/*********************************极光推送************************************/
|
||||||
manifestPlaceholders = [
|
manifestPlaceholders = [
|
||||||
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
|
JPUSH_PKGNAME: "com.jiaoguanyi.appstore",
|
||||||
@@ -234,5 +234,5 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'com.hjq:xxpermissions:6.0'
|
implementation 'com.hjq:xxpermissions:6.0'
|
||||||
|
|
||||||
|
implementation 'com.amap.api:location:5.1.0'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,11 +27,13 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
@@ -229,6 +231,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||||
sendBroadcast(allIntent);
|
sendBroadcast(allIntent);
|
||||||
// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png");
|
// CmdUtil.execute(" screencap -p /sdcard/" + "screen" + System.currentTimeMillis() + ".png");
|
||||||
|
|
||||||
|
Utils.getMachine(this);
|
||||||
|
Utils.getHardware(this);
|
||||||
|
// Utils.queryStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取教管易版本号
|
//获取教管易版本号
|
||||||
@@ -246,7 +252,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized public void sendMACaddress() {
|
synchronized public void sendMACaddress() {
|
||||||
String devices_version = Utils.getProperty("ro.custom.build.version", "获取失败");
|
String devices_version = Utils.getProperty("ro.custom.build.version", "获取失败");//获取自定义版本
|
||||||
String rid = JPushInterface.getRegistrationID(MainActivity.this);
|
String rid = JPushInterface.getRegistrationID(MainActivity.this);
|
||||||
OkGo.post(Configure.SEND_DEVICES)
|
OkGo.post(Configure.SEND_DEVICES)
|
||||||
.params("sn", Utils.getSerial())
|
.params("sn", Utils.getSerial())
|
||||||
@@ -739,7 +745,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Intent allIntent = new Intent();
|
Intent allIntent = new Intent();
|
||||||
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
|
||||||
sendBroadcast(allIntent);
|
sendBroadcast(allIntent);
|
||||||
loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL);
|
// loadHeadImg(Configure.HTTP_TAG_HOME_PAGE_URL);
|
||||||
getLockedState(mHandler);
|
getLockedState(mHandler);
|
||||||
// MyApplication.getInstance().getWhitePackageList();
|
// MyApplication.getInstance().getWhitePackageList();
|
||||||
getInfo(mHandler);
|
getInfo(mHandler);
|
||||||
@@ -776,86 +782,86 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
});// 请求方式和请求url
|
});// 请求方式和请求url
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadHeadImg(String URL) {
|
// private void loadHeadImg(String URL) {
|
||||||
BrankPicApi brankPicApi = Network.getBrankPicApi();
|
// BrankPicApi brankPicApi = Network.getBrankPicApi();
|
||||||
brankPicApi.getBrankPicApi(Configure.HTTP_KEY, Utils.getSerial(), "1")
|
// brankPicApi.getBrankPicApi(Configure.HTTP_KEY, Utils.getSerial(), "1")
|
||||||
.subscribeOn(Schedulers.io())
|
// .subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
// .observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(new Observer<CommonPicBean>() {
|
// .subscribe(new Observer<CommonPicBean>() {
|
||||||
@Override
|
// @Override
|
||||||
public void onSubscribe(Disposable d) {
|
// public void onSubscribe(Disposable d) {
|
||||||
|
//
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(CommonPicBean projectPicBean) {
|
|
||||||
paraData(projectPicBean);
|
|
||||||
Log.e("mjsheng", "brankPicApi---" + projectPicBean.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
// Utils.showToast(MainActivity.this, "网络出错!");
|
|
||||||
Log.e("mjsheng", "brankPicApi---error----" + e.getMessage());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void paraData(CommonPicBean categoryPicBean) {
|
|
||||||
int code = categoryPicBean.getCode();
|
|
||||||
switch (code) {
|
|
||||||
case 200:
|
|
||||||
final List<CommonPicData> data = categoryPicBean.getData();
|
|
||||||
// if (data != null && data.size() > 0) {
|
|
||||||
// List<String> list = new ArrayList<>();
|
|
||||||
// for (int i = 0; i < data.size(); i++) {
|
|
||||||
// list.add(data.get(i).getImg());
|
|
||||||
// }
|
// }
|
||||||
// webBannerAdapter = new WebBannerAdapter(getActivity(), list);
|
//
|
||||||
// webBannerAdapter.setOnBannerItemClickListener(new BannerLayout.OnBannerItemClickListener() {
|
// @Override
|
||||||
// @Override
|
// public void onNext(CommonPicBean projectPicBean) {
|
||||||
// public void onItemClick(int position) {
|
// paraData(projectPicBean);
|
||||||
// loadProjectByType(Configure.HTTP_TAG_BRAND_DETAILS_URL, data.get(position).getId(), data.get(position).getName());
|
// Log.e("mjsheng", "brankPicApi---" + projectPicBean.toString());
|
||||||
// }
|
// }
|
||||||
// });
|
//
|
||||||
// recyclerBanner.setAdapter(webBannerAdapter);
|
// @Override
|
||||||
// mAdapter = new TopRecyclerViewAdapter(getActivity(), "home", list, new TopRecyclerViewAdapter.HorizontalScrollViewListener() {
|
// public void onError(Throwable e) {
|
||||||
// @Override
|
//// Utils.showToast(MainActivity.this, "网络出错!");
|
||||||
// public void onClick(String iconUrl, int position) {
|
// Log.e("mjsheng", "brankPicApi---error----" + e.getMessage());
|
||||||
// sound.playSoundEffect();
|
//
|
||||||
// loadProjectByType(Configure.HTTP_TAG_BRAND_DETAILS_URL, data.get(position).getId(), data.get(position).getName());
|
// }
|
||||||
// }
|
//
|
||||||
// });
|
// @Override
|
||||||
// mTopRlView.setAdapter(mAdapter);
|
// public void onComplete() {
|
||||||
// } else {
|
//
|
||||||
// // Utils.showToast(getContext(), "数据为空!");
|
// }
|
||||||
// Log.e("mjsheng", "推荐页轮播图为空!");
|
// });
|
||||||
// }
|
//
|
||||||
break;
|
//
|
||||||
case -200:
|
// }
|
||||||
paraError(categoryPicBean.getMsg());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void paraError(String msg) {
|
// private void paraData(CommonPicBean categoryPicBean) {
|
||||||
switch (msg) {
|
// int code = categoryPicBean.getCode();
|
||||||
case "没有找到SN码":
|
// switch (code) {
|
||||||
ToastUtil.show(msg);
|
// case 200:
|
||||||
break;
|
// final List<CommonPicData> data = categoryPicBean.getData();
|
||||||
default:
|
//// if (data != null && data.size() > 0) {
|
||||||
ToastUtil.show(msg);
|
//// List<String> list = new ArrayList<>();
|
||||||
break;
|
//// for (int i = 0; i < data.size(); i++) {
|
||||||
}
|
//// list.add(data.get(i).getImg());
|
||||||
}
|
//// }
|
||||||
|
//// webBannerAdapter = new WebBannerAdapter(getActivity(), list);
|
||||||
|
//// webBannerAdapter.setOnBannerItemClickListener(new BannerLayout.OnBannerItemClickListener() {
|
||||||
|
//// @Override
|
||||||
|
//// public void onItemClick(int position) {
|
||||||
|
//// loadProjectByType(Configure.HTTP_TAG_BRAND_DETAILS_URL, data.get(position).getId(), data.get(position).getName());
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// recyclerBanner.setAdapter(webBannerAdapter);
|
||||||
|
//// mAdapter = new TopRecyclerViewAdapter(getActivity(), "home", list, new TopRecyclerViewAdapter.HorizontalScrollViewListener() {
|
||||||
|
//// @Override
|
||||||
|
//// public void onClick(String iconUrl, int position) {
|
||||||
|
//// sound.playSoundEffect();
|
||||||
|
//// loadProjectByType(Configure.HTTP_TAG_BRAND_DETAILS_URL, data.get(position).getId(), data.get(position).getName());
|
||||||
|
//// }
|
||||||
|
//// });
|
||||||
|
//// mTopRlView.setAdapter(mAdapter);
|
||||||
|
//// } else {
|
||||||
|
//// // Utils.showToast(getContext(), "数据为空!");
|
||||||
|
//// Log.e("mjsheng", "推荐页轮播图为空!");
|
||||||
|
//// }
|
||||||
|
// break;
|
||||||
|
// case -200:
|
||||||
|
// paraError(categoryPicBean.getMsg());
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// private void paraError(String msg) {
|
||||||
|
// switch (msg) {
|
||||||
|
// case "没有找到SN码":
|
||||||
|
// ToastUtil.show(msg);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// ToastUtil.show(msg);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
@@ -993,18 +999,23 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
updateBuilder.check();
|
updateBuilder.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// 用来计算返回键的点击间隔时间
|
||||||
public void onBackPressed() {
|
private long exitTime = 0;
|
||||||
lazyExit();
|
|
||||||
|
|
||||||
super.onBackPressed();
|
@Override
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
|
lazyExit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lazyExit() {
|
private void lazyExit() {
|
||||||
if (System.currentTimeMillis() - mPreClickTime > 1000) {
|
if (System.currentTimeMillis() - mPreClickTime > 1000) {
|
||||||
ToastUtils.showShort("再按一次,退出");
|
ToastUtils.showShort("再按一次,退出");
|
||||||
mPreClickTime = System.currentTimeMillis();
|
mPreClickTime = System.currentTimeMillis();
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -1221,7 +1232,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setNetAndlaunch(netAndLaunchBean);
|
setNetAndlaunch(netAndLaunchBean);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ToastUtils.showShort(netAndLaunchBean.getMsg());
|
// ToastUtils.showShort(netAndLaunchBean.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -745,4 +745,34 @@ public class HTTPInterface {
|
|||||||
// context.sendBroadcast(intent1);
|
// context.sendBroadcast(intent1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public void updateDeviceInfo(Context context) {
|
||||||
|
// UpdateDeviceInfo updateDeviceInfo = Network.getUpdateDeviceInfo();
|
||||||
|
//
|
||||||
|
// updateDeviceInfo.updateDeviceInfo()
|
||||||
|
// .subscribeOn(Schedulers.io())
|
||||||
|
// .observeOn(AndroidSchedulers.mainThread())
|
||||||
|
// .subscribe(new Observer<ResponseBody>() {
|
||||||
|
// @Override
|
||||||
|
// public void onSubscribe(Disposable d) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onNext(ResponseBody responseBody) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onError(Throwable e) {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onComplete() {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ import com.mjsheng.myappstore.network.api.SystemSettingApi;
|
|||||||
import com.mjsheng.myappstore.network.api.UpdateApi;
|
import com.mjsheng.myappstore.network.api.UpdateApi;
|
||||||
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
|
import com.mjsheng.myappstore.network.api.UploadAppInfoApi;
|
||||||
import com.mjsheng.myappstore.network.api.newapi.GetLockState;
|
import com.mjsheng.myappstore.network.api.newapi.GetLockState;
|
||||||
|
import com.mjsheng.myappstore.network.api.newapi.UpdateDeviceInfo;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -64,7 +65,7 @@ public class Network {
|
|||||||
private static ForceDownloadApi forceDownloadApi;
|
private static ForceDownloadApi forceDownloadApi;
|
||||||
|
|
||||||
private static GetLockState getLockState;
|
private static GetLockState getLockState;
|
||||||
|
private static UpdateDeviceInfo updateDeviceInfo;
|
||||||
|
|
||||||
private static final long cacheSize = 1024 * 1024 * 20;// 缓存文件最大限制大小20M
|
private static final long cacheSize = 1024 * 1024 * 20;// 缓存文件最大限制大小20M
|
||||||
private static String cacheDirectory = Environment.getExternalStorageDirectory() + "/okttpcaches"; // 设置缓存文件路径
|
private static String cacheDirectory = Environment.getExternalStorageDirectory() + "/okttpcaches"; // 设置缓存文件路径
|
||||||
@@ -269,4 +270,18 @@ public class Network {
|
|||||||
return getLockState;
|
return getLockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UpdateDeviceInfo getUpdateDeviceInfo() {
|
||||||
|
if (updateDeviceInfo == null) {
|
||||||
|
Retrofit retrofit = new Retrofit.Builder()
|
||||||
|
.client(cacheClient)
|
||||||
|
.baseUrl(ROOT_URL)
|
||||||
|
.addConverterFactory(gsonConverterFactory)
|
||||||
|
.addCallAdapterFactory(rxJavaCallAdapterFactory)
|
||||||
|
.build();
|
||||||
|
updateDeviceInfo = retrofit.create(UpdateDeviceInfo.class);
|
||||||
|
}
|
||||||
|
return updateDeviceInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.mjsheng.myappstore.network.api.newapi;
|
||||||
|
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import okhttp3.ResponseBody;
|
||||||
|
import retrofit2.http.Field;
|
||||||
|
import retrofit2.http.FormUrlEncoded;
|
||||||
|
import retrofit2.http.POST;
|
||||||
|
|
||||||
|
public interface UpdateDeviceInfo {
|
||||||
|
@FormUrlEncoded
|
||||||
|
@POST("Application/getLockState")
|
||||||
|
Observable<ResponseBody> updateDeviceInfo(
|
||||||
|
@Field("sn") String sn,
|
||||||
|
@Field("key") String key,
|
||||||
|
@Field("machine") String machine,
|
||||||
|
@Field("hardware") String hardware,
|
||||||
|
@Field("address") String address
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -111,6 +111,11 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
private final String DEVICES_REBOOT = "22";//重启
|
private final String DEVICES_REBOOT = "22";//重启
|
||||||
|
|
||||||
|
private final String GET_DEVICES_INFO = "23";//获取设备详细信息
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private int changeNum(int paramInt) {
|
private int changeNum(int paramInt) {
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ public class InitJpushServer extends Service {
|
|||||||
setNetAndlaunch(netAndLaunchBean);
|
setNetAndlaunch(netAndLaunchBean);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ToastUtils.showShort(netAndLaunchBean.getMsg());
|
// ToastUtils.showShort(netAndLaunchBean.getMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -963,7 +963,7 @@ public class InitJpushServer extends Service {
|
|||||||
//摄像头开关
|
//摄像头开关
|
||||||
int setting_camera = changeNum(data.optInt("setting_camera"));
|
int setting_camera = changeNum(data.optInt("setting_camera"));
|
||||||
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_camera", setting_camera);
|
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_camera", setting_camera);
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.mediatek.camera");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.mediatek.camera");
|
||||||
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
|
Log.e("SystemSetting", "setting_camera---------" + setting_camera);
|
||||||
String cameraStatus = "";
|
String cameraStatus = "";
|
||||||
switch (setting_camera) {
|
switch (setting_camera) {
|
||||||
@@ -1022,22 +1022,22 @@ public class InitJpushServer extends Service {
|
|||||||
//时钟
|
//时钟
|
||||||
int deskclock = changeNum(data.optInt("setting_clock"));
|
int deskclock = changeNum(data.optInt("setting_clock"));
|
||||||
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_deskclock", deskclock);
|
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_deskclock", deskclock);
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.deskclock");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.android.deskclock");
|
||||||
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
|
Log.e("SystemSetting", "qch_app_deskclock" + deskclock);
|
||||||
//录音机
|
//录音机
|
||||||
int soundrecorder = changeNum(data.optInt("setting_recording"));
|
int soundrecorder = changeNum(data.optInt("setting_recording"));
|
||||||
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
|
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_soundrecorder", soundrecorder);
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.soundrecorder");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.android.soundrecorder");
|
||||||
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
|
Log.e("SystemSetting", "qch_app_soundrecorder" + soundrecorder);
|
||||||
//音乐
|
//音乐
|
||||||
int music = changeNum(data.optInt("setting_music"));
|
int music = changeNum(data.optInt("setting_music"));
|
||||||
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_music", music);
|
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_music", music);
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.music");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.android.music");
|
||||||
Log.e("SystemSetting", "qch_app_music" + music);
|
Log.e("SystemSetting", "qch_app_music" + music);
|
||||||
//图库
|
//图库
|
||||||
int gallery = changeNum(data.optInt("setting_picture"));
|
int gallery = changeNum(data.optInt("setting_picture"));
|
||||||
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_gallery", gallery);
|
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_gallery", gallery);
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.gallery3d");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.android.gallery3d");
|
||||||
Log.e("SystemSetting", "qch_app_gallery" + gallery);
|
Log.e("SystemSetting", "qch_app_gallery" + gallery);
|
||||||
//壁纸
|
//壁纸
|
||||||
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
|
int wallpaper = changeNum(data.optInt("setting_wallpaper"));
|
||||||
@@ -1046,10 +1046,10 @@ public class InitJpushServer extends Service {
|
|||||||
//文件管理器
|
//文件管理器
|
||||||
int filemanager = changeNum(data.optInt("setting_file"));
|
int filemanager = changeNum(data.optInt("setting_file"));
|
||||||
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_filemanager", filemanager);
|
Settings.System.putInt(InitJpushServer.this.getContentResolver(), "qch_app_filemanager", filemanager);
|
||||||
if (Build.VERSION.SDK_INT<Build.VERSION_CODES.O){
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.mediatek.filemanager");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.mediatek.filemanager");
|
||||||
}else {
|
} else {
|
||||||
ApkUtils.hideSystemSettingAPP(InitJpushServer.this,"com.android.documentsui");
|
ApkUtils.hideSystemSettingAPP(InitJpushServer.this, "com.android.documentsui");
|
||||||
}
|
}
|
||||||
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
|
Log.e("SystemSetting", "qch_app_filemanager" + filemanager);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -805,7 +805,11 @@ public class ApkUtils {
|
|||||||
installedList += s + ",";
|
installedList += s + ",";
|
||||||
Log.e("addShortcut", s);
|
Log.e("addShortcut", s);
|
||||||
}
|
}
|
||||||
installedList = installedList.substring(0, installedList.length() - 1);
|
if (installedList.length() != 0) {
|
||||||
|
installedList = installedList.substring(0, installedList.length() - 1);
|
||||||
|
} else {
|
||||||
|
Log.e("addShortcut", installedList);
|
||||||
|
}
|
||||||
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList);
|
boolean qch_force_app = Settings.System.putString(context.getContentResolver(), "qch_launcher_icon_app", installedList);
|
||||||
// String old = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
|
// String old = Settings.System.getString(context.getContentResolver(), "qch_launcher_icon_app");
|
||||||
// Log.e("addShortcut", old);
|
// Log.e("addShortcut", old);
|
||||||
|
|||||||
@@ -207,6 +207,7 @@ public class Configure {
|
|||||||
public static final String GET_STUDENTS_INFO = HTTP_TAG_HEAD_NEW + "Sn/getStudent";
|
public static final String GET_STUDENTS_INFO = HTTP_TAG_HEAD_NEW + "Sn/getStudent";
|
||||||
//通过sn获取信息
|
//通过sn获取信息
|
||||||
public static final String SEND_SCREENSHOT = HTTP_TAG_HEAD_NEW + "Screenshot/addImg";
|
public static final String SEND_SCREENSHOT = HTTP_TAG_HEAD_NEW + "Screenshot/addImg";
|
||||||
|
//上传截图
|
||||||
|
public static final String UPDATE_DEVICEINFO = HTTP_TAG_HEAD_NEW + "Mac/getInfo";
|
||||||
|
//上传设备信息
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,20 +29,25 @@ import android.net.wifi.WifiInfo;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.os.Environment;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
|
import android.os.StatFs;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.format.Formatter;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.WindowManager;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.blankj.utilcode.util.EncryptUtils;
|
|
||||||
import com.blankj.utilcode.util.FileUtils;
|
import com.blankj.utilcode.util.FileUtils;
|
||||||
import com.blankj.utilcode.util.PathUtils;
|
import com.blankj.utilcode.util.PathUtils;
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
@@ -51,10 +56,12 @@ import com.google.zxing.WriterException;
|
|||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
import com.google.zxing.qrcode.QRCodeWriter;
|
import com.google.zxing.qrcode.QRCodeWriter;
|
||||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||||
|
import com.mjsheng.myappstore.BuildConfig;
|
||||||
import com.mjsheng.myappstore.R;
|
import com.mjsheng.myappstore.R;
|
||||||
import com.mjsheng.myappstore.MyApplication;
|
import com.mjsheng.myappstore.MyApplication;
|
||||||
import com.mjsheng.myappstore.comm.CommonDatas;
|
import com.mjsheng.myappstore.comm.CommonDatas;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
@@ -66,6 +73,7 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -74,6 +82,7 @@ import java.util.Collections;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
@@ -901,23 +910,29 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized public static void doMasterClear(Context context) {
|
synchronized public static void doMasterClear(Context context) {
|
||||||
if (getBatteryLevel(context) >= CommonDatas.MIN_POWER) {
|
if (BuildConfig.DEBUG) {
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
ToastUtil.show("收到重置设备推送消息");
|
||||||
Intent intent = new Intent("android.intent.action.FACTORY_RESET");
|
return;
|
||||||
intent.setPackage("android");
|
}
|
||||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||||
intent.putExtra("android.intent.extra.REASON", "MasterClearConfirm");
|
Intent intent = new Intent("android.intent.action.FACTORY_RESET");
|
||||||
intent.putExtra("android.intent.extra.WIPE_EXTERNAL_STORAGE", false);
|
intent.setPackage("android");
|
||||||
intent.putExtra("com.android.internal.intent.extra.WIPE_ESIMS", false);
|
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||||
context.sendBroadcast(intent);
|
intent.putExtra("android.intent.extra.REASON", "MasterClearConfirm");
|
||||||
} else {
|
intent.putExtra("android.intent.extra.WIPE_EXTERNAL_STORAGE", false);
|
||||||
|
intent.putExtra("com.android.internal.intent.extra.WIPE_ESIMS", false);
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
} else {
|
||||||
|
//10.0的不需要最小电量
|
||||||
|
if (getBatteryLevel(context) >= CommonDatas.MIN_POWER) {
|
||||||
Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
|
Intent intent = new Intent("android.intent.action.MASTER_CLEAR");
|
||||||
// intent.setPackage("com.android.settings");
|
// intent.setPackage("com.android.settings");
|
||||||
context.sendBroadcast(intent);
|
context.sendBroadcast(intent);
|
||||||
|
} else {
|
||||||
|
MySQLData.SetBooleanData(context, CommonDatas.IS_RESET, true);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
MySQLData.SetBooleanData(context, CommonDatas.IS_RESET, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized private static int getBatteryLevel(Context mContext) {
|
synchronized private static int getBatteryLevel(Context mContext) {
|
||||||
@@ -1034,7 +1049,7 @@ public class Utils {
|
|||||||
* 屏幕截图
|
* 屏幕截图
|
||||||
* 适用于lanucher版
|
* 适用于lanucher版
|
||||||
*/
|
*/
|
||||||
public void shotScreen() {
|
public void shotScreen() {
|
||||||
//adb截图方法
|
//adb截图方法
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1097,5 +1112,242 @@ public class Utils {
|
|||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAndroiodScreenProperty(Context context) {
|
||||||
|
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
DisplayMetrics dm = new DisplayMetrics();
|
||||||
|
wm.getDefaultDisplay().getRealMetrics(dm);
|
||||||
|
int width = dm.widthPixels; // 屏幕宽度(像素)
|
||||||
|
int height = dm.heightPixels; // 屏幕高度(像素)
|
||||||
|
float density = dm.density; // 屏幕密度(0.75 / 1.0 / 1.5)
|
||||||
|
int densityDpi = dm.densityDpi; // 屏幕密度dpi(120 / 160 / 240)
|
||||||
|
// 屏幕宽度算法:屏幕宽度(像素)/屏幕密度
|
||||||
|
int screenWidth = (int) (width / density); // 屏幕宽度(dp)
|
||||||
|
int screenHeight = (int) (height / density);// 屏幕高度(dp)
|
||||||
|
|
||||||
|
|
||||||
|
Log.e("h_bl", "屏幕宽度(像素):" + width);
|
||||||
|
Log.e("h_bl", "屏幕高度(像素):" + height);
|
||||||
|
Log.e("h_bl", "屏幕密度(0.75 / 1.0 / 1.5):" + density);
|
||||||
|
Log.e("h_bl", "屏幕密度dpi(120 / 160 / 240):" + densityDpi);
|
||||||
|
Log.e("h_bl", "屏幕宽度(dp):" + screenWidth);
|
||||||
|
Log.e("h_bl", "屏幕高度(dp):" + screenHeight);
|
||||||
|
return screenWidth + "×" + screenHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getIMEI(Context context) {
|
||||||
|
String IMEI = "unknow";
|
||||||
|
String IMEI1, IMEI2, IMEI3;
|
||||||
|
//获取手机设备号
|
||||||
|
TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
//8.0及以后版本获取
|
||||||
|
// if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
|
// IMEI1 = TelephonyMgr.getDeviceId();
|
||||||
|
// } else
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
|
// try {
|
||||||
|
// Method method = TelephonyMgr.getClass().getMethod("getImei");
|
||||||
|
// IMEI2 = (String) method.invoke(TelephonyMgr);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// Log.e("getIMEI", e.getMessage());
|
||||||
|
// }
|
||||||
|
// } else {//9.0到10.0获取
|
||||||
|
IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
}
|
||||||
|
Log.e("IMEI:", "IMEI: " + IMEI);
|
||||||
|
return IMEI.toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMachine(Context context) {
|
||||||
|
String device = Build.MODEL;//机型
|
||||||
|
String imei = getIMEI(context);
|
||||||
|
String system_version = Build.VERSION.RELEASE;
|
||||||
|
String firmware_version = getProperty("ro.build.display.id", "获取失败");
|
||||||
|
String rom = getProperty("ro.custom.build.version", "获取失败");
|
||||||
|
String screen_rate = getAndroiodScreenProperty(context);
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("device", device);
|
||||||
|
jsonObject.put("imei", imei);
|
||||||
|
jsonObject.put("system_version", system_version);
|
||||||
|
jsonObject.put("firmware_version", firmware_version);
|
||||||
|
jsonObject.put("rom", rom);
|
||||||
|
jsonObject.put("screen_rate", screen_rate);
|
||||||
|
return jsonObject.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getHardware(Context context) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
String electric = getBattery(context) + "%";
|
||||||
|
String charging = String.valueOf(getIsCharging(context));
|
||||||
|
String memory = Formatter.formatFileSize(context, getAvailMemory(context)) + "\t 已用" + "/" + "共" + Formatter.formatFileSize(context, getTotalMemory(context));
|
||||||
|
String storage = getRemnantSize(context) + "/" + getDataTotalSize(context);
|
||||||
|
// String CPU = ;
|
||||||
|
return jsonObject.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
public static int getBattery(Context context) {
|
||||||
|
try {
|
||||||
|
BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||||
|
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("getBattery", "getBattery" + e.getMessage());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBatteryPercentage(Context context) {
|
||||||
|
|
||||||
|
IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||||
|
Intent batteryStatus = context.registerReceiver(null, iFilter);
|
||||||
|
|
||||||
|
int level = batteryStatus != null ? batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1) : -1;
|
||||||
|
int scale = batteryStatus != null ? batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1) : -1;
|
||||||
|
|
||||||
|
float batteryPct = level / (float) scale;
|
||||||
|
|
||||||
|
return (int) (batteryPct * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getIsCharging(Context context) {
|
||||||
|
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
|
||||||
|
Intent batteryStatus = context.registerReceiver(null, ifilter);
|
||||||
|
// Are we charging / charged?
|
||||||
|
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||||
|
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||||
|
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||||
|
|
||||||
|
// How are we charging?
|
||||||
|
// int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||||
|
// boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
|
||||||
|
// boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
|
||||||
|
if (isCharging) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述:获取可用内存.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static long getAvailMemory(Context context) {
|
||||||
|
// 获取android当前可用内存大小
|
||||||
|
ActivityManager activityManager = (ActivityManager) context
|
||||||
|
.getSystemService(Context.ACTIVITY_SERVICE);
|
||||||
|
ActivityManager.MemoryInfo memoryInfo = new ActivityManager.MemoryInfo();
|
||||||
|
activityManager.getMemoryInfo(memoryInfo);
|
||||||
|
// 当前系统可用内存 ,将获得的内存大小规格化
|
||||||
|
|
||||||
|
return memoryInfo.availMem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 描述:总内存.
|
||||||
|
*
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static long getTotalMemory(Context context) {
|
||||||
|
// 系统内存信息文件
|
||||||
|
String file = "/proc/meminfo";
|
||||||
|
String memInfo;
|
||||||
|
String[] strs;
|
||||||
|
long memory = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileReader fileReader = new FileReader(file);
|
||||||
|
BufferedReader bufferedReader = new BufferedReader(fileReader, 8192);
|
||||||
|
// 读取meminfo第一行,系统内存大小
|
||||||
|
memInfo = bufferedReader.readLine();
|
||||||
|
strs = memInfo.split("\\s+");
|
||||||
|
// for (String str : strs) {
|
||||||
|
// L.d(AppUtil.class, str + "\t");
|
||||||
|
// }
|
||||||
|
// 获得系统总内存,单位KB
|
||||||
|
memory = Integer.valueOf(strs[1]).intValue();
|
||||||
|
bufferedReader.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// Byte转位KB或MB
|
||||||
|
return memory * 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String formatFileSize(long fileS) {
|
||||||
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
|
String fileSizeString = "";
|
||||||
|
String wrongSize = "0B";
|
||||||
|
if (fileS == 0) {
|
||||||
|
return wrongSize;
|
||||||
|
}
|
||||||
|
if (fileS < 1024) {
|
||||||
|
fileSizeString = df.format((double) fileS) + "B";
|
||||||
|
} else if (fileS < 1048576) {
|
||||||
|
fileSizeString = df.format((double) fileS / 1024) + "KB";
|
||||||
|
} else if (fileS < 1073741824) {
|
||||||
|
fileSizeString = df.format((double) fileS / 1048576) + "MB";
|
||||||
|
} else {
|
||||||
|
fileSizeString = df.format((double) fileS / 1073741824) + "GB";
|
||||||
|
}
|
||||||
|
return fileSizeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void queryStorage() {
|
||||||
|
StatFs statFs = new StatFs(Environment.getExternalStorageDirectory().getPath());
|
||||||
|
|
||||||
|
//存储块总数量
|
||||||
|
long blockCount = statFs.getBlockCount();
|
||||||
|
//块大小
|
||||||
|
long blockSize = statFs.getBlockSize();
|
||||||
|
//可用块数量
|
||||||
|
long availableCount = statFs.getAvailableBlocks();
|
||||||
|
//剩余块数量,注:这个包含保留块(including reserved blocks)即应用无法使用的空间
|
||||||
|
long freeBlocks = statFs.getFreeBlocks();
|
||||||
|
//这两个方法是直接输出总内存和可用空间,也有getFreeBytes
|
||||||
|
//API level 18(JELLY_BEAN_MR2)引入
|
||||||
|
long totalSize = statFs.getTotalBytes();
|
||||||
|
long availableSize = statFs.getAvailableBytes();
|
||||||
|
|
||||||
|
Log.e("statfs", "total = " + getUnit(totalSize));
|
||||||
|
Log.e("statfs", "availableSize = " + getUnit(availableSize));
|
||||||
|
|
||||||
|
//这里可以看出 available 是小于 free ,free 包括保留块。
|
||||||
|
Log.e("statfs", "total = " + getUnit(blockSize * blockCount));
|
||||||
|
Log.e("statfs", "available = " + getUnit(blockSize * availableCount));
|
||||||
|
Log.e("statfs", "free = " + getUnit(blockSize * freeBlocks));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String[] units = {"B", "KB", "MB", "GB", "TB"};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位转换
|
||||||
|
*/
|
||||||
|
private static String getUnit(float size) {
|
||||||
|
int index = 0;
|
||||||
|
while (size > 1024 && index < 4) {
|
||||||
|
size = size / 1024;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
return String.format(Locale.getDefault(), " %.2f %s", size, units[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getDataTotalSize(Context context) {
|
||||||
|
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||||
|
long blockSize = sf.getBlockSize();
|
||||||
|
long totalBlocks = sf.getBlockCount();
|
||||||
|
return Formatter.formatFileSize(context, blockSize * totalBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getRemnantSize(Context context) {
|
||||||
|
StatFs sf = new StatFs(context.getCacheDir().getAbsolutePath());
|
||||||
|
long availableSize = sf.getAvailableBytes();
|
||||||
|
return Formatter.formatFileSize(context, availableSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user