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

Commit 67365603 authored by Diogo Ferreira's avatar Diogo Ferreira
Browse files

Settings: Add CM-specific settings

Change-Id: Iae0f60a62a51e96893766c4fa50a60ac4a214102
Ticket: CYNGNOS-1577
parent 1eb75899
Loading
Loading
Loading
Loading
+8 −30
Original line number Diff line number Diff line
@@ -84,8 +84,8 @@ public class SecuritySettings extends SettingsPreferenceFragment
            new Intent(TrustAgentService.SERVICE_INTERFACE);

    // Fitler types for this panel
    private static final String FILTER_TYPE_EXTRA = "filter_type";
    private static final int TYPE_LOCKSCREEN_EXTRA = 0;
    protected static final String FILTER_TYPE_EXTRA = "filter_type";
    protected static final int TYPE_LOCKSCREEN_EXTRA = 0;
    private static final int TYPE_SECURITY_EXTRA = 1;

    // Lock Settings
@@ -132,9 +132,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
    // Only allow one trust agent on the platform.
    private static final boolean ONLY_ONE_TRUST_AGENT = true;

    private static final int MY_USER_ID = UserHandle.myUserId();
    protected static final int MY_USER_ID = UserHandle.myUserId();

    private static final String LIVE_LOCK_SCREEN_FEATURE = "org.cyanogenmod.livelockscreen";
    protected static final String LIVE_LOCK_SCREEN_FEATURE = "org.cyanogenmod.livelockscreen";

    private PackageManager mPM;
    private DevicePolicyManager mDPM;
