Kill privacy guard

* Replaced by permission hub

Change-Id: I03a56d850f021cebc307bee15df5f5658c422802
diff --git a/res/drawable/ic_privacy_guard_off.xml b/res/drawable/ic_privacy_guard_off.xml
deleted file mode 100644
index 283d15c..0000000
--- a/res/drawable/ic_privacy_guard_off.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2017 The LineageOS 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:colorControlNormal">
-
-    <path
-        android:fillColor="#FFFFFFFF"
-        android:pathData="M5,3L19,3C20.105,3 21,3.895 21,5L21,12C21,16.971 16.971,21 12,21C7.029,21 3,16.971 3,12L3,5C3,3.895 3.895,3 5,3ZM18.902,13.168C18.994,12.624 18.627,12.108 18.082,12.016C17.538,11.925 17.022,12.292 16.93,12.837C16.528,15.225 14.45,17 12,17C9.55,17 7.472,15.226 7.069,12.838C6.978,12.294 6.462,11.927 5.917,12.018C5.373,12.11 5.005,12.626 5.097,13.171C5.661,16.517 8.57,19 12,19C15.43,19 18.339,16.516 18.902,13.168ZM11.046,5.698L9.127,11.297C9.045,11.516 9,11.753 9,12C9,13.104 9.895,14 11,14C11.01,14 11.019,14 11.029,14L13,14C13.55,14 14.05,13.78 14.41,13.41C14.78,13.05 15,12.55 15,12L12.6,12L11,11.999L11.438,10.724L11.646,10.116L12.938,6.346C12.978,6.238 13,6.121 13,6C13,5.448 12.552,5 12,5C11.553,5 11.174,5.293 11.046,5.698Z" />
-</vector>
diff --git a/res/drawable/ic_privacy_guard_on.xml b/res/drawable/ic_privacy_guard_on.xml
deleted file mode 100644
index 11e70c7..0000000
--- a/res/drawable/ic_privacy_guard_on.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-     Copyright (C) 2017 The LineageOS 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24"
-    android:tint="?android:colorControlActivated">
-
-    <path
-        android:fillColor="#FFFFFFFF"
-        android:pathData="M5,3L19,3C20.105,3 21,3.895 21,5L21,12C21,16.971 16.971,21 12,21C7.029,21 3,16.971 3,12L3,5C3,3.895 3.895,3 5,3ZM18.902,13.168C18.994,12.624 18.627,12.108 18.082,12.016C17.538,11.925 17.022,12.292 16.93,12.837C16.528,15.225 14.45,17 12,17C9.55,17 7.472,15.226 7.069,12.838C6.978,12.294 6.462,11.927 5.917,12.018C5.373,12.11 5.005,12.626 5.097,13.171C5.661,16.517 8.57,19 12,19C15.43,19 18.339,16.516 18.902,13.168ZM11.046,5.698L9.127,11.297C9.045,11.516 9,11.753 9,12C9,13.104 9.895,14 11,14C11.01,14 11.019,14 11.029,14L13,14C13.55,14 14.05,13.78 14.41,13.41C14.78,13.05 15,12.55 15,12L12.6,12L11,11.999L11.438,10.724L11.646,10.116L12.938,6.346C12.978,6.238 13,6.121 13,6C13,5.448 12.552,5 12,5C11.553,5 11.174,5.293 11.046,5.698Z" />
-</vector>
diff --git a/res/layout/privacy_guard_manager.xml b/res/layout/privacy_guard_manager.xml
deleted file mode 100644
index cc04cfc..0000000
--- a/res/layout/privacy_guard_manager.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 Slimroms 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-    <FrameLayout
-        android:id="@+id/privacy_guard_prefs"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
-    <TextView
-        android:id="@+id/error"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginTop="20dip"
-        android:layout_gravity="center"
-        android:gravity="center_horizontal"
-        android:textColor="?android:attr/textColorPrimary"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:visibility="gone" />
-    <FrameLayout
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="1">
-
-        <ListView android:id="@+id/apps_list"
-            android:drawSelectorOnTop="false"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:clipToPadding="false"
-            android:scrollbarStyle="@*android:integer/preference_fragment_scrollbarStyle"
-            android:visibility="gone"/>
-
-        <LinearLayout android:id="@+id/loading_container"
-                android:orientation="vertical"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:visibility="gone"
-                android:gravity="center">
-
-            <ProgressBar style="?android:attr/progressBarStyleLarge"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content" />
-
-            <TextView android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:textAppearance="?android:attr/textAppearanceSmall"
-                    android:text="@string/loading"
-                    android:paddingTop="4dip"
-                    android:singleLine="true" />
-
-        </LinearLayout>
-    </FrameLayout>
-
-</LinearLayout>
diff --git a/res/layout/privacy_guard_manager_list_row.xml b/res/layout/privacy_guard_manager_list_row.xml
deleted file mode 100644
index e8a20dc..0000000
--- a/res/layout/privacy_guard_manager_list_row.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 Slimroms 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.
--->
-
-<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:minHeight="?android:attr/listPreferredItemHeight"
-    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
-    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
-    android:paddingTop="8dip"
-    android:paddingBottom="8dip" >
-    <LinearLayout
-        android:id="@+id/icon_frame"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:minWidth="56dp"
-        android:gravity="start|center_vertical"
-        android:orientation="horizontal"
-        android:paddingRight="8dp"
-        android:paddingTop="4dp"
-        android:paddingBottom="4dp">
-        <androidx.preference.internal.PreferenceImageView
-            android:id="@+id/app_icon"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            app:maxWidth="48dp"
-            app:maxHeight="48dp" />
-    </LinearLayout>
-    <TextView
-        android:id="@+id/app_title"
-        android:layout_width="0dip"
-        android:layout_gravity="fill_horizontal|center_vertical"
-        android:layout_marginTop="2dip"
-        android:singleLine="true"
-        android:ellipsize="marquee"
-        android:textAppearance="?android:attr/textAppearanceMedium"
-        android:textAlignment="viewStart" />
-    <ImageView
-        android:id="@+id/app_privacy_guard_icon"
-        android:layout_width="@android:dimen/app_icon_size"
-        android:layout_height="@android:dimen/app_icon_size"
-        android:layout_gravity="center_vertical"
-        android:scaleType="centerInside"
-        android:contentDescription="@null" />
-</GridLayout>
diff --git a/res/menu/privacy_guard_manager.xml b/res/menu/privacy_guard_manager.xml
deleted file mode 100644
index 4728309..0000000
--- a/res/menu/privacy_guard_manager.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 Slimroms 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.
--->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:id="@+id/reset"
-          android:showAsAction="always"
-          android:icon="@drawable/ic_settings_backup_restore"
-          android:title="@string/privacy_guard_reset_title" />
-    <item android:id="@+id/privacy_guard_default"
-          android:title="@string/privacy_guard_default_title"
-          android:checkable="true" />
-    <item android:id="@+id/privacy_guard_notification"
-          android:title="@string/privacy_guard_notification_title"
-          android:checkable="true" />
-    <item android:id="@+id/show_system_apps"
-          android:title="@string/privacy_guard_manager_show_system_apps"
-          android:checkable="true" />
-    <item android:id="@+id/advanced"
-          android:title="@string/privacy_guard_advanced_settings_title" />
-    <item android:id="@+id/help"
-          android:title="@string/privacy_guard_help_title" />
-</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8863817..26c9b49 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -48,22 +48,6 @@
     <string name="privacy_settings_title">Privacy</string>
     <string name="privacy_settings_category" translatable="false">LineageOS</string>
 
