This commit is contained in:
fht
2020-02-22 19:13:29 +08:00
parent a781113b30
commit 503d4146f6
11 changed files with 163 additions and 114 deletions

View File

@@ -16,8 +16,8 @@ android {
targetSdkVersion 26 targetSdkVersion 26
// versionCode 85 // versionCode 85
// versionName "2.0.4.6"//正式jiaoguanyi.com // versionName "2.0.4.6"//正式jiaoguanyi.com
versionCode 98 versionCode 105
versionName "2.6.0"//测试jiaoguanyi.cn versionName "2.6.7"//测试jiaoguanyi.cn
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
packagingOptions { packagingOptions {

View File

@@ -306,66 +306,66 @@ public class MyApplication extends MultiDexApplication implements Thread.Uncaugh
NetStateChangeReceiver.unregisterReceiver(this); NetStateChangeReceiver.unregisterReceiver(this);
} }
static List<FileData> fileList = new ArrayList<>(); // static List<FileData> fileList = new ArrayList<>();
//
//
static String packageName = ""; // static String packageName = "";
//
public void setInstallIngPackageName(String packageNames) { // public void setInstallIngPackageName(String packageNames) {
packageName = packageNames; // packageName = packageNames;
Log.e("fht", "正在安装:" + packageNames); // Log.e("fht", "正在安装:" + packageNames);
} // }
//
public String getInstallIngPackageName() { // public String getInstallIngPackageName() {
return packageName; // return packageName;
} // }
//
public void addFileData(FileData data) { // public void addFileData(FileData data) {
fileList.add(data); // fileList.add(data);
updateList(); // updateList();
} // }
//
public void removeDate(String packageName) { // public void removeDate(String packageName) {
if (fileList != null && fileList.size() > 0) { // if (fileList != null && fileList.size() > 0) {
for (FileData data : fileList) { // for (FileData data : fileList) {
if (data.getPackageName().equals(packageName)) { // if (data.getPackageName().equals(packageName)) {
fileList.remove(data); // fileList.remove(data);
break; // break;
} else { // } else {
Log.e("fht", "not found object"); // Log.e("fht", "not found object");
} // }
} // }
} // }
setInstallIngPackageName(""); // setInstallIngPackageName("");
if (fileList.size() > 0) { // if (fileList.size() > 0) {
updateList(); // updateList();
} else { // } else {
Log.e("fht", "fileList为空"); // Log.e("fht", "fileList为空");
setInstallIngPackageName(""); // setInstallIngPackageName("");
} // }
//
} // }
//
public void updateList() { // public void updateList() {
if (getInstallIngPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), packageName)) { // if (getInstallIngPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), packageName)) {
if (fileList != null && fileList.size() > 0) { // if (fileList != null && fileList.size() > 0) {
if (!fileList.get(0).getPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), fileList.get(0).getPackageName())) { // if (!fileList.get(0).getPackageName().equals("") || ApkUtils.isAvailable(getAppContext(), fileList.get(0).getPackageName())) {
String s = packageName; // String s = packageName;
ApkUtils.installApp(this, fileList.get(0).getFilePath()); // ApkUtils.installApp(this, fileList.get(0).getFilePath());
setInstallIngPackageName(fileList.get(0).getPackageName()); // setInstallIngPackageName(fileList.get(0).getPackageName());
} else { // } else {
removeDate(fileList.get(0).getPackageName()); // removeDate(fileList.get(0).getPackageName());
Log.e("fht", "已安装"); // Log.e("fht", "已安装");
setInstallIngPackageName(""); // setInstallIngPackageName("");
} // }
} else { // } else {
Log.e("fht", "任务为空"); // Log.e("fht", "任务为空");
} // }
} else { // } else {
Log.e("fht", "安装中:" + packageName); // Log.e("fht", "安装中:" + packageName);
//
} // }
} // }
} }

View File