@@ -205,7 +205,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
        }
    }

    private static int getResIdForLockUnlockScreen(Context context,
    protected static int getResIdForLockUnlockScreen(Context context,
            LockPatternUtils lockPatternUtils) {
        int resid = 0;
        if (!lockPatternUtils.isSecure(MY_USER_ID)) {
@@ -540,7 +540,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
        }
    }

    private static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
    protected static ArrayList<TrustAgentComponentInfo> getActiveTrustAgents(
            PackageManager pm, LockPatternUtils utils, DevicePolicyManager dpm) {
        ArrayList<TrustAgentComponentInfo> result = new ArrayList<TrustAgentComponentInfo>();
        List<ResolveInfo> resolveInfos = pm.queryIntentServices(TRUST_AGENT_INTENT,
@@ -874,14 +874,8 @@ public class SecuritySettings extends SettingsPreferenceFragment

            List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>();

            LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
            // Add options for lock/unlock screen
            int resId = getResIdForLockUnlockScreen(context, lockPatternUtils);

            SearchIndexableResource sir = new SearchIndexableResource(context);
            sir.xmlResId = resId;
            result.add(sir);

            int resId = 0;
            SearchIndexableResource sir;
            if (mIsPrimary) {
                DevicePolicyManager dpm = (DevicePolicyManager)
                        context.getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -932,22 +926,6 @@ public class SecuritySettings extends SettingsPreferenceFragment
                result.add(data);
            }

            // Fingerprint
            FingerprintManager fpm =
                    (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
            if (fpm.isHardwareDetected()) {
                // This catches the title which can be overloaded in an overlay
                data = new SearchIndexableRaw(context);
                data.title = res.getString(R.string.security_settings_fingerprint_preference_title);
                data.screenTitle = screenTitle;
                result.add(data);
                // Fallback for when the above doesn't contain "fingerprint"
                data = new SearchIndexableRaw(context);
                data.title = res.getString(R.string.fingerprint_manage_category_title);
                data.screenTitle = screenTitle;
                result.add(data);
            }

            // Credential storage
            final UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);

+125 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The CyanogenMod 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.cyanogenmod;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.SecuritySettings;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.SearchIndexableRaw;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource;
import com.android.settings.R;
import java.util.ArrayList;
import java.util.List;

public class LockscreenSettingsAlias extends SecuritySettings {
    public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new SecuritySearchIndexProvider();

    private static class SecuritySearchIndexProvider extends BaseSearchIndexProvider {

        boolean mIsPrimary;

        public SecuritySearchIndexProvider() {
            super();

            mIsPrimary = MY_USER_ID == UserHandle.USER_OWNER;
        }

        @Override
        public List<SearchIndexableResource> getXmlResourcesToIndex(
                Context context, boolean enabled) {

            List<SearchIndexableResource> result = new ArrayList<SearchIndexableResource>();

            LockPatternUtils lockPatternUtils = new LockPatternUtils(context);
            // Add options for lock/unlock screen
            int resId = getResIdForLockUnlockScreen(context, lockPatternUtils);

            SearchIndexableResource sir = new SearchIndexableResource(context);
            sir.xmlResId = resId;
            result.add(sir);

            return result;
        }

        @Override
        public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
            final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
            final Resources res = context.getResources();

            final String screenTitle = res.getString(R.string.lockscreen_settings);

            SearchIndexableRaw data = new SearchIndexableRaw(context);
            data.title = screenTitle;
            data.screenTitle = screenTitle;
            result.add(data);

            if (!mIsPrimary) {
                int resId = (UserManager.get(context).isLinkedUser()) ?
                        R.string.profile_info_settings_title : R.string.user_info_settings_title;

                data = new SearchIndexableRaw(context);
                data.title = res.getString(resId);
                data.screenTitle = screenTitle;
                result.add(data);
            }

            // Fingerprint
            FingerprintManager fpm =
                    (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
            if (fpm.isHardwareDetected()) {
                // This catches the title which can be overloaded in an overlay
                data = new SearchIndexableRaw(context);
                data.title = res.getString(R.string.security_settings_fingerprint_preference_title);
                data.screenTitle = screenTitle;
                result.add(data);
                // Fallback for when the above doesn't contain "fingerprint"
                data = new SearchIndexableRaw(context);
                data.title = res.getString(R.string.fingerprint_manage_category_title);
                data.screenTitle = screenTitle;
                result.add(data);
            }

            PackageManager pm = context.getPackageManager();
            if (pm.hasSystemFeature(LIVE_LOCK_SCREEN_FEATURE)) {
                data = new SearchIndexableRaw(context);
                data.title = res.getString(R.string.live_lock_screen_title);
                data.screenTitle = screenTitle;
                result.add(data);
            }

            return result;
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        Bundle bundle = getArguments();
        if (bundle != null) {
            bundle.putInt(FILTER_TYPE_EXTRA, TYPE_LOCKSCREEN_EXTRA);
        }
        super.onCreate(savedInstanceState);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ public class IndexDatabaseHelper extends SQLiteOpenHelper {
    private static final String TAG = "IndexDatabaseHelper";

    private static final String DATABASE_NAME = "search_index.db";
    private static final int DATABASE_VERSION = 116;
    private static final int DATABASE_VERSION = 117;

    public interface Tables {
        public static final String TABLE_PREFS_INDEX = "prefs_index";
+6 −0
Original line number Diff line number Diff line
@@ -53,6 +53,9 @@ import com.android.settings.wifi.AdvancedWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;

import com.android.settings.ButtonSettings;
import com.android.settings.cyanogenmod.StatusBarSettings;

import java.util.HashMap;

/**
@@ -117,6 +120,8 @@ public final class Ranking {

        // Display
        sRankMap.put(DisplaySettings.class.getName(), RANK_DISPLAY);
        sRankMap.put(ButtonSettings.class.getName(), RANK_DISPLAY);
        sRankMap.put(StatusBarSettings.class.getName(), RANK_DISPLAY);

        // Wallpapers
        sRankMap.put(WallpaperTypeSettings.class.getName(), RANK_WALLPAPER);
@@ -156,6 +161,7 @@ public final class Ranking {

        // Privacy
        sRankMap.put(PrivacySettings.class.getName(), RANK_PRIVACY);
        sRankMap.put(com.android.settings.cyanogenmod.PrivacySettings.class.getName(), RANK_PRIVACY);

        // Date / Time
        sRankMap.put(DateTimeSettings.class.getName(), RANK_DATE_TIME);
+34 −0
Original line number Diff line number Diff line
@@ -54,6 +54,9 @@ import com.android.settings.wifi.AdvancedWifiSettings;
import com.android.settings.wifi.SavedAccessPointsWifiSettings;
import com.android.settings.wifi.WifiSettings;

import com.android.settings.ButtonSettings;
import com.android.settings.cyanogenmod.StatusBarSettings;

import java.util.Collection;
import java.util.HashMap;

@@ -309,6 +312,37 @@ public final class SearchIndexableResources {
                        R.xml.wifi_calling_settings,
                        WifiCallingSettings.class.getName(),
                        R.drawable.ic_settings_wireless));

        // CyanogenMod Settings
        sResMap.put(ButtonSettings.class.getName(),
                new SearchIndexableResource(
                        Ranking.getRankForClassName(ButtonSettings.class.getName()),
                        R.xml.button_settings,
                        ButtonSettings.class.getName(),
                        R.drawable.ic_settings_buttons));

        sResMap.put(StatusBarSettings.class.getName(),
                new SearchIndexableResource(
                        Ranking.getRankForClassName(StatusBarSettings.class.getName()),
                        R.xml.status_bar_settings,
                        StatusBarSettings.class.getName(),
                        R.drawable.ic_settings_statusbar));

        sResMap.put(com.android.settings.cyanogenmod.PrivacySettings.class.getName(),
                new SearchIndexableResource(
                        Ranking.getRankForClassName(
                                com.android.settings.cyanogenmod.PrivacySettings.class.getName()),
                        R.xml.privacy_settings_cyanogenmod,
                        com.android.settings.cyanogenmod.PrivacySettings.class.getName(),
                        R.drawable.ic_settings_privacy));

        sResMap.put(com.android.settings.cyanogenmod.LockscreenSettingsAlias.class.getName(),
                new SearchIndexableResource(
                        Ranking.getRankForClassName(
                                com.android.settings.cyanogenmod.LockscreenSettingsAlias.class.getName()),
                        NO_DATA_RES_ID,
                        com.android.settings.cyanogenmod.LockscreenSettingsAlias.class.getName(),
                        R.drawable.ic_settings_lockscreen));
    }

    private SearchIndexableResources() {