Merge "Deleting sample code demonstrating how to extend Launcher3" into ub-launcher3-master
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 23bddf6..6ef7828 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -112,53 +112,5 @@
             android:writePermission="com.android.launcher3.permission.WRITE_SETTINGS"
             android:readPermission="com.android.launcher3.permission.READ_SETTINGS" />
 
-        <!-- ENABLE_FOR_TESTING
-
-        <activity
-            android:name="com.android.launcher3.testing.LauncherExtension"
-            android:launchMode="singleTask"
-            android:clearTaskOnLaunch="true"
-            android:stateNotNeeded="true"
-            android:theme="@style/Theme"
-            android:windowSoftInputMode="adjustPan"
-            android:screenOrientation="nosensor"
-            >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.HOME" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.MONKEY"/>
-            </intent-filter>
-        </activity>
-
-        <activity
-            android:name="com.android.launcher3.testing.MemoryDumpActivity"
-            android:theme="@android:style/Theme.NoDisplay"
-            android:label="* HPROF"
-            android:excludeFromRecents="true"
-            android:icon="@drawable/ic_launcher_home"
-            >
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-
-        <activity
-            android:name="com.android.launcher3.testing.ToggleWeightWatcher"
-            android:label="Show Mem"
-            android:icon="@drawable/ic_launcher_home">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.DEFAULT" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-
-        <service android:name="com.android.launcher3.testing.MemoryTracker" />
-
-        -->
-
     </application>
 </manifest>
diff --git a/res/layout/zzz_weight_watcher.xml b/res/layout/zzz_weight_watcher.xml
deleted file mode 100644
index 07fd39e..0000000
--- a/res/layout/zzz_weight_watcher.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<com.android.launcher3.testing.WeightWatcher xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent" />
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 1542703..94d9067 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -138,7 +138,6 @@
 import com.android.launcher3.util.PendingRequestArgs;
 import com.android.launcher3.util.RunnableWithId;
 import com.android.launcher3.util.SystemUiController;
-import com.android.launcher3.util.TestingUtils;
 import com.android.launcher3.util.Themes;
 import com.android.launcher3.util.Thunk;
 import com.android.launcher3.util.TraceHelper;
@@ -1100,10 +1099,6 @@
         mDropTargetBar.setup(mDragController);
 
         mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace);
-
-        if (TestingUtils.MEMORY_DUMP_ENABLED) {
-            TestingUtils.addWeightWatcher(this);
-        }
     }
 
     private void setupOverviewPanel() {
diff --git a/src/com/android/launcher3/LauncherAppState.java b/src/com/android/launcher3/LauncherAppState.java
index dfb30fd..0136c70 100644
--- a/src/com/android/launcher3/LauncherAppState.java
+++ b/src/com/android/launcher3/LauncherAppState.java
@@ -27,12 +27,10 @@
 import com.android.launcher3.compat.LauncherAppsCompat;
 import com.android.launcher3.compat.PackageInstallerCompat;
 import com.android.launcher3.compat.UserManagerCompat;
-import com.android.launcher3.config.FeatureFlags;
 import com.android.launcher3.notification.NotificationListener;
 import com.android.launcher3.util.ConfigMonitor;
 import com.android.launcher3.util.Preconditions;
 import com.android.launcher3.util.SettingsObserver;
-import com.android.launcher3.util.TestingUtils;
 
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -88,10 +86,6 @@
         Preconditions.assertUIThread();
         mContext = context;
 
-        if (TestingUtils.MEMORY_DUMP_ENABLED) {
-            TestingUtils.startTrackingMemory(mContext);
-        }
-
         mInvariantDeviceProfile = new InvariantDeviceProfile(mContext);
         mIconCache = new IconCache(mContext, mInvariantDeviceProfile);
         mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache);