-    <!-- Privacy Guard -->
-    <string name="privacy_guard_switch_label">Enable Privacy Guard</string>
-    <string name="privacy_guard_dlg_title">Enable Privacy Guard?</string>
-    <string name="privacy_guard_dlg_text">When Privacy Guard is enabled, the app will not be able to access personal data such as contacts, messages or call logs.</string>
-    <string name="privacy_guard_dlg_system_app_text">When enabling Privacy Guard for a built-in app, the app will not be able to access or provide personal data. This may cause other apps to misbehave.</string>
-    <string name="privacy_guard_default_title">Enabled by default</string>
-    <string name="privacy_guard_manager_summary">Manage which apps have access to your personal data</string>
-    <string name="privacy_guard_no_user_apps">No apps are installed</string>
-    <string name="privacy_guard_help_title">Help</string>
-    <string name="privacy_guard_reset_title">Reset</string>
-    <string name="privacy_guard_reset_text">Reset permissions?</string>
-    <string name="privacy_guard_help_text">In this screen you can choose which apps Privacy Guard should be active for by simply tapping on them. Selected apps will not be able to access your personal data such as contacts, messages or call logs. Long pressing an app\'s entry opens its app details screen.\n\nBuilt-in apps are not shown by default but can be revealed by selecting the respective menu option.</string>
-    <string name="privacy_guard_manager_show_system_apps">Show built-in apps</string>
-    <string name="privacy_guard_advanced_settings_title">Advanced</string>
-    <string name="privacy_guard_notification_title">Show notification</string>
-
     <!-- Notification channels -->
     <string name="channel_light_settings_id" translatable="false">light_settings</string>
     <string name="channel_light_settings_name">Light settings preview</string>
