fix:
update:优化app霸屏
This commit is contained in:
2022-06-09 20:38:48 +08:00
parent 83159cc584
commit b917401e86
12 changed files with 81 additions and 15 deletions

View File

@@ -14,4 +14,5 @@ interface SystemInfoInterface {
String getSerial();
List<String> getHideIcon();
List<String> getDisableIcon();
String getTopAppPackage();
}

View File

@@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.media.AudioManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
@@ -28,6 +29,7 @@ import com.aoleyun.sn.R;
import com.aoleyun.sn.activity.checknet.CheckNetActivity;
import com.aoleyun.sn.activity.main.MainActivity;
import com.aoleyun.sn.base.BaseApplication;
import com.aoleyun.sn.comm.CommonConfig;
import com.aoleyun.sn.comm.JGYActions;
import com.aoleyun.sn.comm.PackageNames;
import com.aoleyun.sn.network.NetInterfaceManager;
@@ -151,8 +153,8 @@ public class SplashActivity extends AppCompatActivity {
Log.i(TAG, "DebugTest: qch_hide_NavigationBar: " + Settings.System.getString(getContentResolver(), "qch_hide_NavigationBar"));
String only_jgy_shortcut_list = Settings.System.getString(getContentResolver(), JGYActions.ACTION_JGY_SHORTCUTLIST);
Log.i(TAG, "debugTest: only_jgy_shortcut_list:" + only_jgy_shortcut_list);
String qch_app_forbid = Settings.System.getString(getContentResolver(), "qch_app_forbid");
Settings.System.putString(getContentResolver(), "qch_app_forbid", qch_app_forbid + ",com.aoleyun.browser");
String qch_app_forbid = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
Settings.System.putString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, qch_app_forbid + ",com.aoleyun.browser");
Log.e(TAG, "debugTest: qch_app_forbid:" + qch_app_forbid);
Log.i(TAG, "debugTest: ip = " + JGYUtils.getInstance().getIPAddress());
Log.i(TAG, "debugTest: getPackage = " + Utils.getPackage());
@@ -196,6 +198,17 @@ public class SplashActivity extends AppCompatActivity {
// JGYUtils.getInstance().shutdown();
Log.e(TAG, "debugTest: " + PathUtils.getExternalDownloadsPath());
Log.e(TAG, "debugTest: " + ContextCompat.getExternalFilesDirs(this, Environment.DIRECTORY_DOWNLOADS)[0]);
//静音
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.P) {
int ringMax = audioManager.getStreamMinVolume(AudioManager.STREAM_RING);
int musicMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_MUSIC);
int voiceMax = audioManager.getStreamMinVolumeInt(AudioManager.STREAM_VOICE_CALL);
audioManager.setStreamVolume(AudioManager.STREAM_RING, ringMax, 0);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, voiceMax, 0);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, musicMax, 0); //音乐音量
}
}
@SuppressLint("NewApi")

View File

@@ -1,5 +1,10 @@
package com.aoleyun.sn.bean;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.JsonParser;
import java.io.Serializable;
public class TopApp implements Serializable {
@@ -13,4 +18,10 @@ public class TopApp implements Serializable {
public void setApp_package(String app_package) {
this.app_package = app_package;
}
@NonNull
@Override
public String toString() {
return JsonParser.parseString(new Gson().toJson(this)).getAsJsonObject().toString();
}
}

View File

@@ -52,5 +52,8 @@ public class CommonConfig {
* 管控系统指令
*/
public final static String aole_action_usb_usb_charge = "aole_action_usb_usb_charge";
public final static String AOLE_ACTION_USB_USB_CHARGE = "aole_action_usb_usb_charge";
public final static String AOLE_ACTION_APP_FORBID = "aole_app_forbid";
}

View File

@@ -2825,12 +2825,12 @@ public class NetInterfaceManager {
String app_package = response.data.getApp_package();
cacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, GsonUtils.toJsonString(response.data));
ForegroundAppUtil.setTopAppClass(mContext, app_package);
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, app_package);
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, app_package);
ForegroundAppUtil.openTopApp(mContext);
} else {
cacheHelper.put(UrlAddress.GET_TOP_APP_CONTROL, "");
ForegroundAppUtil.setTopAppClass(mContext, "");
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, "");
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, "");
}
}
@@ -2844,6 +2844,7 @@ public class NetInterfaceManager {
public void onComplete() {
Log.e("getTopApp", "onComplete: ");
callback.onComplete();
Log.e("getTopApp", "onComplete: " + Settings.Global.getString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY));
ToastUtil.betaShow("获取app霸屏管控结束");
}
});

