客户要求在升级界面不能灭屏,三方APP 不愿意修改,自己在Framework修改的内容,
超时的时候,设置不灭屏。
- diff --git a/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java b/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
- index 8ea3b0b7fa..d20a0cd132 100755
- --- a/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
- +++ b/frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
- @@ -117,6 +117,11 @@ import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Objects;
- +import android.app.ActivityThread;
- +import android.app.usage.UsageStatsManager;
- +import java.util.Calendar;
- +import android.app.usage.UsageEvents;
- +import android.content.ComponentName;
-
- /**
- * The power manager service is responsible for coordinating power management
- @@ -1958,6 +1963,24 @@ public final class PowerManagerService extends SystemService
- Trace.traceEnd(Trace.TRACE_TAG_POWER);
- }
- }
- + // get current app
- + public static String getForegroundPackageName(Context context) {
- + Calendar calendar = Calendar.getInstance();
- + final long end = calendar.getTimeInMillis();
- + calendar.add(Calendar.MONTH, -1);
- + final long start = calendar.getTimeInMillis();
- + UsageStatsManager usageStatsManager = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);
- + UsageEvents usageEvents = usageStatsManager.queryEvents(start, end);
- + UsageEvents.Event event = new UsageEvents.Event();
- + String packageName = null;
- + while (usageEvents.hasNextEvent()) {
- + usageEvents.getNextEvent(event);
- + if (event.getEventType() == UsageEvents.Event.ACTIVITY_RESUMED) {
- + packageName = event.getPackageName();
- + }
- + }
- + return packageName;
- + }
-
- /**
- * Check profile timeouts and notify profiles that should be locked.
- @@ -2294,6 +2317,12 @@ public final class PowerManagerService extends SystemService
- if (now < nextTimeout) {
- mUserActivitySummary = USER_ACTIVITY_SCREEN_DIM;
- }
- + // com.cw.update
- + String packageName2 = getForegroundPackageName(mContext);
- + if( "com.cw.update".equals(packageName2)){
- + android.util.Log.d(TAG, "if ture ,so Timeout not work com.cw.update.......");
- + mUserActivitySummary = USER_ACTIVITY_SCREEN_BRIGHT;
- + }
- }
- }
- if (mUserActivitySummary == 0