style: 统一日志级别并清理字符串三元与静默 catch
将 18 个文件中的 Log.d/Log.i/Log.w 统一为 Log.e;6 处字符串三元改为 if/else;3 处静默 catch 补充日志,并修正 SPUtils 打印堆栈数组地址的问题。 验证::app:assembleOfficialZhanRuiRelease 编译通过。
This commit is contained in:
1 parent
7a4e03fdde
commit
e62d0443ec
24 files changed
+154
-123
No files matched your search
@@ -100,7 +100,7 @@ public class BaseApplication extends Application {
|
||||
|
||||
private void utilsInint() {
|
||||
String rootDir = MMKV.initialize(this);
|
||||
Log.i(TAG, "mmkv root: " + rootDir);
|
||||
Log.e(TAG, "mmkv root: " + rootDir);
|
||||
|
||||
PushManager.init(this);
|
||||
aliyunPushInit();
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class BaseFragment extends Fragment {
|
||||
public boolean prepareFetchData(boolean forceUpdate) {
|
||||
if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
|
||||
if (!isDataInitiated) {
|
||||
Log.d(TAG, "lazyLoad trigger: " + getClass().getSimpleName());
|
||||
Log.e(TAG, "lazyLoad trigger: " + getClass().getSimpleName());
|
||||
onLazyLoad();
|
||||
}
|
||||
// 只在非强制刷新时标记为已初始化,保证首屏只渲染一次
|
||||
|
||||
@@ -171,6 +171,7 @@ public class DeviceIdUtils {
|
||||
return res1.toString();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log.e(TAG, "getMacAddress: " + ex.getMessage());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.fuying.sn.core.common.gson;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -9,9 +11,14 @@ import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class IntegerDefault0Adapter implements JsonSerializer<Integer>, JsonDeserializer<Integer> {
|
||||
|
||||
private static final String TAG = "IntegerDefault0Adapter";
|
||||
|
||||
@Override
|
||||
public Integer deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
@@ -20,6 +27,7 @@ public class IntegerDefault0Adapter implements JsonSerializer<Integer>, JsonDese
|
||||
return 0;
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
Log.e(TAG, "deserialize: " + ignore.getMessage());
|
||||
}
|
||||
try {
|
||||
return json.getAsInt();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GlideLoadUtils {
|
||||
if (context != null) {
|
||||
Glide.with(context).load(url).centerCrop().error(defaultImage).placeholder(imageView.getDrawable()).dontAnimate().into(imageView);
|
||||
} else {
|
||||
Log.i(TAG, "Picture loading failed,context is null");
|
||||
Log.e(TAG, "Picture loading failed,context is null");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -423,7 +423,7 @@ public class CacheHelper {
|
||||
DiskLruCache.Editor edit = mDiskLruCache.edit(hashKey);
|
||||
//edit maybe null :the entry is editing
|
||||
if (edit == null) {
|
||||
Log.w(TAG, "the entry spcified key:" + hashKey + " is editing by other . ");
|
||||
Log.e(TAG, "the entry spcified key:" + hashKey + " is editing by other . ");
|
||||
}
|
||||
return edit;
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -114,6 +114,7 @@ public class SPUtils {
|
||||
Class clz = SharedPreferences.Editor.class;
|
||||
return clz.getMethod("apply");
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.e(TAG, "findApplyMethod: " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -125,12 +126,12 @@ public class SPUtils {
|
||||
public static boolean apply(SharedPreferences.Editor editor) {
|
||||
try {
|
||||
if (sApplyMethod != null) {
|
||||
Log.i(TAG, "apply: false");
|
||||
Log.e(TAG, "apply: false");
|
||||
sApplyMethod.invoke(editor);
|
||||
return false;
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
|
||||
Log.e(TAG, "apply: " + e.getStackTrace());
|
||||
Log.e(TAG, "apply: " + e.getMessage());
|
||||
}
|
||||
return editor.commit();
|
||||
}
|
||||
|
||||
@@ -200,7 +200,10 @@ public class RepeatRequestInterceptor implements Interceptor {
|
||||
|
||||
private static void log(String action, String requestKey, Request request, String bodyText) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
String body = bodyText.length() > MAX_LOG_BODY_LENGTH ? "-too long" : bodyText;
|
||||
String body = bodyText;
|
||||
if (bodyText.length() > MAX_LOG_BODY_LENGTH) {
|
||||
body = "-too long";
|
||||
}
|
||||
Log.e("REPEAT-REQUEST", action + requestKey + " Method @" + request.method()
|
||||
+ " --- " + " URL = " + request.url().encodedPath() + "\t" + body);
|
||||
} else {
|
||||
|
||||
@@ -159,7 +159,7 @@ public class TimeConfigRepository {
|
||||
try {
|
||||
mSnInfo = mGson.fromJson(snInfoJson, new TypeToken<SnInfo>() {
|
||||
}.getType());
|
||||
Log.d(TAG, "Loaded SN info from cache.");
|
||||
Log.e(TAG, "Loaded SN info from cache.");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load SN info from cache: " + e.getMessage());
|
||||
mMMKV.remove(SN_INFO);
|
||||
@@ -171,7 +171,7 @@ public class TimeConfigRepository {
|
||||
try {
|
||||
mSnTimeControlInfo = mGson.fromJson(snJson, new TypeToken<SnTimeControlInfo>() {
|
||||
}.getType());
|
||||
Log.d(TAG, "Loaded SN local config from cache.");
|
||||
Log.e(TAG, "Loaded SN local config from cache.");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load SN local config: " + e.getMessage());
|
||||
mMMKV.remove(SN_TIME_CONTROL_INFO);
|
||||
@@ -189,7 +189,7 @@ public class TimeConfigRepository {
|
||||
mAppTimeControlList.add(info);
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "Loaded App config from Room, size=" + mAppTimeControlList.size());
|
||||
Log.e(TAG, "Loaded App config from Room, size=" + mAppTimeControlList.size());
|
||||
return; // Room 有数据则优先,MMKV 仅作兜底
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public class TimeConfigRepository {
|
||||
try {
|
||||
mAppTimeControlList = mGson.fromJson(appJson, new TypeToken<List<AppTimeControlInfo>>() {
|
||||
}.getType());
|
||||
Log.d(TAG, "Loaded App local config from MMKV cache.");
|
||||
Log.e(TAG, "Loaded App local config from MMKV cache.");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to load App local config: " + e.getMessage());
|
||||
mMMKV.remove(APP_TIME_CONTROL_INFO);
|
||||
@@ -219,7 +219,7 @@ public class TimeConfigRepository {
|
||||
Observable<Boolean> sn =
|
||||
DeviceRepository.getInstance().getSnTimeControlObservable()
|
||||
.map(resp -> {
|
||||
Log.d(TAG, "fetchConfigOnce: sn resp=" + resp);
|
||||
Log.e(TAG, "fetchConfigOnce: sn resp=" + resp);
|
||||
handleSnResponse(resp);
|
||||
// 业务状态码中仅将 400 转为异常重试;网络等异常也会进入该路重试流程。
|
||||
if (resp.code == 400) {
|
||||
@@ -230,7 +230,7 @@ public class TimeConfigRepository {
|
||||
Observable<Boolean> app =
|
||||
DeviceRepository.getInstance().getAppTimeControlInfoObservable()
|
||||
.map(resp -> {
|
||||
Log.d(TAG, "fetchConfigOnce: app resp=" + resp);
|
||||
Log.e(TAG, "fetchConfigOnce: app resp=" + resp);
|
||||
handleAppResponse(resp);
|
||||
// 业务状态码中仅将 400 转为异常重试;网络等异常也会进入该路重试流程。
|
||||
if (resp.code == 400) {
|
||||
@@ -241,7 +241,7 @@ public class TimeConfigRepository {
|
||||
Observable<Boolean> snInfo =
|
||||
DeviceRepository.getInstance().getSnInfoControl()
|
||||
.map(resp -> {
|
||||
Log.d(TAG, "fetchConfigOnce: snInfo resp=" + resp);
|
||||
Log.e(TAG, "fetchConfigOnce: snInfo resp=" + resp);
|
||||
handleSnInfoResponse(resp);
|
||||
return true;
|
||||
});
|
||||
@@ -264,7 +264,7 @@ public class TimeConfigRepository {
|
||||
if (attempt > MAX_RETRY_COUNT) {
|
||||
throw error;
|
||||
}
|
||||
Log.w(TAG, "Config fetch failed, scheduling retry " + attempt
|
||||
Log.e(TAG, "Config fetch failed, scheduling retry " + attempt
|
||||
+ "/" + MAX_RETRY_COUNT, error);
|
||||
return attempt;
|
||||
})
|
||||
@@ -337,7 +337,7 @@ public class TimeConfigRepository {
|
||||
mSnTimeControlInfo = info;
|
||||
mSnControlFetched = true;
|
||||
mMMKV.encode(SN_TIME_CONTROL_INFO, GsonUtils.toJSONString(mSnTimeControlInfo));
|
||||
Log.d(TAG, "SN config applied: " + info);
|
||||
Log.e(TAG, "SN config applied: " + info);
|
||||
if (mListener != null) {
|
||||
mListener.onSnConfigUpdated(mSnTimeControlInfo);
|
||||
}
|
||||
@@ -373,7 +373,7 @@ public class TimeConfigRepository {
|
||||
mMMKV.encode(APP_TIME_CONTROL_INFO, GsonUtils.toJSONString(mAppTimeControlList));
|
||||
// 同步写入 Room,保证重启后立即恢复
|
||||
saveAppControlsToDb(mAppTimeControlList);
|
||||
Log.d(TAG, "App config applied, size=" + mAppTimeControlList.size());
|
||||
Log.e(TAG, "App config applied, size=" + mAppTimeControlList.size());
|
||||
if (mListener != null) {
|
||||
mListener.onAppConfigUpdated(mAppTimeControlList);
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class TimeConfigRepository {
|
||||
if (!entities.isEmpty()) {
|
||||
mDao.insertControls(entities);
|
||||
}
|
||||
Log.d(TAG, "Saved App controls to Room, size=" + entities.size());
|
||||
Log.e(TAG, "Saved App controls to Room, size=" + entities.size());
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to save App controls to Room: " + e.getMessage());
|
||||
}
|
||||
|
||||
@@ -450,7 +450,11 @@ public class UsageFragment extends BaseMvvmFragment<UsageViewModel, FragmentUsag
|
||||
}
|
||||
|
||||
private void onError(Throwable e) {
|
||||
ToastUtil.show(e != null && e.getMessage() != null ? e.getMessage() : getString(R.string.open_app_fail));
|
||||
String message = getString(R.string.open_app_fail);
|
||||
if (e != null && e.getMessage() != null) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
ToastUtil.show(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -511,7 +515,10 @@ public class UsageFragment extends BaseMvvmFragment<UsageViewModel, FragmentUsag
|
||||
return "";
|
||||
}
|
||||
String name = labels.get(index);
|
||||
return name.length() > 8 ? name.substring(0, 8) + "..." : name;
|
||||
if (name.length() > 8) {
|
||||
return name.substring(0, 8) + "...";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,11 @@ public class UsageDetailActivity extends BaseMvvmActivity<UsageDetailViewModel,
|
||||
}
|
||||
|
||||
private void onError(Throwable e) {
|
||||
ToastUtil.show(e != null && e.getMessage() != null ? e.getMessage() : getString(R.string.open_app_fail));
|
||||
String message = getString(R.string.open_app_fail);
|
||||
if (e != null && e.getMessage() != null) {
|
||||
message = e.getMessage();
|
||||
}
|
||||
ToastUtil.show(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,11 @@ public class UsageDetailViewModel extends BaseViewModel {
|
||||
Disposable disposable = mRepository.getAppUseTime(queryType, isAll)
|
||||
.subscribe(
|
||||
resp -> {
|
||||
Log.e(TAG, "loadAppUseTime: " + (resp == null ? "null" : resp));
|
||||
if (resp == null) {
|
||||
Log.e(TAG, "loadAppUseTime: null");
|
||||
} else {
|
||||
Log.e(TAG, "loadAppUseTime: " + resp);
|
||||
}
|
||||
appUseTime.setValue(resp);
|
||||
loading.setValue(false);
|
||||
},
|
||||
|
||||
@@ -38,7 +38,7 @@ public class InstallResultReceiver extends BroadcastReceiver {
|
||||
// Set<String> ks = extras.keySet();
|
||||
// Iterator<String> iterator = ks.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// Log.d("KEY", iterator.next());
|
||||
// Log.e("KEY", iterator.next());
|
||||
// }
|
||||
String STATUS = intent.getStringExtra(PackageInstaller.EXTRA_STATUS);
|
||||
String PACKAGE_NAME = intent.getStringExtra(PackageInstaller.EXTRA_PACKAGE_NAME);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class RunningAppManager {
|
||||
|
||||
globalRemainingTime = mMMKV.decodeLong(GLOBAL_REMAINING_TIME_KEY, 0);
|
||||
String remainsTimeJson = mMMKV.decodeString(RemainingTimeMap, "");
|
||||
Log.i(TAG, "remainsTimeJson: " + remainsTimeJson);
|
||||
Log.e(TAG, "remainsTimeJson: " + remainsTimeJson);
|
||||
Gson gson = new Gson();
|
||||
Type remainsTimeType = new TypeToken<HashMap<String, AppRunTimeBean>>() {
|
||||
}.getType();
|
||||
@@ -134,7 +134,7 @@ public class RunningAppManager {
|
||||
}
|
||||
|
||||
String globalUsageTimeJson = mMMKV.decodeString(GlobalUsageTimeMap, "");
|
||||
Log.i(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
||||
Log.e(TAG, "globalUsageTimeJson: " + globalUsageTimeJson);
|
||||
Type globalUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||
}.getType();
|
||||
HashMap<String, AppUsageTime> appUsageTimeHashMap = gson.fromJson(globalUsageTimeJson, globalUsageTimeType);
|
||||
@@ -143,7 +143,7 @@ public class RunningAppManager {
|
||||
}
|
||||
|
||||
String allAppUsageTimeJson = mMMKV.decodeString(AllApplUsageTimeMap, "");
|
||||
Log.i(TAG, "allAppUsageTimeJson: " + globalUsageTimeJson);
|
||||
Log.e(TAG, "allAppUsageTimeJson: " + globalUsageTimeJson);
|
||||
Type allAppUsageTimeType = new TypeToken<HashMap<String, AppUsageTime>>() {
|
||||
}.getType();
|
||||
HashMap<String, AppUsageTime> allAppUsageTimeHashMap = gson.fromJson(allAppUsageTimeJson, allAppUsageTimeType);
|
||||
@@ -192,13 +192,13 @@ public class RunningAppManager {
|
||||
JgyUtils.getInstance().killPackage("org.chromium.browser");
|
||||
}
|
||||
String appPackageName = getAppPackageName();
|
||||
Log.d(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||
Log.d(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
||||
Log.e(TAG, "checkForegroundAppName: topPackage = " + topPackage);
|
||||
Log.e(TAG, "checkForegroundAppName: appPackageName = " + appPackageName);
|
||||
|
||||
if (!SystemUtils.isScreenOn(mContext)) {
|
||||
Log.d(TAG, "checkForegroundAppName: isScreenOn = false");
|
||||
Log.e(TAG, "checkForegroundAppName: isScreenOn = false");
|
||||
if (!TextUtils.isEmpty(appPackageName)) {
|
||||
Log.d(TAG, "checkForegroundAppName: isEmpty = false");
|
||||
Log.e(TAG, "checkForegroundAppName: isEmpty = false");
|
||||
// TODO: 2025/11/11 不确定是否因为这里导致网络请求频繁
|
||||
// AppUsageReporter.getInstance().sendCloseApp(appPackageName, new RequestCallbacks.CompleteCallback() {
|
||||
// @Override
|
||||
@@ -216,11 +216,11 @@ public class RunningAppManager {
|
||||
if (!TextUtils.isEmpty(appPackageName)) {
|
||||
if (!topPackage.equals(appPackageName)) {
|
||||
//切换出去了
|
||||
Log.i(TAG, "checkForegroundAppName: 切换应用1:" + topPackage);
|
||||
Log.e(TAG, "checkForegroundAppName: 切换应用1:" + topPackage);
|
||||
DeviceSyncGateways.get().reportAppClose(appPackageName, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i(TAG, "onComplete: ");
|
||||
Log.e(TAG, "onComplete: ");
|
||||
DeviceSyncGateways.get().refreshAppTimeControl();
|
||||
DeviceSyncGateways.get().refreshMachineTimeControl();
|
||||
}
|
||||
@@ -236,23 +236,23 @@ public class RunningAppManager {
|
||||
}
|
||||
}
|
||||
mMMKV.encode(RUNNING_APP_PACKAGENAME, "");
|
||||
Log.d(TAG, "checkForegroundAppName: allow: " + topPackage);
|
||||
Log.e(TAG, "checkForegroundAppName: allow: " + topPackage);
|
||||
return;
|
||||
}
|
||||
//如果appPackageName 为空则topPackage是才打开
|
||||
if (TextUtils.isEmpty(appPackageName)) {
|
||||
Log.d(TAG, "checkForegroundAppName: open: " + topPackage);
|
||||
Log.e(TAG, "checkForegroundAppName: open: " + topPackage);
|
||||
recordPackageOpenTime(topPackage);
|
||||
AppUsedTimeUtils.getInstance().setApp_package(topPackage);
|
||||
AppUsedTimeUtils.getInstance().setStart_time(System.currentTimeMillis() / 1000);
|
||||
return;
|
||||
}
|
||||
long onClickTime = getOnClickTime();
|
||||
Log.i(TAG, "checkForegroundAppName: getAppPackageName = " + appPackageName);
|
||||
Log.e(TAG, "checkForegroundAppName: getAppPackageName = " + appPackageName);
|
||||
if (appPackageName.equals(topPackage)) {
|
||||
Log.i(TAG, "checkForegroundAppName: 没有切换应用");
|
||||
Log.e(TAG, "checkForegroundAppName: 没有切换应用");
|
||||
if (inControlTime(appPackageName)) {
|
||||
Log.i(TAG, "checkForegroundAppName: 没有剩余时间1");
|
||||
Log.e(TAG, "checkForegroundAppName: 没有剩余时间1");
|
||||
// removeTask(topPackage);
|
||||
DeviceSyncGateways.get().refreshAppTimeControl();
|
||||
DeviceSyncGateways.get().refreshMachineTimeControl();
|
||||
@@ -260,11 +260,11 @@ public class RunningAppManager {
|
||||
killApp();
|
||||
gotoLauncher();
|
||||
} else {
|
||||
Log.i(TAG, "checkForegroundAppName: 没有管控");
|
||||
Log.e(TAG, "checkForegroundAppName: 没有管控");
|
||||
reduceAppRemainingTime(topPackage, 1);
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "checkForegroundAppName: 切换应用2:" + topPackage);
|
||||
Log.e(TAG, "checkForegroundAppName: 切换应用2:" + topPackage);
|
||||
DeviceSyncGateways.get().reportAppClose(appPackageName, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -280,7 +280,7 @@ public class RunningAppManager {
|
||||
// AppUsageReporter.getInstance().sendRunningApp();
|
||||
AppUsedTimeUtils.getInstance().setStart_time(onClickTime);
|
||||
if (inControlTime(appPackageName)) {
|
||||
Log.i(TAG, "checkForegroundAppName: 没有剩余时间2");
|
||||
Log.e(TAG, "checkForegroundAppName: 没有剩余时间2");
|
||||
// removeTask(topPackage);
|
||||
killApp();
|
||||
JgyUtils.getInstance().killPackage(appPackageName);
|
||||
@@ -289,7 +289,7 @@ public class RunningAppManager {
|
||||
DeviceSyncGateways.get().refreshMachineTimeControl();
|
||||
} else {
|
||||
recordPackageOpenTime(topPackage);
|
||||
Log.i(TAG, "checkForegroundAppName: 没有管控2");
|
||||
Log.e(TAG, "checkForegroundAppName: 没有管控2");
|
||||
}
|
||||
}
|
||||
saveAppRemainingTime();
|
||||
@@ -342,7 +342,7 @@ public class RunningAppManager {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
Log.i(TAG, "TimeChangedReceiver:" + action);
|
||||
Log.e(TAG, "TimeChangedReceiver:" + action);
|
||||
long time = System.currentTimeMillis();
|
||||
String finaWayDate = sdf.format(time);
|
||||
Log.e(TAG, "onReceive: finaWayDate = " + finaWayDate);
|
||||
@@ -400,7 +400,7 @@ public class RunningAppManager {
|
||||
|
||||
for (ActivityManager.RecentTaskInfo info : list) {
|
||||
if (info.realActivity != null) {
|
||||
Log.i(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
Log.e(TAG, "removeAllTask: " + info.realActivity.getPackageName());
|
||||
//排除自身
|
||||
if (BuildConfig.APPLICATION_ID.equals(info.realActivity.getPackageName())) {
|
||||
continue;
|
||||
@@ -410,7 +410,7 @@ public class RunningAppManager {
|
||||
ActivityManagerNative.getDefault().removeTask(info.id);
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.i(TAG, "removeAllTask: " + e.getMessage());
|
||||
Log.e(TAG, "removeAllTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,9 +425,9 @@ public class RunningAppManager {
|
||||
ActivityManagerNative.getDefault().removeTask(taskMap.get(packageName));
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
Log.i(TAG, "removeTask: " + e.getMessage());
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
} catch (NullPointerException e) {
|
||||
Log.i(TAG, "removeTask: " + e.getMessage());
|
||||
Log.e(TAG, "removeTask: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ public class RunningAppManager {
|
||||
return ActivityTaskManager.getService().getRecentTasks(numTasks,
|
||||
RECENT_IGNORE_UNAVAILABLE, userId).getList();
|
||||
} catch (RemoteException e) {
|
||||
Log.i(TAG, "Failed to get recent tasks " + e);
|
||||
Log.e(TAG, "Failed to get recent tasks " + e);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -546,7 +546,7 @@ public class RunningAppManager {
|
||||
appRunTimeBean.setAppRunTime(appTimeControl.getToday_time());
|
||||
mRemainingTimeMap.put(appTimeControl.getApp_package(), appRunTimeBean);
|
||||
}
|
||||
Log.i(TAG, "syncAppRemainingTime: Finish" + mRemainingTimeMap);
|
||||
Log.e(TAG, "syncAppRemainingTime: Finish" + mRemainingTimeMap);
|
||||
}
|
||||
|
||||
/*同步所有应用使用时间*/
|
||||
@@ -632,7 +632,7 @@ public class RunningAppManager {
|
||||
return;
|
||||
}
|
||||
int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||
Log.i(TAG, "reduceAppRemainingTime: isControl = " + isControl);
|
||||
Log.e(TAG, "reduceAppRemainingTime: isControl = " + isControl);
|
||||
//家长管控关闭始终可用
|
||||
if (isControl == 0) {
|
||||
return;
|
||||
@@ -688,7 +688,7 @@ public class RunningAppManager {
|
||||
}
|
||||
mAllAppUsageTime.put(pkg, singleAppUsageTime);
|
||||
Log.e(TAG, "reduceAppRemainingTime: mAllAppUsageTime = " + mAllAppUsageTime.toString());
|
||||
Log.i(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
||||
Log.e(TAG, "reduceAppRemainingTime: " + appTimeControl.getToday_time());
|
||||
long remainingTime = appTimeControl.getToday_time() - time;
|
||||
if (remainingTime < 0) {
|
||||
remainingTime = 0;
|
||||
@@ -703,7 +703,7 @@ public class RunningAppManager {
|
||||
if (machineControl == null) {
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "reduceAppRemainingTime: " + machineControl.getToday_time());
|
||||
Log.e(TAG, "reduceAppRemainingTime: " + machineControl.getToday_time());
|
||||
long remainingTime = machineControl.getToday_time() - time;
|
||||
if (remainingTime < 0) {
|
||||
remainingTime = 0;
|
||||
@@ -775,13 +775,13 @@ public class RunningAppManager {
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean inControlTime2(String pkg) {
|
||||
Log.i(TAG, "inControlTime: pkg = " + pkg);
|
||||
Log.e(TAG, "inControlTime: pkg = " + pkg);
|
||||
if (allowPackage.contains(pkg)) {
|
||||
Log.i(TAG, "inControlTime: allow = " + pkg);
|
||||
Log.e(TAG, "inControlTime: allow = " + pkg);
|
||||
return false;
|
||||
}
|
||||
int isControl = Settings.System.getInt(mContext.getContentResolver(), CommonConfig.KEY_IS_CONTROL, 1);
|
||||
Log.i(TAG, "inControlTime: isControl = " + isControl);
|
||||
Log.e(TAG, "inControlTime: isControl = " + isControl);
|
||||
//家长管控关闭 始终可用
|
||||
if (isControl == 0) {
|
||||
return false;
|
||||
@@ -823,7 +823,7 @@ public class RunningAppManager {
|
||||
boolean inControlTime = inControlTime(machineControl, appTimeControl);
|
||||
//判断是否在时间段内
|
||||
if (inControlTime) {
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.getTime_part().toString());
|
||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.getTime_part().toString());
|
||||
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
||||
Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
|
||||
return true;
|
||||
@@ -848,7 +848,7 @@ public class RunningAppManager {
|
||||
boolean inControlTime = inControlTime(machineControl, appTimeControl);
|
||||
//判断是否在时间段内
|
||||
if (inControlTime) {
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.getTime_part().toString());
|
||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.getTime_part().toString());
|
||||
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
||||
Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
|
||||
return true;
|
||||
@@ -879,7 +879,7 @@ public class RunningAppManager {
|
||||
boolean inControlTime = inControlTime(machineControl, appTimeControl);
|
||||
//判断是否在时间段内
|
||||
if (inControlTime) {
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.getTime_part().toString());
|
||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + appTimeControl.getTime_part().toString());
|
||||
ToastUtil.show("该应用" + partTime2String(appTimeControl));
|
||||
Log.e(TAG, "inControlTime: " + "该应用" + partTime2String(appTimeControl));
|
||||
return true;
|
||||
@@ -917,7 +917,7 @@ public class RunningAppManager {
|
||||
} else {
|
||||
boolean inControlTime = inControlTime(machineControl);
|
||||
if (inControlTime) {
|
||||
Log.i(TAG, "inControlTime: " + "应用在管控时间段不能打开" + machineControl.getTime_part().toString());
|
||||
Log.e(TAG, "inControlTime: " + "应用在管控时间段不能打开" + machineControl.getTime_part().toString());
|
||||
ToastUtil.show("该应用" + partTime2String(machineControl));
|
||||
}
|
||||
return inControlTime;
|
||||
@@ -969,7 +969,7 @@ public class RunningAppManager {
|
||||
if (havaConfigure) {//app有单独配置的情况
|
||||
//有单独设置 不管是分类整机还是其他都是这个设置
|
||||
AppTimeControl appTimeControl = TimeControlManager.getInstance().getAppTimeControl(pkg);
|
||||
Log.d(TAG, "inControlTime: appTimeControl = " + appTimeControl);
|
||||
Log.e(TAG, "inControlTime: appTimeControl = " + appTimeControl);
|
||||
if (appTimeControl.getIs_control() == 0) {//先判断是否被禁用
|
||||
Log.e(TAG, "inControlTime: appTimeControl " + "应用已被禁用");
|
||||
ToastUtil.show("应用已被禁用");
|
||||
|
||||
@@ -79,13 +79,13 @@ public final class AndroidSettingsWriter {
|
||||
boolean serverVerified = TextUtils.equals(serverValue, value);
|
||||
|
||||
if (serverVerified) {
|
||||
Log.d(TAG, "putString succeeded via SettingsProvider for " + namespace + "/" + name
|
||||
Log.e(TAG, "putString succeeded via SettingsProvider for " + namespace + "/" + name
|
||||
+ " (serverVerified=true)");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 3. 服务端校验未通过或 result 为空时,退回 directPutString 直接写入
|
||||
Log.w(TAG, "putString via provider failed for " + namespace + "/" + name
|
||||
Log.e(TAG, "putString via provider failed for " + namespace + "/" + name
|
||||
+ " (result=" + result + ", serverValue=" + serverValue + "), fallback to direct put");
|
||||
boolean directOk = directPutString(targetContext.getContentResolver(), namespace, name, value);
|
||||
|
||||
@@ -93,7 +93,7 @@ public final class AndroidSettingsWriter {
|
||||
String readBackDirect = readSetting(targetContext.getContentResolver(), namespace, name);
|
||||
boolean directVerified = TextUtils.equals(readBackDirect, value);
|
||||
|
||||
Log.d(TAG, "directPutString for " + namespace + "/" + name + " (directOk=" + directOk
|
||||
Log.e(TAG, "directPutString for " + namespace + "/" + name + " (directOk=" + directOk
|
||||
+ ", verified=" + directVerified + ")");
|
||||
return directOk || directVerified;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public final class AndroidSettingsWriter {
|
||||
return Settings.System.getString(cr, name);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Log.w(TAG, "readSetting failed for " + namespace + "/" + name + ": " + t);
|
||||
Log.e(TAG, "readSetting failed for " + namespace + "/" + name + ": " + t);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public final class AndroidSettingsWriter {
|
||||
try {
|
||||
result = context.getContentResolver().call(SETTINGS_URI, "PUT_" + namespace, name, arg);
|
||||
} catch (Throwable t) {
|
||||
Log.w(TAG, "callSettingsPut ContentResolver.call failed: " + t);
|
||||
Log.e(TAG, "callSettingsPut ContentResolver.call failed: " + t);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -171,7 +171,7 @@ public final class AndroidSettingsWriter {
|
||||
try {
|
||||
result = context.getContentResolver().call(SETTINGS_URI, "GET_" + namespace, name, arg);
|
||||
} catch (Throwable t) {
|
||||
Log.w(TAG, "callSettingsGet ContentResolver.call failed: " + t);
|
||||
Log.e(TAG, "callSettingsGet ContentResolver.call failed: " + t);
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
@@ -227,10 +227,10 @@ public final class AndroidSettingsWriter {
|
||||
} catch (Throwable t) {
|
||||
Throwable root = t instanceof java.lang.reflect.InvocationTargetException
|
||||
&& t.getCause() != null ? t.getCause() : t;
|
||||
Log.w(TAG, "invokeProviderCall " + callMethod + " failed via " + m.getName() + ": " + root);
|
||||
Log.e(TAG, "invokeProviderCall " + callMethod + " failed via " + m.getName() + ": " + root);
|
||||
}
|
||||
}
|
||||
Log.w(TAG, "invokeProviderCall: no matching call overload on " + provider.getClass().getName());
|
||||
Log.e(TAG, "invokeProviderCall: no matching call overload on " + provider.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -310,14 +310,14 @@ public final class AndroidSettingsWriter {
|
||||
m.setAccessible(true);
|
||||
Object provider = m.invoke(cr, args);
|
||||
if (provider != null) {
|
||||
Log.d(TAG, "putString: acquired via " + m.getName()
|
||||
Log.e(TAG, "putString: acquired via " + m.getName()
|
||||
+ java.util.Arrays.toString(types) + " slots=" + combo[0] + "/" + combo[1]);
|
||||
return provider;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Throwable root = t instanceof java.lang.reflect.InvocationTargetException
|
||||
&& t.getCause() != null ? t.getCause() : t;
|
||||
Log.w(TAG, "putString: " + m.getName() + " slots=" + combo[0]
|
||||
Log.e(TAG, "putString: " + m.getName() + " slots=" + combo[0]
|
||||
+ "/" + combo[1] + " failed: " + root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,11 +23,11 @@ public class CmdUtil {
|
||||
* @return 结果
|
||||
*/
|
||||
public static Result execute(String command) {
|
||||
Log.i(TAG, "execute() command = " + command);
|
||||
Log.e(TAG, "execute() command = " + command);
|
||||
Result result = new Result();
|
||||
|
||||
if (TextUtils.isEmpty(command)) {
|
||||
Log.w(TAG, "WARNING: command should not be null or empty");
|
||||
Log.e(TAG, "WARNING: command should not be null or empty");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CmdUtil {
|
||||
result.code = process.waitFor();
|
||||
result.success = readBuffer(new BufferedReader(new InputStreamReader(process.getInputStream())));
|
||||
result.error = readBuffer(new BufferedReader(new InputStreamReader(process.getErrorStream())));
|
||||
Log.i(TAG, "result = " + result);
|
||||
Log.e(TAG, "result = " + result);
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
Log.e(TAG, ioe.getMessage());
|
||||
|
||||
@@ -302,7 +302,7 @@ public class JgyUtils {
|
||||
field.setAccessible(true);
|
||||
Object sProviderInstance = field.get(null);
|
||||
if (sProviderInstance != null) {
|
||||
Log.i(TAG, "sProviderInstance isn't null");
|
||||
Log.e(TAG, "sProviderInstance isn't null");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class JgyUtils {
|
||||
} else if (sdkInt == 22) {
|
||||
getProviderClassMethod = factoryClass.getDeclaredMethod("getFactoryClass");
|
||||
} else {
|
||||
Log.i(TAG, "Don't need to Hook WebView");
|
||||
Log.e(TAG, "Don't need to Hook WebView");
|
||||
return;
|
||||
}
|
||||
getProviderClassMethod.setAccessible(true);
|
||||
@@ -341,12 +341,12 @@ public class JgyUtils {
|
||||
|
||||
if (sProviderInstance != null) {
|
||||
field.set("sProviderInstance", sProviderInstance);
|
||||
Log.i(TAG, "Hook success!");
|
||||
Log.e(TAG, "Hook success!");
|
||||
} else {
|
||||
Log.i(TAG, "Hook failed!");
|
||||
Log.e(TAG, "Hook failed!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.w(TAG, e);
|
||||
Log.e(TAG, "hookWebView: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -483,27 +483,27 @@ public class JgyUtils {
|
||||
}
|
||||
|
||||
// synchronized public static int getInt(ContentResolver cr, String name, int def) {
|
||||
// Log.i(TAG, "getInt: " + name);
|
||||
// Log.e(TAG, "getInt: " + name);
|
||||
// return Settings.System.getInt(cr, name, def);
|
||||
// }
|
||||
//
|
||||
// synchronized public static int getInt(ContentResolver cr, String name) throws Settings.SettingNotFoundException {
|
||||
// Log.i(TAG, "getInt: " + name);
|
||||
// Log.e(TAG, "getInt: " + name);
|
||||
// return Settings.System.getInt(cr, name);
|
||||
// }
|
||||
//
|
||||
// synchronized public static String getString(ContentResolver cr, String name) {
|
||||
// Log.i(TAG, "getString: " + name);
|
||||
// Log.e(TAG, "getString: " + name);
|
||||
// return Settings.System.getString(cr, name);
|
||||
// }
|
||||
//
|
||||
// synchronized public static boolean putInt(ContentResolver cr, String name, int value) {
|
||||
// Log.i(TAG, "putInt: " + "name = " + name + ", value = " + value);
|
||||
// Log.e(TAG, "putInt: " + "name = " + name + ", value = " + value);
|
||||
// return Settings.System.putInt(cr, name, value);
|
||||
// }
|
||||
//
|
||||
// synchronized public static boolean putString(ContentResolver cr, String name, String value) {
|
||||
// Log.i(TAG, "putString: " + "name = " + name + ", value = " + value);
|
||||
// Log.e(TAG, "putString: " + "name = " + name + ", value = " + value);
|
||||
// return Settings.System.putString(cr, name, value);
|
||||
// }
|
||||
|
||||
@@ -563,7 +563,7 @@ public class JgyUtils {
|
||||
// 定义回调
|
||||
Consumer<Boolean> callback = successful -> {
|
||||
if (successful) {
|
||||
Log.i(TAG, "setRoleHolderAsUser: Successfully set " + packageName + " as " + roleName);
|
||||
Log.e(TAG, "setRoleHolderAsUser: Successfully set " + packageName + " as " + roleName);
|
||||
} else {
|
||||
Log.e(TAG, "setRoleHolderAsUser: Failed to set " + packageName + " as " + roleName + ". Check system logs.");
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public class JgyUtils {
|
||||
Method method = RoleManager.class.getMethod("addRoleHolderAsUser",
|
||||
String.class, String.class, int.class, UserHandle.class, Executor.class, Consumer.class);
|
||||
|
||||
Log.d(TAG, "setRoleHolderAsUser: Invoking addRoleHolderAsUser for package: " + packageName);
|
||||
Log.e(TAG, "setRoleHolderAsUser: Invoking addRoleHolderAsUser for package: " + packageName);
|
||||
method.invoke(roleManager, roleName, packageName, 0, user, executor, callback);
|
||||
|
||||
// roleManager.addRoleHolderAsUser(roleName, packageName, 0, user, executor, callback);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SystemUtils {
|
||||
manager.getRunningServices(Integer.MAX_VALUE);
|
||||
if (runningServices == null) {
|
||||
// 部分 ROM 在后台或权限受限时会返回 null,此时不能直接遍历,否则会抛 NPE
|
||||
Log.i("ServiceAliveUtils", serviceName + " :isServiceAlive: false, runningServices is null");
|
||||
Log.e("ServiceAliveUtils", serviceName + " :isServiceAlive: false, runningServices is null");
|
||||
return false;
|
||||
}
|
||||
// 枚举全部运行中服务,只要类名命中即视为存活;命中后不提前 return,保持原有日志出口唯一
|
||||
@@ -84,7 +84,7 @@ public class SystemUtils {
|
||||
isServiceRunning = true;
|
||||
}
|
||||
}
|
||||
Log.i("ServiceAliveUtils", serviceName + " :isServiceAlive: " + isServiceRunning);
|
||||
Log.e("ServiceAliveUtils", serviceName + " :isServiceAlive: " + isServiceRunning);
|
||||
return isServiceRunning;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ public class TimeManager {
|
||||
|
||||
@Override
|
||||
public void onFail(int code, String msg) {
|
||||
Log.w(TAG, "SendAppInstallInfo failed, code=" + code + ", msg=" + msg);
|
||||
Log.e(TAG, "SendAppInstallInfo failed, code=" + code + ", msg=" + msg);
|
||||
getTimeControl();
|
||||
}
|
||||
});
|
||||
@@ -244,7 +244,7 @@ public class TimeManager {
|
||||
*/
|
||||
private void onUidImportanceChanged(int uid, int importance) {
|
||||
String packageName = getFirstPackageNameForUid(uid);
|
||||
Log.d(TAG, "onUidImportanceChanged: uid = " + uid + ", importance = " + importance+", packageName = " + packageName);
|
||||
Log.e(TAG, "onUidImportanceChanged: uid = " + uid + ", importance = " + importance+", packageName = " + packageName);
|
||||
if (TextUtils.isEmpty(packageName)) {
|
||||
return;
|
||||
}
|
||||
@@ -261,13 +261,13 @@ public class TimeManager {
|
||||
long prevStartTime = usedTime.getStart_time();
|
||||
String prevPackage = usedTime.settleAndClear();
|
||||
if (prevPackage != null && !prevPackage.equals(packageName)) {
|
||||
Log.d(TAG, "onUidImportanceChanged Detect app switch. Finishing record for: " + prevPackage);
|
||||
Log.e(TAG, "onUidImportanceChanged Detect app switch. Finishing record for: " + prevPackage);
|
||||
DeviceSyncGateways.get().reportAppUsage(prevPackage, prevStartTime, nowTime, this::getTimeControl);
|
||||
}
|
||||
|
||||
// 开启对新进入应用的记录(排除系统应用及白名单应用)
|
||||
if (!ApkUtils.isSystemApp(mContext, packageName) && !isPackageExempted(packageName)) {
|
||||
Log.d(TAG, "onUidImportanceChanged New foreground app: " + packageName + ". Start recording.");
|
||||
Log.e(TAG, "onUidImportanceChanged New foreground app: " + packageName + ". Start recording.");
|
||||
usedTime.startRecord(packageName, nowTime);
|
||||
}
|
||||
// 系统应用或豁免应用:不开启记录,settleAndClear 已清空状态
|
||||
@@ -281,7 +281,7 @@ public class TimeManager {
|
||||
if (TextUtils.equals(usedTime.getApp_package(), packageName)) {
|
||||
long prevStartTime = usedTime.getStart_time();
|
||||
String settledPackage = usedTime.settleAndClear();
|
||||
Log.d(TAG, "onUidImportanceChanged App moved to background: " + packageName + ". Uploading usage record.");
|
||||
Log.e(TAG, "onUidImportanceChanged App moved to background: " + packageName + ". Uploading usage record.");
|
||||
DeviceSyncGateways.get().reportAppUsage(packageName, prevStartTime, nowTime, this::getTimeControl);
|
||||
}
|
||||
}
|
||||
@@ -307,7 +307,7 @@ public class TimeManager {
|
||||
if (TextUtils.isEmpty(entity.app_package)) continue;
|
||||
mRemainingTimeMap.put(entity.app_package, entity.remaining_seconds);
|
||||
}
|
||||
Log.d(TAG, "Restored remaining time from Room, size=" + remainingList.size());
|
||||
Log.e(TAG, "Restored remaining time from Room, size=" + remainingList.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,14 +360,14 @@ public class TimeManager {
|
||||
private void checkForegroundAppName() {
|
||||
String pkg = getTopActivityPackageName();
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "checkForegroundAppName: " + pkg);
|
||||
Log.e(TAG, "checkForegroundAppName: " + pkg);
|
||||
}
|
||||
if (TextUtils.isEmpty(pkg)) return;
|
||||
|
||||
//如果应用没有退出锁屏,获取到的还是应用的包名
|
||||
if (isDeviceLocked(mContext)) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.d(TAG, "checkForegroundAppName: DeviceLocked ");
|
||||
Log.e(TAG, "checkForegroundAppName: DeviceLocked ");
|
||||
}
|
||||
// if (!allowPackage.contains(pkg)) {
|
||||
// killBackgroundProcesses(pkg);
|
||||
@@ -533,7 +533,10 @@ public class TimeManager {
|
||||
List<ActivityManager.RunningTaskInfo> tasks = manager.getRunningTasks(1);
|
||||
if (tasks != null && !tasks.isEmpty()) {
|
||||
ComponentName top = tasks.get(0).topActivity;
|
||||
return top != null ? top.getPackageName() : "";
|
||||
if (top != null) {
|
||||
return top.getPackageName();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -651,7 +654,7 @@ public class TimeManager {
|
||||
}
|
||||
|
||||
public void getTimeControl() {
|
||||
Log.d(TAG, "Syncing time control config from server...");
|
||||
Log.e(TAG, "Syncing time control config from server...");
|
||||
// 关键:必须订阅 Observable,否则冷 Observable 不会执行内部网络请求,配置无法同步。
|
||||
// 直接复用 fetchConfigWithRetry 完成订阅与失败重试。
|
||||
fetchConfigWithRetry();
|
||||
@@ -681,13 +684,13 @@ public class TimeManager {
|
||||
|
||||
@Override
|
||||
public void onSnInfoUpdated(SnInfo info) {
|
||||
Log.d(TAG, "onSnInfoUpdated: " + info);
|
||||
Log.e(TAG, "onSnInfoUpdated: " + info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigFetchFinished() {
|
||||
Log.e(TAG, "onConfigFetchFinished: " );
|
||||
Log.d(TAG, "Config fetch finished. sn=" + mConfigRepository.isSnControlFetched()
|
||||
Log.e(TAG, "Config fetch finished. sn=" + mConfigRepository.isSnControlFetched()
|
||||
+ ", app=" + mConfigRepository.isAppControlFetched());
|
||||
}
|
||||
};
|
||||
@@ -709,7 +712,7 @@ public class TimeManager {
|
||||
private class TimeChangedReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "System time/date changed: " + intent.getAction());
|
||||
Log.e(TAG, "System time/date changed: " + intent.getAction());
|
||||
handleDateChanged();
|
||||
}
|
||||
}
|
||||
@@ -720,13 +723,13 @@ public class TimeManager {
|
||||
*/
|
||||
private void handleDateChanged() {
|
||||
LocalDate today = LocalDate.now();
|
||||
Log.d(TAG, "handleDateChanged: today = " + today);
|
||||
Log.d(TAG, "handleDateChanged: mLastProcessedDate = " + mLastProcessedDate);
|
||||
Log.e(TAG, "handleDateChanged: today = " + today);
|
||||
Log.e(TAG, "handleDateChanged: mLastProcessedDate = " + mLastProcessedDate);
|
||||
if (today.equals(mLastProcessedDate)) {
|
||||
return;
|
||||
}
|
||||
mLastProcessedDate = today;
|
||||
Log.d(TAG, "Date changed to " + today + ", resetting daily quota and fetching latest config.");
|
||||
Log.e(TAG, "Date changed to " + today + ", resetting daily quota and fetching latest config.");
|
||||
|
||||
// 乐观重置:使用本地缓存的当日配额重置剩余时长,保证跨天后立即可用
|
||||
if (mSnTimeControlInfo != null) {
|
||||
@@ -763,12 +766,12 @@ public class TimeManager {
|
||||
|
||||
@Override
|
||||
public void onError(Throwable error) {
|
||||
Log.w(TAG, "Config fetch failed after retries", error);
|
||||
Log.e(TAG, "Config fetch failed after retries", error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
Log.d(TAG, "Config fetch retry flow finished.");
|
||||
Log.e(TAG, "Config fetch retry flow finished.");
|
||||
}
|
||||
}));
|
||||
mConfigRetryDisposable = disposable;
|
||||
|
||||
@@ -173,7 +173,7 @@ public class TimeUtils {
|
||||
private static SntpClient mNtpClient;
|
||||
|
||||
public static long getTimeFromNtpServer(String hostAddress) {
|
||||
Log.d(TAG, "getTimeFromNtpServer()");
|
||||
Log.e(TAG, "getTimeFromNtpServer()");
|
||||
if (TextUtils.isEmpty(hostAddress)) {
|
||||
Log.e(TAG, "Ntp host is null.");
|
||||
return -1;
|
||||
@@ -244,7 +244,7 @@ public class TimeUtils {
|
||||
|
||||
// get current time and write it to the request packet
|
||||
long requestTime = System.currentTimeMillis();
|
||||
Log.d(TAG, "RequestTime:" + new Date(requestTime));
|
||||
Log.e(TAG, "RequestTime:" + new Date(requestTime));
|
||||
long requestTicks = SystemClock.elapsedRealtime();
|
||||
writeTimeStamp(buffer, TRANSMIT_TIME_OFFSET, requestTime);
|
||||
|
||||
@@ -276,9 +276,9 @@ public class TimeUtils {
|
||||
// = (transit + skew - transit + skew)/2
|
||||
// = (2 * skew)/2 = skew
|
||||
long clockOffset = ((receiveTime - requestTime) + (transmitTime - System.currentTimeMillis())) / 2;
|
||||
// if (false) Log.d(TAG, "round trip: " + roundTripTime +
|
||||
// if (false) Log.e(TAG, "round trip: " + roundTripTime +
|
||||
// " ms");
|
||||
// if (false) Log.d(TAG, "clock offset: " + clockOffset +
|
||||
// if (false) Log.e(TAG, "clock offset: " + clockOffset +
|
||||
// " ms");
|
||||
|
||||
// save our results - use the times on this side of the network
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotification(Context context, String title, String summary, Map<String, String> extraMap) {
|
||||
Log.i(TAG, "收到一条推送通知 : " + title + ", summary:" + summary);
|
||||
Log.e(TAG, "收到一条推送通知 : " + title + ", summary:" + summary);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onMessage(Context context, CPushMessage cPushMessage) {
|
||||
Log.i(TAG, "收到一条推送消息 : " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
|
||||
Log.e(TAG, "收到一条推送消息 : " + cPushMessage.getTitle() + ", content:" + cPushMessage.getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +54,7 @@ public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationOpened(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
Log.e(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
Log.e(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationRemoved(Context context, String messageId) {
|
||||
Log.i(TAG, "onNotificationRemoved : " + messageId);
|
||||
Log.e(TAG, "onNotificationRemoved : " + messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,6 +94,6 @@ public class AliMessageIntentService extends AliyunMessageIntentService {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
|
||||
Log.i(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
|
||||
Log.e(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
|
||||
}
|
||||
}
|
||||
@@ -34,12 +34,12 @@ public class AliyunMessageReceiver extends MessageReceiver {
|
||||
// TODO 处理推送通知
|
||||
if (null != extraMap) {
|
||||
for (Map.Entry<String, String> entry : extraMap.entrySet()) {
|
||||
Log.i(TAG, "@Get diy param : Key=" + entry.getKey() + " , Value=" + entry.getValue());
|
||||
Log.e(TAG, "@Get diy param : Key=" + entry.getKey() + " , Value=" + entry.getValue());
|
||||
}
|
||||
} else {
|
||||
Log.i(TAG, "@收到通知 && 自定义消息为空");
|
||||
Log.e(TAG, "@收到通知 && 自定义消息为空");
|
||||
}
|
||||
Log.i(TAG, "收到一条推送通知 : " + title + ", summary:" + summary);
|
||||
Log.e(TAG, "收到一条推送通知 : " + title + ", summary:" + summary);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public class AliyunMessageReceiver extends MessageReceiver {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationReceivedInApp(Context context, String title, String summary, Map<String, String> extraMap, int openType, String openActivity, String openUrl) {
|
||||
Log.i(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
|
||||
Log.e(TAG, "onNotificationReceivedInApp : " + " : " + title + " : " + summary + " " + extraMap + " : " + openType + " : " + openActivity + " : " + openUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +87,7 @@ public class AliyunMessageReceiver extends MessageReceiver {
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationOpened(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
Log.e(TAG, "onNotificationOpened : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +98,7 @@ public class AliyunMessageReceiver extends MessageReceiver {
|
||||
*/
|
||||
@Override
|
||||
public void onNotificationRemoved(Context context, String messageId) {
|
||||
Log.i(TAG, "onNotificationRemoved : " + messageId);
|
||||
Log.e(TAG, "onNotificationRemoved : " + messageId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,6 +111,6 @@ public class AliyunMessageReceiver extends MessageReceiver {
|
||||
*/
|
||||
@Override
|
||||
protected void onNotificationClickedWithNoAction(Context context, String title, String summary, String extraMap) {
|
||||
Log.i(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
Log.e(TAG, "onNotificationClickedWithNoAction : " + " : " + title + " : " + summary + " : " + extraMap);
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class MainService extends BaseService implements ViewModelStoreOwner, Net
|
||||
return;
|
||||
}
|
||||
|
||||
Disposable disposable = AppInventorySync.getInstance().getAppWhiteListRequest(() -> Log.d(TAG, "Device sync: whitelist updated"))
|
||||
Disposable disposable = AppInventorySync.getInstance().getAppWhiteListRequest(() -> Log.e(TAG, "Device sync: whitelist updated"))
|
||||
.subscribeWith(new RequestCompletion(mDisposables, "Device sync: whitelist request"));
|
||||
mDisposables.add(disposable);
|
||||
mViewModel.getSnInfo();
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class AppUsageReporter {
|
||||
}
|
||||
|
||||
public void sendAppUsageRecord(String packageName, long openTime, long closeTime, CompleteCallback completeCallback) {
|
||||
Log.d(TAG, "sendAppUsageRecord: packageName = " + packageName + ", openTime = " + openTime + ", closeTime = " + closeTime);
|
||||
Log.e(TAG, "sendAppUsageRecord: packageName = " + packageName + ", openTime = " + openTime + ", closeTime = " + closeTime);
|
||||
int isLogined = (int) SPUtils.get(mContext, CommonConfig.isLogined, 2);
|
||||
if (isLogined != 1) {
|
||||
Log.e(TAG, "sendAppUsageRecord: 没有绑定");
|
||||
|
||||
Reference in new issue
Block a user