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

Commit 768722fe authored by Jason Hsu's avatar Jason Hsu Committed by Android (Google) Code Review
Browse files

Merge "Support ability to add different page id for different accessibility...

Merge "Support ability to add different page id for different accessibility service page in settings." into sc-v2-dev
parents a448a917 3d0f12d0
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.settings.accessibility;

import android.content.ComponentName;

import androidx.annotation.Nullable;

/**
 * Provider for Accessibility metrics related features.
 */
public interface AccessibilityMetricsFeatureProvider {

    /**
     * Returns {@link android.app.settings.SettingsEnums} value according to the {@code
     * componentName}.
     *
     * @param componentName the component name of the downloaded service or activity
     * @return value in {@link android.app.settings.SettingsEnums}
     */
    int getDownloadedFeatureMetricsCategory(@Nullable ComponentName componentName);
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.settings.accessibility;

import android.app.settings.SettingsEnums;
import android.content.ComponentName;

/**
 * Provider implementation for Accessibility metrics related features.
 */
public class AccessibilityMetricsFeatureProviderImpl implements
        AccessibilityMetricsFeatureProvider {

    @Override
    public int getDownloadedFeatureMetricsCategory(ComponentName componentName) {
        return SettingsEnums.ACCESSIBILITY_SERVICE;
    }
}
+15 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import androidx.annotation.Nullable;
import androidx.preference.Preference;

import com.android.settings.R;
import com.android.settings.overlay.FeatureFactory;

import java.util.ArrayList;
import java.util.List;
@@ -51,6 +52,19 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
    private static final String EMPTY_STRING = "";
    protected static final String KEY_LAUNCH_PREFERENCE = "launch_preference";

    @Override
    public int getMetricsCategory() {
        // Retrieve from getArguments() directly because this function will be executed from
        // onAttach(), but variable mComponentName only available after onProcessArguments()
        // which comes from onCreateView().
        final ComponentName componentName = getArguments().getParcelable(
                AccessibilitySettings.EXTRA_COMPONENT_NAME);

        return FeatureFactory.getFactory(getActivity().getApplicationContext())
                .getAccessibilityMetricsFeatureProvider()
                .getDownloadedFeatureMetricsCategory(componentName);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
@@ -60,7 +74,7 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
        initLaunchPreference();
        removePreference(KEY_USE_SERVICE_PREFERENCE);
        return view;
    };
    }

    @Override
    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
@@ -70,7 +84,6 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
    @Override
    protected void onProcessArguments(Bundle arguments) {
        super.onProcessArguments(arguments);

        mComponentName = arguments.getParcelable(AccessibilitySettings.EXTRA_COMPONENT_NAME);
        final ActivityInfo info = getAccessibilityShortcutInfo().getActivityInfo();
        mPackageName = info.loadLabel(getPackageManager()).toString();
+10 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import androidx.annotation.Nullable;
import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
import com.android.settingslib.accessibility.AccessibilityUtils;

@@ -84,7 +85,15 @@ public class ToggleAccessibilityServicePreferenceFragment extends

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.ACCESSIBILITY_SERVICE;
        // Retrieve from getArguments() directly because this function will be executed from
        // onAttach(), but variable mComponentName only available after onProcessArguments()
        // which comes from onCreateView().
        final ComponentName componentName = getArguments().getParcelable(
                AccessibilitySettings.EXTRA_COMPONENT_NAME);

        return FeatureFactory.getFactory(getActivity().getApplicationContext())
                .getAccessibilityMetricsFeatureProvider()
                .getDownloadedFeatureMetricsCategory(componentName);
    }

    @Override
+12 −6
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.util.Log;
import androidx.annotation.Nullable;

import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityMetricsFeatureProvider;
import com.android.settings.accessibility.AccessibilitySearchFeatureProvider;
import com.android.settings.accounts.AccountFeatureProvider;
import com.android.settings.applications.ApplicationFeatureProvider;
@@ -111,13 +112,13 @@ public abstract class FeatureFactory {
    public abstract PowerUsageFeatureProvider getPowerUsageFeatureProvider(Context context);

    /**
     * Retrieve implementation for Battery Status feature.
     * Retrieves implementation for Battery Status feature.
     */
    public abstract BatteryStatusFeatureProvider getBatteryStatusFeatureProvider(
            Context context);

    /**
     * Get implementation for Battery Settings provider.
     * Gets implementation for Battery Settings provider.
     */
    public abstract BatterySettingsFeatureProvider getBatterySettingsFeatureProvider(
            Context context);
@@ -161,25 +162,30 @@ public abstract class FeatureFactory {
    public abstract WifiTrackerLibProvider getWifiTrackerLibProvider();

    /**
     * Retrieve implementation for Extra App Info feature.
     * Retrieves implementation for Extra App Info feature.
     */
    public abstract ExtraAppInfoFeatureProvider getExtraAppInfoFeatureProvider();

    /**
     * Retrieve implementation for SecuritySettings feature.
     * Retrieves implementation for SecuritySettings feature.
     */
    public abstract SecuritySettingsFeatureProvider getSecuritySettingsFeatureProvider();

    /**
     * Retrieve implementation for Game Settings feature.
     * Retrieves implementation for Game Settings feature.
     */
    public abstract GameSettingsFeatureProvider getGameSettingsFeatureProvider();

    /**
     * Retrieve implementation for Accessibility search index feature.
     * Retrieves implementation for Accessibility search index feature.
     */
    public abstract AccessibilitySearchFeatureProvider getAccessibilitySearchFeatureProvider();

    /**
     * Retrieves implementation for Accessibility metrics category feature.
     */
    public abstract AccessibilityMetricsFeatureProvider getAccessibilityMetricsFeatureProvider();

    public static final class FactoryNotFoundException extends RuntimeException {
        public FactoryNotFoundException(Throwable throwable) {
            super("Unable to create factory. Did you misconfigure Proguard?", throwable);
Loading