Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/base/SPenSupport.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/SPenSupport.java b/ui/android/java/src/org/chromium/ui/base/SPenSupport.java |
| similarity index 77% |
| rename from content/public/android/java/src/org/chromium/content/browser/SPenSupport.java |
| rename to ui/android/java/src/org/chromium/ui/base/SPenSupport.java |
| index 62fb90c6fcea95734d7bdffe3878bb98eb98b21f..9aae52aa7fc58527a5e11663e402e8dae87be32f 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/SPenSupport.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/SPenSupport.java |
| @@ -1,8 +1,8 @@ |
| -// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -package org.chromium.content.browser; |
| +package org.chromium.ui.base; |
| import android.content.Context; |
| import android.content.pm.FeatureInfo; |
| @@ -13,7 +13,6 @@ import android.view.MotionEvent; |
| * Support S-Pen event detection and conversion. |
| */ |
| public final class SPenSupport { |
|
boliu
2017/02/27 19:21:57
I think we don't need to expose this at all, just
Jinsuk Kim
2017/02/28 06:56:04
This is used by Chrome too. See CompositorViewHold
boliu
2017/02/28 22:44:54
ok, I guess hiding this needs to come after chrome
Jinsuk Kim
2017/03/02 04:08:34
I agree. Left a TODO for that. I think it gets eas
|
| - |
| // These values are obtained from Samsung. |
| private static final int SPEN_ACTION_DOWN = 211; |
| private static final int SPEN_ACTION_UP = 212; |
| @@ -21,28 +20,22 @@ public final class SPenSupport { |
| private static final int SPEN_ACTION_CANCEL = 214; |
| private static Boolean sIsSPenSupported; |
| - /** |
| - * @return Whether SPen is supported on the device. |
| - */ |
| - public static boolean isSPenSupported(Context context) { |
| - if (sIsSPenSupported == null) { |
| - sIsSPenSupported = detectSPenSupport(context); |
| - } |
| - return sIsSPenSupported.booleanValue(); |
| - } |
| + public static void detect(Context context) { |
| + if (sIsSPenSupported != null) return; |
| - private static boolean detectSPenSupport(Context context) { |
| if (!"SAMSUNG".equalsIgnoreCase(Build.MANUFACTURER)) { |
| - return false; |
| + sIsSPenSupported = false; |
| + return; |
| } |
| final FeatureInfo[] infos = context.getPackageManager().getSystemAvailableFeatures(); |
| for (FeatureInfo info : infos) { |
| if ("com.sec.feature.spen_usp".equalsIgnoreCase(info.name)) { |
| - return true; |
| + sIsSPenSupported = true; |
| + return; |
| } |
| } |
| - return false; |
| + sIsSPenSupported = false; |
| } |
| /** |
| @@ -53,6 +46,9 @@ public final class SPenSupport { |
| * @return Event action after the conversion. |
| */ |
| public static int convertSPenEventAction(int eventActionMasked) { |
| + assert sIsSPenSupported != null; |
|
boliu
2017/02/27 19:21:57
how is client supposed to know if detect succeeded
Jinsuk Kim
2017/02/28 06:56:04
? |sIsSPenSupported| will either be true or false.
boliu
2017/02/28 22:44:54
oh oops, misread, I thought it's "assert sIsSPenSu
Jinsuk Kim
2017/03/02 04:08:34
Acknowledged.
|
| + if (!sIsSPenSupported.booleanValue()) return eventActionMasked; |
| + |
| // S-Pen support: convert to normal stylus event handling |
| switch (eventActionMasked) { |
| case SPEN_ACTION_DOWN: |