@@ -160,7 +160,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
Aria.download(this).removeAllTask(false); // Aria.download(this).removeAllTask(false);
callback = new ToastCallback(this); callback = new ToastCallback(this);
initView(); initView();
@@ -173,7 +173,19 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
sendBroadcast(allIntent); sendBroadcast(allIntent);
} }
//获取教管易版本号
synchronized private String getAPPVersionName() {
PackageManager pm = getPackageManager();
String versionName;
try {
PackageInfo packageInfo = pm.getPackageInfo("com.jiaoguanyi.store", 0);
versionName = packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
versionName = "0";
}
return versionName;
}
synchronized public void sendMACaddress() { synchronized public void sendMACaddress() {
String rid = JPushInterface.getRegistrationID(getApplicationContext()); String rid = JPushInterface.getRegistrationID(getApplicationContext());
@@ -181,8 +193,9 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
.params("sn", Utils.getSerial()) .params("sn", Utils.getSerial())
.params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress()) .params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress())
.params("jpush_id", rid) .params("jpush_id", rid)
.params("appstore_version", Utils.getProperty("ro.custom.build.version", "获取失败")) .params("devices_version", Utils.getProperty("ro.custom.build.version", "获取失败"))
.params("store_version", BuildConfig.VERSION_NAME) .params("appstore_version", BuildConfig.VERSION_NAME)//设备信息版本号
.params("store_version", getAPPVersionName())//管教易版本号
.execute(new StringCallback() { .execute(new StringCallback() {
@Override @Override
public void onSuccess(String s, Call call, Response response) { public void onSuccess(String s, Call call, Response response) {
@@ -404,7 +417,7 @@ public class MainActivity extends AppCompatActivity implements NetStateChangeObs
getSystemSetting();//设置系统管控 getSystemSetting();//设置系统管控
getNetAndLaunchSetting();//联网管控 getNetAndLaunchSetting();//联网管控
Aria.download(this).resumeAllTask(); Aria.download(this).resumeAllTask();
getForceDownload();//强制下载apk // getForceDownload();//强制下载apk
resetDevice();//恢复出厂设置 resetDevice();//恢复出厂设置
checkUpdate();//更新app checkUpdate();//更新app
// fromNetToUpdate(); // fromNetToUpdate();

View File

@@ -7,6 +7,7 @@ import android.util.Log;
import com.mjsheng.myappstore.server.GuardService; import com.mjsheng.myappstore.server.GuardService;
import com.mjsheng.myappstore.server.InitJpushServer; import com.mjsheng.myappstore.server.InitJpushServer;
import com.mjsheng.myappstore.server.MyDownloadService;
import com.mjsheng.myappstore.server.StepService; import com.mjsheng.myappstore.server.StepService;
public class BootReceiver extends BroadcastReceiver { public class BootReceiver extends BroadcastReceiver {
@@ -16,10 +17,27 @@ public class BootReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Log.e("BootReceiver", intent.getAction()); Log.e("BootReceiver", intent.getAction());
if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) {
Intent i = new Intent(context, InitJpushServer.class); context.startService(new Intent(context, InitJpushServer.class));
context.startService(i);
context.startService(new Intent(context, StepService.class)); context.startService(new Intent(context, StepService.class));
context.startService(new Intent(context, GuardService.class)); context.startService(new Intent(context, GuardService.class));
context.startService(new Intent(context, MyDownloadService.class));
} else if (
intent.getAction().equals("android.intent.action.BATTERY_CHANGED")
|| intent.getAction().equals("android.intent.action.BATTERY_CHANGED")
|| intent.getAction().equals("android.intent.action.BATTERY_LOW")
|| intent.getAction().equals("android.intent.action.BATTERY_OKAY")
|| intent.getAction().equals("android.intent.action.ACTION_POWER_CONNECTED")
|| intent.getAction().equals("android.intent.action.DATE_CHANGED")
|| intent.getAction().equals("android.intent.action.TIME_TICK")
|| intent.getAction().equals("android.intent.action.USER_PRESENT")
|| intent.getAction().equals("android.intent.action.ACTION_SCREEN_ON")
|| intent.getAction().equals("android.intent.action.ACTION_SCREEN_OFF")
) {
Log.e("fht", "BootReceiver MSG" + intent.getAction());
context.startService(new Intent(context, InitJpushServer.class));
context.startService(new Intent(context, StepService.class));
context.startService(new Intent(context, GuardService.class));
context.startService(new Intent(context, MyDownloadService.class));
} }
} }

View File

@@ -46,20 +46,20 @@ public class NewAppReceiver extends BroadcastReceiver {
allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION); allIntent.setAction(Utils.DOWNLOAD_ALLTASK_ACTION);
context.sendBroadcast(allIntent); context.sendBroadcast(allIntent);
String packageName = intent.getDataString().replace("package:", ""); String packageName = intent.getDataString().replace("package:", "");
MyApplication.getInstance().removeDate(packageName); // MyApplication.getInstance().removeDate(packageName);
Log.e(TAG, "安装了:" + packageName + "包名的程序"); Log.e(TAG, "安装了:" + packageName + "包名的程序");
Log.e("fht", "安装了:" + packageName + "包名的程序"); Log.e("fht", "安装了:" + packageName + "包名的程序");
OkGo.post(Configure.HTTP_TAG_DOWNLOAD_URL) // OkGo.post(Configure.HTTP_TAG_DOWNLOAD_URL)
.params("key", Configure.HTTP_KEY) // .params("key", Configure.HTTP_KEY)
.params("sn", Utils.getSerial()) // .params("sn", Utils.getSerial())
.params("package", packageName) // .params("package", packageName)
.tag(this) // .tag(this)
.execute(new StringCallback() { // .execute(new StringCallback() {
@Override // @Override
public void onSuccess(String s, Call call, Response response) { // public void onSuccess(String s, Call call, Response response) {
//
} // }
}); // });
SaveListUtils.getDownLoadList().remove(packageName);//移除下载列表 SaveListUtils.getDownLoadList().remove(packageName);//移除下载列表
// ToastTool.show("安装成功"); // ToastTool.show("安装成功");
if (!packageName.equals(Utils.YOUNGSYSTEM_APP_TONGBU) && !packageName.equals(context.getPackageName())) { if (!packageName.equals(Utils.YOUNGSYSTEM_APP_TONGBU) && !packageName.equals(context.getPackageName())) {

View File

@@ -83,14 +83,14 @@ public class GuardService extends Service {
//在这里处理任务执行中的状态,如进度进度条的刷新 //在这里处理任务执行中的状态,如进度进度条的刷新
@Download.onTaskRunning @Download.onTaskRunning
protected void running(com.arialyy.aria.core.download.DownloadTask task) { protected void running(com.arialyy.aria.core.download.DownloadTask task) {
Log.e("mjsheng", "正在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField()); Log.e("info", "正在下载=--------------::" + task.getState() + "-------" + task.getPercent() + "-------" + task.getExtendField());
ToastUtils.showShort("正在下载=--------------::" + task.getExtendField() + "-------" + task.getPercent()); ToastUtils.showShort("正在下载=--------------::" + task.getExtendField() + "-------" + task.getPercent());
} }
@Download.onTaskComplete @Download.onTaskComplete
void taskComplete(com.arialyy.aria.core.download.DownloadTask task) { void taskComplete(com.arialyy.aria.core.download.DownloadTask task) {
//在这里处理任务完成的状态 //在这里处理任务完成的状态
String filepath = task.getDownloadPath(); final String filepath = task.getDownloadPath();
final String packageName = task.getExtendField(); final String packageName = task.getExtendField();
Log.e("mjsheng", "downloadPath::" + filepath); Log.e("mjsheng", "downloadPath::" + filepath);
Log.e("mjsheng", "extendField::" + packageName); Log.e("mjsheng", "extendField::" + packageName);
@@ -100,7 +100,12 @@ public class GuardService extends Service {
s1 = s + "," + packageName; s1 = s + "," + packageName;
Settings.System.putString(getContentResolver(), "qch_app_forbid", s1); Settings.System.putString(getContentResolver(), "qch_app_forbid", s1);
} }
new Thread(new Runnable() {
@Override
public void run() {
ApkUtils.installApp(GuardService.this, filepath); ApkUtils.installApp(GuardService.this, filepath);
}
}).start();
} }
} }

View File

@@ -93,6 +93,7 @@ public class InitJpushServer extends Service {
return super.onStartCommand(intent, flags, startId); return super.onStartCommand(intent, flags, startId);
} }
private void setJpushTags() { private void setJpushTags() {
OkGo.get(Configure.GET_DEVICES_TAGS) OkGo.get(Configure.GET_DEVICES_TAGS)
.params("sn", Utils.getSerial()) .params("sn", Utils.getSerial())
@@ -652,6 +653,20 @@ public class InitJpushServer extends Service {
}); });
} }
//获取教管易版本号
synchronized private String getAPPVersionName() {
PackageManager pm = getPackageManager();
String versionName;
try {
PackageInfo packageInfo = pm.getPackageInfo("com.jiaoguanyi.store", 0);
versionName = packageInfo.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
versionName = "0";
}
return versionName;
}
synchronized public void sendMACaddress() { synchronized public void sendMACaddress() {
String rid = JPushInterface.getRegistrationID(getApplicationContext()); String rid = JPushInterface.getRegistrationID(getApplicationContext());
@@ -659,8 +674,9 @@ public class InitJpushServer extends Service {
.params("sn", Utils.getSerial()) .params("sn", Utils.getSerial())
.params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress()) .params("mac", com.blankj.utilcode.util.DeviceUtils.getMacAddress())
.params("jpush_id", rid) .params("jpush_id", rid)
.params("appstore_version", Utils.getProperty("ro.custom.build.version","获取失败")) .params("devices_version", Utils.getProperty("ro.custom.build.version", "获取失败"))
.params("store_version", BuildConfig.VERSION_NAME) .params("appstore_version", BuildConfig.VERSION_NAME)//设备信息版本号
.params("store_version", getAPPVersionName())//管教易版本号
.execute(new StringCallback() { .execute(new StringCallback() {
@Override @Override
public void onSuccess(String s, Call call, Response response) { public void onSuccess(String s, Call call, Response response) {
@@ -714,7 +730,7 @@ public class InitJpushServer extends Service {
getDeselectBrowerID(); getDeselectBrowerID();
getNetAndLaunchSetting(); getNetAndLaunchSetting();
Aria.download(this).resumeAllTask(); Aria.download(this).resumeAllTask();
getForceDownload(); // getForceDownload();
getSystemSetting();//从后台获取功能状态 getSystemSetting();//从后台获取功能状态
resetDevice(); resetDevice();
checkUpdate(); checkUpdate();

View File

@@ -67,17 +67,17 @@ public class StepService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
// startForeground(1, new Notification()); // startForeground(1, new Notification());
// 绑定建立链接 // 绑定建立链接
try { // try {
final String filePath = intent.getStringExtra("filePath"); // final String filePath = intent.getStringExtra("filePath");
final String packageName = intent.getStringExtra("packageName"); // final String packageName = intent.getStringExtra("packageName");
Log.e("fht", filePath); // Log.e("fht", filePath);
Log.e("fht", packageName); // Log.e("fht", packageName);
FileData fileData = new FileData(filePath, packageName); // FileData fileData = new FileData(filePath, packageName);
MyApplication.getInstance().addFileData(fileData); // MyApplication.getInstance().addFileData(fileData);
//
} catch (Exception e) { // } catch (Exception e) {
Log.e("fht", e.getMessage()); // Log.e("fht", e.getMessage());
} // }
bindService(new Intent(this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT); bindService(new Intent(this, GuardService.class), mServiceConnection, Context.BIND_IMPORTANT);
return START_STICKY; return START_STICKY;

View File

@@ -92,11 +92,12 @@
android:id="@+id/version" android:id="@+id/version"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="60dp" android:layout_marginTop="80dp"
android:text="版本:"
android:text="版本:"
android:textColor="#8c8b8b" android:textColor="#8c8b8b"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@@ -4,9 +4,7 @@ buildscript {
repositories { repositories {
google() google()
jcenter{ jcenter()
url 'http://jcenter.bintray.com'
}
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.0.1'
@@ -20,9 +18,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter{ jcenter()
url 'http://jcenter.bintray.com'
}
} }
repositories { repositories {
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }

View File

@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle. # Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the # For customization when using a Version Control System, please read the
# header note. # header note.
#Thu Jun 13 17:48:17 CST 2019 #Tue Feb 11 20:46:09 CST 2020
sdk.dir=C\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk sdk.dir=E\:\\1tHDD\\Other\\SDK