Skip to content

Commit 5111726

Browse files
author
Jim Miller
committed
Handle DevicePolicyManagement and safe mode when inflating widgets
Bug 7459120 Bug 7444159 Bug 7444016 Change-Id: I7966ec510da8113ac571b5a4b9dc48dd291396e8 Conflicts: policy/src/com/android/internal/policy/impl/keyguard/KeyguardWidgetPager.java
1 parent 475255b commit 5111726

File tree

5 files changed

+206
-98
lines changed

5 files changed

+206
-98
lines changed

core/java/android/provider/Settings.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,6 +3228,13 @@ public static boolean putFloatForUser(ContentResolver cr, String name, float val
32283228
public static final String LOCK_SCREEN_APPWIDGET_IDS =
32293229
"lock_screen_appwidget_ids";
32303230

3231+
/**
3232+
* Id of the appwidget shown on the lock screen when appwidgets are disabled.
3233+
* @hide
3234+
*/
3235+
public static final String LOCK_SCREEN_FALLBACK_APPWIDGET_ID =
3236+
"lock_screen_fallback_appwidget_id";
3237+
32313238
/**
32323239
* Index of the lockscreen appwidget to restore, -1 if none.
32333240
* @hide

core/java/com/android/internal/widget/LockPatternUtils.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.app.ActivityManagerNative;
2020
import android.app.admin.DevicePolicyManager;
21+
import android.appwidget.AppWidgetManager;
2122
import android.content.ContentResolver;
2223
import android.content.Context;
2324
import android.content.Intent;
@@ -35,6 +36,7 @@
3536
import android.telephony.TelephonyManager;
3637
import android.text.TextUtils;
3738
import android.util.Log;
39+
import android.view.IWindowManager;
3840
import android.view.View;
3941
import android.widget.Button;
4042

@@ -1112,6 +1114,25 @@ private static String combineStrings(int[] list, String separator) {
11121114
return sb.toString();
11131115
}
11141116

1117+
// appwidget used when appwidgets are disabled (we make an exception for
1118+
// default clock widget)
1119+
public void writeFallbackAppWidgetId(int appWidgetId) {
1120+
Settings.Secure.putIntForUser(mContentResolver,
1121+
Settings.Secure.LOCK_SCREEN_FALLBACK_APPWIDGET_ID,
1122+
appWidgetId,
1123+
UserHandle.USER_CURRENT);
1124+
}
1125+
1126+
// appwidget used when appwidgets are disabled (we make an exception for
1127+
// default clock widget)
1128+
public int getFallbackAppWidgetId() {
1129+
return Settings.Secure.getIntForUser(
1130+
mContentResolver,
1131+
Settings.Secure.LOCK_SCREEN_FALLBACK_APPWIDGET_ID,
1132+
AppWidgetManager.INVALID_APPWIDGET_ID,
1133+
UserHandle.USER_CURRENT);
1134+
}
1135+
11151136
private void writeAppWidgets(int[] appWidgetIds) {
11161137
Settings.Secure.putStringForUser(mContentResolver,
11171138
Settings.Secure.LOCK_SCREEN_APPWIDGET_IDS,
@@ -1325,5 +1346,15 @@ public void setPowerButtonInstantlyLocks(boolean enabled) {
13251346
public boolean getPowerButtonInstantlyLocks() {
13261347
return getBoolean(LOCKSCREEN_POWER_BUTTON_INSTANTLY_LOCKS, true);
13271348
}
1349+
1350+
public static boolean isSafeModeEnabled() {
1351+
try {
1352+
return IWindowManager.Stub.asInterface(
1353+
ServiceManager.getService("window")).isSafeModeEnabled();
1354+
} catch (RemoteException e) {
1355+
// Shouldn't happen!
1356+
}
1357+
return false;
1358+
}
13281359

13291360
}

0 commit comments

Comments
 (0)