update:2020.03.11 新增启动时写入能安装的包名
This commit is contained in:
@@ -15,8 +15,8 @@ android {
|
||||
applicationId "com.info.sn"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 28
|
||||
versionCode 10
|
||||
versionName "1.1.0"
|
||||
versionCode 13
|
||||
versionName "1.1.3"
|
||||
multiDexEnabled true
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
|
||||
@@ -19,4 +19,6 @@ public class UrlPath {
|
||||
//获取当前最顶层应用和电量
|
||||
public final static String SEND_DRIVE_STATE = HOMEPATHRUL + "Online/online";
|
||||
|
||||
public final static String GET_ALL_PACKAGENAME = HOMEPATHRUL + "/App/allPackage";
|
||||
//获取所有应用包名
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class HTTPInterface {
|
||||
@@ -233,6 +234,43 @@ public class HTTPInterface {
|
||||
}
|
||||
});
|
||||
}
|
||||
synchronized public static void getAllAppPackageName(final Handler handler) {
|
||||
OkGo.<String>get(UrlPath.GET_ALL_PACKAGENAME).execute(new StringCallback() {
|
||||
@Override
|
||||
public void onSuccess(Response<String> response) {
|
||||
String s = response.body();
|
||||
try {
|
||||
JSONObject body = JSON.parseObject(s);
|
||||
int code = body.getInteger("code");
|
||||
String msg = body.getString("msg");
|
||||
String data = body.getString("data");
|
||||
if (code == 200) {
|
||||
List<JSONObject> jsonArray = JSON.parseArray(data, JSONObject.class);
|
||||
String packageList = "";
|
||||
for (JSONObject jsonObject : jsonArray) {
|
||||
packageList += jsonObject.getString("app_package") + ",";
|
||||
}
|
||||
if (!packageList.isEmpty()) {
|
||||
Log.e("fht", packageList);
|
||||
Message message = new Message();
|
||||
message.what = 201;
|
||||
message.obj = packageList;
|
||||
handler.sendMessage(message);
|
||||
} else {
|
||||
handler.sendEmptyMessage(202);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Response<String> response) {
|
||||
super.onError(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
@@ -48,6 +49,8 @@ public class MyDownloadService extends Service {
|
||||
startService(new Intent(this, StepService.class));
|
||||
startService(new Intent(this, GuardService.class));
|
||||
CheckUpdate();
|
||||
HTTPInterface.getAllAppPackageName(handler);
|
||||
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
@@ -89,6 +92,15 @@ public class MyDownloadService extends Service {
|
||||
Bundle bundle = (Bundle) msg.obj;
|
||||
getFile(bundle);
|
||||
break;
|
||||
case 201:
|
||||
String apppackage = (String) msg.obj;
|
||||
Log.e("fht", Settings.System.getString(getContentResolver(), "qch_app_forbid") + "?");
|
||||
if (Settings.System.putString(getContentResolver(), "qch_app_forbid", apppackage)) {
|
||||
Log.e("fht", "app package write successful");
|
||||
}
|
||||
break;
|
||||
case 202:
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user