DivestOS/Patches/CyanogenMod-13.0/android_packages_apps_Trebuchet/Remove_Analytics.patch
2016-12-21 19:30:02 -05:00

2565 lines
100 KiB
Diff

From 11df11ec7fe9f43798cf5fa33b65acbb45dc52b4 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 5 May 2016 02:53:50 -0400
Subject: [PATCH 1/5] Revert "Trebuchet Statistics:"
This reverts commit a20b046db71039ee581bb80274cf1fc450b3fd99.
Change-Id: I4c71ccdc40151d5d3f98b776f2ce215027009978
---
Android.mk | 2 +-
AndroidManifest.xml | 10 --
src/com/android/launcher3/Launcher.java | 32 -----
src/com/android/launcher3/LauncherModel.java | 37 +----
.../launcher3/WallpaperChangedReceiver.java | 15 --
.../launcher3/stats/external/StatsUtil.java | 117 ---------------
.../launcher3/stats/external/TrackingBundle.java | 67 ---------
.../stats/internal/db/DatabaseHelper.java | 159 ---------------------
.../stats/internal/db/TrackingEventContract.java | 31 ----
.../stats/internal/model/CountAction.java | 73 ----------
.../internal/model/CountOriginByPackageAction.java | 91 ------------
.../stats/internal/model/ITrackingAction.java | 45 ------
src/com/android/launcher3/stats/util/Logger.java | 55 -------
13 files changed, 4 insertions(+), 730 deletions(-)
delete mode 100644 src/com/android/launcher3/stats/external/StatsUtil.java
delete mode 100644 src/com/android/launcher3/stats/external/TrackingBundle.java
delete mode 100644 src/com/android/launcher3/stats/internal/db/DatabaseHelper.java
delete mode 100644 src/com/android/launcher3/stats/internal/db/TrackingEventContract.java
delete mode 100644 src/com/android/launcher3/stats/internal/model/CountAction.java
delete mode 100644 src/com/android/launcher3/stats/internal/model/CountOriginByPackageAction.java
delete mode 100644 src/com/android/launcher3/stats/internal/model/ITrackingAction.java
delete mode 100644 src/com/android/launcher3/stats/util/Logger.java
diff --git a/Android.mk b/Android.mk
index 5ef85b4..9915fc5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -45,7 +45,7 @@ LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.v7.recyclerview
-#LOCAL_SDK_VERSION := current
+LOCAL_SDK_VERSION := current
LOCAL_PACKAGE_NAME := Trebuchet
LOCAL_PRIVILEGED_MODULE := true
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index dbdabfa..ee80841 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -69,10 +69,8 @@
<uses-permission android:name="com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS" />
<uses-permission android:name="com.android.launcher3.permission.RECEIVE_FIRST_LOAD_BROADCAST" />
<uses-permission android:name="cyanogenmod.permission.PROTECTED_APP" />
- <uses-permission android:name="com.cyngn.stats.SEND_ANALYTICS" />
<application
- android:name="com.android.launcher3.LauncherApplication"
android:allowBackup="@bool/enable_backup"
android:backupAgent="com.android.launcher3.LauncherBackupAgentHelper"
android:hardwareAccelerated="true"
@@ -184,14 +182,6 @@
>
</service>
- <service
- android:name="com.android.launcher3.stats.internal.service.AggregationIntentService"
- android:exported="false">
- <intent-filter>
- <action android:name="com.cyanogenmod.trebuchet.AGGREGATE_AND_TRACK" />
- </intent-filter>
- </service>
-
<receiver
android:name="com.android.launcher3.WallpaperChangedReceiver">
<intent-filter>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8161d38..37f3931 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -111,7 +111,6 @@ import com.android.launcher3.compat.UserManagerCompat;
import com.android.launcher3.list.SettingsPinnedHeaderAdapter;
import com.android.launcher3.model.WidgetsModel;
import com.android.launcher3.settings.SettingsProvider;
-import com.android.launcher3.stats.LauncherStats;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LongArrayMap;
import com.android.launcher3.util.Thunk;
@@ -170,10 +169,6 @@ public class Launcher extends Activity
private static final float BOUNCE_ANIMATION_TENSION = 1.3f;
-
- public static final String LONGPRESS_CHANGE = "wallpaper_changed_by_longpress";
-
-
/**
* IntentStarter uses request codes starting with this. This must be greater than all activity
* request codes used internally.
@@ -2136,9 +2131,6 @@ public class Launcher extends Activity
public void removeAppWidget(LauncherAppWidgetInfo launcherInfo) {
removeWidgetToAutoAdvance(launcherInfo.hostView);
launcherInfo.hostView = null;
- AppWidgetProviderInfo info = mAppWidgetManager.getAppWidgetInfo(launcherInfo.appWidgetId);
- String packageName = info.providerInfo.packageName;
- LauncherApplication.getLauncherStats().sendWidgetRemoveEvent(packageName);
}
public void showOutOfSpaceMessage(boolean isHotseatLayout) {
@@ -2632,8 +2624,6 @@ public class Launcher extends Activity
completeAddAppWidget(appWidgetId, info.container, info.screenId, boundWidget,
appWidgetInfo);
mWorkspace.removeExtraEmptyScreenDelayed(true, onComplete, delay, false);
- String packageName = appWidgetInfo.providerInfo.packageName;
- LauncherApplication.getLauncherStats().sendWidgetAddEvent(packageName);
}
}
@@ -2893,13 +2883,6 @@ public class Launcher extends Activity
} else if (tag instanceof AppInfo) {
AppInfo info = (AppInfo) tag;
startAppShortcutOrInfoActivity(v);
- LauncherApplication.getLauncherStats().sendAppLaunchEvent(
- LauncherStats.ORIGIN_APPDRAWER, info.componentName.getPackageName());
- String packageName = info.getIntent().getComponent().getPackageName();
- if (LauncherStats.SETTINGS_PACKAGE_NAME.equals(packageName)) {
- LauncherApplication.getLauncherStats()
- .sendSettingsOpenedEvent(LauncherStats.ORIGIN_APPDRAWER);
- }
} else if (tag instanceof LauncherAppWidgetInfo) {
if (v instanceof PendingAppWidgetHostView) {
onClickPendingWidget((PendingAppWidgetHostView) v);
@@ -3048,17 +3031,6 @@ public class Launcher extends Activity
// Start activities
startAppShortcutOrInfoActivity(v);
- ComponentName componentName = intent.getComponent();
- if (componentName != null) {
- String packageName = intent.getComponent().getPackageName();
- LauncherApplication.getLauncherStats()
- .sendAppLaunchEvent(LauncherStats.ORIGIN_HOMESCREEN,
- packageName);
- if (LauncherStats.SETTINGS_PACKAGE_NAME.equals(packageName)) {
- LauncherApplication.getLauncherStats().sendSettingsOpenedEvent(
- LauncherStats.ORIGIN_HOMESCREEN);
- }
- }
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onClickAppShortcut(v);
@@ -4173,10 +4145,6 @@ public class Launcher extends Activity
mWorkspace.createCustomContentContainer();
populateCustomContentContainer();
}
-
- LauncherModel.saveWidgetCount(this);
- LauncherModel.savePageCount(this);
-
}
@Override
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 687e565..e758817 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -28,7 +28,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.Intent.ShortcutIconResource;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ProviderInfo;
import android.content.pm.ResolveInfo;
@@ -65,9 +64,6 @@ import com.android.launcher3.util.ManagedProfileHeuristic;
import com.android.launcher3.util.Thunk;
import cyanogenmod.providers.CMSettings;
-import com.android.launcher3.settings.SettingsProvider;
-import com.android.launcher3.stats.internal.service.AggregationIntentService;
-
import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
import java.security.InvalidParameterException;
@@ -1055,22 +1051,10 @@ public class LauncherModel extends BroadcastReceiver
}
/**
- * Saves the total widget count to a shared preference
- *
- * @param context {@link Context}
- */
- /* package */ static void saveWidgetCount(Context context) {
- int widgetCount = LauncherModel.sBgAppWidgets.size();
- SharedPreferences prefs = context.getSharedPreferences(LauncherAppState
- .getSharedPreferencesKey(), Context.MODE_PRIVATE);
- prefs.edit().putInt(AggregationIntentService.PREF_KEY_WIDGET_COUNT, widgetCount).apply();
- }
-
- /**
* Add an item to the database in a specified container. Sets the container, screen, cellX and
* cellY fields of the item. Also assigns an ID to the item.
*/
- public static void addItemToDatabase(final Context context, final ItemInfo item, final long container,
+ public static void addItemToDatabase(Context context, final ItemInfo item, final long container,
final long screenId, final int cellX, final int cellY) {
item.container = container;
item.cellX = cellX;
@@ -1120,7 +1104,6 @@ public class LauncherModel extends BroadcastReceiver
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
sBgAppWidgets.add((LauncherAppWidgetInfo) item);
- saveWidgetCount(context);
break;
}
}
@@ -1173,7 +1156,7 @@ public class LauncherModel extends BroadcastReceiver
* @param context
* @param items
*/
- static void deleteItemsFromDatabase(final Context context, final ArrayList<? extends ItemInfo> items) {
+ static void deleteItemsFromDatabase(Context context, final ArrayList<? extends ItemInfo> items) {
final ContentResolver cr = context.getContentResolver();
Runnable r = new Runnable() {
public void run() {
@@ -1203,7 +1186,6 @@ public class LauncherModel extends BroadcastReceiver
break;
case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
sBgAppWidgets.remove((LauncherAppWidgetInfo) item);
- saveWidgetCount(context);
break;
}
sBgItemsIdMap.remove(item.id);
@@ -1215,22 +1197,10 @@ public class LauncherModel extends BroadcastReceiver
}
/**
- * Saves the count of workspace pages
- *
- * @param context {@link Context}
- */
- /* package */ static void savePageCount(Context context) {
- int pageCount = LauncherModel.sBgWorkspaceScreens.size();
- SharedPreferences prefs = context.getSharedPreferences(LauncherAppState
- .getSharedPreferencesKey(), Context.MODE_PRIVATE);
- prefs.edit().putInt(AggregationIntentService.PREF_KEY_PAGE_COUNT, pageCount).apply();
- }
-
- /**
* Update the order of the workspace screens in the database. The array list contains
* a list of screen ids in the order that they should appear.
*/
- public void updateWorkspaceScreenOrder(final Context context, final ArrayList<Long> screens) {
+ public void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
final ContentResolver cr = context.getContentResolver();
final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;
@@ -1268,7 +1238,6 @@ public class LauncherModel extends BroadcastReceiver
synchronized (sBgLock) {
sBgWorkspaceScreens.clear();
sBgWorkspaceScreens.addAll(screensCopy);
- savePageCount(context);
}
}
};
diff --git a/src/com/android/launcher3/WallpaperChangedReceiver.java b/src/com/android/launcher3/WallpaperChangedReceiver.java
index 0a6a7ef..2d5612f 100644
--- a/src/com/android/launcher3/WallpaperChangedReceiver.java
+++ b/src/com/android/launcher3/WallpaperChangedReceiver.java
@@ -20,25 +20,10 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-import android.content.SharedPreferences;
-import com.android.launcher3.stats.LauncherStats;
-
public class WallpaperChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent data) {
LauncherAppState.setApplicationContext(context.getApplicationContext());
LauncherAppState appState = LauncherAppState.getInstance();
appState.onWallpaperChanged();
- SharedPreferences prefs = context.getSharedPreferences(LauncherAppState
- .getSharedPreferencesKey(), Context.MODE_PRIVATE);
- boolean fromSelf = prefs.getBoolean(Launcher.LONGPRESS_CHANGE, false);
- if (fromSelf) {
- prefs.edit().putBoolean(Launcher.LONGPRESS_CHANGE, false).apply();
- LauncherApplication.getLauncherStats().sendWallpaperChangedEvent(
- LauncherStats.ORIGIN_TREB_LONGPRESS);
- } else {
- LauncherApplication.getLauncherStats().sendWallpaperChangedEvent(
- LauncherStats.ORIGIN_CHOOSER);
- }
-
}
}
diff --git a/src/com/android/launcher3/stats/external/StatsUtil.java b/src/com/android/launcher3/stats/external/StatsUtil.java
deleted file mode 100644
index 697df54..0000000
--- a/src/com/android/launcher3/stats/external/StatsUtil.java
+++ /dev/null
@@ -1,117 +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 com.android.launcher3.stats.external;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.util.Log;
-import com.android.launcher3.stats.util.Logger;
-
-/**
- * StatsUtil
- * <pre>
- * Utility for interfacing with CyanogenStats
- * </pre>
- */
-public class StatsUtil {
-
- // Tag and logging
- private static final String TAG = StatsUtil.class.getSimpleName();
-
- // Constants
- private static final String KEY_TRACKING_ID = "tracking_id";
- private static final String ANALYTIC_INTENT = "com.cyngn.stats.action.SEND_ANALYTIC_EVENT";
- private static final String STATS_PACKAGE = "com.cyngn.stats";
-
- /**
- * Checks if stats collection is enabled
- *
- * @param context {@link android.content.Context}
- * @return {@link java.lang.Boolean}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public static boolean isStatsCollectionEnabled(Context context)
- throws IllegalArgumentException {
- return isStatsPackageInstalledAndSystemApp(context);
- }
-
- /**
- * Checks if the stats package is installed
- *
- * @param context {@link android.content.Context}
- * @return {@link Boolean {@link Boolean {@link Boolean {@link Boolean}}}}
- */
- private static boolean isStatsPackageInstalledAndSystemApp(Context context)
- throws IllegalArgumentException {
- if (context == null) {
- throw new IllegalArgumentException("'context' cannot be null!");
- }
- try {
- PackageInfo pi = context.getPackageManager().getPackageInfo(STATS_PACKAGE, 0);
- boolean isSystemApp = (pi.applicationInfo.flags &
- (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0;
- return pi.applicationInfo.enabled && isSystemApp;
- } catch (PackageManager.NameNotFoundException e) {
- Log.e(TAG, "stats not found!");
- return false;
- }
- }
-
- /**
- * Send an event to CyangenStats
- *
- * @param context {@link Context} not null
- * @param trackingBundle {@link Bundle}
- * @throws IllegalArgumentException
- */
- public static void sendEvent(Context context, Bundle trackingBundle)
- throws IllegalArgumentException {
- if (context == null) {
- throw new IllegalArgumentException("'context' cannot be null!");
- }
- if (trackingBundle == null) {
- throw new IllegalArgumentException("'trackingBundle' cannot be null!");
- }
- if (!isStatsCollectionEnabled(context)) {
- Logger.logd(TAG, "Stats collection: DISABLED!");
- return;
- }
- Logger.logd(TAG, "Stats collection: ENABLED!");
-
- Intent newIntent = new Intent(ANALYTIC_INTENT);
-
- if (!trackingBundle.containsKey(KEY_TRACKING_ID)) {
- Logger.logd(TAG, "No tracking id in bundle");
- return;
- } else {
- if (trackingBundle.containsKey(TrackingBundle.KEY_EVENT_CATEGORY)
- && trackingBundle.containsKey(TrackingBundle.KEY_EVENT_ACTION)) {
- Logger.logd(TAG, trackingBundle.toString());
- newIntent.putExtras(trackingBundle);
- context.sendBroadcast(newIntent);
- } else {
- Logger.logd(TAG, "Not a valid tracking bundle");
- }
- }
- }
-
-}
diff --git a/src/com/android/launcher3/stats/external/TrackingBundle.java b/src/com/android/launcher3/stats/external/TrackingBundle.java
deleted file mode 100644
index 6ca5d97..0000000
--- a/src/com/android/launcher3/stats/external/TrackingBundle.java
+++ /dev/null
@@ -1,67 +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 com.android.launcher3.stats.external;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-
-/**
- * <pre>
- * Extension of a {@link Bundle} to provider streamline interfaces for
- * the specific task of sending events
- * </pre>
- *
- * @see {@link Bundle}
- */
-public class TrackingBundle {
-
- // Constants
- public static final String KEY_TRACKING_ID = "tracking_id";
- public static final String KEY_EVENT_CATEGORY = "category";
- public static final String KEY_EVENT_ACTION = "action";
- public static final String KEY_METADATA_VALUE = "value";
- public static final String KEY_METADATA_ORIGIN = "origin";
- public static final String KEY_METADATA_PACKAGE = "package";
-
-
- /**
- * Constructor
- *
- * @param trackingId {@link String}
- * @param category {@link String}
- * @param action {@link String}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public static Bundle createTrackingBundle(String trackingId, String category, String action)
- throws IllegalArgumentException {
- if (TextUtils.isEmpty(trackingId)) {
- throw new IllegalArgumentException("'trackingId' cannot be null or empty!");
- }
- if (TextUtils.isEmpty(category)) {
- throw new IllegalArgumentException("'category' cannot be null or empty!");
- }
- if (TextUtils.isEmpty(action)) {
- throw new IllegalArgumentException("'action' cannot be null or empty!");
- }
- Bundle bundle = new Bundle();
- bundle.putString(KEY_EVENT_CATEGORY, category);
- bundle.putString(KEY_EVENT_ACTION, action);
- bundle.putString(KEY_TRACKING_ID, trackingId);
- return bundle;
- }
-
-}
\ No newline at end of file
diff --git a/src/com/android/launcher3/stats/internal/db/DatabaseHelper.java b/src/com/android/launcher3/stats/internal/db/DatabaseHelper.java
deleted file mode 100644
index 7ffd509..0000000
--- a/src/com/android/launcher3/stats/internal/db/DatabaseHelper.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package com.android.launcher3.stats.internal.db;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteOpenHelper;
-import com.android.launcher3.stats.internal.model.TrackingEvent;
-import com.android.launcher3.stats.util.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <pre>
- * Helper for accessing the database
- * </pre>
- *
- * @see {@link SQLiteOpenHelper}
- */
-public class DatabaseHelper extends SQLiteOpenHelper {
-
- // Constants
- private static final String TAG = DatabaseHelper.class.getSimpleName();
- private static final String DATABASE_NAME = "events";
- private static final int DATABASE_VERSION = 1;
-
- // Instance
- private static DatabaseHelper sInstance = null;
-
- /**
- * Constructor
- *
- * @param context {@link Context}
- * @return {@link DatabaseHelper}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public static DatabaseHelper createInstance(Context context) throws IllegalArgumentException {
- if (sInstance == null) {
- sInstance = new DatabaseHelper(context);
- }
- return sInstance;
- }
-
- /**
- * Constructor
- *
- * @param context {@link Context}
- */
- public DatabaseHelper(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- /**
- * Write an event to the database
- *
- * @param trackingEvent {@link TrackingEvent}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public void writeEvent(TrackingEvent trackingEvent)
- throws IllegalArgumentException {
- if (trackingEvent == null) {
- throw new IllegalArgumentException("'trackingEvent' cannot be null!");
- }
- Logger.logd(TAG, "Event written to database: " + trackingEvent);
- SQLiteDatabase db = getWritableDatabase();
- ContentValues contentValues = trackingEvent.toContentValues();
- db.insert(TrackingEventContract.EVENT_TABLE_NAME, null, contentValues);
- db.close();
- }
-
- /**
- * Get a list of tracking events
- *
- * @param instanceId {@link Integer}
- * @return {@link List}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public List<TrackingEvent> getTrackingEventsByCategory(int instanceId,
- TrackingEvent.Category category) throws IllegalArgumentException {
- if (category == null) {
- throw new IllegalArgumentException("'category' cannot be null!");
- }
-
- List<TrackingEvent> eventList = new ArrayList<TrackingEvent>();
-
- // Get a writable database
- SQLiteDatabase db = getWritableDatabase();
-
- // Update unclaimed items for this instance
- ContentValues contentValues = new ContentValues();
- contentValues.put(TrackingEventContract.EVENT_COLUMN_INSTANCE, instanceId);
- String whereClause = TrackingEventContract.EVENT_COLUMN_INSTANCE + " IS NULL AND "
- + TrackingEventContract.EVENT_COLUMN_CATEGORY + " = ? ";
- String[] whereArgs = new String[] {
- category.name(),
- };
- int cnt = db.update(TrackingEventContract.EVENT_TABLE_NAME, contentValues, whereClause,
- whereArgs);
-
- // Short circuit empty update
- if (cnt < 1) {
- return eventList;
- }
-
- // Select all tagged items
- String selection = TrackingEventContract.EVENT_COLUMN_CATEGORY + " = ? AND "
- + TrackingEventContract.EVENT_COLUMN_INSTANCE + " = ? ";
- String[] selectionArgs = new String[]{
- category.name(),
- String.valueOf(instanceId),
- };
- Cursor c = db.query(TrackingEventContract.EVENT_TABLE_NAME, null, selection, selectionArgs,
- null, null, null);
-
- // Build return list
- while (c != null && c.getCount() > 0 && c.moveToNext()) {
- eventList.add(new TrackingEvent(c));
- }
-
- db.close();
-
- return eventList;
- }
-
- /**
- * Deletes events related to the instance
- *
- * @param instanceId {@link Integer}
- * @return {@link Integer}
- */
- public int deleteEventsByInstanceId(int instanceId) {
- SQLiteDatabase db = getWritableDatabase();
- String whereClause = TrackingEventContract.EVENT_COLUMN_INSTANCE + " = ?";
- String[] whereArgs = new String[]{
- String.valueOf(instanceId),
- };
- int cnt = db.delete(TrackingEventContract.EVENT_TABLE_NAME, whereClause, whereArgs);
- db.close();
- return cnt;
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(TrackingEventContract.CREATE_EVENT_TABLE);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
-
- // [NOTE][MSB]: This will lose data, need to make sure this is handled if/when database
- // schema changes
-
- // db.execSQL("DROP TABLE IF EXISTS " + TrackingEventContract.EVENT_TABLE_NAME);
- // onCreate(db);
-
- }
-
-}
diff --git a/src/com/android/launcher3/stats/internal/db/TrackingEventContract.java b/src/com/android/launcher3/stats/internal/db/TrackingEventContract.java
deleted file mode 100644
index 481a431..0000000
--- a/src/com/android/launcher3/stats/internal/db/TrackingEventContract.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.android.launcher3.stats.internal.db;
-
-import android.provider.BaseColumns;
-
-/**
- * <pre>
- * Table contract definition
- * </pre>
- *
- * @see {@link BaseColumns}
- */
-public class TrackingEventContract implements BaseColumns {
-
- // Constants
- public static final String EVENT_TABLE_NAME = "event";
-
- // Columns
- public static final String EVENT_COLUMN_CATEGORY = "category";
- public static final String EVENT_COLUMN_METADATA = "metadata";
- public static final String EVENT_COLUMN_INSTANCE = "instance";
-
- // SQL
- public static final String CREATE_EVENT_TABLE = "CREATE TABLE " + EVENT_TABLE_NAME
- + " ( "
- + " `" + _ID + "` INTEGER PRIMARY KEY AUTOINCREMENT, "
- + " `" + EVENT_COLUMN_CATEGORY + "` TEXT, "
- + " `" + EVENT_COLUMN_METADATA + "` TEXT, "
- + " `" + EVENT_COLUMN_INSTANCE + "` INTEGER "
- + ");";
-
-}
diff --git a/src/com/android/launcher3/stats/internal/model/CountAction.java b/src/com/android/launcher3/stats/internal/model/CountAction.java
deleted file mode 100644
index d509d4d..0000000
--- a/src/com/android/launcher3/stats/internal/model/CountAction.java
+++ /dev/null
@@ -1,73 +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 com.android.launcher3.stats.internal.model;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-import com.android.launcher3.stats.external.TrackingBundle;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <pre>
- * Handles the specific for sending a tracking event
- * </pre>
- *
- * @see {@link ITrackingAction}
- */
-public class CountAction implements ITrackingAction {
-
- public static final String TRACKING_ACTION = "count";
-
- @Override
- public String toString() {
- return TRACKING_ACTION;
- }
-
- @Override
- public List<Bundle> createTrackingBundles(String trackingId, TrackingEvent.Category category,
- List<TrackingEvent> eventList) {
-
- Map<String, List<TrackingEvent>> eventPackageMap =
- new HashMap<String, List<TrackingEvent>>();
-
- for (TrackingEvent event : eventList) {
- String pkg = event.getMetaData(TrackingEvent.KEY_PACKAGE);
- pkg = (TextUtils.isEmpty(pkg)) ? trackingId : pkg;
- if (!eventPackageMap.containsKey(pkg)) {
- eventPackageMap.put(pkg, new ArrayList<TrackingEvent>());
- }
- eventPackageMap.get(pkg).add(event);
- }
-
- List<Bundle> bundleList = new ArrayList<Bundle>();
- for (Map.Entry<String, List<TrackingEvent>> entry : eventPackageMap.entrySet()) {
- Bundle bundle = TrackingBundle.createTrackingBundle(trackingId, category.name(),
- TRACKING_ACTION);
- bundle.putInt(TrackingBundle.KEY_METADATA_VALUE, entry.getValue().size());
- String pkg = entry.getKey();
- if (!pkg.equals(trackingId)) {
- bundle.putString(TrackingBundle.KEY_METADATA_PACKAGE, pkg);
- }
- bundleList.add(bundle);
- }
- return bundleList;
- }
-}
diff --git a/src/com/android/launcher3/stats/internal/model/CountOriginByPackageAction.java b/src/com/android/launcher3/stats/internal/model/CountOriginByPackageAction.java
deleted file mode 100644
index fc04ca0..0000000
--- a/src/com/android/launcher3/stats/internal/model/CountOriginByPackageAction.java
+++ /dev/null
@@ -1,91 +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 com.android.launcher3.stats.internal.model;
-
-import android.os.Bundle;
-import android.text.TextUtils;
-import com.android.launcher3.stats.external.TrackingBundle;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * <pre>
- * This is an action to send a count of events with common origins
- * </pre>
- */
-public class CountOriginByPackageAction implements ITrackingAction {
-
- public static final String TRACKING_ACTION = "count_by_origin";
-
- @Override
- public String toString() {
- return TRACKING_ACTION;
- }
-
- @Override
- public List<Bundle> createTrackingBundles(String trackingId, TrackingEvent.Category category,
- List<TrackingEvent> eventList) {
- // Make an origin mapper
- Map<String, Map<String, List<TrackingEvent>>> originEventMap =
- new HashMap<String, Map<String, List<TrackingEvent>>>();
-
- // Parse the event list and categorize by origin
- for (TrackingEvent event : eventList) {
- // We are parsing for things with origin, if no origin is set, discard it!
- if (TextUtils.isEmpty(event.getMetaData(TrackingEvent.KEY_ORIGIN))) {
- continue;
- }
- String originKey = event.getMetaData(TrackingEvent.KEY_ORIGIN);
- if (!originEventMap.containsKey(originKey)) {
- HashMap<String, List<TrackingEvent>> newMap =
- new HashMap<String, List<TrackingEvent>>();
- originEventMap.put(originKey, newMap);
- }
- String packageName = event.getMetaData(TrackingEvent.KEY_PACKAGE);
- // Set a default so our iteration picks it up and just discard package metadata
- packageName = (TextUtils.isEmpty(packageName)) ? trackingId : packageName;
- if (!originEventMap.get(originKey).containsKey(packageName)) {
- originEventMap.get(originKey).put(packageName, new ArrayList<TrackingEvent>());
- }
- originEventMap.get(originKey).get(packageName).add(event);
- }
-
- // Start building result tracking bundles
- List<Bundle> bundleList = new ArrayList<Bundle>();
- for (Map.Entry<String, Map<String, List<TrackingEvent>>> entry :
- originEventMap.entrySet()) {
- String origin = entry.getKey();
- for (Map.Entry<String, List<TrackingEvent>> entry2 : entry.getValue().entrySet()) {
- String pkg = entry2.getKey();
- List<TrackingEvent> events = entry2.getValue();
- Bundle bundle = TrackingBundle.createTrackingBundle(trackingId, category.name(),
- TRACKING_ACTION);
- bundle.putString(TrackingBundle.KEY_METADATA_ORIGIN, origin);
- bundle.putInt(TrackingBundle.KEY_METADATA_VALUE, events.size());
- if (!trackingId.equals(pkg)) {
- bundle.putString(TrackingBundle.KEY_METADATA_PACKAGE, pkg);
- }
- bundleList.add(bundle);
- }
- }
- return bundleList;
- }
-
-}
diff --git a/src/com/android/launcher3/stats/internal/model/ITrackingAction.java b/src/com/android/launcher3/stats/internal/model/ITrackingAction.java
deleted file mode 100644
index b577ed2..0000000
--- a/src/com/android/launcher3/stats/internal/model/ITrackingAction.java
+++ /dev/null
@@ -1,45 +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 com.android.launcher3.stats.internal.model;
-
-import android.os.Bundle;
-
-import java.util.List;
-
-/**
- * <pre>
- * This is an action we want to perfrom from a report.
- *
- * e.g.
- * 1. I want to get the COUNT of widgets added
- * 2. I want to get the origin of app launches
- * </pre>
- */
-public interface ITrackingAction {
-
- /**
- * Creates a new bundle used to tracking events
- *
- * @param trackingId {@link String}
- * @param category {@link com.android.launcher3.stats.internal.model.TrackingEvent.Category}
- * @param eventList {@link List}
- * @return {@link List}
- */
- List<Bundle> createTrackingBundles(String trackingId, TrackingEvent.Category category,
- List<TrackingEvent> eventList);
-
-}
diff --git a/src/com/android/launcher3/stats/util/Logger.java b/src/com/android/launcher3/stats/util/Logger.java
deleted file mode 100644
index 8d73f54..0000000
--- a/src/com/android/launcher3/stats/util/Logger.java
+++ /dev/null
@@ -1,55 +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 com.android.launcher3.stats.util;
-
-import android.os.Build;
-import android.text.TextUtils;
-import android.util.Log;
-
-/**
- * <pre>
- * Metrics debug logging
- * </pre>
- */
-public class Logger {
-
- private static final String TAG = "TrebuchetStats";
-
- /**
- * Log a debug message
- *
- * @param tag {@link String}
- * @param msg {@link String }
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public static void logd(String tag, String msg) throws IllegalArgumentException {
- if (TextUtils.isEmpty(tag)) {
- throw new IllegalArgumentException("'tag' cannot be empty!");
- }
- if (TextUtils.isEmpty(msg)) {
- throw new IllegalArgumentException("'msg' cannot be empty!");
- }
- if (isDebugging()) {
- Log.d(TAG, tag + " [ " + msg + " ]");
- }
- }
-
- private static boolean isDebugging() {
- return Log.isLoggable(TAG, Log.DEBUG);
- }
-
-}
--
2.8.2
From 2514dc636747cc8f9f13709877e152d28eeefd95 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 5 May 2016 09:48:16 -0400
Subject: [PATCH 2/5] Nuke analytics
Change-Id: Iced69b10508f8a5a1926ae475272982ee41ffb17
---
src/com/android/launcher3/Launcher.java | 3 -
src/com/android/launcher3/LauncherApplication.java | 15 --
src/com/android/launcher3/stats/LauncherStats.java | 246 ---------------------
.../stats/internal/model/TrackingEvent.java | 206 -----------------
.../internal/service/AggregationIntentService.java | 238 --------------------
5 files changed, 708 deletions(-)
delete mode 100644 src/com/android/launcher3/stats/LauncherStats.java
delete mode 100644 src/com/android/launcher3/stats/internal/model/TrackingEvent.java
delete mode 100644 src/com/android/launcher3/stats/internal/service/AggregationIntentService.java
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 37f3931..f5744dd 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -5297,9 +5297,6 @@ public class Launcher extends Activity
AnimationDrawable frameAnimation = (AnimationDrawable) mAnimatedArrow.getBackground();
frameAnimation.start();
-
- LauncherApplication.getLauncherStats().sendSettingsOpenedEvent(
- LauncherStats.ORIGIN_TREB_LONGPRESS);
}
@Override
diff --git a/src/com/android/launcher3/LauncherApplication.java b/src/com/android/launcher3/LauncherApplication.java
index 4bbcec0..a921128 100644
--- a/src/com/android/launcher3/LauncherApplication.java
+++ b/src/com/android/launcher3/LauncherApplication.java
@@ -18,27 +18,12 @@ package com.android.launcher3;
import android.app.Application;
-import com.android.launcher3.stats.LauncherStats;
-import com.android.launcher3.stats.internal.service.AggregationIntentService;
public class LauncherApplication extends Application {
- private static LauncherStats sLauncherStats = null;
-
- /**
- * Get the reference handle for LauncherStats commands
- *
- * @return {@link LauncherStats}
- */
- public static LauncherStats getLauncherStats() {
- return sLauncherStats;
- }
-
@Override
public void onCreate() {
super.onCreate();
- sLauncherStats = LauncherStats.getInstance(this);
- AggregationIntentService.scheduleService(this);
}
}
diff --git a/src/com/android/launcher3/stats/LauncherStats.java b/src/com/android/launcher3/stats/LauncherStats.java
deleted file mode 100644
index 5e8cb83..0000000
--- a/src/com/android/launcher3/stats/LauncherStats.java
+++ /dev/null
@@ -1,246 +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 com.android.launcher3.stats;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Message;
-import android.text.TextUtils;
-import android.util.Log;
-import com.android.launcher3.stats.internal.db.DatabaseHelper;
-import com.android.launcher3.stats.internal.model.TrackingEvent;
-
-/**
- * <pre>
- * Utility class made specifically for Launcher related events
- * </pre>
- */
-public class LauncherStats {
-
- // Constants
- private static final String TAG = LauncherStats.class.getSimpleName();
- private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
- private static final int MSG_STORE_EVENT = 1000;
- public static final String SETTINGS_PACKAGE_NAME = "com.android.settings";
- public static final String ORIGIN_HOMESCREEN = "homescreen";
- public static final String ORIGIN_APPDRAWER = "appdrawer";
- public static final String ORIGIN_TREB_LONGPRESS = "trebuchet_longpress";
- public static final String ORIGIN_CHOOSER = "theme_chooser";
- public static final String ORIGIN_SETTINGS = "settings";
- public static final String ORIGIN_DRAG_DROP = "drag_drop";
- public static final String ORIGIN_FOLDER = "folder";
-
- private static void log(String msg) throws IllegalArgumentException {
- if (TextUtils.isEmpty(msg)) {
- throw new IllegalArgumentException("'msg' cannot be null or empty!");
- }
- if (DEBUG) {
- Log.d(TAG, msg);
- }
- }
-
- private static void loge(String msg) throws IllegalArgumentException {
- if (TextUtils.isEmpty(msg)) {
- throw new IllegalArgumentException("'msg' cannot be null or empty!");
- }
- Log.e(TAG, msg);
- }
-
- /**
- * <pre>
- * This is a thread responsible for writing events to a database
- * </pre>
- *
- * @see {@link HandlerThread}
- */
- private static class WriteHandlerThread extends HandlerThread {
- public WriteHandlerThread() {
- super(WriteHandlerThread.class.getSimpleName());
- }
- }
-
- /**
- * <pre>
- * Handler for issuing db writes
- * </pre>
- *
- * @see {@link Handler}
- */
- private static class WriteHandler extends Handler {
-
- public WriteHandler() {
- super(sHandlerThread.getLooper());
- }
-
- @Override
- public void handleMessage(Message msg) {
- log("Handling message: " + msg.what);
- switch (msg.what) {
- case MSG_STORE_EVENT:
- handleStoreEvent((TrackingEvent) msg.obj);
- break;
- default:
- super.handleMessage(msg);
- }
- }
- }
-
- // Instance
- private static LauncherStats sInstance = null;
-
- // Members
- private static WriteHandlerThread sHandlerThread;
- private static WriteHandler sWriteHandler;
- private static DatabaseHelper sDatabaseHelper;
-
- /**
- * Send a message to the handler to store event data
- *
- * @param trackingEvent {@link TrackingEvent}
- */
- protected void sendStoreEventMessage(TrackingEvent trackingEvent) {
- log("Sending tracking event to handler: " + trackingEvent);
- Message msg = new Message();
- msg.what = MSG_STORE_EVENT;
- msg.obj = trackingEvent;
- sWriteHandler.sendMessage(msg);
- }
-
- /**
- * Handle the storing work
- *
- * @param trackingEvent {@link TrackingEvent}
- */
- private static void handleStoreEvent(TrackingEvent trackingEvent) {
- log("Handling store event: " + trackingEvent);
- if (trackingEvent != null) {
- sDatabaseHelper.writeEvent(trackingEvent);
- } else {
- loge("Tracking event was null!");
- }
- }
-
- /**
- * Used only for overlay extensions
- */
- protected LauncherStats() { }
-
- /**
- * Constructor
- *
- * @param context {@link Context} not null!
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- private LauncherStats(Context context) throws IllegalArgumentException {
- if (context == null) {
- throw new IllegalArgumentException("'context' cannot be null!");
- }
- sDatabaseHelper = new DatabaseHelper(context);
- sHandlerThread = new WriteHandlerThread();
- sHandlerThread.start();
- sWriteHandler = new WriteHandler();
- }
-
- /**
- * Gets a singleton instance of the stats utility
- *
- * @param context {@link Context} not null!
- * @return {@link LauncherStats}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public static LauncherStats getInstance(Context context)
- throws IllegalArgumentException {
- if (sInstance == null) {
- sInstance = new LauncherStats(context);
- }
- return sInstance;
- }
-
- /**
- * Interface for posting a new widget add event
- *
- * @param pkg {@link String} package name of widget
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public void sendWidgetAddEvent(String pkg) throws IllegalArgumentException {
- if (TextUtils.isEmpty(pkg)) {
- throw new IllegalArgumentException("'pkg' cannot be null!");
- }
- TrackingEvent trackingEvent = new TrackingEvent(TrackingEvent.Category.WIDGET_ADD);
- trackingEvent.setMetaData(TrackingEvent.KEY_PACKAGE, pkg);
- sendStoreEventMessage(trackingEvent);
- }
-
- /**
- * Interface for posting a new widget removal event
- *
- * @param pkg {@link String} package name of widget
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public void sendWidgetRemoveEvent(String pkg) throws IllegalArgumentException {
- if (TextUtils.isEmpty(pkg)) {
- throw new IllegalArgumentException("'pkg' cannot be null!");
- }
- TrackingEvent trackingEvent = new TrackingEvent(TrackingEvent.Category.WIDGET_REMOVE);
- trackingEvent.setMetaData(TrackingEvent.KEY_PACKAGE, pkg);
- sendStoreEventMessage(trackingEvent);
- }
-
- /**
- * Interface for posting an app launch event
- *
- * @param origin {@link String} origin of application launch
- * @param pkg {@link String} package of app launched
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public void sendAppLaunchEvent(String origin, String pkg) throws IllegalArgumentException {
- if (TextUtils.isEmpty(origin)) {
- throw new IllegalArgumentException("'origin' cannot be null!");
- }
- if (TextUtils.isEmpty(pkg)) {
- throw new IllegalArgumentException("'pkg' cannot be null!");
- }
- TrackingEvent trackingEvent = new TrackingEvent(TrackingEvent.Category.APP_LAUNCH);
- trackingEvent.setMetaData(TrackingEvent.KEY_ORIGIN, origin);
- trackingEvent.setMetaData(TrackingEvent.KEY_PACKAGE, pkg);
- sendStoreEventMessage(trackingEvent);
- }
-
- /**
- * Interface for sending a "settings opened" event
- *
- * @param origin {@link String} origin of the event
- */
- public void sendSettingsOpenedEvent(String origin) {
- TrackingEvent trackingEvent = new TrackingEvent(TrackingEvent.Category.SETTINGS_OPEN);
- trackingEvent.setMetaData(TrackingEvent.KEY_ORIGIN, origin);
- sendStoreEventMessage(trackingEvent);
- }
-
- /**
- * Interface for sending a "wallpaper changed" event
- *
- * @param origin {@link String} origin of the event
- */
- public void sendWallpaperChangedEvent(String origin) {
- TrackingEvent trackingEvent = new TrackingEvent(TrackingEvent.Category.WALLPAPER_CHANGE);
- trackingEvent.setMetaData(TrackingEvent.KEY_ORIGIN, origin);
- sendStoreEventMessage(trackingEvent);
- }
-
-}
diff --git a/src/com/android/launcher3/stats/internal/model/TrackingEvent.java b/src/com/android/launcher3/stats/internal/model/TrackingEvent.java
deleted file mode 100644
index 44aaeb3..0000000
--- a/src/com/android/launcher3/stats/internal/model/TrackingEvent.java
+++ /dev/null
@@ -1,206 +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 com.android.launcher3.stats.internal.model;
-
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
-import com.android.launcher3.stats.external.TrackingBundle;
-import com.android.launcher3.stats.internal.db.TrackingEventContract;
-import com.android.launcher3.stats.util.Logger;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * <pre>
- * Model of an event to track
- * </pre>
- */
-public class TrackingEvent {
-
- // Constants
- private static final String TAG = TrackingEvent.class.getSimpleName();
-
- // Members
- private Category mCategory;
- private final Map<String, String> mMetaData = new HashMap<String, String>();
-
- public enum Category {
- APP_LAUNCH,
- WIDGET_ADD,
- WIDGET_REMOVE,
- SETTINGS_OPEN,
- WALLPAPER_CHANGE,
- HOMESCREEN_PAGE,
- WIDGET,
- REMOTE_FOLDER
- }
-
- public static final String KEY_ORIGIN = TrackingBundle.KEY_METADATA_ORIGIN;
- public static final String KEY_VALUE = TrackingBundle.KEY_METADATA_VALUE;
- public static final String KEY_PACKAGE = TrackingBundle.KEY_METADATA_PACKAGE;
- public static final String KEY_ACTION = TrackingBundle.KEY_EVENT_ACTION;
-
- /**
- * Constructor
- *
- * @param category {@link TrackingEvent.Category}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public TrackingEvent(Category category) throws IllegalArgumentException {
- if (category == null) {
- throw new IllegalArgumentException("'category' cannot be null or empty!");
- }
- mCategory = category;
- }
-
- /**
- * Constructor
- *
- * @param cursor {@link Cursor}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public TrackingEvent(Cursor cursor) throws IllegalArgumentException {
- if (cursor == null) {
- throw new IllegalArgumentException("'cursor' cannot be null!");
- }
- mCategory = Category.valueOf(cursor.getString(cursor.getColumnIndex(
- TrackingEventContract.EVENT_COLUMN_CATEGORY)));
- String metadata = cursor.getString(cursor.getColumnIndex(
- TrackingEventContract.EVENT_COLUMN_METADATA));
- if (!TextUtils.isEmpty(metadata)) {
- String[] parts = metadata.split(",");
- for (String part : parts) {
- try {
- String key = part.split("=")[0];
- String val = part.split("=")[1];
- mMetaData.put(key, val);
- } catch (IndexOutOfBoundsException e) {
- Log.w(TAG, e.getMessage(), e);
- }
- }
- }
- }
-
- /**
- * Get the category
- *
- * @return {@link TrackingEvent.Category}
- */
- public Category getCategory() {
- return mCategory;
- }
-
- /**
- * Get the set of meta data keys
- *
- * @return {@link Set}
- */
- public Set<String> getMetaDataKeySet() {
- return mMetaData.keySet();
- }
-
- /**
- * Set some meta data
- *
- * @param key {@link String}
- * @param value {@link String}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public void setMetaData(String key, String value) throws IllegalArgumentException {
- if (TextUtils.isEmpty(key)) {
- throw new IllegalArgumentException("'key' cannot be null or empty!");
- }
- if (TextUtils.isEmpty(value)) {
- throw new IllegalArgumentException("'value' cannot be null or empty!");
- }
- mMetaData.put(key, value);
- }
-
- /**
- * Get some meta data value
- *
- * @param key {@link String}
- * @return {@link String}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public String getMetaData(String key) throws IllegalArgumentException {
- if (TextUtils.isEmpty(key)) {
- throw new IllegalArgumentException("'key' cannot be null or empty!");
- }
- if (mMetaData.containsKey(key)) {
- return mMetaData.get(key);
- }
- return null;
- }
-
- /**
- * Remove some meta data
- *
- * @param key {@link String}
- * @return {@link String} or null
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public String removeMetaData(String key) throws IllegalArgumentException {
- if (TextUtils.isEmpty(key)) {
- throw new IllegalArgumentException("'key' cannot be null or empty!");
- }
- if (mMetaData.containsKey(key)) {
- return mMetaData.remove(key);
- }
- return null;
- }
-
- /**
- * Converts this object into content values for use with sqlite
- *
- * @return {@link ContentValues}
- */
- public ContentValues toContentValues() {
- ContentValues contentValues = new ContentValues();
- contentValues.put(TrackingEventContract.EVENT_COLUMN_CATEGORY, mCategory.name());
- StringBuilder sb = new StringBuilder();
- for (String key : mMetaData.keySet()) {
- sb.append(key).append("=").append(mMetaData.get(key)).append(",");
- }
- if (sb.length() > 0) {
- String metadata = sb.toString();
- metadata = metadata.substring(0, metadata.length() - 1);
- Logger.logd(TAG, "MetaData: " + metadata);
- contentValues.put(TrackingEventContract.EVENT_COLUMN_METADATA, metadata);
- }
- return contentValues;
- }
-
- /**
- * Convert this object into a tracking bundle
- *
- * @param trackingId {@link String}
- * @param action {@link ITrackingAction}
- * @return {@link Bundle}
- */
- public Bundle toTrackingBundle(String trackingId, ITrackingAction action) {
- Bundle bundle = TrackingBundle.createTrackingBundle(trackingId, mCategory.name(),
- action.toString());
- return bundle;
- }
-
-}
diff --git a/src/com/android/launcher3/stats/internal/service/AggregationIntentService.java b/src/com/android/launcher3/stats/internal/service/AggregationIntentService.java
deleted file mode 100644
index b32d79b..0000000
--- a/src/com/android/launcher3/stats/internal/service/AggregationIntentService.java
+++ /dev/null
@@ -1,238 +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 com.android.launcher3.stats.internal.service;
-
-import android.app.AlarmManager;
-import android.app.IntentService;
-import android.app.PendingIntent;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.util.Log;
-
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.stats.external.StatsUtil;
-import com.android.launcher3.stats.external.TrackingBundle;
-import com.android.launcher3.stats.internal.db.DatabaseHelper;
-import com.android.launcher3.stats.internal.model.CountAction;
-import com.android.launcher3.stats.internal.model.CountOriginByPackageAction;
-import com.android.launcher3.stats.internal.model.ITrackingAction;
-import com.android.launcher3.stats.internal.model.RemoteFolderAction;
-import com.android.launcher3.stats.internal.model.TrackingEvent;
-import com.android.launcher3.stats.util.Logger;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <pre>
- * Service that starts on a timer and handles aggregating events and sending them to
- * CyanogenStats
- * </pre>
- *
- * @see {@link IntentService}
- */
-public class AggregationIntentService extends IntentService {
-
- // Constants
- private static final String TAG = AggregationIntentService.class.getSimpleName();
- private static final String TRACKING_ID = "com.cyanogenmod.trebuchet";
- public static final String ACTION_AGGREGATE_AND_TRACK =
- "com.cyanogenmod.trebuchet.AGGREGATE_AND_TRACK";
- private static final List<ITrackingAction> TRACKED_ACTIONS = new ArrayList<ITrackingAction>() {
- {
- add(new CountAction());
- add(new CountOriginByPackageAction());
- }
- };
- private static final int INVALID_COUNT = -1;
- private static final String KEY_LAST_TIME_RAN = "last_time_stats_ran";
- public static final String PREF_KEY_PAGE_COUNT = "page_count";
- public static final String PREF_KEY_WIDGET_COUNT = "widget_count";
-
- // Members
- private DatabaseHelper mDatabaseHelper = null;
- private int mInstanceId = -1;
- private SharedPreferences mPrefs = null;
-
- /**
- * Creates an IntentService. Invoked by your subclass's constructor.
- */
- public AggregationIntentService() {
- super(AggregationIntentService.class.getSimpleName());
- }
-
- @Override
- protected void onHandleIntent(Intent intent) {
- if (!isTrebuchetDefaultLauncher()) {
- // Cancel repeating schedule
- unscheduleService();
- // don't return b/c we still want to upload whatever metrics are left.
- }
- String action = intent.getAction();
- if (ACTION_AGGREGATE_AND_TRACK.equals(action)) {
- mPrefs = getSharedPreferences(LauncherAppState.getSharedPreferencesKey(),
- Context.MODE_PRIVATE);
- mPrefs.edit().putLong(KEY_LAST_TIME_RAN, System.currentTimeMillis()).apply();
- mInstanceId = (int) System.currentTimeMillis();
- mDatabaseHelper = DatabaseHelper.createInstance(this);
- performAggregation();
- deleteTrackingEventsForInstance();
- handleNonEventMetrics();
- }
- }
-
- private void performAggregation() {
-
- // Iterate available categories
- for (TrackingEvent.Category category : TrackingEvent.Category.values()) {
-
- // Fetch the events from the database based on the category
- List<TrackingEvent> eventList =
- mDatabaseHelper.getTrackingEventsByCategory(mInstanceId, category);
-
- Logger.logd(TAG, "Event list size: " + eventList.size());
- // Short circuit if no events for the category
- if (eventList.size() < 1) {
- continue;
- }
-
- // Now crunch the data into actionable events for the server.
- // Remote Folder data will process itself separately.
- if (category == TrackingEvent.Category.REMOTE_FOLDER) {
- performTrackingCall(new RemoteFolderAction(), category, eventList);
- } else {
- for (ITrackingAction action : TRACKED_ACTIONS) {
- performTrackingCall(action, category, eventList);
- }
- }
- }
- }
-
- private void deleteTrackingEventsForInstance() {
- mDatabaseHelper.deleteEventsByInstanceId(mInstanceId);
- }
-
- /**
- * These are metrics that are not event based and need a snapshot every INTERVAL
- */
- private void handleNonEventMetrics() {
- sendPageCountStats();
- sendWidgetCountStats();
-
- }
-
- private void sendPageCountStats() {
- int pageCount = mPrefs.getInt(PREF_KEY_PAGE_COUNT, INVALID_COUNT);
- if (pageCount == INVALID_COUNT) {
- return;
- }
- Bundle bundle = TrackingBundle
- .createTrackingBundle(TRACKING_ID, TrackingEvent.Category.HOMESCREEN_PAGE.name(),
- "count");
- bundle.putString(TrackingEvent.KEY_VALUE, String.valueOf(pageCount));
- StatsUtil.sendEvent(this, bundle);
- }
-
- private void sendWidgetCountStats() {
- int widgetCount = mPrefs.getInt(PREF_KEY_WIDGET_COUNT, INVALID_COUNT);
- if (widgetCount == INVALID_COUNT) {
- return;
- }
- Bundle bundle = TrackingBundle
- .createTrackingBundle(TRACKING_ID, TrackingEvent.Category.WIDGET.name(), "count");
- bundle.putString(TrackingEvent.KEY_VALUE, String.valueOf(widgetCount));
- StatsUtil.sendEvent(this, bundle);
- }
-
- private void performTrackingCall(ITrackingAction action, TrackingEvent.Category category,
- List<TrackingEvent> eventList)
- throws IllegalArgumentException {
- try {
- for (Bundle bundle : action.createTrackingBundles(TRACKING_ID, category, eventList)) {
- StatsUtil.sendEvent(this, bundle);
- }
- } catch (NullPointerException e) {
- Log.e(TAG, "NPE fetching bundle list!", e);
- } catch (IllegalArgumentException e) {
- Log.e(TAG, "Illegal argument!", e);
- }
- }
-
- private void unscheduleService() {
- Intent intent = new Intent(this, AggregationIntentService.class);
- intent.setAction(ACTION_AGGREGATE_AND_TRACK);
- PendingIntent pi = PendingIntent.getService(this, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
- alarmManager.cancel(pi);
- }
-
- private boolean isTrebuchetDefaultLauncher() {
- final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
- filter.addCategory(Intent.CATEGORY_HOME);
-
- List<IntentFilter> filters = new ArrayList<IntentFilter>();
- filters.add(filter);
-
- final String myPackageName = getPackageName();
- List<ComponentName> activities = new ArrayList<ComponentName>();
- final PackageManager packageManager = getPackageManager();
-
- // You can use name of your package here as third argument
- packageManager.getPreferredActivities(filters, activities, null);
-
- for (ComponentName activity : activities) {
- if (myPackageName.equals(activity.getPackageName())) {
- Logger.logd(TAG, "Trebuchet IS default launcher!");
- return true;
- }
- }
- Logger.logd(TAG, "Trebuchet IS NOT default launcher!");
- return false;
- }
-
- private static final long ALARM_INTERVAL = 86400000; // 1 day
-
- /**
- * Schedule an alarm service, will cancel existing
- *
- * @param context {@link Context}
- * @throws IllegalArgumentException {@link IllegalArgumentException}
- */
- public static void scheduleService(Context context) throws IllegalArgumentException {
- if (context == null) {
- throw new IllegalArgumentException("'context' cannot be null!");
- }
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- long lastTimeRan = prefs.getLong(KEY_LAST_TIME_RAN, 0);
- Intent intent = new Intent(context, AggregationIntentService.class);
- intent.setAction(ACTION_AGGREGATE_AND_TRACK);
- PendingIntent pi = PendingIntent.getService(context, 0, intent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
- alarmManager.cancel(pi);
- alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, lastTimeRan + ALARM_INTERVAL,
- ALARM_INTERVAL, pi);
- }
-
-}
--
2.8.2
From 3a182fd5cd65ca8ee85fddd458cbe32c562a58eb Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 5 May 2016 10:05:20 -0400
Subject: [PATCH 3/5] Nuke remotefolder
Change-Id: Ie56aa15051c66a3957c9dfd3b2b20639e27512cc
---
RemoteFolder/Android-prebuilt-libs.mk | 1 -
RemoteFolder/Android.mk | 1 -
.../com/android/launcher3/RemoteFolderManager.java | 151 ---------------------
.../stats/internal/model/RemoteFolderAction.java | 30 ----
res/layout/user_folder.xml | 4 -
res/values/preferences_defaults.xml | 2 -
src/com/android/launcher3/FolderInfo.java | 20 ---
src/com/android/launcher3/Launcher.java | 37 +----
src/com/android/launcher3/LauncherModel.java | 7 +-
.../list/SettingsPinnedHeaderAdapter.java | 26 ----
.../launcher3/settings/SettingsProvider.java | 2 -
11 files changed, 7 insertions(+), 274 deletions(-)
delete mode 100644 RemoteFolder/Android-prebuilt-libs.mk
delete mode 100644 RemoteFolder/Android.mk
delete mode 100644 RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
delete mode 100644 RemoteFolder/src/com/android/launcher3/stats/internal/model/RemoteFolderAction.java
diff --git a/RemoteFolder/Android-prebuilt-libs.mk b/RemoteFolder/Android-prebuilt-libs.mk
deleted file mode 100644
index 65357a8..0000000
--- a/RemoteFolder/Android-prebuilt-libs.mk
+++ /dev/null
@@ -1 +0,0 @@
-# Empty file needed to mirror lib makefile in overlay
\ No newline at end of file
diff --git a/RemoteFolder/Android.mk b/RemoteFolder/Android.mk
deleted file mode 100644
index 2a74413..0000000
--- a/RemoteFolder/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-LOCAL_SRC_FILES += $(call all-java-files-under, RemoteFolder/src)
diff --git a/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java b/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
deleted file mode 100644
index 142a4d1..0000000
--- a/RemoteFolder/src/com/android/launcher3/RemoteFolderManager.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package com.android.launcher3;
-
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
-import android.view.View;
-import android.view.ViewGroup;
-import com.android.launcher3.allapps.AllAppsGridAdapter;
-import com.android.launcher3.allapps.AlphabeticalAppsList;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Manages adding and removing the remote folder from the workspace.
- */
-public class RemoteFolderManager {
-
- public RemoteFolderManager(final Launcher launcher) { }
-
- /**
- * Called when launcher receives a non-initial {@link Launcher#onCreate(Bundle)} call.
- * @param launcher new launcher activity.
- */
- public void onRecreateLauncher(final Launcher launcher) { }
-
- /**
- * Called when Launcher's views are loaded and ready.
- */
- public void onSetupViews() { }
-
- /**
- * Create a remote folder view.
- * @param icon folder icon view on the workspace.
- * @return a view for the remote folder.
- */
- public Folder createRemoteFolder(final FolderIcon icon, ViewGroup root) { return null; }
-
- /**
- * Get a drawable for the supplied item in the folder icon preview.
- * @param items list of views in the folder.
- * @param position index of icon to retreive.
- * @return an icon to draw in the folder preview.
- */
- public Drawable getFolderIconDrawable(final ArrayList<View> items,
- final int position) { return null; }
-
- /**
- * Called when Launcher finishes binding items from the model.
- */
- public void bindFinished() { }
-
- /**
- * Called when a setting for remote folder is updated.
- */
- public void onSettingChanged() { }
-
- /**
- * Called when the remote folder is dropped into the delete area on the workspace.
- */
- public void onFolderDeleted() { }
-
- /**
- * Called when the app drawer is opened.
- */
- public void onAppDrawerOpened() { }
-
- /**
- * Called when the app drawer is reloaded.
- */
- public void onReloadAppDrawer() { }
-
- /**
- * Called when the app drawer is measured.
- * @param numAppsPerRow the number of apps the drawer will show in a row.
- */
- public void onMeasureDrawer(int numAppsPerRow) { }
-
- /**
- * Called when new apps are added to launcher.
- * @param apps list of added apps.
- */
- public void onBindAddApps(ArrayList<AppInfo> apps) { }
-
- /**
- * Called when the info icon is clicked
- */
- public void onInfoIconClicked() { }
-
- /**
- * Called when the grid size for launcher is updated.
- */
- public void onGridSizeChanged() { }
-
- /**
- * Change the appearance of FolderIcon for our RemoteFolder by adding a badge
- * @param icon the FolderIcon to update
- * @return a FolderIcon with an added ImageView
- */
- public static FolderIcon addBadgeToFolderIcon(FolderIcon icon) {
- return icon;
- }
-
- /**
- * Called when adapter items for predicted apps are updated.
- * @param items current list of built adapter items.
- * @param fastScrollInfo fast scroller info for this section.
- * @param sectionInfo info about apps in this section.
- * @param position current position of item to be built into the adapter.
- * @return the new position to start from for next adapter items.
- */
- public int onUpdateAdapterItems(final List<AlphabeticalAppsList.AdapterItem> items,
- final AlphabeticalAppsList.FastScrollSectionInfo fastScrollInfo,
- final AlphabeticalAppsList.SectionInfo sectionInfo,
- int position) { return position; }
-
- /**
- * Called when a view holder is created for a remote app.
- * @param holder remote view holder.
- * @param viewType specific type of view holder.
- */
- public void onCreateViewHolder(final AllAppsGridAdapter.ViewHolder holder, final int viewType) { }
-
- /**
- * Called when a view holder is bound for a remote app.
- * @param holder remote view holder.
- * @param item info for this app.
- */
- public void onBindViewHolder(final AllAppsGridAdapter.ViewHolder holder, final AppInfo item) { }
-
- /**
- * Populate home settings list with additional values as needed.
- * @param values list of settings strings.
- * @param context application context.
- */
- public static void onInitializeHomeSettings(final ArrayList<String> values,
- final Context context) { }
-
- /**
- * Populate drawer settings list with additional values as needed.
- * @param values list of settings strings.
- * @param context application context.
- */
- public static void onInitializeDrawerSettings(final ArrayList<String> values,
- final Context context) { }
-
- /**
- * Apply icon pack when the theme changes.
- */
- public synchronized void onThemeChanged() { }
-}
diff --git a/RemoteFolder/src/com/android/launcher3/stats/internal/model/RemoteFolderAction.java b/RemoteFolder/src/com/android/launcher3/stats/internal/model/RemoteFolderAction.java
deleted file mode 100644
index dc36332..0000000
--- a/RemoteFolder/src/com/android/launcher3/stats/internal/model/RemoteFolderAction.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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.launcher3.stats.internal.model;
-
-import android.os.Bundle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class RemoteFolderAction implements ITrackingAction {
- @Override
- public List<Bundle> createTrackingBundles(String trackingId, TrackingEvent.Category category,
- List<TrackingEvent> eventList) {
- return new ArrayList<Bundle>();
- }
-}
diff --git a/res/layout/user_folder.xml b/res/layout/user_folder.xml
index 516da30..c2712ff 100644
--- a/res/layout/user_folder.xml
+++ b/res/layout/user_folder.xml
@@ -24,10 +24,6 @@
android:layout_margin="@dimen/folder_margin"
android:layout_gravity="bottom|center_horizontal">
- <include layout="@layout/remote_folder"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
<FrameLayout
android:id="@+id/folder_content_wrapper"
android:layout_width="wrap_content"
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml
index 63c5e9c..556f4f8 100644
--- a/res/values/preferences_defaults.xml
+++ b/res/values/preferences_defaults.xml
@@ -11,7 +11,5 @@
<bool name="preferences_interface_use_horizontal_scrubber_default">true</bool>
<bool name="preferences_interface_drawer_search_default">true</bool>
<bool name="preferences_interface_allow_rotation">false</bool>
- <bool name="preferences_interface_homescreen_remote_folder_default">false</bool>
- <bool name="preferences_interface_drawer_remote_apps_default">false</bool>
<integer name="preferences_interface_homescreen_id_default">1</integer>
</resources>
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java
index 7969d62..2fa3dbc 100644
--- a/src/com/android/launcher3/FolderInfo.java
+++ b/src/com/android/launcher3/FolderInfo.java
@@ -28,7 +28,6 @@ import java.util.Arrays;
* Represents a folder containing shortcuts or apps.
*/
public class FolderInfo extends ItemInfo {
- public static final int REMOTE_SUBTYPE = 1;
public static final int NO_FLAGS = 0x00000000;
@@ -123,25 +122,6 @@ public class FolderInfo extends ItemInfo {
itemsChanged();
}
- /**
- * @return true if this info represents a remote folder, false otherwise
- */
- public boolean isRemote() {
- return (subType & REMOTE_SUBTYPE) != 0;
- }
-
- /**
- * Set flag indicating whether this folder is remote
- * @param remote true if folder is remote, false otherwise
- */
- public void setRemote(final boolean remote) {
- if (remote) {
- subType |= REMOTE_SUBTYPE;
- } else {
- subType &= ~REMOTE_SUBTYPE;
- }
- }
-
public void setTitle(CharSequence title) {
this.title = title;
for (int i = 0; i < listeners.size(); i++) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index f5744dd..77f7db6 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -264,8 +264,6 @@ public class Launcher extends Activity
private View mWeightWatcher;
private DynamicGridSizeFragment mDynamicGridSizeFragment;
- protected static RemoteFolderManager sRemoteFolderManager;
-
private AppWidgetManagerCompat mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
@@ -519,12 +517,6 @@ public class Launcher extends Activity
mAppWidgetHost = new LauncherAppWidgetHost(this, APPWIDGET_HOST_ID);
- if (sRemoteFolderManager == null) {
- sRemoteFolderManager = new RemoteFolderManager(this);
- } else {
- sRemoteFolderManager.onRecreateLauncher(this);
- }
-
// If we are getting an onCreate, we can actually preempt onResume and unset mPaused here,
// this also ensures that any synchronous binding below doesn't re-trigger another
// LauncherModel load.
@@ -1629,7 +1621,6 @@ public class Launcher extends Activity
mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
}
- sRemoteFolderManager.onSetupViews();
}
/**
@@ -1887,7 +1878,6 @@ public class Launcher extends Activity
mAppsView.addApps(addedApps);
tryAndUpdatePredictedApps();
mAppsView.onReloadAppDrawer();
- sRemoteFolderManager.onReloadAppDrawer();
}
public void reloadWidgetView() {
@@ -1945,9 +1935,6 @@ public class Launcher extends Activity
reloadLauncher(false, true);
}
- // Must be called after reload and before settings invalidation.
- sRemoteFolderManager.onGridSizeChanged();
-
mOverviewSettingsPanel.notifyDataSetInvalidated();
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
@@ -2154,10 +2141,6 @@ public class Launcher extends Activity
return mWorkspace;
}
- public RemoteFolderManager getRemoteFolderManager() {
- return sRemoteFolderManager;
- }
-
public Hotseat getHotseat() {
return mHotseat;
}
@@ -3797,8 +3780,6 @@ public class Launcher extends Activity
tryAndUpdatePredictedApps();
}
showAppsOrWidgets(State.APPS, animated, focusSearchBar);
-
- sRemoteFolderManager.onAppDrawerOpened();
}
/**
@@ -3918,18 +3899,13 @@ public class Launcher extends Activity
* resumed.
*/
private void tryAndUpdatePredictedApps() {
- boolean mRemoteDrawerEnabled = SettingsProvider.getBoolean(this,
- SettingsProvider.SETTINGS_UI_DRAWER_REMOTE_APPS,
- R.bool.preferences_interface_drawer_remote_apps_default);
- if (!mRemoteDrawerEnabled) {
- if (mLauncherCallbacks != null) {
- List<ComponentKey> apps = mLauncherCallbacks.getPredictedApps();
- if (apps != null) {
- mAppsView.setPredictedAppComponents(apps);
- }
- }
+ if (mLauncherCallbacks != null) {
+ List<ComponentKey> apps = mLauncherCallbacks.getPredictedApps();
+ if (apps != null) {
+ mAppsView.setPredictedAppComponents(apps);
}
}
+ }
void lockAllApps() {
// TODO
@@ -4213,7 +4189,6 @@ public class Launcher extends Activity
if (addedApps != null && mAppsView != null) {
mAppsView.addApps(addedApps);
- sRemoteFolderManager.onBindAddApps(addedApps);
}
}
@@ -4539,8 +4514,6 @@ public class Launcher extends Activity
}
mWorkspace.stripEmptyScreens();
-
- sRemoteFolderManager.bindFinished();
}
private void sendLoadingCompleteBroadcastIfNecessary() {
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index e758817..beabeaa 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -2707,9 +2707,7 @@ public class LauncherModel extends BroadcastReceiver
finalItem.container = folder.container;
LauncherModel.deleteItemFromDatabase(mContext, folder);
// only replace this item back on the workspace if it's not protected
- // and not a remote folder.
- if (!mHiddenApps.contains(finalItem.intent.getComponent()) &&
- !folder.isRemote()) {
+ if (!mHiddenApps.contains(finalItem.intent.getComponent())) {
LauncherModel.addOrMoveItemInDatabase(mContext, finalItem,
folder.container, folder.screenId, folder.cellX, folder.cellY);
workspaceItems.add(finalItem);
@@ -2717,8 +2715,7 @@ public class LauncherModel extends BroadcastReceiver
workspaceItems.remove(i);
folders.remove(Long.valueOf(item.id));
- // Remote folders are always empty on bind.
- } else if (folder.contents.size() == 0 && !folder.isRemote()) {
+ } else if (folder.contents.size() == 0) {
LauncherModel.deleteFolderContentsFromDatabase(mContext, folder);
workspaceItems.remove(i);
folders.remove(Long.valueOf(item.id));
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index 1ccd2da..d1dbbf7 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -125,13 +125,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
SettingsProvider.SETTINGS_UI_ALLOW_ROTATION,
R.bool.preferences_interface_allow_rotation);
setSettingSwitch(stateView, settingSwitch, current);
- break;
- case 5:
- current = SettingsProvider.getBoolean(mContext,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_REMOTE_FOLDER,
- R.bool.preferences_interface_homescreen_remote_folder_default);
- setSettingSwitch(stateView, settingSwitch, current);
- break;
default:
hideStates(stateView, settingSwitch);
}
@@ -181,12 +174,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_drawer_search_default);
setSettingSwitch(stateView, settingSwitch, current);
break;
- case 6:
- current = SettingsProvider.getBoolean(mContext,
- SettingsProvider.SETTINGS_UI_DRAWER_REMOTE_APPS,
- R.bool.preferences_interface_drawer_remote_apps_default);
- setSettingSwitch(stateView, settingSwitch, current);
- break;
default:
hideStates(stateView, settingSwitch);
}
@@ -295,13 +282,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
key, extras);
break;
- case 5:
- onSettingsBooleanChanged(v,
- SettingsProvider.SETTINGS_UI_HOMESCREEN_REMOTE_FOLDER,
- R.bool.preferences_interface_homescreen_remote_folder_default,
- false);
- mLauncher.getRemoteFolderManager().onSettingChanged();
- break;
}
break;
case OverviewSettingsPanel.DRAWER_SETTINGS_POSITION:
@@ -351,12 +331,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
R.bool.preferences_interface_drawer_search_default, false);
mLauncher.reloadAppDrawer();
break;
- case 6:
- onSettingsBooleanChanged(v,
- SettingsProvider.SETTINGS_UI_DRAWER_REMOTE_APPS,
- R.bool.preferences_interface_drawer_remote_apps_default, false);
- mLauncher.getRemoteFolderManager().onSettingChanged();
- break;
}
break;
case OverviewSettingsPanel.APP_SETTINGS_POSITION:
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java
index e809a8a..a0e18cb 100644
--- a/src/com/android/launcher3/settings/SettingsProvider.java
+++ b/src/com/android/launcher3/settings/SettingsProvider.java
@@ -26,8 +26,6 @@ public final class SettingsProvider {
public static final String SETTINGS_UI_HOMESCREEN_SEARCH = "ui_homescreen_search";
public static final String SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS = "ui_homescreen_general_hide_icon_labels";
public static final String SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL = "ui_homescreen_scrolling_wallpaper_scroll";
- public static final String SETTINGS_UI_HOMESCREEN_REMOTE_FOLDER = "ui_homescreen_remote_folder";
- public static final String SETTINGS_UI_DRAWER_REMOTE_APPS = "ui_drawer_remote_apps";
public static final String SETTINGS_UI_DYNAMIC_GRID_SIZE = "ui_dynamic_grid_size";
public static final String SETTINGS_UI_HOMESCREEN_ROWS = "ui_homescreen_rows";
public static final String SETTINGS_UI_HOMESCREEN_COLUMNS = "ui_homescreen_columns";
--
2.8.2
From 10d5ba7b72cf47eec82dee12ba8cf0b8b77ae8b5 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 5 May 2016 10:17:17 -0400
Subject: [PATCH 4/5] Nuke remote folder some more
Change-Id: I55d1c6a995fe009b91eb94d3c961389a78da768c
---
Android.mk | 6 ----
src/com/android/launcher3/DeleteDropTarget.java | 9 ++----
src/com/android/launcher3/FolderIcon.java | 34 ++++------------------
.../android/launcher3/OverviewSettingsPanel.java | 6 ----
.../android/launcher3/ThemeChangedReceiver.java | 4 ---
.../launcher3/allapps/AllAppsContainerView.java | 2 --
.../launcher3/allapps/AllAppsGridAdapter.java | 10 -------
.../launcher3/allapps/AlphabeticalAppsList.java | 5 ----
8 files changed, 8 insertions(+), 68 deletions(-)
diff --git a/Android.mk b/Android.mk
index 9915fc5..3ef528d 100644
--- a/Android.mk
+++ b/Android.mk
@@ -61,16 +61,10 @@ LOCAL_OVERRIDES_PACKAGES := Launcher3
LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROGUARD_ENABLED := full
-REMOTE_FOLDER_UPDATER ?= $(LOCAL_PATH)/RemoteFolder
-include $(REMOTE_FOLDER_UPDATER)/Android.mk
-
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
-REMOTE_FOLDER_UPDATER ?= $(LOCAL_PATH)/RemoteFolder
-include $(REMOTE_FOLDER_UPDATER)/Android-prebuilt-libs.mk
-
include $(BUILD_MULTI_PREBUILT)
include $(CLEAR_VARS)
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index f51a43a..a442442 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -75,13 +75,8 @@ public class DeleteDropTarget extends ButtonDropTarget {
} else if (item instanceof FolderInfo) {
FolderInfo folder = (FolderInfo) item;
- // Remote folder should not really be deleted. Let the manager handle it.
- if (folder.isRemote()) {
- launcher.getRemoteFolderManager().onFolderDeleted();
- } else {
- launcher.removeFolder(folder);
- LauncherModel.deleteFolderContentsFromDatabase(launcher, folder);
- }
+ launcher.removeFolder(folder);
+ LauncherModel.deleteFolderContentsFromDatabase(launcher, folder);
} else if (item instanceof LauncherAppWidgetInfo) {
final LauncherAppWidgetInfo widget = (LauncherAppWidgetInfo) item;
diff --git a/src/com/android/launcher3/FolderIcon.java b/src/com/android/launcher3/FolderIcon.java
index 356c275..c43f120 100644
--- a/src/com/android/launcher3/FolderIcon.java
+++ b/src/com/android/launcher3/FolderIcon.java
@@ -174,16 +174,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
icon.mLauncher = launcher;
icon.setContentDescription(String.format(launcher.getString(R.string.folder_name_format),
folderInfo.title));
- Folder folder;
- if (folderInfo.isRemote()) {
- folder = launcher.getRemoteFolderManager().createRemoteFolder(icon, launcher.getDragLayer());
- if (folder == null) {
- LauncherModel.deleteItemFromDatabase(launcher, folderInfo);
- return null;
- }
- } else {
- folder = Folder.fromXml(launcher, launcher.getDragLayer());
- }
+ Folder folder = Folder.fromXml(launcher, launcher.getDragLayer());
folder.setDragController(launcher.getDragController());
folder.setFolderIcon(icon);
folder.bind(folderInfo);
@@ -245,11 +236,6 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
}
- // Create an overlay badge if this FolderIcon is for a RemoteFolder
- if (folderInfo.isRemote()) {
- icon = RemoteFolderManager.addBadgeToFolderIcon(icon);
- }
-
return icon;
}
@@ -391,14 +377,10 @@ public class FolderIcon extends FrameLayout implements FolderListener {
}
private boolean willAcceptItem(ItemInfo item) {
- if (mInfo.isRemote()) return false;
-
final int itemType = item.itemType;
boolean hidden = false;
if (item instanceof FolderInfo){
- if (((FolderInfo) item).isRemote()) return false;
-
hidden = ((FolderInfo) item).hidden;
}
return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
@@ -704,7 +686,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
super.dispatchDraw(canvas);
if (mFolder == null) return;
- if (mFolder.getItemCount() == 0 && !mAnimating && !mInfo.isRemote()) return;
+ if (mFolder.getItemCount() == 0 && !mAnimating) return;
ArrayList<View> items = mFolder.getItemsInReadingOrder();
Drawable d;
@@ -740,14 +722,10 @@ public class FolderIcon extends FrameLayout implements FolderListener {
if (!mAnimating) {
for (int i = 0; i < NUM_ITEMS_IN_PREVIEW; i++) {
d = null;
- if (mInfo.isRemote()) {
- d = mLauncher.getRemoteFolderManager().getFolderIconDrawable(items, i);
- } else if (i < items.size()) {
- v = (TextView) items.get(i);
- if (!mHiddenItems.contains(v.getTag())) {
- d = getTopDrawable(v);
- }
- }
+ v = (TextView) items.get(i);
+ if (!mHiddenItems.contains(v.getTag())) {
+ d = getTopDrawable(v);
+ }
if (d != null) {
mParams = computePreviewItemDrawingParams(i, mParams);
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index 8f1b435..3fbb65a 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -75,9 +75,6 @@ public class OverviewSettingsPanel {
res.getString(R.string.grid_size_text),
res.getString(R.string.allow_rotation_title)}));
- // Add additional external settings.
- RemoteFolderManager.onInitializeHomeSettings(values, mLauncher);
-
String[] valuesArr = new String[values.size()];
values.toArray(valuesArr);
return valuesArr;
@@ -93,9 +90,6 @@ public class OverviewSettingsPanel {
res.getString(R.string.fast_scroller_type),
res.getString(R.string.home_screen_search_text)}));
- // Add additional external settings.
- RemoteFolderManager.onInitializeDrawerSettings(values, mLauncher);
-
String[] valuesArr = new String[values.size()];
values.toArray(valuesArr);
return valuesArr;
diff --git a/src/com/android/launcher3/ThemeChangedReceiver.java b/src/com/android/launcher3/ThemeChangedReceiver.java
index 3f4f3af..6dac0be 100644
--- a/src/com/android/launcher3/ThemeChangedReceiver.java
+++ b/src/com/android/launcher3/ThemeChangedReceiver.java
@@ -43,10 +43,6 @@ public class ThemeChangedReceiver extends BroadcastReceiver {
app.recreateWidgetPreviewDb();
app.getIconCache().flush();
app.getModel().forceReload();
-
- if (Launcher.sRemoteFolderManager != null) {
- Launcher.sRemoteFolderManager.onThemeChanged();
- }
}
}
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 989148f..23f4f70 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -377,8 +377,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
boolean mergeSections = mSectionStrategy == SECTION_STRATEGY_GRID;
mApps.setNumAppsPerRow(mNumAppsPerRow, mNumPredictedAppsPerRow, mergeSections);
-
- mLauncher.getRemoteFolderManager().onMeasureDrawer(mNumPredictedAppsPerRow);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 6431825..56ce38d 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -42,7 +42,6 @@ import com.android.launcher3.BaseRecyclerViewFastScrollBar.FastScrollFocusable;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
-import com.android.launcher3.RemoteFolderManager;
import com.android.launcher3.Utilities;
import com.android.launcher3.settings.SettingsProvider;
import com.android.launcher3.util.Thunk;
@@ -329,8 +328,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
}
}
- private final RemoteFolderManager mRemoteFolderManager;
-
private Launcher mLauncher;
private LayoutInflater mLayoutInflater;
@Thunk AlphabeticalAppsList mApps;
@@ -419,8 +416,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
if (marketInfo != null) {
mMarketAppName = marketInfo.loadLabel(pm).toString();
}
-
- mRemoteFolderManager = launcher.getRemoteFolderManager();
}
/**
@@ -529,7 +524,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
FastScrollFocusable.FAST_SCROLL_FOCUS_SCALABLE);
ViewHolder holder = new ViewHolder(icon);
- mRemoteFolderManager.onCreateViewHolder(holder, viewType);
return holder;
}
@@ -555,14 +549,12 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
FastScrollFocusApplicator.createApplicator(v,
FastScrollFocusable.FAST_SCROLL_FOCUS_DIMMABLE);
ViewHolder holder = new ViewHolder(v);
- mRemoteFolderManager.onCreateViewHolder(holder, viewType);
return holder;
}
case CUSTOM_PREDICTED_APPS_FOOTER_VIEW_TYPE: {
View v = mLayoutInflater.inflate(R.layout.custom_predicted_apps_footer,
parent, false);
ViewHolder holder = new ViewHolder(v);
- mRemoteFolderManager.onCreateViewHolder(holder, viewType);
return holder;
}
default:
@@ -602,8 +594,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter.
FastScrollFocusApplicator.setFastScrollDimmed(icon, shouldDimPosition(position),
!mIconsDimmed);
FastScrollFocusApplicator.setFastScrollFocused(icon, false, !mIconsDimmed);
-
- mRemoteFolderManager.onBindViewHolder(holder, info);
break;
}
case EMPTY_SEARCH_VIEW_TYPE:
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 9d30f81..4ad2626 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -509,11 +509,6 @@ public class AlphabeticalAppsList {
mAdapterItems.add(appItem);
mFilteredApps.add(info);
}
-
- if (mCustomPredictedAppsEnabled) {
- position = mLauncher.getRemoteFolderManager().onUpdateAdapterItems(
- mAdapterItems, lastFastScrollerSectionInfo, lastSectionInfo, position);
- }
}
}
--
2.8.2
From af55242a51ee25ff5732af26b375a098069316e8 Mon Sep 17 00:00:00 2001
From: Tad <tad@spotco.us>
Date: Thu, 5 May 2016 15:20:44 -0400
Subject: [PATCH 5/5] Fix build breakage
Change-Id: I82319301b59da5d04fe3c0b68791999f04717579
---
src/com/android/launcher3/LauncherModel.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index beabeaa..c6d5e21 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -47,7 +47,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.Pair;
-
+import com.android.launcher3.settings.SettingsProvider;
import com.android.launcher3.compat.AppWidgetManagerCompat;
import com.android.launcher3.compat.LauncherActivityInfoCompat;
import com.android.launcher3.compat.LauncherAppsCompat;
--
2.8.2