summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/KeyguardManager.java8
-rw-r--r--services/java/com/android/server/PackageManagerService.java8
-rw-r--r--services/java/com/android/server/ThrottleService.java37
-rw-r--r--services/java/com/android/server/WindowManagerService.java61
-rw-r--r--services/java/com/android/server/am/ActivityManagerService.java2
5 files changed, 73 insertions, 43 deletions
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index 0c07553b0b61..e3d8e2047c96 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -53,6 +53,9 @@ public class KeyguardManager {
*
* A good place to call this is from {@link android.app.Activity#onResume()}
*
+ * Note: This call has no effect while any {@link android.app.admin.DevicePolicyManager}
+ * is enabled that requires a password.
+ *
* @see #reenableKeyguard()
*/
public void disableKeyguard() {
@@ -66,7 +69,10 @@ public class KeyguardManager {
* Reenable the keyguard. The keyguard will reappear if the previous
* call to {@link #disableKeyguard()} caused it it to be hidden.
*
- * A good place to call this is from {@link android.app.Activity#onPause()}
+ * A good place to call this is from {@link android.app.Activity#onPause()}
+ *
+ * Note: This call has no effect while any {@link android.app.admin.DevicePolicyManager}
+ * is enabled that requires a password.
*
* @see #disableKeyguard()
*/
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 5ed19a2b722e..49d2a76f0d74 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -6593,15 +6593,11 @@ class PackageManagerService extends IPackageManager.Stub {
public void addPackageToPreferred(String packageName) {
- mContext.enforceCallingOrSelfPermission(
- android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
- Slog.w(TAG, "addPackageToPreferred: no longer implemented");
+ Slog.w(TAG, "addPackageToPreferred: this is now a no-op");
}
public void removePackageFromPreferred(String packageName) {
- mContext.enforceCallingOrSelfPermission(
- android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
- Slog.w(TAG, "removePackageFromPreferred: no longer implemented");
+ Slog.w(TAG, "removePackageFromPreferred: this is now a no-op");
}
public List<PackageInfo> getPreferredPackages(int flags) {
diff --git a/services/java/com/android/server/ThrottleService.java b/services/java/com/android/server/ThrottleService.java
index f0b2210c3388..a93a6ee0bca8 100644
--- a/services/java/com/android/server/ThrottleService.java
+++ b/services/java/com/android/server/ThrottleService.java
@@ -123,7 +123,7 @@ public class ThrottleService extends IThrottleManager.Stub {
private boolean mNtpActive;
public ThrottleService(Context context) {
- if (DBG) Slog.d(TAG, "Starting ThrottleService");
+ if (VDBG) Slog.v(TAG, "Starting ThrottleService");
mContext = context;
mNtpActive = false;
@@ -288,7 +288,7 @@ public class ThrottleService extends IThrottleManager.Stub {
}
void systemReady() {
- if (DBG) Slog.d(TAG, "systemReady");
+ if (VDBG) Slog.v(TAG, "systemReady");
mContext.registerReceiver(
new BroadcastReceiver() {
@Override
@@ -371,7 +371,7 @@ public class ThrottleService extends IThrottleManager.Stub {
}
private void onRebootRecovery() {
- if (DBG) Slog.d(TAG, "onRebootRecovery");
+ if (VDBG) Slog.v(TAG, "onRebootRecovery");
// check for sim change TODO
// reregister for notification of policy change
@@ -437,10 +437,12 @@ public class ThrottleService extends IThrottleManager.Stub {
mMaxNtpCacheAgeSec = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.THROTTLE_MAX_NTP_CACHE_AGE_SEC, MAX_NTP_CACHE_AGE_SEC);
- Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" + mPolicyPollPeriodSec +
- ", threshold=" + mPolicyThreshold + ", value=" + mPolicyThrottleValue +
- ", resetDay=" + mPolicyResetDay + ", noteType=" +
- mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec);
+ if (VDBG || (mPolicyThreshold != 0)) {
+ Slog.d(TAG, "onPolicyChanged testing=" + testing +", period=" +
+ mPolicyPollPeriodSec + ", threshold=" + mPolicyThreshold + ", value=" +
+ mPolicyThrottleValue + ", resetDay=" + mPolicyResetDay + ", noteType=" +
+ mPolicyNotificationsAllowedMask + ", maxNtpCacheAge=" + mMaxNtpCacheAgeSec);
+ }
// force updates
mThrottleIndex = THROTTLE_INDEX_UNINITIALIZED;
@@ -485,7 +487,7 @@ public class ThrottleService extends IThrottleManager.Stub {
long periodRx = mRecorder.getPeriodRx(0);
long periodTx = mRecorder.getPeriodTx(0);
long total = periodRx + periodTx;
- if (DBG) {
+ if (VDBG || (mPolicyThreshold != 0)) {
Slog.d(TAG, "onPollAlarm - roaming =" + roaming +
", read =" + incRead + ", written =" + incWrite + ", new total =" + total);
}
@@ -502,7 +504,7 @@ public class ThrottleService extends IThrottleManager.Stub {
mContext.sendStickyBroadcast(broadcast);
mAlarmManager.cancel(mPendingPollIntent);
- mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, next, mPendingPollIntent);
+ mAlarmManager.set(AlarmManager.ELAPSED_REALTIME, next, mPendingPollIntent);
}
private void onIfaceUp() {
@@ -685,7 +687,7 @@ public class ThrottleService extends IThrottleManager.Stub {
}
private void onResetAlarm() {
- if (DBG) {
+ if (VDBG || (mPolicyThreshold != 0)) {
Slog.d(TAG, "onResetAlarm - last period had " + mRecorder.getPeriodRx(0) +
" bytes read and " + mRecorder.getPeriodTx(0) + " written");
}
@@ -703,11 +705,11 @@ public class ThrottleService extends IThrottleManager.Stub {
mAlarmManager.cancel(mPendingResetIntent);
long offset = end.getTimeInMillis() - now;
// use Elapsed realtime so clock changes don't fool us.
- mAlarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
+ mAlarmManager.set(AlarmManager.ELAPSED_REALTIME,
SystemClock.elapsedRealtime() + offset,
mPendingResetIntent);
} else {
- if (DBG) Slog.d(TAG, "no authoritative time - not resetting period");
+ if (VDBG) Slog.d(TAG, "no authoritative time - not resetting period");
}
}
}
@@ -741,7 +743,7 @@ public class ThrottleService extends IThrottleManager.Stub {
cachedNtpTimestamp = SystemClock.elapsedRealtime();
if (!mNtpActive) {
mNtpActive = true;
- if (DBG) Slog.d(TAG, "found Authoritative time - reseting alarm");
+ if (VDBG) Slog.d(TAG, "found Authoritative time - reseting alarm");
mHandler.obtainMessage(EVENT_RESET_ALARM).sendToTarget();
}
if (VDBG) Slog.v(TAG, "using Authoritative time: " + cachedNtp);
@@ -800,13 +802,13 @@ public class ThrottleService extends IThrottleManager.Stub {
if (start.equals(mPeriodStart) && end.equals(mPeriodEnd)) {
// same endpoints - keep collecting
- if (DBG) {
+ if (VDBG) {
Slog.d(TAG, "same period (" + start.getTimeInMillis() + "," +
end.getTimeInMillis() +") - ammending data");
}
startNewPeriod = false;
} else {
- if (DBG) {
+ if (VDBG) {
if(start.equals(mPeriodEnd) || start.after(mPeriodEnd)) {
Slog.d(TAG, "next period (" + start.getTimeInMillis() + "," +
end.getTimeInMillis() + ") - old end was " +
@@ -910,7 +912,7 @@ public class ThrottleService extends IThrottleManager.Stub {
mImsi = mTelephonyManager.getSubscriberId();
if (mImsi == null) return;
- if (DBG) Slog.d(TAG, "finally have imsi - retreiving data");
+ if (VDBG) Slog.d(TAG, "finally have imsi - retreiving data");
retrieve();
}
@@ -1038,7 +1040,8 @@ public class ThrottleService extends IThrottleManager.Stub {
mPeriodCount = Integer.parseInt(parsed[parsedUsed++]);
if (parsed.length != 5 + (2 * mPeriodCount)) {
- Slog.e(TAG, "reading data file with bad length ("+parsed.length+" != "+(5 + (2*mPeriodCount))+") - ignoring");
+ Slog.e(TAG, "reading data file with bad length (" + parsed.length +
+ " != " + (5+(2*mPeriodCount)) + ") - ignoring");
return;
}
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 53de7d99e517..e13f0af5a668 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -54,6 +54,7 @@ import com.android.server.am.BatteryStatsService;
import android.Manifest;
import android.app.ActivityManagerNative;
import android.app.IActivityManager;
+import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
@@ -86,6 +87,7 @@ import android.os.TokenWatcher;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.EventLog;
+import android.util.Log;
import android.util.Slog;
import android.util.SparseIntArray;
import android.view.Display;
@@ -4171,13 +4173,31 @@ public class WindowManagerService extends IWindowManager.Stub
// Misc IWindowSession methods
// -------------------------------------------------------------
+ private boolean allowDisableKeyguard()
+ {
+ // We fail safe if this gets called before the service has started.
+ boolean allow = false;
+ DevicePolicyManager dpm = (DevicePolicyManager) mContext.getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ if (dpm != null) {
+ allow = dpm.getPasswordQuality(null)
+ == DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED;
+ }
+ return allow;
+ }
+
public void disableKeyguard(IBinder token, String tag) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DISABLE_KEYGUARD)
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires DISABLE_KEYGUARD permission");
}
- synchronized (mKeyguardTokenWatcher) {
- mKeyguardTokenWatcher.acquire(token, tag);
+
+ if (allowDisableKeyguard()) {
+ synchronized (mKeyguardTokenWatcher) {
+ mKeyguardTokenWatcher.acquire(token, tag);
+ }
+ } else {
+ Log.w(TAG, tag + ": disableKeyguard() ignored while DevicePolicyAmin is enabled.");
}
}
@@ -4186,25 +4206,30 @@ public class WindowManagerService extends IWindowManager.Stub
!= PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("Requires DISABLE_KEYGUARD permission");
}
- synchronized (mKeyguardTokenWatcher) {
- mKeyguardTokenWatcher.release(token);
-
- if (!mKeyguardTokenWatcher.isAcquired()) {
- // If we are the last one to reenable the keyguard wait until
- // we have actaully finished reenabling until returning.
- // It is possible that reenableKeyguard() can be called before
- // the previous disableKeyguard() is handled, in which case
- // neither mKeyguardTokenWatcher.acquired() or released() would
- // be called. In that case mKeyguardDisabled will be false here
- // and we have nothing to wait for.
- while (mKeyguardDisabled) {
- try {
- mKeyguardTokenWatcher.wait();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
+
+ if (allowDisableKeyguard()) {
+ synchronized (mKeyguardTokenWatcher) {
+ mKeyguardTokenWatcher.release(token);
+
+ if (!mKeyguardTokenWatcher.isAcquired()) {
+ // If we are the last one to reenable the keyguard wait until
+ // we have actaully finished reenabling until returning.
+ // It is possible that reenableKeyguard() can be called before
+ // the previous disableKeyguard() is handled, in which case
+ // neither mKeyguardTokenWatcher.acquired() or released() would
+ // be called. In that case mKeyguardDisabled will be false here
+ // and we have nothing to wait for.
+ while (mKeyguardDisabled) {
+ try {
+ mKeyguardTokenWatcher.wait();
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
}
}
}
+ } else {
+ Log.w(TAG, "reenableKeyguard() ignored while DevicePolicyAmin is enabled.");
}
}
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java
index 8857c5fd1ede..0c11940b1b83 100644
--- a/services/java/com/android/server/am/ActivityManagerService.java
+++ b/services/java/com/android/server/am/ActivityManagerService.java
@@ -5583,7 +5583,7 @@ public final class ActivityManagerService extends ActivityManagerNative implemen
// See if the top visible activity is waiting to run in this process...
HistoryRecord hr = topRunningActivityLocked(null);
- if (hr != null) {
+ if (hr != null && normalMode) {
if (hr.app == null && app.info.uid == hr.info.applicationInfo.uid
&& processName.equals(hr.processName)) {
try {