Exclude accessing settings from PointerIcon.

This code structure causes a crash as rerported, better to extract
access to the settings to InputManagerService, who actually cares
about it.

Bug: 26196092
Change-Id: I4e0dbcc24ccf5d11681738ca3576b64471aa8cc4
This commit is contained in:
Jun Mukai
2015-12-15 16:19:20 -08:00
parent 277fa3cf7e
commit e4e75daa65
2 changed files with 15 additions and 8 deletions

View File

@@ -17,8 +17,6 @@
package android.view;
import android.annotation.NonNull;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.SparseArray;
import com.android.internal.util.XmlUtils;
@@ -142,6 +140,9 @@ public final class PointerIcon implements Parcelable {
private static final PointerIcon gNullIcon = new PointerIcon(STYLE_NULL);
private static final SparseArray<PointerIcon> gSystemIcons = new SparseArray<PointerIcon>();
/** @hide */
public static boolean sUseLargeIcons = false;
private final int mStyle;
private int mSystemIconResourceId;
private Bitmap mBitmap;
@@ -210,10 +211,7 @@ public final class PointerIcon implements Parcelable {
styleIndex = getSystemIconStyleIndex(STYLE_DEFAULT);
}
int accessibilityConfig = Settings.Secure.getIntForUser(
context.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
0, UserHandle.USER_CURRENT);
int defStyle = (accessibilityConfig == 1) ?
int defStyle = sUseLargeIcons ?
com.android.internal.R.style.LargePointer : com.android.internal.R.style.Pointer;
TypedArray a = context.obtainStyledAttributes(null,
com.android.internal.R.styleable.Pointer,

View File

@@ -320,12 +320,13 @@ public class InputManagerService extends IInputManager.Stub
public void onReceive(Context context, Intent intent) {
updatePointerSpeedFromSettings();
updateShowTouchesFromSettings();
nativeReloadPointerIcons(mPtr);
updateAccessibilityLargePointerFromSettings();
}
}, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
updatePointerSpeedFromSettings();
updateShowTouchesFromSettings();
updateAccessibilityLargePointerFromSettings();
}
// TODO(BT) Pass in paramter for bluetooth system
@@ -1366,13 +1367,21 @@ public class InputManagerService extends IInputManager.Stub
}, UserHandle.USER_ALL);
}
public void updateAccessibilityLargePointerFromSettings() {
final int accessibilityConfig = Settings.Secure.getIntForUser(
mContext.getContentResolver(), Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON,
0, UserHandle.USER_CURRENT);
PointerIcon.sUseLargeIcons = (accessibilityConfig == 1);
nativeReloadPointerIcons(mPtr);
}
private void registerAccessibilityLargePointerSettingObserver() {
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor(Settings.Secure.ACCESSIBILITY_LARGE_POINTER_ICON), true,
new ContentObserver(mHandler) {
@Override
public void onChange(boolean selfChange) {
nativeReloadPointerIcons(mPtr);
updateAccessibilityLargePointerFromSettings();
}
}, UserHandle.USER_ALL);
}