version:
update:极光推送优化 fix: add:
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.mjsheng.myappstore.utils;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
@@ -8,6 +10,7 @@ import android.content.IntentFilter;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
@@ -43,8 +46,11 @@ import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class JGYUtils {
|
||||
private static final String TAG = JGYUtils.class.getSimpleName();
|
||||
|
||||
private static JGYUtils sInstance;
|
||||
private Context mContext;
|
||||
public static final String ROOT_URL = BuildConfig.ROOT_URL;
|
||||
@@ -586,11 +592,11 @@ public class JGYUtils {
|
||||
int versionCode = jsonObject.get("app_version_code").getAsInt();
|
||||
String packageName = jsonObject.get("app_package").getAsString();
|
||||
String app_name = jsonObject.get("app_name").getAsString();
|
||||
String app_id = jsonObject.get("app_id").getAsString();
|
||||
// String app_id = jsonObject.get("app_id").getAsString();
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("app_name", app_name);
|
||||
object.put("app_package", packageName);
|
||||
object.put("app_id", app_id);
|
||||
// object.put("app_id", app_id);
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageInfo packageInfo = null;
|
||||
try {
|
||||
@@ -839,4 +845,50 @@ public class JGYUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteScreenshots() {
|
||||
Log.e("File", "deleteScreenshots");
|
||||
String path = mContext.getExternalFilesDir("db").getAbsolutePath();
|
||||
File file = new File(path);
|
||||
File[] files = file.listFiles();
|
||||
for (File f : files) {
|
||||
if (f.isFile()) {
|
||||
Log.e("File", f.getAbsolutePath());
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 忽略电池优化
|
||||
*/
|
||||
private void ignoreBatteryOptimization(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
|
||||
PowerManager powerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName());
|
||||
// 判断当前APP是否有加入电池优化的白名单,如果没有,弹出加入电池优化的白名单的设置对话框。
|
||||
if (!hasIgnored) {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + context.getPackageName()));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void KillOTA() {
|
||||
ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
manager.killBackgroundProcesses("com.adups.fota");
|
||||
CmdUtil.execute("am force-stop " + "com.adups.fota");
|
||||
}
|
||||
|
||||
public void openOTA() {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
/**知道要跳转应用的包命与目标Activity*/
|
||||
ComponentName componentName = new ComponentName("com.adups.fota", "com.adups.fota.GoogleOtaClient");
|
||||
intent.setComponent(componentName);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1155,21 +1155,6 @@ public class Utils {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public static void KillOTA(Context context) {
|
||||
ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
manager.killBackgroundProcesses("com.adups.fota");
|
||||
CmdUtil.execute("am force-stop " + "com.adups.fota");
|
||||
}
|
||||
|
||||
public static void openOTA(Context context) {
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||
/**知道要跳转应用的包命与目标Activity*/
|
||||
ComponentName componentName = new ComponentName("com.adups.fota", "com.adups.fota.GoogleOtaClient");
|
||||
intent.setComponent(componentName);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static String getAndroiodScreenProperty(Context context) {
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics dm = new DisplayMetrics();
|
||||
|
||||
Reference in New Issue
Block a user