version:1.7.0
fix:0918 add:
This commit is contained in:
@@ -102,7 +102,6 @@ public class ApkUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 安装一个apk文件
|
||||
*/
|
||||
@@ -672,7 +671,7 @@ public class ApkUtils {
|
||||
}
|
||||
|
||||
public static void addShortcut(Context context) {
|
||||
String packageList = (String) SPUtils.get(context, "only_jgy_shortcut_list", "Invalid");
|
||||
String packageList = Settings.System.getString(context.getContentResolver(), "only_jgy_shortcut_list");
|
||||
if (TextUtils.isEmpty(packageList)) {
|
||||
JGYUtils.putString(context.getContentResolver(), "qch_launcher_icon_app", "");
|
||||
return;
|
||||
@@ -834,4 +833,28 @@ public class ApkUtils {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取第三方应用
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
public static List<String> queryFilterAppInfo(Context context) {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
// 查询所有已经安装的应用程序
|
||||
List<ApplicationInfo> appInfos = pm.getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);// GET_UNINSTALLED_PACKAGES代表已删除,但还有安装目录的
|
||||
List<String> applicationInfos = new ArrayList<>();
|
||||
for (ApplicationInfo app : appInfos) {
|
||||
// Logutils.e("queryFilterAppInfo", String.valueOf(app.flags));
|
||||
// Logutils.e("queryFilterAppInfo", String.valueOf((app.flags & mask)));
|
||||
if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
|
||||
//通过flag排除系统应用,会将电话、短信也排除掉
|
||||
} else {
|
||||
applicationInfos.add(app.packageName);
|
||||
Log.e("queryFilterAppInfo", app.packageName);
|
||||
}
|
||||
}
|
||||
return applicationInfos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.info.sn.BuildConfig;
|
||||
import com.info.sn.service.RemoteService;
|
||||
|
||||
@@ -561,7 +562,11 @@ public class JGYUtils {
|
||||
|
||||
public static ArrayList<String> getForbidList(Context context) {
|
||||
ArrayList<String> disableApp = new ArrayList<>();
|
||||
if ((int) SPUtils.get(context, "search_topic", 0) == 0) {
|
||||
int search_topic = (int) SPUtils.get(context, "search_topic", 0);
|
||||
Log.e(TAG, "getForbidList: search_topic = " + search_topic);
|
||||
Log.e(TAG, "getForbidList: " + JSONObject.toJSONString(SPUtils.getAll(context)));
|
||||
|
||||
if (search_topic == 0) {
|
||||
disableApp.add("拍照搜题");
|
||||
}
|
||||
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_camera", 0) == 1) {
|
||||
@@ -580,6 +585,9 @@ public class JGYUtils {
|
||||
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_music", 0) == 1) {
|
||||
disableApp.add("com.android.music");
|
||||
}
|
||||
if (JGYUtils.getInt(context.getContentResolver(), "qch_app_browser", 0) == 1) {
|
||||
disableApp.add("com.android.browser");
|
||||
}
|
||||
Log.e(TAG, "getForbidAPP: " + disableApp);
|
||||
return disableApp;
|
||||
}
|
||||
@@ -589,6 +597,7 @@ public class JGYUtils {
|
||||
public static void updateForbidList(Context context) {
|
||||
Intent intent = new Intent(UPDATE_FORBID_APP);
|
||||
intent.putStringArrayListExtra("forbid_app_list", getForbidList(context));
|
||||
Log.e(TAG, "updateForbidList: " + getForbidList(context));
|
||||
intent.setPackage("com.jiaoguanyi.os");
|
||||
intent.setPackage("com.tt.ttutils");
|
||||
context.sendBroadcast(intent);
|
||||
@@ -603,6 +612,7 @@ public class JGYUtils {
|
||||
return new ArrayList<>(Arrays.asList(appString.split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
private static final String UPDATE_HIDE_APP = "UPDATE_HIDE_APP";
|
||||
|
||||
public static void updateHideList(Context context) {
|
||||
@@ -736,6 +746,50 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
|
||||
//删除用户除了在应用市场的其他应用
|
||||
public void deleteOtherApp() {
|
||||
int locked = Settings.System.getInt(mContext.getContentResolver(), "qch_unlock_ipad", 0);
|
||||
if (locked == 1) {
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "deleteOtherApp: " + "start");
|
||||
//获取后台应用白名单
|
||||
String only_jgy_shortcut_list = Settings.System.getString(mContext.getContentResolver(), "only_jgy_shortcut_list");
|
||||
//获取可以被安装的包名
|
||||
String qch_app_forbid = Settings.System.getString(mContext.getContentResolver(), "qch_app_forbid");
|
||||
Log.e("deleteOtherApp", "only_jgy_shortcut_list:" + only_jgy_shortcut_list);
|
||||
Log.e("deleteOtherApp", "qch_app_forbid:" + qch_app_forbid);
|
||||
String[] result_white = only_jgy_shortcut_list.split(",");
|
||||
String[] result_forbid = qch_app_forbid.split(",");
|
||||
List<String> resulWhitetList = new ArrayList<>(Arrays.asList(result_white));
|
||||
List<String> resulForbidtList = new ArrayList<>(Arrays.asList(result_forbid));
|
||||
resulWhitetList.addAll(resulForbidtList);
|
||||
HashSet<String> allWhitePkg = new HashSet<>(resulWhitetList);
|
||||
List<String> installedPackageList = ApkUtils.queryFilterAppInfo(mContext);
|
||||
|
||||
|
||||
Log.e("deleteOtherApp", "installedPackageList:" + installedPackageList.toString());
|
||||
if (allWhitePkg.size() > 0) {
|
||||
for (final String packageName : installedPackageList) {
|
||||
if (ApkUtils.isSystemApp(mContext, packageName)) {
|
||||
Log.e("deleteOtherApp", "is systemApp:" + packageName);
|
||||
continue;
|
||||
}
|
||||
// if (ApkUtils.desktopAPP.contains(packageName)) {
|
||||
// continue;
|
||||
// }
|
||||
// if (ApkUtils.canremove_systemapp.contains(packageName)) {
|
||||
// continue;
|
||||
// }
|
||||
if ("com.jiaoguanyi.appstore".equals(packageName) || "com.jiaoguanyi.store".equals(packageName)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!allWhitePkg.contains(packageName)) {
|
||||
ApkUtils.uninstallApp(mContext, packageName);
|
||||
Log.e("deleteOtherApp", "uninstall apkName:" + packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.e(TAG, "deleteOtherApp: " + "end");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -26,11 +27,12 @@ public class SPUtils {
|
||||
* 保存在手机里面的文件名
|
||||
*/
|
||||
public static final String FILE_NAME = "share_data";
|
||||
private static String TAG = SPUtils.class.getSimpleName();
|
||||
|
||||
/**
|
||||
* 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法
|
||||
*/
|
||||
public static void put(Context context, String key, Object object) {
|
||||
public static boolean put(Context context, String key, Object object) {
|
||||
|
||||
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
|
||||
Context.MODE_PRIVATE);
|
||||
@@ -50,7 +52,7 @@ public class SPUtils {
|
||||
editor.putString(key, object.toString());
|
||||
}
|
||||
|
||||
SharedPreferencesCompat.apply(editor);
|
||||
return SharedPreferencesCompat.apply(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,17 +185,17 @@ public class SPUtils {
|
||||
/**
|
||||
* 如果找到则使用apply执行,否则使用commit
|
||||
*/
|
||||
public static void apply(SharedPreferences.Editor editor) {
|
||||
public static boolean apply(SharedPreferences.Editor editor) {
|
||||
try {
|
||||
if (sApplyMethod != null) {
|
||||
Log.e(TAG, "apply: false");
|
||||
sApplyMethod.invoke(editor);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
|
||||
Log.e(TAG, "apply: " + e.getStackTrace());
|
||||
}
|
||||
editor.commit();
|
||||
return editor.commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
344
app/src/main/java/com/info/sn/utils/StatusBarUtil.java
Normal file
344
app/src/main/java/com/info/sn/utils/StatusBarUtil.java
Normal file
@@ -0,0 +1,344 @@
|
||||
package com.info.sn.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
public class StatusBarUtil {
|
||||
public static int screenWidth;
|
||||
public static int screenHeight;
|
||||
public static int navigationHeight = 0;
|
||||
|
||||
private static DisplayMetrics mMetrics;
|
||||
public static final String HOME_CURRENT_TAB_POSITION = "HOME_CURRENT_TAB_POSITION";
|
||||
|
||||
public static final String SYS_EMUI = "sys_emui";
|
||||
public static final String SYS_MIUI = "sys_miui";
|
||||
public static final String SYS_FLYME = "sys_flyme";
|
||||
private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";
|
||||
private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";
|
||||
private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";
|
||||
private static final String KEY_EMUI_API_LEVEL = "ro.build.hw_emui_api_level";
|
||||
private static final String KEY_EMUI_VERSION = "ro.build.version.emui";
|
||||
private static final String KEY_EMUI_CONFIG_HW_SYS_VERSION = "ro.confg.hw_systemversion";
|
||||
|
||||
public static void init(Activity activity) {
|
||||
ViewGroup contentLayout = activity.getWindow().getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
|
||||
StatusBarUtil.setStatusBar(activity, false, true);
|
||||
StatusBarUtil.setStatusTextColor(true, activity);
|
||||
StatusBarUtil.setStatusBarPadding(activity, contentLayout);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
activity.getWindow().setStatusBarColor(activity.getResources().getColor(android.R.color.transparent));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过反射的方式获取状态栏高度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getStatusBarHeight(Context context) {
|
||||
try {
|
||||
Class<?> c = Class.forName("com.android.internal.R$dimen");
|
||||
Object obj = c.newInstance();
|
||||
Field field = c.getField("status_bar_height");
|
||||
int x = Integer.parseInt(field.get(obj).toString());
|
||||
return context.getResources().getDimensionPixelSize(x);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取底部导航栏高度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static int getNavigationBarHeight(Context context) {
|
||||
Resources resources = context.getResources();
|
||||
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
|
||||
//获取NavigationBar的高度
|
||||
navigationHeight = resources.getDimensionPixelSize(resourceId);
|
||||
return navigationHeight;
|
||||
}
|
||||
|
||||
//获取是否存在NavigationBar
|
||||
public static boolean checkDeviceHasNavigationBar(Context context) {
|
||||
boolean hasNavigationBar = false;
|
||||
Resources rs = context.getResources();
|
||||
int id = rs.getIdentifier("config_showNavigationBar", "bool", "android");
|
||||
if (id > 0) {
|
||||
hasNavigationBar = rs.getBoolean(id);
|
||||
}
|
||||
try {
|
||||
Class systemPropertiesClass = Class.forName("android.os.SystemProperties");
|
||||
Method m = systemPropertiesClass.getMethod("get", String.class);
|
||||
String navBarOverride = (String) m.invoke(systemPropertiesClass, "qemu.hw.mainkeys");
|
||||
if ("1".equals(navBarOverride)) {
|
||||
hasNavigationBar = false;
|
||||
} else if ("0".equals(navBarOverride)) {
|
||||
hasNavigationBar = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return hasNavigationBar;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activity
|
||||
* @param useThemestatusBarColor 是否要状态栏的颜色,不设置则为透明色
|
||||
* @param withoutUseStatusBarColor 是否不需要使用状态栏为暗色调
|
||||
*/
|
||||
public static void setStatusBar(Activity activity, boolean useThemestatusBarColor, boolean withoutUseStatusBarColor) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0及以上
|
||||
View decorView = activity.getWindow().getDecorView();
|
||||
int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
decorView.setSystemUiVisibility(option);
|
||||
if (useThemestatusBarColor) {
|
||||
activity.getWindow().setStatusBarColor(activity.getResources().getColor(android.R.color.white));
|
||||
} else {
|
||||
activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4到5.0
|
||||
WindowManager.LayoutParams localLayoutParams = activity.getWindow().getAttributes();
|
||||
localLayoutParams.flags = (WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | localLayoutParams.flags);
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !withoutUseStatusBarColor) {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
}
|
||||
}
|
||||
|
||||
public static void reMeasure(Activity activity) {
|
||||
Display display = activity.getWindowManager().getDefaultDisplay();
|
||||
mMetrics = new DisplayMetrics();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 17) {
|
||||
display.getRealMetrics(mMetrics);
|
||||
} else {
|
||||
display.getMetrics(mMetrics);
|
||||
}
|
||||
|
||||
screenWidth = mMetrics.widthPixels;
|
||||
screenHeight = mMetrics.heightPixels;
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变魅族的状态栏字体为黑色,要求FlyMe4以上
|
||||
*/
|
||||
private static void processFlyMe(boolean isLightStatusBar, Activity activity) {
|
||||
WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
|
||||
try {
|
||||
Class<?> instance = Class.forName("android.view.WindowManager$LayoutParams");
|
||||
int value = instance.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON").getInt(lp);
|
||||
Field field = instance.getDeclaredField("meizuFlags");
|
||||
field.setAccessible(true);
|
||||
int origin = field.getInt(lp);
|
||||
if (isLightStatusBar) {
|
||||
field.set(lp, origin | value);
|
||||
} else {
|
||||
field.set(lp, (~value) & origin);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变小米的状态栏字体颜色为黑色, 要求MIUI6以上 lightStatusBar为真时表示黑色字体
|
||||
*/
|
||||
private static void processMIUI(boolean lightStatusBar, Activity activity) {
|
||||
Class<? extends Window> clazz = activity.getWindow().getClass();
|
||||
try {
|
||||
int darkModeFlag;
|
||||
Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
|
||||
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
|
||||
darkModeFlag = field.getInt(layoutParams);
|
||||
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
|
||||
extraFlagField.invoke(activity.getWindow(), lightStatusBar ? darkModeFlag : 0, darkModeFlag);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置OPPO手机状态栏字体为黑色(colorOS3.0,6.0以下部分手机)
|
||||
*
|
||||
* @param lightStatusBar
|
||||
* @param activity
|
||||
*/
|
||||
private static final int SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT = 0x00000010;
|
||||
|
||||
private static void setOPPOStatusTextColor(boolean lightStatusBar, Activity activity) {
|
||||
Window window = activity.getWindow();
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
int vis = window.getDecorView().getSystemUiVisibility();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (lightStatusBar) {
|
||||
vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
} else {
|
||||
vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
if (lightStatusBar) {
|
||||
vis |= SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
|
||||
} else {
|
||||
vis &= ~SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
|
||||
}
|
||||
}
|
||||
window.getDecorView().setSystemUiVisibility(vis);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断手机是否是小米
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isMIUI() {
|
||||
return SYS_MIUI.equals(getSystem());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断手机是否是魅族
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isFlyme() {
|
||||
try {
|
||||
// Invoke Build.hasSmartBar()
|
||||
final Method method = Build.class.getMethod("hasSmartBar");
|
||||
return method != null;
|
||||
} catch (final Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态栏文字色值为深色调
|
||||
*
|
||||
* @param useDart 是否使用深色调
|
||||
* @param activity
|
||||
*/
|
||||
public static void setStatusTextColor(boolean useDart, Activity activity) {
|
||||
if (isFlyme()) {
|
||||
processFlyMe(useDart, activity);
|
||||
} else if (isMIUI()) {
|
||||
processMIUI(useDart, activity);
|
||||
} else if (Build.MANUFACTURER.equalsIgnoreCase("OPPO")) {
|
||||
//OPPO
|
||||
setOPPOStatusTextColor(useDart, activity);
|
||||
} else {
|
||||
if (useDart) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
}
|
||||
} else {
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
}
|
||||
activity.getWindow().getDecorView().findViewById(android.R.id.content).setPadding(0, 0, 0, navigationHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 作者:Loyea
|
||||
* 链接:https://www.jianshu.com/p/abd021c22728
|
||||
* 來源:简书
|
||||
* 简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
|
||||
*/
|
||||
public static void setAndroidNativeLightStatusBar(Activity activity, boolean dark) {
|
||||
View decor = activity.getWindow().getDecorView();
|
||||
if (dark) {
|
||||
decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
} else {
|
||||
// We want to change tint color to white again.
|
||||
// You can also record the flags in advance so that you can turn UI back completely if
|
||||
// you have set other flags before, such as translucent or full screen.
|
||||
decor.setSystemUiVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSystem() {
|
||||
String SYS = "";
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
|
||||
if (!TextUtils.isEmpty(getSystemProperty(KEY_MIUI_VERSION_CODE, ""))
|
||||
|| !TextUtils.isEmpty(getSystemProperty(KEY_MIUI_VERSION_NAME, ""))
|
||||
|| !TextUtils.isEmpty(getSystemProperty(KEY_MIUI_INTERNAL_STORAGE, ""))) {
|
||||
SYS = SYS_MIUI;//小米
|
||||
} else if (!TextUtils.isEmpty(getSystemProperty(KEY_EMUI_API_LEVEL, ""))
|
||||
|| !TextUtils.isEmpty(getSystemProperty(KEY_EMUI_VERSION, ""))
|
||||
|| !TextUtils.isEmpty(getSystemProperty(KEY_EMUI_CONFIG_HW_SYS_VERSION, ""))) {
|
||||
SYS = SYS_EMUI;//华为
|
||||
} else if (getMeizuFlymeOSFlag().toLowerCase().contains("flyme")) {
|
||||
SYS = SYS_FLYME;//魅族
|
||||
}
|
||||
return SYS;
|
||||
} else {
|
||||
try {
|
||||
Properties prop = new Properties();
|
||||
prop.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));
|
||||
if (prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null
|
||||
|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null
|
||||
|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null) {
|
||||
SYS = SYS_MIUI;//小米
|
||||
} else if (prop.getProperty(KEY_EMUI_API_LEVEL, null) != null
|
||||
|| prop.getProperty(KEY_EMUI_VERSION, null) != null
|
||||
|| prop.getProperty(KEY_EMUI_CONFIG_HW_SYS_VERSION, null) != null) {
|
||||
SYS = SYS_EMUI;//华为
|
||||
} else if (getMeizuFlymeOSFlag().toLowerCase().contains("flyme")) {
|
||||
SYS = SYS_FLYME;//魅族
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return SYS;
|
||||
} finally {
|
||||
return SYS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getSystemProperty(String key, String defaultValue) {
|
||||
try {
|
||||
Class<?> clz = Class.forName("android.os.SystemProperties");
|
||||
Method get = clz.getMethod("get", String.class, String.class);
|
||||
return (String) get.invoke(clz, key, defaultValue);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static String getMeizuFlymeOSFlag() {
|
||||
return getSystemProperty("ro.build.display.id", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 全屏模式下 针对刘海屏向下移动view
|
||||
*
|
||||
* @param context
|
||||
* @param view 需要设置padding的view
|
||||
*/
|
||||
public static void setStatusBarPadding(Context context, View view) {
|
||||
if (view != null) {
|
||||
view.setPadding(0, getStatusBarHeight(context), 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
app/src/main/java/com/info/sn/utils/SystemUtils.java
Normal file
24
app/src/main/java/com/info/sn/utils/SystemUtils.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package com.info.sn.utils;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SystemUtils {
|
||||
|
||||
public static boolean isMainProcessName(Context cxt, int pid) {
|
||||
String packageName = cxt.getPackageName();
|
||||
ActivityManager am = (ActivityManager) cxt.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
List<ActivityManager.RunningAppProcessInfo> runningApps = am.getRunningAppProcesses();
|
||||
if (runningApps == null) {
|
||||
return false;
|
||||
}
|
||||
for (ActivityManager.RunningAppProcessInfo procInfo : runningApps) {
|
||||
if (procInfo.pid == pid) {
|
||||
return procInfo.processName.equals(packageName);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ public class URLUtils {
|
||||
private static String TAG = URLUtils.class.getSimpleName();
|
||||
private Context mContext;
|
||||
private HashSet<String> baseURLList = new HashSet<>();
|
||||
private HashSet<String> nohttpURLList = new HashSet<>();
|
||||
|
||||
public URLUtils(Context context) {
|
||||
this.mContext = context;
|
||||
@@ -39,6 +40,7 @@ public class URLUtils {
|
||||
public void setBrowserList() {
|
||||
String whiteList = JGYUtils.getString(mContext.getContentResolver(), "DeselectBrowserArray");
|
||||
String homePage = JGYUtils.getString(mContext.getContentResolver(), "homepagURL");
|
||||
Log.e(TAG, "setBrowserList old: " + whiteList);
|
||||
|
||||
HashSet<String> URLList = new HashSet<>();
|
||||
if (!TextUtils.isEmpty(whiteList)){
|
||||
|
||||
Reference in New Issue
Block a user