version:
update:2020.09.04 fix:截图上传,应用信息更新 add:
This commit is contained in:
@@ -99,7 +99,7 @@ android {
|
|||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.debug
|
||||||
/*********************************极光推送end************************************/
|
/*********************************极光推送end************************************/
|
||||||
buildConfigField "String", "ROOT_URL", '"http://name.uiuios.com/api/"'
|
buildConfigField "String", "ROOT_URL", '"http://name.uiuios.com/api/"'
|
||||||
buildConfigField "String", "WebsocketURL", '"ws://39.98.59.202:2345"'
|
buildConfigField "String", "WebsocketURL", '"ws://39.108.116.195:2345"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
|||||||
@@ -113,9 +113,8 @@ import rx.functions.Action1;
|
|||||||
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET;
|
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.ACTION_SET;
|
||||||
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.TagAliasBean;
|
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.TagAliasBean;
|
||||||
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence;
|
import static com.mjsheng.myappstore.jpush.TagAliasOperatorHelper.sequence;
|
||||||
import static com.mjsheng.myappstore.utils.Utils.shotScreen;
|
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private ToastCallback callback;
|
private ToastCallback callback;
|
||||||
private long mPreClickTime;
|
private long mPreClickTime;
|
||||||
@@ -593,16 +592,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
tv_batch.setVisibility(View.VISIBLE);
|
tv_batch.setVisibility(View.VISIBLE);
|
||||||
tv_batch.setText(info.getBatch());
|
tv_batch.setText(info.getBatch());
|
||||||
}
|
}
|
||||||
try {
|
if (info.getClasses().equals("")) {
|
||||||
if (info.getClasses().equals("")) {
|
layout_class.setVisibility(View.GONE);
|
||||||
layout_class.setVisibility(View.GONE);
|
tv_class.setText("暂无信息");
|
||||||
tv_class.setText("暂无信息");
|
} else {
|
||||||
} else {
|
layout_class.setVisibility(View.VISIBLE);
|
||||||
layout_class.setVisibility(View.VISIBLE);
|
tv_class.setText(info.getClasses());
|
||||||
tv_class.setText(info.getClasses());
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e("fht", e.getMessage());
|
|
||||||
}
|
}
|
||||||
if (info.getSno().equals("")) {
|
if (info.getSno().equals("")) {
|
||||||
layout_number.setVisibility(View.GONE);
|
layout_number.setVisibility(View.GONE);
|
||||||
@@ -885,7 +880,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
uploadAppInfo.setId(i);
|
uploadAppInfo.setId(i);
|
||||||
String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime);
|
String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime);
|
||||||
uploadAppInfo.setInstall_time(firstInstallTime);
|
uploadAppInfo.setInstall_time(firstInstallTime);
|
||||||
|
uploadAppInfo.setVersionCode(String.valueOf(packageInfo.versionCode));
|
||||||
// Log.e("mjsheng", "------------------" + uploadAppInfo);
|
// Log.e("mjsheng", "------------------" + uploadAppInfo);
|
||||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class UploadAppInfo {
|
|||||||
private String package_name;
|
private String package_name;
|
||||||
private String app_name;
|
private String app_name;
|
||||||
private String install_time;
|
private String install_time;
|
||||||
|
private String versionCode;
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
public String getPackage_name() {
|
public String getPackage_name() {
|
||||||
@@ -45,6 +46,14 @@ public class UploadAppInfo {
|
|||||||
this.install_time = install_time;
|
this.install_time = install_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVersionCode() {
|
||||||
|
return versionCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersionCode(String versionCode) {
|
||||||
|
this.versionCode = versionCode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "UploadAppInfo{" +
|
return "UploadAppInfo{" +
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.content.pm.PackageManager;
|
|||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
import android.provider.Browser;
|
import android.provider.Browser;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -22,6 +23,8 @@ import com.blankj.utilcode.util.AppUtils;
|
|||||||
import com.blankj.utilcode.util.EncryptUtils;
|
import com.blankj.utilcode.util.EncryptUtils;
|
||||||
import com.blankj.utilcode.util.LogUtils;
|
import com.blankj.utilcode.util.LogUtils;
|
||||||
import com.blankj.utilcode.util.PathUtils;
|
import com.blankj.utilcode.util.PathUtils;
|
||||||
|
import com.lzy.okgo.OkGo;
|
||||||
|
import com.lzy.okgo.callback.StringCallback;
|
||||||
import com.mjsheng.myappstore.BuildConfig;
|
import com.mjsheng.myappstore.BuildConfig;
|
||||||
import com.mjsheng.myappstore.MyApplication;
|
import com.mjsheng.myappstore.MyApplication;
|
||||||
import com.mjsheng.myappstore.activity.MainActivity;
|
import com.mjsheng.myappstore.activity.MainActivity;
|
||||||
@@ -33,6 +36,7 @@ import com.mjsheng.myappstore.network.Network;
|
|||||||
import com.mjsheng.myappstore.network.api.ForceDownloadApi;
|
import com.mjsheng.myappstore.network.api.ForceDownloadApi;
|
||||||
import com.mjsheng.myappstore.server.InitJpushServer;
|
import com.mjsheng.myappstore.server.InitJpushServer;
|
||||||
import com.mjsheng.myappstore.utils.ApkUtils;
|
import com.mjsheng.myappstore.utils.ApkUtils;
|
||||||
|
import com.mjsheng.myappstore.utils.CmdUtil;
|
||||||
import com.mjsheng.myappstore.utils.Configure;
|
import com.mjsheng.myappstore.utils.Configure;
|
||||||
import com.mjsheng.myappstore.utils.MySQLData;
|
import com.mjsheng.myappstore.utils.MySQLData;
|
||||||
import com.mjsheng.myappstore.utils.SaveListUtils;
|
import com.mjsheng.myappstore.utils.SaveListUtils;
|
||||||
@@ -43,15 +47,21 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
import cn.jpush.android.api.JPushInterface;
|
||||||
|
import io.reactivex.Observable;
|
||||||
|
import io.reactivex.ObservableEmitter;
|
||||||
|
import io.reactivex.ObservableOnSubscribe;
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import okhttp3.Call;
|
||||||
|
import okhttp3.Response;
|
||||||
import okhttp3.ResponseBody;
|
import okhttp3.ResponseBody;
|
||||||
|
|
||||||
public class MyJPushReceiver extends BroadcastReceiver {
|
public class MyJPushReceiver extends BroadcastReceiver {
|
||||||
@@ -267,6 +277,15 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
getAppLimitApi();
|
getAppLimitApi();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SN_SCREENSHOT:
|
||||||
|
screenshot(extras);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DEVICES_REBOOT:
|
||||||
|
Utils.rebootDevices(mContext);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1068,4 +1087,84 @@ public class MyJPushReceiver extends BroadcastReceiver {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void screenshot(String s) {
|
||||||
|
try {
|
||||||
|
JSONObject jSONObject = new JSONObject(s);
|
||||||
|
long createTime = jSONObject.getLong("createTime");
|
||||||
|
if (createTime != 0) {
|
||||||
|
Log.e("createTime", String.valueOf(createTime));
|
||||||
|
doscreenshot(createTime);
|
||||||
|
}
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doscreenshot(final long time) {
|
||||||
|
Observable.create(new ObservableOnSubscribe<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
|
||||||
|
String filepath = mContext.getExternalFilesDir("screenshot").getAbsolutePath();
|
||||||
|
int n = CmdUtil.execute("screencap -p " + filepath + File.separator + time + ".png").code;
|
||||||
|
e.onNext(n);
|
||||||
|
}
|
||||||
|
}).subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<Integer>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(Disposable d) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(Integer integer) {
|
||||||
|
if (integer == 0) {
|
||||||
|
uplaodImage(time);
|
||||||
|
} else {
|
||||||
|
Log.e("doscreenshot", "截图失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e("doscreenshot", "Throwable=" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uplaodImage(long time) {
|
||||||
|
String filepath = mContext.getExternalFilesDir("screenshot").getAbsolutePath();
|
||||||
|
|
||||||
|
File file = new File(filepath + File.separator + time + ".png");
|
||||||
|
if (!file.exists()) {
|
||||||
|
Log.e("uplaodImage", "File does not exists");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OkGo.post(Configure.SEND_SCREENSHOT)
|
||||||
|
.params("sn", Utils.getSerial())
|
||||||
|
.params("createtime", time)
|
||||||
|
.params("file", file)
|
||||||
|
.execute(new StringCallback() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String s, Call call, Response response) {
|
||||||
|
com.alibaba.fastjson.JSONObject object = JSON.parseObject(s);
|
||||||
|
int code = object.getInteger("code");
|
||||||
|
String msg = object.getString("msg");
|
||||||
|
Log.e("uplaodImage", "code:" + code + "," + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Call call, Response response, Exception e) {
|
||||||
|
super.onError(call, response, e);
|
||||||
|
Log.e("uplaodImage", "e=" + e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class NewAppReceiver extends BroadcastReceiver {
|
|||||||
uploadAppInfo.setId(i);
|
uploadAppInfo.setId(i);
|
||||||
String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime);
|
String firstInstallTime = Utils.transferLongToDate(packageInfo.firstInstallTime);
|
||||||
uploadAppInfo.setInstall_time(firstInstallTime);
|
uploadAppInfo.setInstall_time(firstInstallTime);
|
||||||
|
uploadAppInfo.setVersionCode(String.valueOf(packageInfo.versionCode));
|
||||||
|
|
||||||
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
if ((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -205,5 +205,8 @@ public class Configure {
|
|||||||
public final static String NET_AND_LAUNCH_API = HTTP_TAG_HEAD_NEW + "automatic/get";
|
public final static String NET_AND_LAUNCH_API = HTTP_TAG_HEAD_NEW + "automatic/get";
|
||||||
//获取应用升级自启
|
//获取应用升级自启
|
||||||
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获取信息
|
||||||
|
public static final String SEND_SCREENSHOT = HTTP_TAG_HEAD_NEW + "Screenshot/addImg";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
|
||||||
@@ -1033,7 +1034,7 @@ public class Utils {
|
|||||||
* 屏幕截图
|
* 屏幕截图
|
||||||
* 适用于lanucher版
|
* 适用于lanucher版
|
||||||
*/
|
*/
|
||||||
public static void shotScreen() {
|
public void shotScreen() {
|
||||||
//adb截图方法
|
//adb截图方法
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1041,7 +1042,7 @@ public class Utils {
|
|||||||
Log.e("whh0914", "开始屏幕截图...");
|
Log.e("whh0914", "开始屏幕截图...");
|
||||||
String filepath = "/sdcard/screenShot.png";
|
String filepath = "/sdcard/screenShot.png";
|
||||||
try {
|
try {
|
||||||
execRootCmdSilent("screencap -p " + filepath);
|
CmdUtil.execute("screencap -p " + filepath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("whh0914", "屏幕截图出现异常:" + e.toString());
|
Log.e("whh0914", "屏幕截图出现异常:" + e.toString());
|
||||||
}
|
}
|
||||||
@@ -1049,6 +1050,7 @@ public class Utils {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行命令但不关注结果输出
|
* 执行命令但不关注结果输出
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user