diff --git a/src/com/android/launcher3/testing/LauncherExtension.java b/src/com/android/launcher3/testing/LauncherExtension.java
deleted file mode 100644
index c40e1fb..0000000
--- a/src/com/android/launcher3/testing/LauncherExtension.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package com.android.launcher3.testing;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.Menu;
-
-import com.android.launcher3.AppInfo;
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherCallbacks;
-
-import java.io.FileDescriptor;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-
-/**
- * This class represents a very trivial LauncherExtension. It primarily serves as a simple
- * class to exercise the LauncherOverlay interface.
- */
-public class LauncherExtension extends Launcher {
-
-    //------ Activity methods -------//
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        setLauncherCallbacks(new LauncherExtensionCallbacks());
-        super.onCreate(savedInstanceState);
-    }
-
-    public class LauncherExtensionCallbacks implements LauncherCallbacks {
-
-        @Override
-        public void preOnCreate() {
-        }
-
-        @Override
-        public void onCreate(Bundle savedInstanceState) {
-        }
-
-        @Override
-        public void onResume() {
-        }
-
-        @Override
-        public void onStart() {
-        }
-
-        @Override
-        public void onStop() {
-        }
-
-        @Override
-        public void onPause() {
-        }
-
-        @Override
-        public void onDestroy() {
-        }
-
-        @Override
-        public void onSaveInstanceState(Bundle outState) {
-        }
-
-        @Override
-        public void onNewIntent(Intent intent) {
-        }
-
-        @Override
-        public void onActivityResult(int requestCode, int resultCode, Intent data) {
-        }
-
-        @Override
-        public void onRequestPermissionsResult(int requestCode, String[] permissions,
-                int[] grantResults) {
-        }
-
-        @Override
-        public void onWindowFocusChanged(boolean hasFocus) {
-        }
-
-        @Override
-        public boolean onPrepareOptionsMenu(Menu menu) {
-            return false;
-        }
-
-        @Override
-        public void dump(String prefix, FileDescriptor fd, PrintWriter w, String[] args) {
-        }
-
-        @Override
-        public void onHomeIntent() {
-        }
-
-        @Override
-        public boolean handleBackPressed() {
-            return false;
-        }
-
-        @Override
-        public void onTrimMemory(int level) {
-        }
-
-        @Override
-        public void onLauncherProviderChange() {
-        }
-
-        @Override
-        public void bindAllApplications(ArrayList<AppInfo> apps) {
-        }
-
-        @Override
-        public boolean startSearch(String initialQuery, boolean selectInitialQuery,
-                Bundle appSearchData) {
-            return false;
-        }
-
-        @Override
-        public boolean hasSettings() {
-            return false;
-        }
-
-        @Override
-        public void onAttachedToWindow() {
-        }
-
-        @Override
-        public void onDetachedFromWindow() {
-        }
-    }
-}
diff --git a/src/com/android/launcher3/testing/MemoryDumpActivity.java b/src/com/android/launcher3/testing/MemoryDumpActivity.java
deleted file mode 100644
index 9bcf92b..0000000
--- a/src/com/android/launcher3/testing/MemoryDumpActivity.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.testing;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.content.pm.PackageManager;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.os.Environment;
-import android.os.IBinder;
-import android.util.Log;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class MemoryDumpActivity extends Activity {
-    private static final String TAG = "MemoryDumpActivity";
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-    }
-
-    public static String zipUp(ArrayList<String> paths) {
-        final int BUFSIZ = 256 * 1024; // 256K
-        final byte[] buf = new byte[BUFSIZ];
-        final String zipfilePath = String.format("%s/hprof-%d.zip",
-                Environment.getExternalStorageDirectory(),
-                System.currentTimeMillis());
-        ZipOutputStream zos = null;
-        try {
-            OutputStream os = new FileOutputStream(zipfilePath);
-            zos = new ZipOutputStream(new BufferedOutputStream(os));
-            for (String filename : paths) {
-                InputStream is = null;
-                try {
-                    is = new BufferedInputStream(new FileInputStream(filename));
-                    ZipEntry entry = new ZipEntry(filename);
-                    zos.putNextEntry(entry);
-                    int len;
-                    while ( 0 < (len = is.read(buf, 0, BUFSIZ)) ) {
-                        zos.write(buf, 0, len);
-                    }
-                    zos.closeEntry();
-                } finally {
-                    is.close();
-                }
-            }
-        } catch (IOException e) {
-            Log.e(TAG, "error zipping up profile data", e);
-            return null;
-        } finally {
-            if (zos != null) {
-                try {
-                    zos.close();
-                } catch (IOException e) {
-                    // ugh, whatever
-                }
-            }
-        }
-        return zipfilePath;
-    }
-
-    public static void dumpHprofAndShare(final Context context, MemoryTracker tracker) {
-        final StringBuilder body = new StringBuilder();
-
-        final ArrayList<String> paths = new ArrayList<String>();
-        final int myPid = android.os.Process.myPid();
-
-        final int[] pids_orig = tracker.getTrackedProcesses();
-        final int[] pids_copy = Arrays.copyOf(pids_orig, pids_orig.length);
-        for (int pid : pids_copy) {
-            MemoryTracker.ProcessMemInfo info = tracker.getMemInfo(pid);
-            if (info != null) {
-                body.append("pid ").append(pid).append(":")
-                    .append(" up=").append(info.getUptime())
-                    .append(" pss=").append(info.currentPss)
-                    .append(" uss=").append(info.currentUss)
-                    .append("\n");
-            }
-            if (pid == myPid) {
-                final String path = String.format("%s/launcher-memory-%d.ahprof",
-                        Environment.getExternalStorageDirectory(),
-                        pid);
-                Log.v(TAG, "Dumping memory info for process " + pid + " to " + path);
-                try {
-                    android.os.Debug.dumpHprofData(path); // will block
-                } catch (IOException e) {
-                    Log.e(TAG, "error dumping memory:", e);
-                }
-                paths.add(path);
-            }
-        }
-
-        String zipfile = zipUp(paths);
-
-        if (zipfile == null) return;
-
-        Intent shareIntent = new Intent(Intent.ACTION_SEND);
-        shareIntent.setType("application/zip");
-
-        final PackageManager pm = context.getPackageManager();
-        shareIntent.putExtra(Intent.EXTRA_SUBJECT, String.format("Launcher memory dump (%d)", myPid));
-        String appVersion;
-        try {
-            appVersion = pm.getPackageInfo(context.getPackageName(), 0).versionName;
-        } catch (PackageManager.NameNotFoundException e) {
-            appVersion = "?";
-        }
-
-        body.append("\nApp version: ").append(appVersion).append("\nBuild: ").append(Build.DISPLAY).append("\n");
-        shareIntent.putExtra(Intent.EXTRA_TEXT, body.toString());
-
-        final File pathFile = new File(zipfile);
-        final Uri pathUri = Uri.fromFile(pathFile);
-
-        shareIntent.putExtra(Intent.EXTRA_STREAM, pathUri);
-        context.startActivity(shareIntent);
-    }
-
-    @Override
-    public void onStart() {
-        super.onStart();
-
-        startDump(this, new Runnable() {
-            @Override
-            public void run() {
-                finish();
-            }
-        });
-    }
-
-    public static void startDump(final Context context) {
-        startDump(context, null);
-    }
-
-    public static void startDump(final Context context, final Runnable andThen) {
-        final ServiceConnection connection = new ServiceConnection() {
-            public void onServiceConnected(ComponentName className, IBinder service) {
-                Log.v(TAG, "service connected, dumping...");
-                dumpHprofAndShare(context,
-                        ((MemoryTracker.MemoryTrackerInterface) service).getService());
-                context.unbindService(this);
-                if (andThen != null) andThen.run();
-            }
-
-            public void onServiceDisconnected(ComponentName className) {
-            }
-        };
-        Log.v(TAG, "attempting to bind to memory tracker");
-        context.bindService(new Intent(context, MemoryTracker.class),
-                connection, Context.BIND_AUTO_CREATE);
-    }
-}
diff --git a/src/com/android/launcher3/testing/MemoryTracker.java b/src/com/android/launcher3/testing/MemoryTracker.java
deleted file mode 100644
index ed2a312..0000000
--- a/src/com/android/launcher3/testing/MemoryTracker.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.testing;
-
-import android.app.ActivityManager;
-import android.app.Service;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Binder;
-import android.os.Debug;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.os.SystemClock;
-import android.util.Log;
-import android.util.LongSparseArray;
-
-import com.android.launcher3.util.TestingUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class MemoryTracker extends Service {
-    public static final String TAG = MemoryTracker.class.getSimpleName();
-
-    private static final long UPDATE_RATE = 5000;
-
-    private static final int MSG_START = 1;
-    private static final int MSG_STOP = 2;
-    private static final int MSG_UPDATE = 3;
-
-    public static class ProcessMemInfo {
-        public int pid;
-        public String name;
-        public long startTime;
-        public long currentPss, currentUss;
-        public long[] pss = new long[256];
-        public long[] uss = new long[256];
-            //= new Meminfo[(int) (30 * 60 / (UPDATE_RATE / 1000))]; // 30 minutes
-        public long max = 1;
-        public int head = 0;
-        public ProcessMemInfo(int pid, String name, long start) {
-            this.pid = pid;
-            this.name = name;
-            this.startTime = start;
-        }
-        public long getUptime() {
-            return System.currentTimeMillis() - startTime;
-        }
-    };
-    public final LongSparseArray<ProcessMemInfo> mData = new LongSparseArray<ProcessMemInfo>();
-    public final ArrayList<Long> mPids = new ArrayList<Long>();
-    private int[] mPidsArray = new int[0];
-    private final Object mLock = new Object();
-
-    Handler mHandler = new Handler() {
-        @Override
-        public void handleMessage(Message m) {
-            switch (m.what) {
-                case MSG_START:
-                    mHandler.removeMessages(MSG_UPDATE);
-                    mHandler.sendEmptyMessage(MSG_UPDATE);
-                    break;
-                case MSG_STOP:
-                    mHandler.removeMessages(MSG_UPDATE);
-                    break;
-                case MSG_UPDATE:
-                    update();
-                    mHandler.removeMessages(MSG_UPDATE);
-                    mHandler.sendEmptyMessageDelayed(MSG_UPDATE, UPDATE_RATE);
-                    break;
-            }
-        }
-    };
-
-    ActivityManager mAm;
-
-    public ProcessMemInfo getMemInfo(int pid) {
-        return mData.get(pid);
-    }
-
-    public int[] getTrackedProcesses() {
-        return mPidsArray;
-    }
-
-    public void startTrackingProcess(int pid, String name, long start) {
-        synchronized (mLock) {
-            final Long lpid = Long.valueOf(pid);
-
-            if (mPids.contains(lpid)) return;
-
-            mPids.add(lpid);
-            updatePidsArrayL();
-
-            mData.put(pid, new ProcessMemInfo(pid, name, start));
-        }
-    }
-
-    void updatePidsArrayL() {
-        final int N = mPids.size();
-        mPidsArray = new int[N];
-        StringBuffer sb = new StringBuffer("Now tracking processes: ");
-        for (int i=0; i<N; i++) {
-            final int p = mPids.get(i).intValue();
-            mPidsArray[i] = p;
-            sb.append(p); sb.append(" ");
-        }
-        Log.v(TAG, sb.toString());
-    }
-
-    void update() {
-        synchronized (mLock) {
-            Debug.MemoryInfo[] dinfos = mAm.getProcessMemoryInfo(mPidsArray);
-            for (int i=0; i<dinfos.length; i++) {
-                Debug.MemoryInfo dinfo = dinfos[i];
-                if (i > mPids.size()) {
-                    Log.e(TAG, "update: unknown process info received: " + dinfo);
-                    break;
-                }
-                final long pid = mPids.get(i).intValue();
-                final ProcessMemInfo info = mData.get(pid);
-                info.head = (info.head+1) % info.pss.length;
-                info.pss[info.head] = info.currentPss = dinfo.getTotalPss();
-                info.uss[info.head] = info.currentUss = dinfo.getTotalPrivateDirty();
-                if (info.currentPss > info.max) info.max = info.currentPss;
-                if (info.currentUss > info.max) info.max = info.currentUss;
-                // Log.v(TAG, "update: pid " + pid + " pss=" + info.currentPss + " uss=" + info.currentUss);
-                if (info.currentPss == 0) {
-                    Log.v(TAG, "update: pid " + pid + " has pss=0, it probably died");
-                    mData.remove(pid);
-                }
-            }
-            for (int i=mPids.size()-1; i>=0; i--) {
-                final long pid = mPids.get(i).intValue();
-                if (mData.get(pid) == null) {
-                    mPids.remove(i);
-                    updatePidsArrayL();
-                }
-            }
-        }
-    }
-
-    @Override
-    public void onCreate() {
-        mAm = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
-
-        // catch up in case we crashed but other processes are still running
-        List<ActivityManager.RunningServiceInfo> svcs = mAm.getRunningServices(256);
-        for (ActivityManager.RunningServiceInfo svc : svcs) {
-            if (svc.service.getPackageName().equals(getPackageName())) {
-                Log.v(TAG, "discovered running service: " + svc.process + " (" + svc.pid + ")");
-                startTrackingProcess(svc.pid, svc.process,
-                        System.currentTimeMillis() - (SystemClock.elapsedRealtime() - svc.activeSince));
-            }
-        }
-
-        List<ActivityManager.RunningAppProcessInfo> procs = mAm.getRunningAppProcesses();
-        for (ActivityManager.RunningAppProcessInfo proc : procs) {
-            final String pname = proc.processName;
-            if (pname.startsWith(getPackageName())) {
-                Log.v(TAG, "discovered other running process: " + pname + " (" + proc.pid + ")");
-                startTrackingProcess(proc.pid, pname, System.currentTimeMillis());
-            }
-        }
-    }
-
-    @Override
-    public void onDestroy() {
-        mHandler.sendEmptyMessage(MSG_STOP);
-    }
-
-    @Override
-    public int onStartCommand(Intent intent, int flags, int startId) {
-        Log.v(TAG, "Received start id " + startId + ": " + intent);
-
-        if (intent != null) {
-            if (TestingUtils.ACTION_START_TRACKING.equals(intent.getAction())) {
-                final int pid = intent.getIntExtra("pid", -1);
-                final String name = intent.getStringExtra("name");
-                final long start = intent.getLongExtra("start", System.currentTimeMillis());
-                startTrackingProcess(pid, name, start);
-            }
-        }
-
-        mHandler.sendEmptyMessage(MSG_START);
-
-        return START_STICKY;
-    }
-
-    public class MemoryTrackerInterface extends Binder {
-        MemoryTracker getService() {
-            return MemoryTracker.this;
-        }
-    }
-
-    private final IBinder mBinder = new MemoryTrackerInterface();
-
-    public IBinder onBind(Intent intent) {
-        mHandler.sendEmptyMessage(MSG_START);
-
-        return mBinder;
-    }
-}
diff --git a/src/com/android/launcher3/testing/ToggleWeightWatcher.java b/src/com/android/launcher3/testing/ToggleWeightWatcher.java
deleted file mode 100644
index f0c3920..0000000
--- a/src/com/android/launcher3/testing/ToggleWeightWatcher.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.android.launcher3.testing;
-
-import android.app.Activity;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.view.View;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.LauncherAppState;
-import com.android.launcher3.Utilities;
-import com.android.launcher3.util.TestingUtils;
-
-public class ToggleWeightWatcher extends Activity {
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        SharedPreferences sp = Utilities.getPrefs(this);
-        boolean show = sp.getBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, true);
-
-        show = !show;
-        sp.edit().putBoolean(TestingUtils.SHOW_WEIGHT_WATCHER, show).apply();
-
-        Launcher launcher = (Launcher) LauncherAppState.getInstance(this).getModel().getCallback();
-        if (launcher != null && launcher.mWeightWatcher != null) {
-            launcher.mWeightWatcher.setVisibility(show ? View.VISIBLE : View.GONE);
-        }
-        finish();
-    }
-}
diff --git a/src/com/android/launcher3/testing/WeightWatcher.java b/src/com/android/launcher3/testing/WeightWatcher.java
deleted file mode 100644
index a26a2b6..0000000
--- a/src/com/android/launcher3/testing/WeightWatcher.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3.testing;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Message;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.android.launcher3.util.Thunk;
-
-public class WeightWatcher extends LinearLayout {
-    private static final int RAM_GRAPH_RSS_COLOR = 0xFF990000;
-    private static final int RAM_GRAPH_PSS_COLOR = 0xFF99CC00;
-    private static final int TEXT_COLOR = 0xFFFFFFFF;
-    private static final int BACKGROUND_COLOR = 0xc0000000;
-
-    private static final int UPDATE_RATE = 5000;
-
-    private static final int MSG_START = 1;
-    private static final int MSG_STOP = 2;
-    private static final int MSG_UPDATE = 3;
-
-    static int indexOf(int[] a, int x) {
-        for (int i=0; i<a.length; i++) {
-            if (a[i] == x) return i;
-        }
-        return -1;
-    }
-
-    Handler mHandler = new Handler() {
-        @Override
-        public void handleMessage(Message m) {
-            switch (m.what) {
-                case MSG_START:
-                    mHandler.sendEmptyMessage(MSG_UPDATE);
-                    break;
-                case MSG_STOP:
-                    mHandler.removeMessages(MSG_UPDATE);
-                    break;
-                case MSG_UPDATE:
-                    int[] pids = mMemoryService.getTrackedProcesses();
-
-                    final int N = getChildCount();
-                    if (pids.length != N) initViews();
-                    else for (int i=0; i<N; i++) {
-                        ProcessWatcher pw = ((ProcessWatcher) getChildAt(i));
-                        if (indexOf(pids, pw.getPid()) < 0) {
-                            initViews();
-                            break;
-                        }
-                        pw.update();
-                    }
-                    mHandler.sendEmptyMessageDelayed(MSG_UPDATE, UPDATE_RATE);
-                    break;
-            }
-        }
-    };
-    @Thunk MemoryTracker mMemoryService;
-
-    public WeightWatcher(Context context, AttributeSet attrs) {
-        super(context, attrs);
-
-        ServiceConnection connection = new ServiceConnection() {
-            public void onServiceConnected(ComponentName className, IBinder service) {
-                mMemoryService = ((MemoryTracker.MemoryTrackerInterface)service).getService();
-                initViews();
-            }
-
-            public void onServiceDisconnected(ComponentName className) {
-                mMemoryService = null;
-            }
-        };
-        context.bindService(new Intent(context, MemoryTracker.class),
-                connection, Context.BIND_AUTO_CREATE);
-
-        setOrientation(LinearLayout.VERTICAL);
-
-        setBackgroundColor(BACKGROUND_COLOR);
-    }
-
-    public void initViews() {
-        removeAllViews();
-        int[] processes = mMemoryService.getTrackedProcesses();
-        for (int i=0; i<processes.length; i++) {
-            final ProcessWatcher v = new ProcessWatcher(getContext());
-            v.setPid(processes[i]);
-            addView(v);
-        }
-    }
-
-    @Override
-    public void onAttachedToWindow() {
-        super.onAttachedToWindow();
-        mHandler.sendEmptyMessage(MSG_START);
-    }
-
-    @Override
-    public void onDetachedFromWindow() {
-        super.onDetachedFromWindow();
-        mHandler.sendEmptyMessage(MSG_STOP);
-    }
-
-    public class ProcessWatcher extends LinearLayout {
-        GraphView mRamGraph;
-        TextView mText;
-        int mPid;
-        @Thunk MemoryTracker.ProcessMemInfo mMemInfo;
-
-        public ProcessWatcher(Context context) {
-            this(context, null);
-        }
-
-        public ProcessWatcher(Context context, AttributeSet attrs) {
-            super(context, attrs);
-
-            final float dp = getResources().getDisplayMetrics().density;
-
-            mText = new TextView(getContext());
-            mText.setTextColor(TEXT_COLOR);
-            mText.setTextSize(TypedValue.COMPLEX_UNIT_PX, 10 * dp);
-            mText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
-
-            final int p = (int)(2*dp);
-            setPadding(p, 0, p, 0);
-
-            mRamGraph = new GraphView(getContext());
-
-            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
-                    0,
-                    (int)(14 * dp),
-                    1f
-            );
-
-            addView(mText, params);
-            params.leftMargin = (int)(4*dp);
-            params.weight = 0f;
-            params.width = (int)(200 * dp);
-            addView(mRamGraph, params);
-        }
-
-        public void setPid(int pid) {
-            mPid = pid;
-            mMemInfo = mMemoryService.getMemInfo(mPid);
-            if (mMemInfo == null) {
-                Log.v("WeightWatcher", "Missing info for pid " + mPid + ", removing view: " + this);
-                initViews();
-            }
-        }
-
-        public int getPid() {
-            return mPid;
-        }
-
-        public String getUptimeString() {
-            long sec = mMemInfo.getUptime() / 1000;
-            StringBuilder sb = new StringBuilder();
-            long days = sec / 86400;
-            if (days > 0) {
-                sec -= days * 86400;
-                sb.append(days);
-                sb.append("d");
-            }
-
-            long hours = sec / 3600;
-            if (hours > 0) {
-                sec -= hours * 3600;
-                sb.append(hours);
-                sb.append("h");
-            }
-
-            long mins = sec / 60;
-            if (mins > 0) {
-                sec -= mins * 60;
-                sb.append(mins);
-                sb.append("m");
-            }
-
-            sb.append(sec);
-            sb.append("s");
-            return sb.toString();
-        }
-
-        public void update() {
-            //Log.v("WeightWatcher.ProcessWatcher",
-            //        "MSG_UPDATE pss=" + mMemInfo.currentPss);
-            mText.setText("(" + mPid
-                          + (mPid == android.os.Process.myPid()
-                                ? "/A"  // app
-                                : "/S") // service
-                          + ") up " + getUptimeString()
-                          + " P=" + mMemInfo.currentPss
-                          + " U=" + mMemInfo.currentUss
-                          );
-            mRamGraph.invalidate();
-        }
-
-        public class GraphView extends View {
-            Paint pssPaint, ussPaint, headPaint;
-
-            public GraphView(Context context, AttributeSet attrs) {
-                super(context, attrs);
-
-                pssPaint = new Paint();
-                pssPaint.setColor(RAM_GRAPH_PSS_COLOR);
-                ussPaint = new Paint();
-                ussPaint.setColor(RAM_GRAPH_RSS_COLOR);
-                headPaint = new Paint();
-                headPaint.setColor(Color.WHITE);
-            }
-
-            public GraphView(Context context) {
-                this(context, null);
-            }
-
-            @Override
-            public void onDraw(Canvas c) {
-                int w = c.getWidth();
-                int h = c.getHeight();
-
-                if (mMemInfo == null) return;
-
-                final int N = mMemInfo.pss.length;
-                final float barStep = (float) w / N;
-                final float barWidth = Math.max(1, barStep);
-                final float scale = (float) h / mMemInfo.max;
-
-                int i;
-                float x;
-                for (i=0; i<N; i++) {
-                    x = i * barStep;
-                    c.drawRect(x, h - scale * mMemInfo.pss[i], x + barWidth, h, pssPaint);
-                    c.drawRect(x, h - scale * mMemInfo.uss[i], x + barWidth, h, ussPaint);
-                }
-                x = mMemInfo.head * barStep;
-                c.drawRect(x, 0, x + barWidth, h, headPaint);
-            }
-        }
-    }
-}
diff --git a/src/com/android/launcher3/util/TestingUtils.java b/src/com/android/launcher3/util/TestingUtils.java
deleted file mode 100644
index d927dc3..0000000
--- a/src/com/android/launcher3/util/TestingUtils.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.android.launcher3.util;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.FrameLayout;
-
-import com.android.launcher3.Launcher;
-import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
-
-public class TestingUtils {
-
-    public static final String MEMORY_TRACKER = "com.android.launcher3.testing.MemoryTracker";
-    public static final String ACTION_START_TRACKING = "com.android.launcher3.action.START_TRACKING";
-
-    public static final boolean MEMORY_DUMP_ENABLED = false;
-    public static final String SHOW_WEIGHT_WATCHER = "debug.show_mem";
-
-    public static void startTrackingMemory(Context context) {
-        if (MEMORY_DUMP_ENABLED) {
-            context.startService(new Intent()
-                .setComponent(new ComponentName(context.getPackageName(), MEMORY_TRACKER))
-                .setAction(ACTION_START_TRACKING)
-                .putExtra("pid", android.os.Process.myPid())
-                .putExtra("name", "L"));
-        }
-    }
-
-    public static void addWeightWatcher(Launcher launcher) {
-        if (MEMORY_DUMP_ENABLED) {
-            boolean show = Utilities.getPrefs(launcher).getBoolean(SHOW_WEIGHT_WATCHER, true);
-
-            int id = launcher.getResources().getIdentifier("zzz_weight_watcher", "layout",
-                    launcher.getPackageName());
-            View watcher = launcher.getLayoutInflater().inflate(id, null);
-            watcher.setAlpha(0.5f);
-            ((FrameLayout) launcher.findViewById(R.id.launcher)).addView(watcher,
-                    new FrameLayout.LayoutParams(
-                            FrameLayout.LayoutParams.MATCH_PARENT,
-                            FrameLayout.LayoutParams.WRAP_CONTENT,
-                            Gravity.BOTTOM)
-            );
-
-            watcher.setVisibility(show ? View.VISIBLE : View.GONE);
-            launcher.mWeightWatcher = watcher;
-        }
-    }
-}