1.4.0103 更换图标,G10P 标签MTK11改为G104,G10P标签为G10P
This commit is contained in:
@@ -37,25 +37,13 @@ public class EyeProtectionActivity extends BaseActivity {
|
||||
@Override
|
||||
public void initView() {
|
||||
ButterKnife.bind(this);
|
||||
int nightDisplay = Settings.Secure.getInt(getContentResolver(), Settings.Secure.NIGHT_DISPLAY_ACTIVATED, 0);
|
||||
if (nightDisplay == 1) {
|
||||
toggleButton1.setToggleOn();
|
||||
} else {
|
||||
toggleButton1.setToggleOff();
|
||||
}
|
||||
|
||||
toggleButton1.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.NIGHT_DISPLAY_ACTIVATED, on ? 1 : 0);
|
||||
}
|
||||
});
|
||||
|
||||
int accessibilityDisplay = Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
|
||||
if (accessibilityDisplay == 1) {
|
||||
toggleButton2.setToggleOn();
|
||||
} else {
|
||||
toggleButton2.setToggleOff();
|
||||
}
|
||||
toggleButton2.setOnToggleChanged(new ToggleButton.OnToggleChanged() {
|
||||
@Override
|
||||
public void onToggle(boolean on) {
|
||||
@@ -96,4 +84,22 @@ public class EyeProtectionActivity extends BaseActivity {
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
int nightDisplay = Settings.Secure.getInt(getContentResolver(), Settings.Secure.NIGHT_DISPLAY_ACTIVATED, 0);
|
||||
if (nightDisplay == 1) {
|
||||
toggleButton1.setToggleOn();
|
||||
} else {
|
||||
toggleButton1.setToggleOff();
|
||||
}
|
||||
|
||||
int accessibilityDisplay = Settings.Secure.getInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
|
||||
if (accessibilityDisplay == 1) {
|
||||
toggleButton2.setToggleOn();
|
||||
} else {
|
||||
toggleButton2.setToggleOff();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +193,13 @@ public class MainActivity extends BaseActivity implements MainAContact.MainView,
|
||||
});
|
||||
// setStoreUpdateListener(bt_checkupdate);
|
||||
registerReceiver();
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
// ApkUtils.openPackage(MainActivity.this,"com.android.calculator2","com.android.calculator2.Calculator");
|
||||
// ApkUtils.openPackage(MainActivity.this,"com.android.documentsui","com.android.documentsui.LauncherActivity");
|
||||
// ApkUtils.openPackage(MainActivity.this,"com.jxw.wuweijidanci","com.jxw.wuweijidanci.MainActivity");
|
||||
// ApkUtils.openPackage(MainActivity.this,"com.jxw.singsound","com.jxw.singsound.ui.SplashActivity");
|
||||
}
|
||||
}
|
||||
|
||||
private void setStoreUpdateListener(View view) {
|
||||
|
||||
@@ -464,11 +464,16 @@ public class CacheHelper {
|
||||
String cachePath;
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|
||||
|| !Environment.isExternalStorageRemovable()) {
|
||||
cachePath = context.getExternalCacheDir().getPath();
|
||||
if (context.getExternalCacheDir() != null) {
|
||||
cachePath = context.getExternalCacheDir().getPath();
|
||||
} else if (context.getExternalFilesDir("cache") != null) {
|
||||
cachePath = context.getExternalFilesDir("cache").getPath();
|
||||
} else {
|
||||
cachePath = context.getCacheDir().getPath();
|
||||
}
|
||||
} else {
|
||||
cachePath = context.getCacheDir().getPath();
|
||||
}
|
||||
return new File(cachePath + File.separator + uniqueName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ public class AoleyunActivityController extends IActivityController.Stub {
|
||||
public boolean activityStarting(Intent intent, String pkg) {
|
||||
Log.e(TAG, "activityStarting: " + pkg + ", intent= " + intent);
|
||||
//retrun false;//false 则不会启动,直接返回。
|
||||
return JGYUtils.getInstance().isForbid(pkg);
|
||||
boolean status = JGYUtils.getInstance().isForbid(pkg);
|
||||
Log.e(TAG, "activityStarting: " + pkg + "start = " + status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,7 +6,9 @@ import android.app.PendingIntent;
|
||||
import android.app.StatusBarManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
@@ -105,6 +107,7 @@ import com.aoleyun.sn.network.api.post.SnConfirmBindApi;
|
||||
import com.aoleyun.sn.network.api.post.StudentsInfoApi;
|
||||
import com.aoleyun.sn.network.api.post.SystemSettingApi;
|
||||
import com.aoleyun.sn.network.api.post.UpdateDeviceInfoApi;
|
||||
import com.aoleyun.sn.network.api.post.UploadAppImgApi;
|
||||
import com.aoleyun.sn.network.api.post.UploadAppInfoApi;
|
||||
import com.aoleyun.sn.network.interceptor.RepeatRequestInterceptor;
|
||||
import com.aoleyun.sn.rlog.LogDBManager;
|
||||
@@ -113,6 +116,7 @@ import com.aoleyun.sn.service.main.MainService;
|
||||
import com.aoleyun.sn.statistics.AppInformation;
|
||||
import com.aoleyun.sn.statistics.StatisticsInfo;
|
||||
import com.aoleyun.sn.utils.ApkUtils;
|
||||
import com.aoleyun.sn.utils.BitmapUtils;
|
||||
import com.aoleyun.sn.utils.CacheUtils;
|
||||
import com.aoleyun.sn.utils.ForegroundAppUtil;
|
||||
import com.aoleyun.sn.utils.JGYUtils;
|
||||
@@ -150,6 +154,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
@@ -172,6 +177,7 @@ import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@@ -190,6 +196,9 @@ public class NetInterfaceManager {
|
||||
private Retrofit mAolelearnRetrofit;
|
||||
private OkHttpClient mAolelearnOkHttpClient;
|
||||
|
||||
private Set<String> mUploadIconPkgs;
|
||||
private static final String uploadIconPkgsKey = "UPLOAD_ICON_PACKAGE_KEY";
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
private CacheHelper cacheHelper;
|
||||
|
||||
@@ -350,6 +359,9 @@ public class NetInterfaceManager {
|
||||
.addCallAdapterFactory(RxJava3CallAdapterFactory.create())
|
||||
.build();
|
||||
}
|
||||
|
||||
mUploadIconPkgs = mMMKV.decodeStringSet(uploadIconPkgsKey, new HashSet<>());
|
||||
Log.e("init", "NetInterfaceManager: mUploadIconPkgs = " + mUploadIconPkgs);
|
||||
}
|
||||
|
||||
public static void init(Context context) {
|
||||
@@ -372,6 +384,21 @@ public class NetInterfaceManager {
|
||||
return okHttpClient;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(String param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), param);
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(int param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
public static RequestBody convertToRequestBody(long param) {
|
||||
RequestBody requestBody = RequestBody.create(MediaType.parse("text/plain"), String.valueOf(param));
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学习软件
|
||||
*
|
||||
@@ -758,6 +785,12 @@ public class NetInterfaceManager {
|
||||
return mRetrofit.create(SnConfirmBindApi.class);
|
||||
}
|
||||
|
||||
public UploadAppImgApi getUploadAppImgApi() {
|
||||
return mRetrofit.create(UploadAppImgApi.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* execution
|
||||
@@ -2411,6 +2444,8 @@ public class NetInterfaceManager {
|
||||
tagSets.add(JGYUtils.ZR6016Tag);
|
||||
} else if (platform == JGYUtils.HRAD13Platform) {
|
||||
tagSets.add(JGYUtils.HRAD13Tag);
|
||||
} else if (platform == JGYUtils.G10PPlatform) {
|
||||
tagSets.add(JGYUtils.G10PTag);
|
||||
} else if (platform == JGYUtils.C2Platform) {
|
||||
tagSets.add(JGYUtils.C2Tag);
|
||||
}
|
||||
@@ -2539,6 +2574,72 @@ public class NetInterfaceManager {
|
||||
callback.onComplete();
|
||||
}
|
||||
});
|
||||
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
List<PackageInfo> packageInfos = pm.getInstalledPackages(0);
|
||||
List<PackageInfo> filter = packageInfos.stream().filter(new Predicate<PackageInfo>() {
|
||||
@Override
|
||||
public boolean test(PackageInfo packageInfo) {
|
||||
if (ApkUtils.isSystemApp(mContext, packageInfo.packageName)) {
|
||||
if (ApkUtils.systemApps.contains(packageInfo.packageName)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
List<PackageInfo> filterJxwApp = filter.stream().filter(packageInfo -> !ApkUtils.jxwApp.contains(packageInfo.packageName)).collect(Collectors.toList());
|
||||
for (PackageInfo packageInfo : filterJxwApp) {
|
||||
if ("com.uiuipad.find".equals(packageInfo.packageName)
|
||||
|| "com.uiuipad.os".equals(packageInfo.packageName)
|
||||
|| "com.uiui.zybrowser".equals(packageInfo.packageName)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mUploadIconPkgs.contains(packageInfo.packageName)) {
|
||||
Drawable drawable = packageInfo.applicationInfo.loadIcon(pm);
|
||||
File file = BitmapUtils.drawableToFile(mContext, drawable, packageInfo.packageName);
|
||||
//File转RequestBody
|
||||
MediaType mediaType = MediaType.Companion.parse("image/png");
|
||||
RequestBody fileBody = RequestBody.Companion.create(file, mediaType);
|
||||
//设置一个file文件
|
||||
MultipartBody.Part body = MultipartBody.Part.createFormData("file", file.getName(), fileBody);
|
||||
Map<String, RequestBody> params = new HashMap<>();
|
||||
params.put("package", convertToRequestBody(packageInfo.packageName));
|
||||
Call<BaseResponse> call = getUploadAppImgApi().uploadAppImg(params, body);
|
||||
call.enqueue(new RetryCallback<BaseResponse>(call, 1, 30 * 1000) {
|
||||
@Override
|
||||
public void onRequestResponse(Call call, retrofit2.Response response) {
|
||||
BaseResponse baseResponse = (BaseResponse) response.body();
|
||||
Log.e(TAG, "onRequestResponse: " + baseResponse);
|
||||
if (baseResponse.code == 200 || baseResponse.code == 401) {
|
||||
addIcon(packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestFail(Call call, Throwable t) {
|
||||
Log.e(TAG, "onRequestFail: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartRetry() {
|
||||
Log.e(TAG, "onStartRetry: ");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Log.e(TAG, "updateAppInstall: upload " + packageInfo.packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addIcon(String pkg) {
|
||||
mUploadIconPkgs.add(pkg);
|
||||
mMMKV.encode(uploadIconPkgsKey, mUploadIconPkgs);
|
||||
}
|
||||
|
||||
public void uploadLogFile() {
|
||||
|
||||
@@ -146,6 +146,13 @@ public class UrlAddress {
|
||||
/*上传运行日志设置文件*/
|
||||
public static final String UPLOAD_IS_LOG_FILE = "And/sn/uploadIsLogFile";
|
||||
|
||||
/**
|
||||
* 图标相关
|
||||
*/
|
||||
/*获取应用库是否有图标*/
|
||||
public static final String GET_IS_APP_IMG = "And/collectData/getIsAppImg";
|
||||
/*上传应用图标*/
|
||||
public static final String UPLOAD_APP_IMG = "And/collectData/uploadAppImg";
|
||||
|
||||
/*通过ip获取信息*/
|
||||
public static final String PCONLINE_WHOIS = "http://whois.pconline.com.cn/";
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.aoleyun.sn.network.api.get;
|
||||
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.network.UrlAddress;
|
||||
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface AppImgApi {
|
||||
@GET(UrlAddress.GET_IS_APP_IMG)
|
||||
Observable<BaseResponse> getIsAppImg(
|
||||
@Query("package") String pkg
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.aoleyun.sn.network.api.post;
|
||||
|
||||
import com.aoleyun.sn.bean.BaseResponse;
|
||||
import com.aoleyun.sn.network.UrlAddress;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.RequestBody;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Multipart;
|
||||
import retrofit2.http.POST;
|
||||
import retrofit2.http.Part;
|
||||
import retrofit2.http.PartMap;
|
||||
|
||||
public interface UploadAppImgApi {
|
||||
@Multipart
|
||||
@POST(UrlAddress.UPLOAD_APP_IMG)
|
||||
Call<BaseResponse> uploadAppImg(
|
||||
@PartMap Map<String, RequestBody> params,
|
||||
@Part MultipartBody.Part body
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import android.app.IActivityManager;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.app.job.JobScheduler;
|
||||
import android.app.job.JobService;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -446,13 +448,13 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
// createNotificationChannel();
|
||||
// aliyunPushInit();
|
||||
|
||||
IActivityManager activityManager = ActivityManagerNative.getDefault();
|
||||
try {
|
||||
activityManager.setActivityController(new AoleyunActivityController(), true);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "setActivityController: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
// IActivityManager activityManager = ActivityManagerNative.getDefault();
|
||||
// try {
|
||||
// activityManager.setActivityController(new AoleyunActivityController(), true);
|
||||
// } catch (RemoteException e) {
|
||||
// Log.e(TAG, "setActivityController: " + e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -547,6 +549,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
registerInstallReceiver();
|
||||
registerRefreshReceiver();
|
||||
registerScreenLockReceiver();
|
||||
registerDisplayReceiver();
|
||||
}
|
||||
|
||||
private void unRegisterReceivers() {
|
||||
@@ -568,6 +571,9 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
if (null != screenLockReceiver) {
|
||||
unregisterReceiver(screenLockReceiver);
|
||||
}
|
||||
if (null != mDisplayReceiver) {
|
||||
unregisterReceiver(mDisplayReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
private static WindowManager windowManager;
|
||||
@@ -791,6 +797,53 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
|
||||
}
|
||||
}
|
||||
|
||||
private DisplayReceiver mDisplayReceiver;
|
||||
|
||||
|
||||
public void registerDisplayReceiver() {
|
||||
mDisplayReceiver = new DisplayReceiver();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
|
||||
filter.addAction(NIGHT_DISPLAY_ENABLED);
|
||||
filter.addAction(NIGHT_DISPLAY_DISABLED);
|
||||
filter.addAction(READ_MODEL_ENABLED);
|
||||
filter.addAction(READ_MODEL_DISABLED);
|
||||
registerReceiver(mDisplayReceiver, filter);
|
||||
}
|
||||
|
||||
public static final String NIGHT_DISPLAY_ENABLED = "NIGHT_DISPLAY_ENABLED";
|
||||
public static final String NIGHT_DISPLAY_DISABLED = "NIGHT_DISPLAY_DISABLED";
|
||||
public static final String READ_MODEL_ENABLED = "READ_MODEL_ENABLED";
|
||||
public static final String READ_MODEL_DISABLED = "READ_MODEL_DISABLED";
|
||||
|
||||
|
||||
private class DisplayReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
Log.e("DisplayReceiver", "onReceive: " + action);
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
return;
|
||||
}
|
||||
switch (action) {
|
||||
case NIGHT_DISPLAY_ENABLED:
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.NIGHT_DISPLAY_ACTIVATED, 1);
|
||||
break;
|
||||
case NIGHT_DISPLAY_DISABLED:
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.NIGHT_DISPLAY_ACTIVATED, 0);
|
||||
break;
|
||||
case READ_MODEL_ENABLED:
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 1);
|
||||
break;
|
||||
case READ_MODEL_DISABLED:
|
||||
Settings.Secure.putInt(getContentResolver(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final String UPLOAD_LOG_TIME = "23:00:00";
|
||||
|
||||
private void checkUploadLogTime() {
|
||||
|
||||
@@ -111,6 +111,28 @@ public class ApkUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean openPackage(Context context, String packageName, String className) {
|
||||
if (TextUtils.isEmpty(className)) {
|
||||
return openPackage(context, packageName);
|
||||
}
|
||||
ComponentName cn = new ComponentName(packageName, className);
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(cn);
|
||||
intent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
if (context != null) {
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "openPackage: " + e.getMessage());
|
||||
ToastUtil.show("打开失败");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Context getPackageContext(Context context, String packageName) {
|
||||
Context pkgContext = null;
|
||||
if (context.getPackageName().equals(packageName)) {
|
||||
@@ -766,6 +788,12 @@ public class ApkUtils {
|
||||
this.add("com.gl.dwlauncher");
|
||||
this.add("com.qunyu.dividedroad");
|
||||
this.add("com.ygyb.yischool");
|
||||
this.add("com.uiui.floatwindow");
|
||||
this.add("com.uiuipad.find");
|
||||
this.add("com.uiuipad.appstore");
|
||||
this.add("com.uiuipad.os");
|
||||
this.add("com.uiuipad.zyinfo");
|
||||
this.add("com.yixuepai.os");
|
||||
}};
|
||||
|
||||
//出厂自带的app
|
||||
@@ -997,8 +1025,12 @@ public class ApkUtils {
|
||||
|
||||
this.add("com.tencent.wework");
|
||||
this.add("com.tencent.mm");
|
||||
this.add("cn.wps.moffice_eng");
|
||||
this.add("com.baidu.BaiduMap");
|
||||
|
||||
this.add("com.jxw.singsound");
|
||||
this.add("com.qunyu.dividedroad");
|
||||
this.add("com.gl.dwlauncher");
|
||||
this.add("com.gl.dongwa");
|
||||
}};
|
||||
|
||||
public static Set<String> jxwApp = new HashSet<String>() {{
|
||||
@@ -1054,6 +1086,27 @@ public class ApkUtils {
|
||||
this.add("com.teclast.zy");
|
||||
}};
|
||||
|
||||
public static final Set<String> systemApps = new HashSet<String>() {{
|
||||
this.add("com.android.deskclock");
|
||||
this.add("com.android.music");
|
||||
this.add("com.android.documentsui");
|
||||
this.add("com.mediatek.camera");
|
||||
this.add("com.android.calendar");
|
||||
this.add("com.android.calculator2");
|
||||
this.add("com.android.gallery3d");
|
||||
this.add("com.android.soundrecorder");
|
||||
this.add("com.android.settings");
|
||||
this.add("org.chromium.chrome");
|
||||
this.add("com.softwinner.music");
|
||||
this.add("com.softwinner.miracastReceiver");
|
||||
this.add("com.softwinner.camera");
|
||||
this.add("org.chromium.webview_shell");
|
||||
// this.add("com.uiuipad.find");
|
||||
// this.add("com.uiuipad.os");
|
||||
this.add("com.softwinner.videoplayer");
|
||||
this.add("com.sohu.inputmethod.sogou");
|
||||
this.add("com.tencent.mtt");
|
||||
}};
|
||||
|
||||
public static void showAllAPP(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
|
||||
69
app/src/main/java/com/aoleyun/sn/utils/BitmapUtils.java
Normal file
69
app/src/main/java/com/aoleyun/sn/utils/BitmapUtils.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package com.aoleyun.sn.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.WriterException;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.QRCodeWriter;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BitmapUtils {
|
||||
/**
|
||||
* Drawable转换成一个Bitmap
|
||||
*
|
||||
* @param drawable drawable对象
|
||||
* @return
|
||||
*/
|
||||
public static final Bitmap drawableToBitmap(Drawable drawable) {
|
||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
|
||||
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
|
||||
Canvas canvas = new Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
drawable.draw(canvas);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* drawable转为file
|
||||
*
|
||||
* @param mContext
|
||||
* @param drawable drawable
|
||||
* @param fileName 转换后的文件名
|
||||
* @return
|
||||
*/
|
||||
public static File drawableToFile(Context mContext, Drawable drawable, String fileName) {
|
||||
// InputStream is = view.getContext().getResources().openRawResource(R.drawable.logo);
|
||||
Bitmap bitmap = drawableToBitmap(drawable);
|
||||
// Bitmap bitmap = BitmapFactory.decodeStream(is);
|
||||
String defaultPath = Utils.getCacheDir(mContext) + "/iconCache";
|
||||
File file = new File(defaultPath);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
String defaultImgPath = defaultPath + "/" + fileName;
|
||||
File iconFile = new File(defaultImgPath);
|
||||
try {
|
||||
iconFile.createNewFile();
|
||||
FileOutputStream fOut = new FileOutputStream(iconFile);
|
||||
bitmap.compress(Bitmap.CompressFormat.PNG, 20, fOut);
|
||||
// is.close();
|
||||
fOut.flush();
|
||||
fOut.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return iconFile;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class JGYUtils {
|
||||
public static final int AH6016Platform = 9;
|
||||
public static final int ZR6016Platform = 10;
|
||||
public static final int HRAD13Platform = 11;
|
||||
public static final int Teclast8183Platform = 12;
|
||||
public static final int G10PPlatform = 12;
|
||||
public static final int C2Platform = 13;
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ public class JGYUtils {
|
||||
public static final String AH6016Tag = "AH6016";
|
||||
public static final String ZR6016Tag = "ZR6016";
|
||||
public static final String HRAD13Tag = "HRAD13";
|
||||
public static final String Teclast8183Tag = "teclast8183";
|
||||
public static final String G10PTag = "G10P";
|
||||
public static final String C2Tag = "MTK8183";
|
||||
|
||||
|
||||
@@ -255,6 +255,9 @@ public class JGYUtils {
|
||||
} else if (HRAD13Tag.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "HRAD13");
|
||||
return HRAD13Platform;
|
||||
} else if (G10PTag.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "G10P");
|
||||
return G10PPlatform;
|
||||
} else if (C2Tag.equalsIgnoreCase(platform)) {
|
||||
Log.i(TAG, "checkAppPlatform: " + "C2");
|
||||
return C2Platform;
|
||||
@@ -296,6 +299,8 @@ public class JGYUtils {
|
||||
getAppPlatformCallback.AppPlatform(ZR6016Platform);
|
||||
} else if (HRAD13Tag.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(HRAD13Platform);
|
||||
} else if (G10PTag.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(G10PPlatform);
|
||||
} else if (C2Tag.equalsIgnoreCase(platform)) {
|
||||
getAppPlatformCallback.AppPlatform(C2Platform);
|
||||
} else {
|
||||
@@ -321,9 +326,11 @@ public class JGYUtils {
|
||||
return ZR6016Tag;
|
||||
} else if (HRAD13Tag.equalsIgnoreCase(platform)) {
|
||||
return HRAD13Tag;
|
||||
} else if (C2Tag.equalsIgnoreCase(platform)) {
|
||||
} else if (G10PTag.equalsIgnoreCase(platform)) {
|
||||
return G10PTag;
|
||||
} else if (C2Tag.equalsIgnoreCase(platform)) {
|
||||
return C2Tag;
|
||||
}else {
|
||||
} else {
|
||||
return Other;
|
||||
}
|
||||
}
|
||||
@@ -1210,8 +1217,10 @@ public class JGYUtils {
|
||||
pkgSet.addAll(ApkUtils.aoleyunAPP);
|
||||
pkgSet.addAll(ApkUtils.aihuaApp);
|
||||
pkgSet.addAll(ApkUtils.jxwApp);
|
||||
|
||||
pkgSet.removeIf(TextUtils::isEmpty);
|
||||
if (JGYUtils.C2Tag.equalsIgnoreCase(JGYUtils.getInstance().getAppPlatform())) {
|
||||
pkgSet.remove("com.tencent.mm");
|
||||
}
|
||||
String aole_app_forbid = String.join(",", pkgSet);
|
||||
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
|
||||
boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
@@ -1226,6 +1235,9 @@ public class JGYUtils {
|
||||
pkgSet.addAll(ApkUtils.aoleyunAPP);
|
||||
pkgSet.addAll(ApkUtils.aihuaApp);
|
||||
pkgSet.addAll(ApkUtils.jxwApp);
|
||||
if (JGYUtils.C2Tag.equalsIgnoreCase(JGYUtils.getInstance().getAppPlatform())) {
|
||||
pkgSet.remove("com.tencent.mm");
|
||||
}
|
||||
String aole_app_forbid = String.join(",", pkgSet);
|
||||
Log.e(TAG, "writeAppPackageList: " + aole_app_forbid);
|
||||
Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, aole_app_forbid);
|
||||
@@ -1390,39 +1402,43 @@ public class JGYUtils {
|
||||
}
|
||||
|
||||
public void installDesktop(JsonObject jsonObject) {
|
||||
String app_name = jsonObject.get("app_name").getAsString();
|
||||
String app_url = jsonObject.get("app_url").getAsString();
|
||||
String app_package = jsonObject.get("app_package").getAsString();
|
||||
int app_version_code = jsonObject.get("app_version_code").getAsInt();
|
||||
mMMKV.encode(CommonConfig.DEFAULT_DESKTOP_PACKAGE, app_package);
|
||||
Set<String> desktop = new HashSet<>(ApkUtils.desktopAPP);
|
||||
desktop.remove(app_package);
|
||||
for (String s : desktop) {
|
||||
ApkUtils.UninstallAPP(mContext, s);
|
||||
}
|
||||
PackageInfo info = null;
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
if (null != packageManager) {
|
||||
try {
|
||||
info = packageManager.getPackageInfo(app_package, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("fht", "installDesktop: " + e.getMessage());
|
||||
try {
|
||||
String app_name = jsonObject.get("app_name").getAsString();
|
||||
String app_url = jsonObject.get("app_url").getAsString();
|
||||
String app_package = jsonObject.get("app_package").getAsString();
|
||||
int app_version_code = jsonObject.get("app_version_code").getAsInt();
|
||||
mMMKV.encode(CommonConfig.DEFAULT_DESKTOP_PACKAGE, app_package);
|
||||
Set<String> desktop = new HashSet<>(ApkUtils.desktopAPP);
|
||||
desktop.remove(app_package);
|
||||
for (String s : desktop) {
|
||||
ApkUtils.UninstallAPP(mContext, s);
|
||||
}
|
||||
if (null != info) {
|
||||
packageManager.setApplicationEnabledSetting(app_package, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
long versionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
versionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
versionCode = info.versionCode;
|
||||
PackageInfo info = null;
|
||||
PackageManager packageManager = mContext.getPackageManager();
|
||||
if (null != packageManager) {
|
||||
try {
|
||||
info = packageManager.getPackageInfo(app_package, 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
Log.e("fht", "installDesktop: " + e.getMessage());
|
||||
}
|
||||
if (app_version_code > versionCode) {
|
||||
if (null != info) {
|
||||
packageManager.setApplicationEnabledSetting(app_package, PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, 0);
|
||||
long versionCode;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
versionCode = info.getLongVersionCode();
|
||||
} else {
|
||||
versionCode = info.versionCode;
|
||||
}
|
||||
if (app_version_code > versionCode) {
|
||||
Utils.ariaDownload(mContext, app_url, jsonObject);
|
||||
}
|
||||
} else {
|
||||
Utils.ariaDownload(mContext, app_url, jsonObject);
|
||||
}
|
||||
} else {
|
||||
Utils.ariaDownload(mContext, app_url, jsonObject);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "installDesktop: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1728,6 +1744,7 @@ public class JGYUtils {
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AH6016Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZR6016Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.HRAD13Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G10PPlatform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.C2Platform
|
||||
) {
|
||||
Settings.Global.putInt(crv, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, state == 1 ? 0 : 1);
|
||||
@@ -2119,8 +2136,8 @@ public class JGYUtils {
|
||||
private String Launcher3 = "com.android.launcher3";
|
||||
private String Launcher3Class = "com.android.launcher3.Launcher";
|
||||
|
||||
private String AoleyunOs ="com.aoleyun.os";
|
||||
private String AoleyunOsClass ="com.aoleyun.os.Launcher";
|
||||
private String AoleyunOs = "com.aoleyun.os";
|
||||
private String AoleyunOsClass = "com.aoleyun.os.Launcher";
|
||||
|
||||
public void setDefaultLauncher(Context context, String defPackageName, String defClassName) {
|
||||
try {
|
||||
@@ -2229,9 +2246,9 @@ public class JGYUtils {
|
||||
|
||||
private void openLauncher3() {
|
||||
// ApkUtils.openPackage(mContext, Launcher3);
|
||||
if ("C2".equals(Build.MODEL)){
|
||||
if ("C2".equals(Build.MODEL)) {
|
||||
setDefaultDesktop(AoleyunOs, AoleyunOsClass);
|
||||
}else {
|
||||
} else {
|
||||
setDefaultDesktop(Launcher3, Launcher3Class);
|
||||
}
|
||||
}
|
||||
@@ -2435,7 +2452,7 @@ public class JGYUtils {
|
||||
}
|
||||
|
||||
|
||||
public boolean isForbid(String pkg) {
|
||||
public boolean isForbid(String pkg) {
|
||||
switch (pkg) {
|
||||
case "com.mediatek.camera":
|
||||
case "com.android.camera2":
|
||||
@@ -2497,7 +2514,7 @@ public class JGYUtils {
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ public class SysSettingUtils {
|
||||
setBar(context, 1);
|
||||
setCamera(context, 1);
|
||||
setTF(context, 1);
|
||||
setIcon(context, 1);
|
||||
setIcon(context, 0);
|
||||
setWallpaper(context, 0);
|
||||
setCanReset(context, 1);
|
||||
setCanReset(context, 0);
|
||||
setAutoTime(context, 1);
|
||||
setBrowserInput(context, 1);
|
||||
if (!BuildConfig.DEBUG) {
|
||||
@@ -94,7 +94,10 @@ public class SysSettingUtils {
|
||||
public static void setEnableSetting(Context context) {
|
||||
ToastUtil.betaShow("打开所有功能");
|
||||
setPhoneList(context, 0);
|
||||
// setUSBstate(context,0);
|
||||
if (JGYUtils.C2Tag.equalsIgnoreCase(JGYUtils.getInstance().getAppPlatform())) {
|
||||
openMtp(context);
|
||||
}
|
||||
// setUSBstate(context, 0);
|
||||
setBluetooth(context, 0);
|
||||
setHotspot(context, 0);
|
||||
setBar(context, 0);
|
||||
@@ -110,6 +113,12 @@ public class SysSettingUtils {
|
||||
setAdminApp(context, 0);
|
||||
}
|
||||
|
||||
private static void openMtp(Context context) {
|
||||
String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_MTP;
|
||||
Intent usbIntent = new Intent(usbStatus);
|
||||
context.sendBroadcast(usbIntent);
|
||||
}
|
||||
|
||||
private static void setPhoneList(Context context, int state) {
|
||||
try {
|
||||
//设置电话功能,电话白名单
|
||||
@@ -169,8 +178,6 @@ public class SysSettingUtils {
|
||||
//Midi模式:usb_midi
|
||||
if (!BuildConfig.DEBUG) {
|
||||
try {
|
||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||
mService.setUsbDataDisabled(true);
|
||||
boolean aole_usb_choose = Settings.System.putString(context.getContentResolver(), "aole_usb_choose", "usb_charge");
|
||||
Log.e(TAG, "aole_usb_choose:" + aole_usb_choose);
|
||||
String usbStatus = CommonConfig.AOLE_ACTION_USB_USB_CHARGE;
|
||||
@@ -184,6 +191,9 @@ public class SysSettingUtils {
|
||||
usbIntent.setPackage("com.android.settings");
|
||||
}
|
||||
context.sendBroadcast(usbIntent);
|
||||
|
||||
SuperPower mService = (SuperPower) context.getSystemService("mdm");
|
||||
mService.setUsbDataDisabled(true);
|
||||
} catch (NoClassDefFoundError | Exception e) {
|
||||
Log.e(TAG, "setUSBstate: " + e.getMessage());
|
||||
}
|
||||
@@ -552,7 +562,7 @@ public class SysSettingUtils {
|
||||
//设置5个app的开关
|
||||
//时钟
|
||||
// int deskclock = 1;
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", 0);
|
||||
Settings.System.putInt(context.getContentResolver(), "qch_app_deskclock", state);
|
||||
ApkUtils.hideSystemSettingAPP(context, "com.android.deskclock");
|
||||
Log.e(TAG, "qch_app_deskclock" + state);
|
||||
//录音机
|
||||
|
||||
@@ -1766,6 +1766,7 @@ public class Utils {
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.AH6016Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.ZR6016Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.HRAD13Platform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.G10PPlatform
|
||||
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.C2Platform
|
||||
) {
|
||||
return Utils.getProperty("ro.build.display.id", "获取失败");
|
||||
@@ -1962,5 +1963,22 @@ public class Utils {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getCacheDir(Context context) {
|
||||
String cachePath;
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())
|
||||
|| !Environment.isExternalStorageRemovable()) {
|
||||
if (context.getExternalCacheDir() != null) {
|
||||
cachePath = context.getExternalCacheDir().getPath();
|
||||
} else if (context.getExternalFilesDir("cache") != null) {
|
||||
cachePath = context.getExternalFilesDir("cache").getPath();
|
||||
} else {
|
||||
cachePath = context.getCacheDir().getPath();
|
||||
}
|
||||
} else {
|
||||
cachePath = context.getCacheDir().getPath();
|
||||
}
|
||||
return cachePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user