Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dadae54a authored by Xavier Ducrohet's avatar Xavier Ducrohet Committed by Android (Google) Code Review
Browse files

Merge "LayoutLib: updated fake accessbility manager and ensure there's an InputMethodManager"

parents 8c55a9a5 96131eef
Loading
Loading
Loading
Loading
+42 −0
Original line number Diff line number Diff line
@@ -16,8 +16,11 @@

package android.view.accessibility;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.content.Context;
import android.content.pm.ServiceInfo;
import android.view.IWindow;
import android.view.View;

import java.util.Collections;
import java.util.List;
@@ -37,6 +40,19 @@ import java.util.List;
public final class AccessibilityManager {
    private static AccessibilityManager sInstance = new AccessibilityManager();

    /**
     * Listener for the accessibility state.
     */
    public interface AccessibilityStateChangeListener {

        /**
         * Called back on change in the accessibility state.
         *
         * @param enabled Whether accessibility is enabled.
         */
        public void onAccessibilityStateChanged(boolean enabled);
    }

    /**
     * Get an AccessibilityManager instance (create one if necessary).
     *
@@ -92,4 +108,30 @@ public final class AccessibilityManager {
        List<ServiceInfo> services = null;
        return Collections.unmodifiableList(services);
    }

    public List<AccessibilityServiceInfo> getInstalledAccessibilityServiceList() {
        // normal implementation does this in some case, so let's do the same
        // (unmodifiableList wrapped around null).
        List<AccessibilityServiceInfo> services = null;
        return Collections.unmodifiableList(services);
    }

    public boolean addAccessibilityStateChangeListener(
            AccessibilityStateChangeListener listener) {
        return true;
    }

    public boolean removeAccessibilityStateChangeListener(
            AccessibilityStateChangeListener listener) {
        return true;
    }

    public int addAccessibilityInteractionConnection(IWindow windowToken,
            IAccessibilityInteractionConnection connection) {
        return View.NO_ID;
    }

    public void removeAccessibilityInteractionConnection(IWindow windowToken) {
    }

}
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.view.inputmethod;

import com.android.layoutlib.bridge.android.BridgeIInputMethodManager;
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;

import android.os.Looper;


/**
 * Delegate used to provide new implementation of a select few methods of {@link InputMethodManager}
 *
 * Through the layoutlib_create tool, the original  methods of InputMethodManager have been replaced
 * by calls to methods of the same name in this delegate class.
 *
 */
public class InputMethodManager_Delegate {

    // ---- Overridden methods ----

    @LayoutlibDelegate
    /*package*/ static InputMethodManager getInstance(Looper mainLooper) {
        synchronized (InputMethodManager.mInstanceSync) {
            if (InputMethodManager.mInstance != null) {
                return InputMethodManager.mInstance;
            }

            InputMethodManager.mInstance = new InputMethodManager(new BridgeIInputMethodManager(),
                    mainLooper);
        }
        return InputMethodManager.mInstance;

    }
}
+191 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.layoutlib.bridge.android;

import com.android.internal.view.IInputContext;
import com.android.internal.view.IInputMethodClient;
import com.android.internal.view.IInputMethodManager;
import com.android.internal.view.InputBindResult;

import android.os.IBinder;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.text.style.SuggestionSpan;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;

import java.util.List;

/**
 * Basic implementation of IInputMethodManager that does nothing.
 *
 */
public class BridgeIInputMethodManager implements IInputMethodManager {

    public void addClient(IInputMethodClient arg0, IInputContext arg1, int arg2, int arg3)
            throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void finishInput(IInputMethodClient arg0) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public InputMethodSubtype getCurrentInputMethodSubtype() throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public List<InputMethodInfo> getEnabledInputMethodList() throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo arg0,
            boolean arg1) throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public List<InputMethodInfo> getInputMethodList() throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public InputMethodSubtype getLastInputMethodSubtype() throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public List getShortcutInputMethodsAndSubtypes() throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public void hideMySoftInput(IBinder arg0, int arg1) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public boolean hideSoftInput(IInputMethodClient arg0, int arg1, ResultReceiver arg2)
            throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public boolean notifySuggestionPicked(SuggestionSpan arg0, String arg1, int arg2)
            throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public void registerSuggestionSpansForNotification(SuggestionSpan[] arg0)
            throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void removeClient(IInputMethodClient arg0) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public boolean setAdditionalInputMethodSubtypes(IBinder arg0, InputMethodSubtype[] arg1)
            throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public boolean setCurrentInputMethodSubtype(InputMethodSubtype arg0) throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public void setImeWindowStatus(IBinder arg0, int arg1, int arg2) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void setInputMethod(IBinder arg0, String arg1) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void setInputMethodAndSubtype(IBinder arg0, String arg1, InputMethodSubtype arg2)
            throws RemoteException {
        // TODO Auto-generated method stub

    }

    public boolean setInputMethodEnabled(String arg0, boolean arg1) throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public void showInputMethodAndSubtypeEnablerFromClient(IInputMethodClient arg0, String arg1)
            throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void showInputMethodPickerFromClient(IInputMethodClient arg0) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void showMySoftInput(IBinder arg0, int arg1) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public boolean showSoftInput(IInputMethodClient arg0, int arg1, ResultReceiver arg2)
            throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public InputBindResult startInput(IInputMethodClient arg0, IInputContext arg1, EditorInfo arg2,
            boolean arg3, boolean arg4) throws RemoteException {
        // TODO Auto-generated method stub
        return null;
    }

    public boolean switchToLastInputMethod(IBinder arg0) throws RemoteException {
        // TODO Auto-generated method stub
        return false;
    }

    public void updateStatusIcon(IBinder arg0, String arg1, int arg2) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public void windowGainedFocus(IInputMethodClient arg0, IBinder arg1, boolean arg2,
            boolean arg3, int arg4, boolean arg5, int arg6) throws RemoteException {
        // TODO Auto-generated method stub

    }

    public IBinder asBinder() {
        // TODO Auto-generated method stub
        return null;
    }

}
+8 −0
Original line number Diff line number Diff line
@@ -33,8 +33,10 @@ import com.android.resources.ScreenSize;

import android.content.res.Configuration;
import android.os.HandlerThread_Delegate;
import android.os.Looper;
import android.util.DisplayMetrics;
import android.view.ViewConfiguration;
import android.view.inputmethod.InputMethodManager;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
@@ -224,6 +226,9 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
        mContext.initResources();
        sCurrentContext = mContext;

        // create an InputMethodManager
        InputMethodManager.getInstance(Looper.myLooper());

        LayoutLog currentLog = mParams.getLog();
        Bridge.setLog(currentLog);
        mContext.getRenderResources().setFrameworkResourceIdProvider(this);
@@ -245,6 +250,9 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
        // clear the stored ViewConfiguration since the map is per density and not per context.
        ViewConfiguration.sConfigurations.clear();

        // remove the InputMethodManager
        InputMethodManager.mInstance = null;

        sCurrentContext = null;

        Bridge.setLog(null);
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ public final class CreateInfo implements ICreateInfo {
        "android.view.LayoutInflater#rInflate",
        "android.view.LayoutInflater#parseInclude",
        "android.view.View#isInEditMode",
        "android.view.inputmethod.InputMethodManager#getInstance",
        "com.android.internal.util.XmlUtils#convertValueToInt",
        // TODO: comment out once DelegateClass is working
    };