summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey <joey@lineageos.org>2018-07-04 11:13:45 +0200
committerAlexander Martinz <amartinz@shiftphones.com>2018-07-18 10:40:57 +0200
commit5dade749cf87d5e048143717bb79d06fe9a0dbf6 (patch)
treeac640f5c8343e71f90348e943bff7177800fccba
parentc2e09dca5577fd5ba0dd5c532e18804e2fc2de3c (diff)
downloadandroid_packages_apps_Trebuchet-5dade749cf87d5e048143717bb79d06fe9a0dbf6.tar.gz
android_packages_apps_Trebuchet-5dade749cf87d5e048143717bb79d06fe9a0dbf6.tar.bz2
android_packages_apps_Trebuchet-5dade749cf87d5e048143717bb79d06fe9a0dbf6.zip
Revert "Trebuchet: feed integration support"
This reverts commit 8dee56deeed7b09a9e5e9f4d21f27aa9d495930c. Change-Id: I911aff9099b69c07f784b89689dfeae0ec0e223c
-rw-r--r--res/xml/launcher_preferences.xml7
-rw-r--r--src/com/android/launcher3/Launcher.java54
-rw-r--r--src/com/android/launcher3/LauncherTab.java85
-rw-r--r--src/com/android/launcher3/SettingsActivity.java19
-rw-r--r--src/com/android/launcher3/Utilities.java5
-rw-r--r--src/com/google/android/libraries/launcherclient/ILauncherOverlay.java319
-rw-r--r--src/com/google/android/libraries/launcherclient/ILauncherOverlayCallback.java94
-rw-r--r--src/com/google/android/libraries/launcherclient/LauncherClient.java423
-rw-r--r--src/com/google/android/libraries/launcherclient/LauncherClientCallbacks.java7
-rw-r--r--src/com/google/android/libraries/launcherclient/LauncherClientCallbacksAdapter.java13
10 files changed, 0 insertions, 1026 deletions
diff --git a/res/xml/launcher_preferences.xml b/res/xml/launcher_preferences.xml
index 195b6bf18..e9bf50482 100644
--- a/res/xml/launcher_preferences.xml
+++ b/res/xml/launcher_preferences.xml
@@ -42,13 +42,6 @@
android:title="@string/statusbar_expand" />
<SwitchPreference
- android:defaultValue="false"
- android:icon="@drawable/ic_settings_feed"
- android:key="pref_feed_integration"
- android:persistent="true"
- android:title="@string/settings_feed" />
-
- <SwitchPreference
android:defaultValue="true"
android:icon="@drawable/ic_settings_add_shortcut"
android:key="pref_add_icon_to_home"
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8bdd8836c..6fbbd52fd 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -368,10 +368,6 @@ public class Launcher extends BaseActivity
private EditText mIconEditTitle;
private IconsHandler mIconsHandler;
- // Feed integration
- private LauncherTab mLauncherTab;
- private boolean mFeedIntegrationEnabled;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
if (DEBUG_STRICT_MODE) {
@@ -500,9 +496,6 @@ public class Launcher extends BaseActivity
// we want the screen to auto-rotate based on the current orientation
setOrientation();
- mFeedIntegrationEnabled = isFeedIntegrationEnabled();
- mLauncherTab = new LauncherTab(this, mFeedIntegrationEnabled);
-
setContentView(mLauncherView);
// Listen for broadcasts
@@ -1085,9 +1078,6 @@ public class Launcher extends BaseActivity
if (shouldShowDiscoveryBounce()) {
mAllAppsController.showDiscoveryBounce();
}
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().onResume();
- }
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onResume();
}
@@ -1112,10 +1102,6 @@ public class Launcher extends BaseActivity
mWorkspace.getCustomContentCallbacks().onHide();
}
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().onPause();
- }
-
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onPause();
}
@@ -1627,11 +1613,6 @@ public class Launcher extends BaseActivity
super.onAttachedToWindow();
FirstFrameAnimatorHelper.initializeDrawListener(getWindow().getDecorView());
-
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().onAttachedToWindow();
- }
-
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onAttachedToWindow();
}
@@ -1641,11 +1622,6 @@ public class Launcher extends BaseActivity
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
-
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().onDetachedFromWindow();
- }
-
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDetachedFromWindow();
}
@@ -1811,10 +1787,6 @@ public class Launcher extends BaseActivity
mIconEditDialog = null;
}
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().hideOverlay(true);
- }
-
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onHomeIntent();
}
@@ -1926,10 +1898,6 @@ public class Launcher extends BaseActivity
clearPendingBinds();
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().onDestroy();
- }
-
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onDestroy();
}
@@ -4179,10 +4147,6 @@ public class Launcher extends BaseActivity
return super.onKeyShortcut(keyCode, event);
}
- private boolean isFeedIntegrationEnabled() {
- return Utilities.hasFeedIntegration(this);
- }
-
public static CustomAppWidget getCustomAppWidget(String name) {
return sCustomAppWidgets.get(name);
}
@@ -4207,24 +4171,6 @@ public class Launcher extends BaseActivity
// Recreate the activity so that it initializes the rotation preference again.
recreate();
}
- if (SettingsActivity.KEY_FEED_INTEGRATION.equals(key)) {
- if (mLauncherTab == null) {
- return;
- }
-
- mFeedIntegrationEnabled = isFeedIntegrationEnabled();
- mLauncherTab.updateLauncherTab(mFeedIntegrationEnabled);
-
- if (mLauncherTab.getClient() == null) {
- return;
- }
-
- if (mFeedIntegrationEnabled) {
- mLauncherTab.getClient().onAttachedToWindow();
- } else {
- mLauncherTab.getClient().onDestroy();
- }
- }
}
}
}
diff --git a/src/com/android/launcher3/LauncherTab.java b/src/com/android/launcher3/LauncherTab.java
deleted file mode 100644
index 2bb450070..000000000
--- a/src/com/android/launcher3/LauncherTab.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2017 Paranoid Android
- * Copyright (C) 2018 The LineageOS Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.launcher3;
-
-import com.android.launcher3.Launcher.LauncherOverlay;
-import com.android.launcher3.Launcher.LauncherOverlayCallbacks;
-
-import com.google.android.libraries.launcherclient.LauncherClient;
-import com.google.android.libraries.launcherclient.LauncherClientCallbacksAdapter;
-
-public class LauncherTab {
-
- public static final String SEARCH_PACKAGE = "com.google.android.googlequicksearchbox";
-
- private Launcher mLauncher;
- private LauncherClient mLauncherClient;
- private Workspace mWorkspace;
-
- public LauncherTab(Launcher launcher, boolean enabled) {
- mLauncher = launcher;
- mWorkspace = launcher.getWorkspace();
-
- updateLauncherTab(enabled);
- if (enabled && mLauncherClient.isConnected()) {
- launcher.setLauncherOverlay(new LauncherOverlays());
- }
- }
-
- protected void updateLauncherTab(boolean enabled) {
- if (enabled) {
- mLauncherClient = new LauncherClient(mLauncher,
- new LauncherClientCallbacks(), SEARCH_PACKAGE, true);
- mLauncher.setLauncherOverlay(new LauncherOverlays());
- } else {
- mLauncher.setLauncherOverlay(null);
- }
- }
-
- protected LauncherClient getClient() {
- return mLauncherClient;
- }
-
- private class LauncherOverlays implements LauncherOverlay {
- @Override
- public void onScrollInteractionBegin() {
- mLauncherClient.startMove();
- }
-
- @Override
- public void onScrollInteractionEnd() {
- mLauncherClient.endMove();
- }
-
- @Override
- public void onScrollChange(float progress, boolean rtl) {
- mLauncherClient.updateMove(progress);
- }
-
- @Override
- public void setOverlayCallbacks(LauncherOverlayCallbacks callbacks) {
- }
- }
-
- private class LauncherClientCallbacks extends LauncherClientCallbacksAdapter {
- @Override
- public void onOverlayScrollChanged(float progress) {
- mWorkspace.onOverlayScrollChanged(progress);
- }
- }
-}
diff --git a/src/com/android/launcher3/SettingsActivity.java b/src/com/android/launcher3/SettingsActivity.java
index e538df99b..63a01d122 100644
--- a/src/com/android/launcher3/SettingsActivity.java
+++ b/src/com/android/launcher3/SettingsActivity.java
@@ -30,9 +30,6 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -61,7 +58,6 @@ public class SettingsActivity extends Activity {
private static final String KEY_SHOW_DESKTOP_LABELS = "pref_desktop_show_labels";
private static final String KEY_SHOW_DRAWER_LABELS = "pref_drawer_show_labels";
- static final String KEY_FEED_INTEGRATION = "pref_feed_integration";
static final String KEY_PREDICTIVE_APPS = "pref_predictive_apps";
public static final String KEY_WORKSPACE_EDIT = "pref_workspace_edit";
public static final String KEY_FORCE_ADAPTIVE_ICONS = "pref_icon_force_adaptive";
@@ -139,11 +135,6 @@ public class SettingsActivity extends Activity {
mIconBadgingObserver.register(NOTIFICATION_BADGING, NOTIFICATION_ENABLED_LISTENERS);
}
- SwitchPreference feedIntegration = (SwitchPreference)
- findPreference(KEY_FEED_INTEGRATION);
- if (!hasPackageInstalled(LauncherTab.SEARCH_PACKAGE)) {
- homeGroup.removePreference(feedIntegration);
- }
SwitchPreference iconAdaptiveOverride = (SwitchPreference)
findPreference(KEY_FORCE_ADAPTIVE_ICONS);
@@ -205,16 +196,6 @@ public class SettingsActivity extends Activity {
manager.set(AlarmManager.RTC, java.lang.System.currentTimeMillis() + 1, pi);
java.lang.System.exit(0);
}
-
- private boolean hasPackageInstalled(String pkgName) {
- try {
- ApplicationInfo ai = getContext().getPackageManager()
- .getApplicationInfo(pkgName, 0);
- return ai.enabled;
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
}
/**
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index d6aaae445..2cb24ab5b 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -707,11 +707,6 @@ public final class Utilities {
return !(currentPack.equals(defaultPack) || currentPack.equals(defaultLocalizedPack));
}
- static boolean hasFeedIntegration(Context context) {
- SharedPreferences prefs = getPrefs(context.getApplicationContext());
- return prefs.getBoolean(SettingsActivity.KEY_FEED_INTEGRATION, false);
- }
-
public static boolean isWorkspaceEditAllowed(Context context) {
SharedPreferences prefs = getPrefs(context.getApplicationContext());
return prefs.getBoolean(SettingsActivity.KEY_WORKSPACE_EDIT, true);
diff --git a/src/com/google/android/libraries/launcherclient/ILauncherOverlay.java b/src/com/google/android/libraries/launcherclient/ILauncherOverlay.java
deleted file mode 100644
index 1b54b26ea..000000000
--- a/src/com/google/android/libraries/launcherclient/ILauncherOverlay.java
+++ /dev/null
@@ -1,319 +0,0 @@
-package com.google.android.libraries.launcherclient;
-
-import android.os.Binder;
-import android.os.IBinder;
-import android.os.IInterface;
-import android.os.Parcel;
-import android.os.RemoteException;
-import android.view.WindowManager;
-
-public interface ILauncherOverlay extends IInterface {
- void closeOverlay(int options) throws RemoteException;
-
- void endScroll() throws RemoteException;
-
- String getVoiceSearchLanguage() throws RemoteException;
-
- boolean isVoiceDetectionRunning() throws RemoteException;
-
- void onPause() throws RemoteException;
-
- void onResume() throws RemoteException;
-
- void onScroll(float progress) throws RemoteException;
-
- void openOverlay(int options) throws RemoteException;
-
- void requestVoiceDetection(boolean start) throws RemoteException;
-
- void startScroll() throws RemoteException;
-
- void windowAttached(WindowManager.LayoutParams attrs, ILauncherOverlayCallback callbacks,
- int options) throws RemoteException;
-
- void windowDetached(boolean isChangingConfigurations) throws RemoteException;
-
- abstract class Stub extends Binder implements ILauncherOverlay {
- static final int START_SCROLL_TRANSACTION = 1;
- static final int ON_SCROLL_TRANSACTION = 2;
- static final int END_SCROLL_TRANSACTION = 3;
- static final int WINDOW_ATTACHED_TRANSACTION = 4;
- static final int WINDOW_DETACHED_TRANSACTION = 5;
- static final int CLOSE_OVERLAY_TRANSACTION = 6;
- static final int ON_PAUSE_TRANSACTION = 7;
- static final int ON_RESUME_TRANSACTION = 8;
- static final int OPEN_OVERLAY_TRANSACTION = 9;
- static final int REQUEST_VOICE_DETECTION_TRANSACTION = 10;
- static final int GET_VOICE_SEARCH_LANGUAGE_TRANSACTION = 11;
- static final int IS_VOICE_DETECTION_RUNNING_TRANSACTION = 12;
-
-
- public static ILauncherOverlay asInterface(IBinder obj) {
- if (obj == null) {
- return null;
- }
-
- IInterface iin = obj.queryLocalInterface(ILauncherOverlay.class.getName());
- if (iin != null && iin instanceof ILauncherOverlay) {
- return (ILauncherOverlay) iin;
- }
- else {
- return new Proxy(obj);
- }
- }
-
- public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
- throws RemoteException {
- switch (code) {
- case INTERFACE_TRANSACTION:
- reply.writeString(ILauncherOverlay.class.getName());
- return true;
- case START_SCROLL_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- startScroll();
- return true;
- case ON_SCROLL_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- float _arg0 = data.readFloat();
- onScroll(_arg0);
- return true;
- case END_SCROLL_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- endScroll();
- return true;
- case WINDOW_ATTACHED_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- WindowManager.LayoutParams layoutParams = null;
- if (data.readInt() != 0) {
- layoutParams = WindowManager.LayoutParams.CREATOR.createFromParcel(data);
- }
-
- windowAttached(
- layoutParams,
- ILauncherOverlayCallback.Stub.asInterface(data.readStrongBinder()),
- data.readInt()
- );
-
- return true;
- case WINDOW_DETACHED_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- windowDetached(data.readInt() != 0);
- return true;
- case CLOSE_OVERLAY_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- closeOverlay(data.readInt());
- return true;
- case ON_PAUSE_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- onPause();
- return true;
- case ON_RESUME_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- onResume();
- return true;
- case OPEN_OVERLAY_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- openOverlay(data.readInt());
- return true;
- case REQUEST_VOICE_DETECTION_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- requestVoiceDetection(data.readInt() != 0);
- return true;
- case GET_VOICE_SEARCH_LANGUAGE_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- String language = getVoiceSearchLanguage();
- reply.writeNoException();
- reply.writeString(language);
- return true;
- case IS_VOICE_DETECTION_RUNNING_TRANSACTION:
- data.enforceInterface(ILauncherOverlay.class.getName());
- boolean running = isVoiceDetectionRunning();
- reply.writeNoException();
- reply.writeInt(running ? 1 : 0);
- return true;
- default:
- return super.onTransact(code, data, reply, flags);
- }
- }
-
- private static class Proxy implements ILauncherOverlay {
- private IBinder mRemote;
-
- public Proxy(IBinder remote) {
- mRemote = remote;
- }
-
- public IBinder asBinder() {
- return mRemote;
- }
-
- public void closeOverlay(int options) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
- _data.writeInt(options);
-
- mRemote.transact(CLOSE_OVERLAY_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- public void endScroll() throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
-
- mRemote.transact(END_SCROLL_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- public String getVoiceSearchLanguage() throws RemoteException {
- Parcel _data = Parcel.obtain();
- Parcel _reply = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
-
- mRemote.transact(GET_VOICE_SEARCH_LANGUAGE_TRANSACTION, _data, _reply, 0);
- _reply.readException();
- return _reply.readString();
- } finally {
- _data.recycle();
- _reply.recycle();
- }
- }
-
- @Override
- public boolean isVoiceDetectionRunning() throws RemoteException {
- Parcel _data = Parcel.obtain();
- Parcel _reply = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
-
- mRemote.transact(IS_VOICE_DETECTION_RUNNING_TRANSACTION, _data, _reply, 0);
- _reply.readException();
- return _reply.readInt() != 0;
- } finally {
- _data.recycle();
- _reply.recycle();
- }
- }
-
- @Override
- public void onPause() throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
-
- mRemote.transact(ON_PAUSE_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void onResume() throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
-
- mRemote.transact(ON_RESUME_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void onScroll(float progress) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
- _data.writeFloat(progress);
-
- mRemote.transact(ON_SCROLL_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void openOverlay(int options) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
- _data.writeInt(options);
-
- mRemote.transact(OPEN_OVERLAY_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void requestVoiceDetection(boolean start) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
- _data.writeInt(start ? 1 : 0);
-
- mRemote.transact(REQUEST_VOICE_DETECTION_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void startScroll() throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
-
- mRemote.transact(START_SCROLL_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void windowAttached(WindowManager.LayoutParams attrs,
- ILauncherOverlayCallback callbacks, int options)
- throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
- if (attrs != null) {
- _data.writeInt(1);
- attrs.writeToParcel(_data, 0);
- } else {
- _data.writeInt(0);
- }
- _data.writeStrongBinder(callbacks.asBinder());
- _data.writeInt(options);
-
- _data.writeInt(1);
-
- mRemote.transact(WINDOW_ATTACHED_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- @Override
- public void windowDetached(boolean isChangingConfigurations) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlay.class.getName());
- _data.writeInt(isChangingConfigurations ? 1 : 0);
-
- mRemote.transact(WINDOW_DETACHED_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
- }
-
-
- }
-} \ No newline at end of file
diff --git a/src/com/google/android/libraries/launcherclient/ILauncherOverlayCallback.java b/src/com/google/android/libraries/launcherclient/ILauncherOverlayCallback.java
deleted file mode 100644
index 2f6d029e4..000000000
--- a/src/com/google/android/libraries/launcherclient/ILauncherOverlayCallback.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.google.android.libraries.launcherclient;
-
-import android.os.Binder;
-import android.os.IBinder;
-import android.os.IInterface;
-import android.os.Parcel;
-import android.os.RemoteException;
-
-public interface ILauncherOverlayCallback extends IInterface {
- void overlayScrollChanged(float progress) throws RemoteException;
-
- void overlayStatusChanged(int status) throws RemoteException;
-
- abstract class Stub extends Binder implements ILauncherOverlayCallback {
- static final int OVERLAY_SCROLL_CHANGED_TRANSACTION = 1;
- static final int OVERLAY_STATUS_CHANGED_TRANSACTION = 2;
-
- public Stub() {
- attachInterface(this, ILauncherOverlayCallback.class.getName());
- }
-
- public static ILauncherOverlayCallback asInterface(IBinder obj) {
- if (obj == null) {
- return null;
- }
-
- IInterface iin = obj.queryLocalInterface(ILauncherOverlayCallback.class.getName());
- if (iin != null && iin instanceof ILauncherOverlayCallback) {
- return (ILauncherOverlayCallback) iin;
- } else {
- return new Proxy(obj);
- }
- }
-
- public IBinder asBinder() {
- return this;
- }
-
- public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
- throws RemoteException {
- switch (code) {
- case INTERFACE_TRANSACTION:
- reply.writeString(ILauncherOverlay.class.getName());
- return true;
- case OVERLAY_SCROLL_CHANGED_TRANSACTION:
- data.enforceInterface(ILauncherOverlayCallback.class.getName());
- overlayScrollChanged(data.readFloat());
- return true;
- case OVERLAY_STATUS_CHANGED_TRANSACTION:
- data.enforceInterface(ILauncherOverlayCallback.class.getName());
- overlayStatusChanged(data.readInt());
- default:
- return super.onTransact(code, data, reply, flags);
- }
- }
-
- private static class Proxy implements ILauncherOverlayCallback {
- private IBinder mRemote;
-
- public Proxy(IBinder remote) {
- mRemote = remote;
- }
-
- public IBinder asBinder() {
- return mRemote;
- }
-
- public void overlayScrollChanged(float progress) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlayCallback.class.getName());
- _data.writeFloat(progress);
-
- mRemote.transact(OVERLAY_SCROLL_CHANGED_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
-
- public void overlayStatusChanged(int status) throws RemoteException {
- Parcel _data = Parcel.obtain();
- try {
- _data.writeInterfaceToken(ILauncherOverlayCallback.class.getName());
- _data.writeInt(status);
-
- mRemote.transact(OVERLAY_STATUS_CHANGED_TRANSACTION, _data, null, FLAG_ONEWAY);
- } finally {
- _data.recycle();
- }
- }
- }
-
- }
-} \ No newline at end of file
diff --git a/src/com/google/android/libraries/launcherclient/LauncherClient.java b/src/com/google/android/libraries/launcherclient/LauncherClient.java
deleted file mode 100644
index 5a1985600..000000000
--- a/src/com/google/android/libraries/launcherclient/LauncherClient.java
+++ /dev/null
@@ -1,423 +0,0 @@
-package com.google.android.libraries.launcherclient;
-
-import android.app.Activity;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.graphics.Point;
-import android.net.Uri;
-import android.os.Handler;
-import android.os.IBinder;
-import android.os.Looper;
-import android.os.Message;
-import android.os.PatternMatcher;
-import android.os.Process;
-import android.os.RemoteException;
-import android.util.Log;
-import android.view.Window;
-import android.view.WindowManager;
-
-import com.android.launcher3.Utilities;
-
-public class LauncherClient {
-
- private static AppServiceConnection sApplicationConnection;
-
- private final Activity mActivity;
- private OverlayCallbacks mCurrentCallbacks;
- private boolean mDestroyed;
- private boolean mIsResumed;
- private boolean mIsServiceConnected;
- private LauncherClientCallbacks mLauncherClientCallbacks;
- private ILauncherOverlay mOverlay;
- private OverlayServiceConnection mServiceConnection;
- private int mServiceConnectionOptions;
- private final Intent mServiceIntent;
- private int mServiceStatus;
- private int mState;
- private final BroadcastReceiver mUpdateReceiver;
- private WindowManager.LayoutParams mWindowAttrs;
-
- public LauncherClient(Activity activity, LauncherClientCallbacks callbacks,
- String targetPackage, boolean overlayEnabled) {
- mUpdateReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- reconnect();
- }
- };
- mIsResumed = false;
- mDestroyed = false;
- mIsServiceConnected = false;
- mServiceStatus = -1;
- mActivity = activity;
- mServiceIntent = LauncherClient.getServiceIntent(activity, targetPackage);
- mLauncherClientCallbacks = callbacks;
- mState = 0;
- mServiceConnection = new OverlayServiceConnection();
- mServiceConnectionOptions = overlayEnabled ? 3 : 2;
-
- IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
- filter.addDataScheme("package");
- filter.addDataSchemeSpecificPart(targetPackage, PatternMatcher.PATTERN_LITERAL);
- mActivity.registerReceiver(mUpdateReceiver, filter);
-
- reconnect();
- }
-
- private void applyWindowToken() {
- if (mOverlay == null) {
- return;
- }
-
- try {
- if (mCurrentCallbacks == null) {
- mCurrentCallbacks = new OverlayCallbacks();
- }
-
- mCurrentCallbacks.setClient(this);
- mOverlay.windowAttached(mWindowAttrs, mCurrentCallbacks, mServiceConnectionOptions);
-
- if (mIsResumed) {
- mOverlay.onResume();
- }
- else {
- mOverlay.onPause();
- }
- }
- catch (RemoteException ignored) {
-
- }
- }
-
- private boolean connectSafely(Context context, ServiceConnection conn, int flags) {
- try {
- return context.bindService(mServiceIntent, conn, flags | Context.BIND_AUTO_CREATE);
- }
- catch (SecurityException e) {
- Log.e("DrawerOverlayClient", "Unable to connect to overlay service");
- return false;
- }
- }
-
- static Intent getServiceIntent(Context context, String targetPackage) {
- Uri uri = Uri.parse("app://" + context.getPackageName() + ":" + Process.myUid()).buildUpon()
- .appendQueryParameter("v", Integer.toString(0))
- .build();
-
- return new Intent("com.android.launcher3.WINDOW_OVERLAY")
- .setPackage(targetPackage)
- .setData(uri);
- }
-
- public boolean isConnected() {
- return mOverlay != null;
- }
-
- private void notifyStatusChanged(int status) {
- if (mServiceStatus == status) {
- return;
- }
-
- mServiceStatus = status;
- mLauncherClientCallbacks.onServiceStateChanged((status & 1) != 0, true);
- }
-
- private void removeClient(boolean removeAppConnection) {
- mDestroyed = true;
- if (mIsServiceConnected) {
- mActivity.unbindService(mServiceConnection);
- mIsServiceConnected = false;
- }
- mActivity.unregisterReceiver(mUpdateReceiver);
-
- if (mCurrentCallbacks != null) {
- mCurrentCallbacks.clear();
- mCurrentCallbacks = null;
- }
-
- if (removeAppConnection && sApplicationConnection != null) {
- mActivity.getApplicationContext().unbindService(sApplicationConnection);
- sApplicationConnection = null;
- }
- }
-
- private void setWindowAttrs(WindowManager.LayoutParams windowAttrs) {
- mWindowAttrs = windowAttrs;
- if (mWindowAttrs != null) {
- applyWindowToken();
- }
- else if (mOverlay != null) {
- try {
- mOverlay.windowDetached(mActivity.isChangingConfigurations());
- }
- catch (RemoteException ignored) {
-
- }
- mOverlay = null;
- }
- }
-
- public void endMove() {
- if (!isConnected()) {
- return;
- }
-
- try {
- mOverlay.endScroll();
- }
- catch (RemoteException ignored) {
-
- }
- }
-
- public void hideOverlay(boolean animate) {
- if (mOverlay == null) {
- return;
- }
-
- try {
- mOverlay.closeOverlay(animate ? 1 : 0);
- }
- catch (RemoteException ignored) {
-
- }
- }
-
- public final void onAttachedToWindow() {
- if (mDestroyed) {
- return;
- }
-
- setWindowAttrs(mActivity.getWindow().getAttributes());
- }
-
- public void onDestroy() {
- removeClient(!mActivity.isChangingConfigurations());
- }
-
- public final void onDetachedFromWindow() {
- if (mDestroyed) {
- return;
- }
-
- setWindowAttrs(null);
- }
-
- public void onPause() {
- if (mDestroyed) {
- return;
- }
-
- mIsResumed = false;
- if (mOverlay != null && mWindowAttrs != null) {
- try {
- mOverlay.onPause();
- }
- catch (RemoteException ignored) {
-
- }
- }
- }
-
- public void onResume() {
- if (mDestroyed) {
- return;
- }
-
- reconnect();
- mIsResumed = true;
- if (mOverlay != null && mWindowAttrs != null) {
- try {
- mOverlay.onResume();
- }
- catch (RemoteException ignored) {
-
- }
- }
- }
-
- public void reconnect() {
- if (mDestroyed || mState != 0) {
- return;
- }
-
- if (sApplicationConnection != null &&
- !sApplicationConnection.packageName.equals(mServiceIntent.getPackage())) {
- mActivity.getApplicationContext().unbindService(sApplicationConnection);
- }
-
- if (sApplicationConnection == null) {
- sApplicationConnection = new AppServiceConnection(mServiceIntent.getPackage());
-
- if (!connectSafely(mActivity.getApplicationContext(), sApplicationConnection,
- Context.BIND_WAIVE_PRIORITY)) {
- sApplicationConnection = null;
- }
- }
-
- if (sApplicationConnection != null) {
- mState = 2;
-
- if (!connectSafely(mActivity, mServiceConnection, Context.BIND_ADJUST_WITH_ACTIVITY)) {
- mState = 0;
- } else {
- mIsServiceConnected = true;
- }
- }
-
- if (mState == 0) {
- mActivity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- notifyStatusChanged(0);
- }
- });
- }
- }
-
- public void startMove() {
- if (!isConnected()) {
- return;
- }
-
- try {
- mOverlay.startScroll();
- }
- catch (RemoteException ignored) {
-
- }
- }
-
- public void updateMove(float progressX) {
- if (!isConnected()) {
- return;
- }
-
- try {
- mOverlay.onScroll(progressX);
- }
- catch (RemoteException ignored) {
-
- }
- }
-
-
- final class AppServiceConnection implements ServiceConnection {
- public final String packageName;
-
- public AppServiceConnection(String pkg) {
- packageName = pkg;
- }
-
- public void onServiceConnected(ComponentName name, IBinder service) {
-
- }
-
- public void onServiceDisconnected(ComponentName name) {
- if (name.getPackageName().equals(packageName)) {
- sApplicationConnection = null;
- }
- }
- }
-
- private static class OverlayCallbacks extends ILauncherOverlayCallback.Stub
- implements Handler.Callback {
- private LauncherClient mClient;
- private final Handler mUIHandler;
- private Window mWindow;
- private boolean mWindowHidden;
- private WindowManager mWindowManager;
- private int mWindowShift;
-
- public OverlayCallbacks() {
- mWindowHidden = false;
- mUIHandler = new Handler(Looper.getMainLooper(), this);
- }
-
- private void hideActivityNonUI(boolean isHidden) {
- if (mWindowHidden != isHidden) {
- mWindowHidden = isHidden;
- }
- }
-
- public void clear() {
- mClient = null;
- mWindowManager = null;
- mWindow = null;
- }
-
- public boolean handleMessage(Message msg) {
- if (mClient == null) {
- return true;
- }
-
- switch (msg.what) {
- case 2:
- if ((mClient.mServiceStatus & 1) != 0) {
- mClient.mLauncherClientCallbacks.onOverlayScrollChanged((float) msg.obj);
- }
- return true;
- case 3:
- WindowManager.LayoutParams attrs = mWindow.getAttributes();
- if ((boolean) msg.obj) {
- attrs.x = mWindowShift;
- attrs.flags = attrs.flags |
- WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
- }
- mWindowManager.updateViewLayout(mWindow.getDecorView(), attrs);
- return true;
- case 4:
- mClient.notifyStatusChanged(msg.arg1);
- return true;
- default:
- return false;
- }
- }
-
- public void overlayScrollChanged(float progress) throws RemoteException {
- mUIHandler.removeMessages(2);
- Message.obtain(mUIHandler, 2, progress).sendToTarget();
-
- if (progress > 0) {
- hideActivityNonUI(false);
- }
- }
-
- public void overlayStatusChanged(int status) {
- Message.obtain(mUIHandler, 4, status, 0).sendToTarget();
- }
-
- public void setClient(LauncherClient client) {
- mClient = client;
- mWindowManager = client.mActivity.getWindowManager();
-
- Point p = new Point();
- mWindowManager.getDefaultDisplay().getRealSize(p);
- mWindowShift = Math.max(p.x, p.y);
-
- mWindow = client.mActivity.getWindow();
- }
- }
-
- private class OverlayServiceConnection implements ServiceConnection {
- public void onServiceConnected(ComponentName name, IBinder service) {
- mState = 1;
- mOverlay = ILauncherOverlay.Stub.asInterface(service);
- if (mWindowAttrs != null) {
- applyWindowToken();
- }
- }
-
- public void onServiceDisconnected(ComponentName name) {
- mState = 0;
- mOverlay = null;
- notifyStatusChanged(0);
- }
- }
-
-
-} \ No newline at end of file
diff --git a/src/com/google/android/libraries/launcherclient/LauncherClientCallbacks.java b/src/com/google/android/libraries/launcherclient/LauncherClientCallbacks.java
deleted file mode 100644
index e21440bfa..000000000
--- a/src/com/google/android/libraries/launcherclient/LauncherClientCallbacks.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.google.android.libraries.launcherclient;
-
-public interface LauncherClientCallbacks {
- void onOverlayScrollChanged(float progress);
-
- void onServiceStateChanged(boolean overlayAttached, boolean hotwordActive);
-}
diff --git a/src/com/google/android/libraries/launcherclient/LauncherClientCallbacksAdapter.java b/src/com/google/android/libraries/launcherclient/LauncherClientCallbacksAdapter.java
deleted file mode 100644
index 6fbcb64be..000000000
--- a/src/com/google/android/libraries/launcherclient/LauncherClientCallbacksAdapter.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.google.android.libraries.launcherclient;
-
-public class LauncherClientCallbacksAdapter implements LauncherClientCallbacks {
- @Override
- public void onOverlayScrollChanged(float progress) {
-
- }
-
- @Override
- public void onServiceStateChanged(boolean overlayAttached, boolean hotwordActive) {
-
- }
-}