View File

@@ -4,11 +4,15 @@ import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.provider.Settings;
import android.util.Log;
import com.aoleyun.sn.SystemInfoInterface;
import com.aoleyun.sn.utils.ForegroundAppUtil;
import com.aoleyun.sn.utils.JGYUtils;
import com.aoleyun.sn.utils.SPUtils;
import com.aoleyun.sn.utils.Utils;
import com.tencent.mmkv.MMKV;
import java.util.List;
@@ -51,6 +55,14 @@ public class RemoteService extends Service {
List<String> disable = JGYUtils.getInstance().getDisablePackage();
return disable;
}
@Override
public String getTopAppPackage() throws RemoteException {
String pkg = Settings.Global.getString(getContentResolver(), ForegroundAppUtil.TOPAPP_KEY);
Log.e(TAG, "getTopAppPackage: " + pkg);
return pkg;
}
};

View File

@@ -824,7 +824,7 @@ public class MainService extends Service implements MainSContact.MainView, Netwo
*/
@SuppressLint("NewApi")
synchronized private void installApkByPackage(String filePath, String pkg) {
String oldListString = Settings.System.getString(getContentResolver(), "qch_app_forbid");
String oldListString = Settings.System.getString(getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
HashSet<String> packageList = new HashSet<>(Arrays.asList(oldListString.split(",")));
if (!packageList.contains(pkg)) {
Log.e(TAG, "installApkByPackage: " + "packageName: " + pkg + " not in whitelist");

View File

@@ -66,6 +66,7 @@ import com.tencent.android.tpush.XGPushClickedResult;
import com.tencent.android.tpush.XGPushRegisterResult;
import com.tencent.android.tpush.XGPushShowedResult;
import com.tencent.android.tpush.XGPushTextMessage;
import com.tencent.mmkv.MMKV;
import java.io.File;
import java.lang.reflect.Type;
@@ -1105,13 +1106,14 @@ public class MessageReceiver extends XGPushBaseReceiver {
String packageName = jsonObject.getString("app_package");
if (TextUtils.isEmpty(packageName)) {
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, "");
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, "");
ForegroundAppUtil.setTopAppClass(mContext, "");
} else {
SPUtils.put(mContext, ForegroundAppUtil.TOPAPP_KEY, packageName);
Settings.Global.putString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY, packageName);
ForegroundAppUtil.setTopAppClass(mContext, packageName);
ForegroundAppUtil.openTopApp(mContext);
}
Log.e(TAG, "getTopApp: " + Settings.Global.getString(mContext.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY));
}
private void setBootanimation(String extras) {

View File

@@ -10,6 +10,8 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import com.tencent.mmkv.MMKV;
import java.util.List;
public class ForegroundAppUtil {
@@ -29,7 +31,7 @@ public class ForegroundAppUtil {
}
public static void openTopApp(Context context) {
String topAppName = (String) SPUtils.get(context, ForegroundAppUtil.TOPAPP_KEY, "");
String topAppName = Settings.Global.getString(context.getContentResolver(), ForegroundAppUtil.TOPAPP_KEY);
if (TextUtils.isEmpty(topAppName)) {
return;
}

View File

@@ -1102,8 +1102,8 @@ public class JGYUtils {
pkgSet.removeIf(TextUtils::isEmpty);
String qch_app_forbid = String.join(",", pkgSet);
Log.e(TAG, "writeAppPackageList: " + qch_app_forbid);
boolean b = Settings.System.putString(crv, "qch_app_forbid", qch_app_forbid);
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(crv, "qch_app_forbid"));
boolean b = Settings.System.putString(crv, CommonConfig.AOLE_ACTION_APP_FORBID, qch_app_forbid);
Log.e("writeAppPackageList: ", "qch_app_forbid is :" + b + " " + Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID));
}
public void checkForceDownload() {
@@ -1314,7 +1314,7 @@ public class JGYUtils {
result_white = only_jgy_shortcut_list.split(",");
}
//获取可以被安装的包名
String qch_app_forbid = Settings.System.getString(crv, "qch_app_forbid");
String qch_app_forbid = Settings.System.getString(crv, CommonConfig.AOLE_ACTION_APP_FORBID);
if (!TextUtils.isEmpty(qch_app_forbid)) {
result_forbid = qch_app_forbid.split(",");
}

View File

@@ -1059,7 +1059,7 @@ public class Utils {
* @return
*/
static synchronized public boolean writeDisableUpdateList(Context context, String[] allowList, String[] disallowList) {
String now = Settings.System.getString(context.getContentResolver(), "qch_app_forbid");
String now = Settings.System.getString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID);
String[] nowList;
List<String> allList;
if (now == null || "".equalsIgnoreCase(now)) {
@@ -1096,10 +1096,10 @@ public class Utils {
}
list = list.substring(0, list.length() - 1);
Log.e("fht", list);
writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", list);
writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, list);
Log.e("fht", "qch_app_forbid:" + list);
} else {
writeSucceed = Settings.System.putString(context.getContentResolver(), "qch_app_forbid", "Invalid");
writeSucceed = Settings.System.putString(context.getContentResolver(), CommonConfig.AOLE_ACTION_APP_FORBID, "Invalid");
}
return writeSucceed;

View File

@@ -397,6 +397,11 @@
<dimen name="dp_720">720dp</dimen>
<!-- font size,you can add if there is no one -->
<dimen name="sp_1">1sp</dimen>
<dimen name="sp_2">2sp</dimen>
<dimen name="sp_3">3sp</dimen>
<dimen name="sp_4">4sp</dimen>
<dimen name="sp_5">5sp</dimen>
<dimen name="sp_6">6sp</dimen>
<dimen name="sp_7">7sp</dimen>
<dimen name="sp_8">8sp</dimen>
@@ -417,14 +422,30 @@
<dimen name="sp_23">23sp</dimen>
<dimen name="sp_24">24sp</dimen>
<dimen name="sp_25">25sp</dimen>
<dimen name="sp_26">26sp</dimen>
<dimen name="sp_27">27sp</dimen>
<dimen name="sp_28">28sp</dimen>
<dimen name="sp_29">29sp</dimen>
<dimen name="sp_30">30sp</dimen>
<dimen name="sp_301">31sp</dimen>
<dimen name="sp_32">32sp</dimen>
<dimen name="sp_33">33sp</dimen>
<dimen name="sp_34">34sp</dimen>
<dimen name="sp_35">35sp</dimen>
<dimen name="sp_36">36sp</dimen>
<dimen name="sp_37">37sp</dimen>
<dimen name="sp_38">38sp</dimen>
<dimen name="sp_39">39sp</dimen>
<dimen name="sp_40">40sp</dimen>
<dimen name="sp_41">41sp</dimen>
<dimen name="sp_42">42sp</dimen>
<dimen name="sp_43">43sp</dimen>
<dimen name="sp_44">44sp</dimen>
<dimen name="sp_45">45sp</dimen>
<dimen name="sp_46">46sp</dimen>
<dimen name="sp_47">47sp</dimen>
<dimen name="sp_48">48sp</dimen>
<dimen name="sp_49">49sp</dimen>
<dimen name="sp_50">50sp</dimen>
</resources>