diff --git a/res/xml/parts_catalog.xml b/res/xml/parts_catalog.xml
index a91deb9..546b96a 100644
--- a/res/xml/parts_catalog.xml
+++ b/res/xml/parts_catalog.xml
@@ -80,11 +80,6 @@
           android:fragment="org.lineageos.lineageparts.input.PowerMenuActions"
           lineage:xmlRes="@xml/power_menu_settings" />
 
-    <part android:key="privacy_guard_manager"
-          android:title="@*lineageos.platform:string/privacy_guard_manager_title"
-          android:fragment="org.lineageos.lineageparts.privacyguard.PrivacyGuardManager"
-          lineage:xmlRes="@xml/privacy_guard_prefs" />
-
     <part android:key="weather_settings"
           android:title="@string/weather_settings_title"
           android:fragment="org.lineageos.lineageparts.weather.WeatherServiceSettings"
diff --git a/res/xml/privacy_guard_prefs.xml b/res/xml/privacy_guard_prefs.xml
deleted file mode 100644
index 2409042..0000000
--- a/res/xml/privacy_guard_prefs.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 Slimroms 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.
--->
-
-<PreferenceScreen
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:key="privacy_guard_manager"
-    android:title="@*lineageos.platform:string/privacy_guard_manager_title">
-</PreferenceScreen>
diff --git a/res/xml/trust_preferences.xml b/res/xml/trust_preferences.xml
index 6833cfe..03d6576 100644
--- a/res/xml/trust_preferences.xml
+++ b/res/xml/trust_preferences.xml
@@ -43,9 +43,6 @@
         android:key="trust_category_tools"
         android:title="@string/trust_category_tools">
 
-        <org.lineageos.internal.lineageparts.LineagePartsPreference
-            android:key="privacy_guard_manager" />
-
         <lineageos.preference.LineageSecureSettingSwitchPreference
             android:key="trust_restrict_usb"
             android:title="@string/trust_restrict_usb_title"
