Loading core/java/android/app/AppOpsManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -333,7 +333,9 @@ public class AppOpsManager { public static int resolveFirstUnrestrictedUidState(int op) { switch (op) { case OP_FINE_LOCATION: case OP_COARSE_LOCATION: { case OP_COARSE_LOCATION: case OP_MONITOR_LOCATION: case OP_MONITOR_HIGH_POWER_LOCATION: { return UID_STATE_FOREGROUND_SERVICE_LOCATION; } } Loading services/core/java/com/android/server/appop/AppOpsService.java +8 −7 Original line number Diff line number Diff line Loading @@ -341,7 +341,7 @@ public class AppOpsService extends IAppOpsService.Stub { int evalMode(int op, int mode) { if (mode == AppOpsManager.MODE_FOREGROUND) { return state <= AppOpsManager.resolveLastRestrictedUidState(op) return state <= AppOpsManager.resolveFirstUnrestrictedUidState(op) ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED; } return mode; Loading Loading @@ -915,9 +915,12 @@ public class AppOpsService extends IAppOpsService.Stub { if (uidState != null && uidState.pendingState != newState) { final int oldPendingState = uidState.pendingState; uidState.pendingState = newState; if (newState < uidState.state || newState <= UID_STATE_MAX_LAST_NON_RESTRICTED) { // We are moving to a more important state, or the new state is in the // foreground, then always do it immediately. if (newState < uidState.state || (newState <= UID_STATE_MAX_LAST_NON_RESTRICTED && uidState.state > UID_STATE_MAX_LAST_NON_RESTRICTED)) { // We are moving to a more important state, or the new state may be in the // foreground and the old state is in the background, then always do it // immediately. commitUidPendingStateLocked(uidState); } else if (uidState.pendingStateCommitTime == 0) { // We are moving to a less important state for the first time, Loading Loading @@ -2414,9 +2417,7 @@ public class AppOpsService extends IAppOpsService.Stub { } private void commitUidPendingStateLocked(UidState uidState) { final boolean lastForeground = uidState.state <= UID_STATE_MAX_LAST_NON_RESTRICTED; final boolean nowForeground = uidState.pendingState <= UID_STATE_MAX_LAST_NON_RESTRICTED; if (uidState.hasForegroundWatchers && lastForeground != nowForeground) { if (uidState.hasForegroundWatchers) { for (int fgi = uidState.foregroundOps.size() - 1; fgi >= 0; fgi--) { if (!uidState.foregroundOps.valueAt(fgi)) { continue; Loading Loading
core/java/android/app/AppOpsManager.java +3 −1 Original line number Diff line number Diff line Loading @@ -333,7 +333,9 @@ public class AppOpsManager { public static int resolveFirstUnrestrictedUidState(int op) { switch (op) { case OP_FINE_LOCATION: case OP_COARSE_LOCATION: { case OP_COARSE_LOCATION: case OP_MONITOR_LOCATION: case OP_MONITOR_HIGH_POWER_LOCATION: { return UID_STATE_FOREGROUND_SERVICE_LOCATION; } } Loading
services/core/java/com/android/server/appop/AppOpsService.java +8 −7 Original line number Diff line number Diff line Loading @@ -341,7 +341,7 @@ public class AppOpsService extends IAppOpsService.Stub { int evalMode(int op, int mode) { if (mode == AppOpsManager.MODE_FOREGROUND) { return state <= AppOpsManager.resolveLastRestrictedUidState(op) return state <= AppOpsManager.resolveFirstUnrestrictedUidState(op) ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED; } return mode; Loading Loading @@ -915,9 +915,12 @@ public class AppOpsService extends IAppOpsService.Stub { if (uidState != null && uidState.pendingState != newState) { final int oldPendingState = uidState.pendingState; uidState.pendingState = newState; if (newState < uidState.state || newState <= UID_STATE_MAX_LAST_NON_RESTRICTED) { // We are moving to a more important state, or the new state is in the // foreground, then always do it immediately. if (newState < uidState.state || (newState <= UID_STATE_MAX_LAST_NON_RESTRICTED && uidState.state > UID_STATE_MAX_LAST_NON_RESTRICTED)) { // We are moving to a more important state, or the new state may be in the // foreground and the old state is in the background, then always do it // immediately. commitUidPendingStateLocked(uidState); } else if (uidState.pendingStateCommitTime == 0) { // We are moving to a less important state for the first time, Loading Loading @@ -2414,9 +2417,7 @@ public class AppOpsService extends IAppOpsService.Stub { } private void commitUidPendingStateLocked(UidState uidState) { final boolean lastForeground = uidState.state <= UID_STATE_MAX_LAST_NON_RESTRICTED; final boolean nowForeground = uidState.pendingState <= UID_STATE_MAX_LAST_NON_RESTRICTED; if (uidState.hasForegroundWatchers && lastForeground != nowForeground) { if (uidState.hasForegroundWatchers) { for (int fgi = uidState.foregroundOps.size() - 1; fgi >= 0; fgi--) { if (!uidState.foregroundOps.valueAt(fgi)) { continue; Loading