diff --git a/src/org/lineageos/lineageparts/privacyguard/AppInfoLoader.java b/src/org/lineageos/lineageparts/privacyguard/AppInfoLoader.java
deleted file mode 100644
index b2b0a6d..0000000
--- a/src/org/lineageos/lineageparts/privacyguard/AppInfoLoader.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2015 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 org.lineageos.lineageparts.privacyguard;
-
-import android.app.AppOpsManager;
-import android.content.AsyncTaskLoader;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageInfo;
-
-import org.lineageos.lineageparts.privacyguard.PrivacyGuardManager.AppInfo;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * An asynchronous loader implementation that loads AppInfo structures.
- */
-/* package */ class AppInfoLoader extends AsyncTaskLoader<List<AppInfo>> {
-    private PackageManager mPm;
-    private boolean mShowSystemApps;
-    private AppOpsManager mAppOps;
-    private static final String[] BLACKLISTED_PACKAGES = {
-            "com.android.systemui"
-    };
-
-    public AppInfoLoader(Context context, boolean showSystemApps) {
-        super(context);
-        mPm = context.getPackageManager();
-        mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
-        mShowSystemApps = showSystemApps;
-    }
-
-    @Override
-    public List<AppInfo> loadInBackground() {
-        return loadInstalledApps();
-    }
-
-    @Override
-    public void onStartLoading() {
-        forceLoad();
-    }
-
-    @Override
-    public void onStopLoading() {
-        cancelLoad();
-    }
-
-    @Override
-    protected void onReset() {
-        cancelLoad();
-    }
-
-    private boolean isBlacklisted(String packageName) {
-        for (String pkg : BLACKLISTED_PACKAGES)  {
-            if (pkg.equals(packageName)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-    * Uses the package manager to query for all currently installed apps
-    * for the list.
-    *
-    * @return the complete List off installed applications (@code PrivacyGuardAppInfo)
-    */
-    private List<AppInfo> loadInstalledApps() {
-        List<AppInfo> apps = new ArrayList<AppInfo>();
-        List<PackageInfo> packages = mPm.getInstalledPackages(
-            PackageManager.GET_PERMISSIONS | PackageManager.GET_SIGNATURES);
-
-        for (PackageInfo info : packages) {
-            final ApplicationInfo appInfo = info.applicationInfo;
-
-            // skip all system apps if they shall not be included
-            if ((!mShowSystemApps && (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0)
-                    || (appInfo.uid == android.os.Process.SYSTEM_UID)
-                    || isBlacklisted(appInfo.packageName)) {
-                continue;
-            }
-
-            AppInfo app = new AppInfo();
-            app.title = appInfo.loadLabel(mPm).toString();
-            app.packageName = info.packageName;
-            app.enabled = appInfo.enabled;
-            app.uid = info.applicationInfo.uid;
-/*
-            app.privacyGuardEnabled = mAppOps.getPrivacyGuardSettingForPackage(
-                    app.uid, app.packageName);
-*/
-            apps.add(app);
-        }
-
-        // sort the apps by their enabled state, then by title
-        Collections.sort(apps, new Comparator<AppInfo>() {
-            @Override
-            public int compare(AppInfo lhs, AppInfo rhs) {
-                if (lhs.enabled != rhs.enabled) {
-                    return lhs.enabled ? -1 : 1;
-                }
-                return lhs.title.compareToIgnoreCase(rhs.title);
-            }
-        });
-
-        return apps;
-    }
-
-}
diff --git a/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardAppListAdapter.java b/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardAppListAdapter.java
deleted file mode 100644
index d08747e..0000000
--- a/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardAppListAdapter.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2013 SlimRoms Project
- * 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 org.lineageos.lineageparts.privacyguard;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.SectionIndexer;
-import android.widget.TextView;
-
-import org.lineageos.lineageparts.R;
-import org.lineageos.lineageparts.privacyguard.PrivacyGuardManager.AppInfo;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class PrivacyGuardAppListAdapter extends BaseAdapter implements SectionIndexer {
-
-    private LayoutInflater mInflater;
-    private PackageManager mPm;
-
-    private List<AppInfo> mApps;
-    private String[] mSections;
-    private int[] mPositions;
-    private ConcurrentHashMap<String, Drawable> mIcons;
-    private Drawable mDefaultImg;
-
-    private Context mContext;
-
-    //constructor
-    public PrivacyGuardAppListAdapter(Context context, List<AppInfo> apps,
-            List<String> sections, List<Integer> positions) {
-        mContext = context;
-        mInflater = LayoutInflater.from(mContext);
-        mPm = context.getPackageManager();
-
-        mApps = apps;
-        mSections = sections.toArray(new String[sections.size()]);
-        mPositions = new int[positions.size()];
-        for (int i = 0; i < positions.size(); i++) {
-            mPositions[i] = positions.get(i);
-        }
-
-        // set the default icon till the actual app icon is loaded in async task
-        mDefaultImg = mContext.getResources().getDrawable(android.R.mipmap.sym_def_app_icon);
-        mIcons = new ConcurrentHashMap<String, Drawable>();
-
-        new LoadIconsTask().execute(apps.toArray(new PrivacyGuardManager.AppInfo[]{}));
-    }
-
-    @Override
-    public int getCount() {
-        return mApps.size();
-    }
-
-    @Override
-    public Object getItem(int position) {
-        return mApps.get(position);
-    }
-
-    @Override
-    public long getItemId(int position) {
-        return position;
-    }
-
-    @Override
-    public View getView(int position, View convertView, ViewGroup parent) {
-        PrivacyGuardAppViewHolder appHolder;
-
-        if (convertView == null) {
-            convertView = mInflater.inflate(R.layout.privacy_guard_manager_list_row, null);
-
-            // creates a ViewHolder and children references
-            appHolder = new PrivacyGuardAppViewHolder();
-            appHolder.title = (TextView) convertView.findViewById(R.id.app_title);
-            appHolder.icon = (ImageView) convertView.findViewById(R.id.app_icon);
-            appHolder.privacyGuardIcon = (ImageView) convertView.findViewById(R.id.app_privacy_guard_icon);
-            convertView.setTag(appHolder);
-        } else {
-            appHolder = (PrivacyGuardAppViewHolder) convertView.getTag();
-        }
-
-        PrivacyGuardManager.AppInfo app = mApps.get(position);
-
-        appHolder.title.setText(app.title);
-
-        Drawable icon = mIcons.get(app.packageName);
-        appHolder.icon.setImageDrawable(icon != null ? icon : mDefaultImg);
-
-        int privacyGuardDrawableResId = app.privacyGuardEnabled
-                ? R.drawable.ic_privacy_guard_on :
-                  R.drawable.ic_privacy_guard_off;
-        appHolder.privacyGuardIcon.setImageResource(privacyGuardDrawableResId);
-
-        return convertView;
-    }
-
-    @Override
-    public int getPositionForSection(int section) {
-        if (section < 0 || section >= mSections.length) {
-            return -1;
-        }
-
-        return mPositions[section];
-    }
-
-    @Override
-    public int getSectionForPosition(int position) {
-        if (position < 0 || position >= getCount()) {
-            return -1;
-        }
-
-        int index = Arrays.binarySearch(mPositions, position);
-
-        /*
-         * Consider this example: section positions are 0, 3, 5; the supplied
-         * position is 4. The section corresponding to position 4 starts at
-         * position 3, so the expected return value is 1. Binary search will not
-         * find 4 in the array and thus will return -insertPosition-1, i.e. -3.
-         * To get from that number to the expected value of 1 we need to negate
-         * and subtract 2.
-         */
-        return index >= 0 ? index : -index - 2;
-    }
-
-    @Override
-    public Object[] getSections() {
-        return mSections;
-    }
-
-    /**
-     * An asynchronous task to load the icons of the installed applications.
-     */
-    private class LoadIconsTask extends AsyncTask<PrivacyGuardManager.AppInfo, Void, Void> {
-        @Override
-        protected Void doInBackground(PrivacyGuardManager.AppInfo... apps) {
-            for (PrivacyGuardManager.AppInfo app : apps) {
-                try {
-                    Drawable icon = mPm.getApplicationIcon(app.packageName);
-                    mIcons.put(app.packageName, icon);
-                    publishProgress();
-                } catch (PackageManager.NameNotFoundException e) {
-                    // ignored; app will show up with default image
-                }
-            }
-
-            return null;
-        }
-
-        @Override
-        protected void onProgressUpdate(Void... progress) {
-            notifyDataSetChanged();
-        }
-    }
-
-    /**
-     * App view holder used to reuse the views inside the list.
-     */
-    public static class PrivacyGuardAppViewHolder {
-        TextView title;
-        ImageView icon;
-        ImageView privacyGuardIcon;
-    }
-}
diff --git a/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardManager.java b/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardManager.java
deleted file mode 100644
index 0e78ccf..0000000
--- a/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardManager.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (C) 2013 SlimRoms Project
- * Copyright (C) 2016 The CyanogenMod Project
- *               2017 The LineageOS 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 org.lineageos.lineageparts.privacyguard;
-
-import android.app.FragmentTransaction;
-import android.view.animation.AnimationUtils;
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.AppOpsManager;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.app.Fragment;
-import android.app.LoaderManager;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.Loader;
-import android.content.SharedPreferences;
-import android.net.Uri;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.text.TextUtils;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.AdapterView.OnItemLongClickListener;
-import android.widget.ListView;
-import android.widget.TextView;
-
-import lineageos.providers.LineageSettings;
-
-import org.lineageos.lineageparts.R;
-import org.lineageos.lineageparts.SettingsPreferenceFragment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class PrivacyGuardManager extends SettingsPreferenceFragment
-        implements OnItemClickListener, OnItemLongClickListener,
-                   LoaderManager.LoaderCallbacks<List<PrivacyGuardManager.AppInfo>> {
-
-    private static final String TAG = "PrivacyGuardManager";
-
-    private TextView mNoUserAppsInstalled;
-    private ListView mAppsList;
-    private View mLoadingContainer;
-    private PrivacyGuardAppListAdapter mAdapter;
-    private List<AppInfo> mApps;
-
-    private Activity mActivity;
-
-    private SharedPreferences mPreferences;
-    private AppOpsManager mAppOps;
-
-    private int mSavedFirstVisiblePosition = AdapterView.INVALID_POSITION;
-    private int mSavedFirstItemOffset;
-
-    // keys for extras and icicles
-    private final static String LAST_LIST_POS = "last_list_pos";
-    private final static String LAST_LIST_OFFSET = "last_list_offset";
-
-    // Privacy Guard Fragment
-    private final static String PRIVACY_GUARD_FRAGMENT_TAG = "privacy_guard_fragment";
-
-    // holder for package data passed into the adapter
-    public static final class AppInfo {
-        String title;
-        String packageName;
-        boolean enabled;
-        boolean privacyGuardEnabled;
-        int uid;
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
-        mActivity = getActivity();
-        mAppOps = (AppOpsManager)getActivity().getSystemService(Context.APP_OPS_SERVICE);
-
-        View hostView = inflater.inflate(R.layout.privacy_guard_manager, container, false);
-
-        Fragment privacyGuardPrefs = PrivacyGuardPrefs.newInstance();
-        FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
-        fragmentTransaction.replace(R.id.privacy_guard_prefs, privacyGuardPrefs,
-                PRIVACY_GUARD_FRAGMENT_TAG);
-        fragmentTransaction.commit();
-        return hostView;
-    }
-
-    @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-
-        mNoUserAppsInstalled = (TextView) mActivity.findViewById(R.id.error);
-
-        mAppsList = (ListView) mActivity.findViewById(R.id.apps_list);
-        mAppsList.setOnItemClickListener(this);
-        mAppsList.setOnItemLongClickListener(this);
-
-        mLoadingContainer = mActivity.findViewById(R.id.loading_container);
-
-        // get shared preference
-        mPreferences = mActivity.getSharedPreferences("privacy_guard_manager", Activity.MODE_PRIVATE);
-        if (savedInstanceState == null && !mPreferences.getBoolean("first_help_shown", false)) {
-            showHelp();
-        }
-
-        if (savedInstanceState != null) {
-            mSavedFirstVisiblePosition = savedInstanceState.getInt(LAST_LIST_POS,
-                    AdapterView.INVALID_POSITION);
-            mSavedFirstItemOffset = savedInstanceState.getInt(LAST_LIST_OFFSET, 0);
-        } else {
-            mSavedFirstVisiblePosition = AdapterView.INVALID_POSITION;
-            mSavedFirstItemOffset = 0;
-        }
-
-        // load apps and construct the list
-        scheduleAppsLoad();
-
-        setHasOptionsMenu(true);
-    }
-
-    @Override
-    public void onViewStateRestored(Bundle savedInstanceState) {
-        super.onViewStateRestored(savedInstanceState);
-    }
-
-    @Override
-    public void onSaveInstanceState(Bundle outState) {
-        super.onSaveInstanceState(outState);
-
-        outState.putInt(LAST_LIST_POS, mSavedFirstVisiblePosition);
-        outState.putInt(LAST_LIST_OFFSET, mSavedFirstItemOffset);
-    }
-
-    @Override
-    public void onPause() {
-        super.onPause();
-
-        // Remember where the list is scrolled to so we can restore the scroll position
-        // when we come back to this activity and *after* we complete querying for the
-        // conversations.
-        mSavedFirstVisiblePosition = mAppsList.getFirstVisiblePosition();
-        View firstChild = mAppsList.getChildAt(0);
-        mSavedFirstItemOffset = (firstChild == null) ? 0 : firstChild.getTop();
-    }
-
-    @Override
-    public void onResume() {
-        super.onResume();
-
-        // rebuild the list; the user might have changed settings inbetween
-        scheduleAppsLoad();
-    }
-
-    @Override
-    public Loader<List<AppInfo>> onCreateLoader(int id, Bundle args) {
-        mLoadingContainer.startAnimation(AnimationUtils.loadAnimation(
-              mActivity, android.R.anim.fade_in));
-        mAppsList.startAnimation(AnimationUtils.loadAnimation(
-              mActivity, android.R.anim.fade_out));
-
-        mAppsList.setVisibility(View.INVISIBLE);
-        mLoadingContainer.setVisibility(View.VISIBLE);
-        return new AppInfoLoader(mActivity, shouldShowSystemApps());
-    }
-
-    @Override
-    public void onLoadFinished(Loader<List<AppInfo>> loader, List<AppInfo> apps) {
-        mApps = apps;
-        prepareAppAdapter();
-
-        mLoadingContainer.startAnimation(AnimationUtils.loadAnimation(
-              mActivity, android.R.anim.fade_out));
-        mAppsList.startAnimation(AnimationUtils.loadAnimation(
-              mActivity, android.R.anim.fade_in));
-
-        if (mSavedFirstVisiblePosition != AdapterView.INVALID_POSITION) {
-            mAppsList.setSelectionFromTop(mSavedFirstVisiblePosition, mSavedFirstItemOffset);
-            mSavedFirstVisiblePosition = AdapterView.INVALID_POSITION;
-        }
-
-        mLoadingContainer.setVisibility(View.INVISIBLE);
-        mAppsList.setVisibility(View.VISIBLE);
-    }
-
-    @Override
-    public void onLoaderReset(Loader<List<AppInfo>> loader) {
-    }
-
-    private void scheduleAppsLoad() {
-        getLoaderManager().restartLoader(0, null, this);
-    }
-
-    private void prepareAppAdapter() {
-        // if app list is empty inform the user
-        // else go ahead and construct the list
-        if (mApps == null || mApps.isEmpty()) {
-            mNoUserAppsInstalled.setText(R.string.privacy_guard_no_user_apps);
-            mNoUserAppsInstalled.setVisibility(View.VISIBLE);
-            mAppsList.setVisibility(View.GONE);
-            mAppsList.setAdapter(null);
-        } else {
-            mNoUserAppsInstalled.setVisibility(View.GONE);
-            mAppsList.setVisibility(View.VISIBLE);
-            mAdapter = createAdapter();
-            mAppsList.setAdapter(mAdapter);
-            mAppsList.setFastScrollEnabled(true);
-        }
-    }
-
-    private PrivacyGuardAppListAdapter createAdapter() {
-        String lastSectionIndex = null;
-        ArrayList<String> sections = new ArrayList<String>();
-        ArrayList<Integer> positions = new ArrayList<Integer>();
-        int count = mApps.size(), offset = 0;
-
-        for (int i = 0; i < count; i++) {
-            AppInfo app = mApps.get(i);
-            String sectionIndex;
-
-            if (!app.enabled) {
-                sectionIndex = "--"; //XXX
-            } else if (app.title.isEmpty()) {
-                sectionIndex = "";
-            } else {
-                sectionIndex = app.title.substring(0, 1).toUpperCase();
-            }
-
-            if (lastSectionIndex == null ||
-                    !TextUtils.equals(sectionIndex, lastSectionIndex)) {
-                sections.add(sectionIndex);
-                positions.add(offset);
-                lastSectionIndex = sectionIndex;
-            }
-            offset++;
-        }
-
-        return new PrivacyGuardAppListAdapter(mActivity, mApps, sections, positions);
-    }
-
-    private void resetPrivacyGuard() {
-        if (mApps == null || mApps.isEmpty()) {
-            return;
-        }
-        showResetDialog();
-    }
-
-    @Override
-    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
-        // on click change the privacy guard status for this item
-        final AppInfo app = (AppInfo) parent.getItemAtPosition(position);
-
-        app.privacyGuardEnabled = !app.privacyGuardEnabled;
-/*
-        mAppOps.setPrivacyGuardSettingForPackage(app.uid, app.packageName, app.privacyGuardEnabled);
-*/
-
-        mAdapter.notifyDataSetChanged();
-    }
-
-    @Override
-    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
-        // on long click open app details window
-        final AppInfo app = (AppInfo) parent.getItemAtPosition(position);
-
-        Bundle args = new Bundle();
-        args.putString("package", app.packageName);
-
-/*
-        final Intent i = new Intent(Settings.ACTION_APP_OPS_DETAILS_SETTINGS,
-                Uri.fromParts("package", app.packageName, null));
-        mActivity.startActivityForResult(i, 0);
-*/
-        return true;
-    }
-
-
-    private boolean shouldShowSystemApps() {
-        return mPreferences.getBoolean("show_system_apps", false);
-    }
-
-    public static class HelpDialogFragment extends DialogFragment {
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            return new AlertDialog.Builder(getActivity())
-                    .setTitle(R.string.privacy_guard_help_title)
-                    .setMessage(R.string.privacy_guard_help_text)
-                    .setNegativeButton(R.string.dlg_ok, new DialogInterface.OnClickListener() {
-                        @Override
-                        public void onClick(DialogInterface dialog, int which) {
-                            dialog.cancel();
-                        }
-                    })
-                    .create();
-        }
-
-        @Override
-        public void onCancel(DialogInterface dialog) {
-            getActivity().getSharedPreferences("privacy_guard_manager", Activity.MODE_PRIVATE)
-                    .edit()
-                    .putBoolean("first_help_shown", true)
-                    .commit();
-        }
-    }
-
-    private void showHelp() {
-        HelpDialogFragment fragment = new HelpDialogFragment();
-        fragment.show(getFragmentManager(), "help_dialog");
-    }
-
-    public static class ResetDialogFragment extends DialogFragment {
-        @Override
-        public Dialog onCreateDialog(Bundle savedInstanceState) {
-            return new AlertDialog.Builder(getActivity())
-                    .setTitle(R.string.privacy_guard_reset_title)
-                    .setMessage(R.string.privacy_guard_reset_text)
-                    .setPositiveButton(R.string.dlg_ok,
-                        new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                ((PrivacyGuardManager)getTargetFragment()).doReset();
-                        }
-                    })
-                    .setNegativeButton(R.string.cancel,
-                        new DialogInterface.OnClickListener() {
-                            public void onClick(DialogInterface dialog, int which) {
-                                // Do nothing
-                        }
-                    })
-                    .create();
-        }
-    }
-
-    private void doReset() {
-        // turn off privacy guard for all apps shown in the current list
-        for (AppInfo app : mApps) {
-            app.privacyGuardEnabled = false;
-        }
-        mAppOps.resetAllModes();
-        mAdapter.notifyDataSetChanged();
-    }
-
-    private void showResetDialog() {
-        ResetDialogFragment dialog = new ResetDialogFragment();
-        dialog.setTargetFragment(this, 0);
-        dialog.show(getFragmentManager(), "reset_dialog");
-    }
-
-    @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        super.onCreateOptionsMenu(menu, inflater);
-        inflater.inflate(R.menu.privacy_guard_manager, menu);
-        menu.findItem(R.id.privacy_guard_default).setChecked(
-                LineageSettings.Secure.getInt(getContentResolver(),
-                LineageSettings.Secure.PRIVACY_GUARD_DEFAULT, 0) == 1);
-        menu.findItem(R.id.privacy_guard_notification).setChecked(
-                LineageSettings.Secure.getInt(getContentResolver(),
-                LineageSettings.Secure.PRIVACY_GUARD_NOTIFICATION, 1) == 1);
-        menu.findItem(R.id.show_system_apps).setChecked(shouldShowSystemApps());
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case R.id.help:
-                showHelp();
-                return true;
-            case R.id.reset:
-                resetPrivacyGuard();
-                return true;
-            case R.id.privacy_guard_default:
-                item.setChecked(!item.isChecked());
-                LineageSettings.Secure.putInt(getContentResolver(),
-                        LineageSettings.Secure.PRIVACY_GUARD_DEFAULT,
-                        item.isChecked() ? 1 : 0);
-                return true;
-            case R.id.privacy_guard_notification:
-                item.setChecked(!item.isChecked());
-                LineageSettings.Secure.putInt(getContentResolver(),
-                        LineageSettings.Secure.PRIVACY_GUARD_NOTIFICATION,
-                        item.isChecked() ? 1 : 0);
-                return true;
-            case R.id.show_system_apps:
-                final String prefName = "show_system_apps";
-                // set the menu checkbox and save it in
-                // shared preference and rebuild the list
-                item.setChecked(!item.isChecked());
-                mPreferences.edit().putBoolean(prefName, item.isChecked()).commit();
-                scheduleAppsLoad();
-                return true;
-            case R.id.advanced:
-                Intent i = new Intent("android.settings.APP_OPS_SETTINGS");
-                mActivity.startActivityForResult(i, 0);
-                return true;
-            default:
-                return super.onContextItemSelected(item);
-        }
-    }
-}
diff --git a/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardPrefs.java b/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardPrefs.java
deleted file mode 100644
index b2f0666..0000000
--- a/src/org/lineageos/lineageparts/privacyguard/PrivacyGuardPrefs.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2013 Slimroms
- * 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 org.lineageos.lineageparts.privacyguard;
-
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import org.lineageos.lineageparts.R;
-import org.lineageos.lineageparts.SettingsPreferenceFragment;
-
-import lineageos.providers.LineageSettings;
-
-public class PrivacyGuardPrefs extends SettingsPreferenceFragment {
-
-    private static final String TAG = "PrivacyGuardPrefs";
-
-    public static PrivacyGuardPrefs newInstance() {
-        PrivacyGuardPrefs privacyGuardFragment = new PrivacyGuardPrefs();
-        return privacyGuardFragment;
-    }
-
-    @Override
-    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
-        addPreferencesFromResource(R.xml.privacy_guard_prefs);
-        watch(LineageSettings.Secure.getUriFor(LineageSettings.Secure.PRIVACY_GUARD_DEFAULT));
-    }
-
-    @Override
-    public View onCreateView(LayoutInflater inflater,
-            ViewGroup container, Bundle savedInstanceState) {
-        final View view = super.onCreateView(inflater, container, savedInstanceState);
-        final ViewGroup list = (ViewGroup) getListView().getParent();
-        // our container already takes care of the padding
-        int paddingTop = list.getPaddingTop();
-        int paddingBottom = list.getPaddingBottom();
-        list.setPadding(0, paddingTop, 0, paddingBottom);
-        return view;
-    }
-}