Merge branch 'dev/11/fp3/security-aosp-rvc-release' into int/11/fp3

* dev/11/fp3/security-aosp-rvc-release:
  Fix permission bypass in legacy shortcut

Change-Id: Ic3c41cb8a61247759f312678de92f2354feb9661
diff --git a/Android.mk b/Android.mk
index 7805b32..e2f2847 100644
--- a/Android.mk
+++ b/Android.mk
@@ -234,7 +234,7 @@
 LOCAL_PACKAGE_NAME := Launcher3QuickStepGo
 LOCAL_PRIVILEGED_MODULE := true
 LOCAL_SYSTEM_EXT_MODULE := true
-LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep
+LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 Launcher3QuickStep Launcher3Go
 LOCAL_REQUIRED_MODULES := privapp_whitelist_com.android.launcher3
 
 LOCAL_FULL_LIBS_MANIFEST_FILES := \
diff --git a/quickstep/AndroidManifest.xml b/quickstep/AndroidManifest.xml
index e49f2ec..a6c3015 100644
--- a/quickstep/AndroidManifest.xml
+++ b/quickstep/AndroidManifest.xml
@@ -30,6 +30,7 @@
     <uses-permission android:name="android.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS" />
     <uses-permission android:name="android.permission.VIBRATE" />
     <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
+    <uses-permission android:name="android.permission.ALLOW_SLIPPERY_TOUCHES"/>
     <uses-permission android:name="${packageName}.permission.HOTSEAT_EDU" />
 
     <application
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java
index cd4be18..ac20648 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java
@@ -235,7 +235,7 @@
                     @Override
                     public void onStateTransitionComplete(LauncherState toState) {
                         // Are we going from Recents to Workspace?
-                        if (toState == LauncherState.NORMAL) {
+                        if (toState == LauncherState.NORMAL || toState == LauncherState.ALL_APPS) {
                             exitRunnable.run();
                             notifyRecentsOfOrientation(deviceState);
                             stateManager.removeStateListener(this);
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
index 7a7cbb4..7e8f2c8 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/StatusBarTouchController.java
@@ -20,6 +20,7 @@
 import static android.view.MotionEvent.ACTION_UP;
 import static android.view.MotionEvent.ACTION_CANCEL;
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SWIPE_DOWN_WORKSPACE_NOTISHADE_OPEN;
+import static android.view.WindowManager.LayoutParams.FLAG_SLIPPERY;
 
 import android.graphics.PointF;
 import android.util.SparseArray;
@@ -49,17 +50,6 @@
 
     private static final String TAG = "StatusBarController";
 
-    /**
-     * Window flag: Enable touches to slide out of a window into neighboring
-     * windows in mid-gesture instead of being captured for the duration of
-     * the gesture.
-     *
-     * This flag changes the behavior of touch focus for this window only.
-     * Touches can slide out of the window but they cannot necessarily slide
-     * back in (unless the other window with touch focus permits it).
-     */
-    private static final int FLAG_SLIPPERY = 0x20000000;
-
     private final Launcher mLauncher;
     private final SystemUiProxy mSystemUiProxy;
     private final float mTouchSlop;
@@ -145,6 +135,15 @@
         return true;
     }
 
+    /**
+     * FLAG_SLIPPERY enables touches to slide out of a window into neighboring
+     * windows in mid-gesture instead of being captured for the duration of
+     * the gesture.
+     *
+     * This flag changes the behavior of touch focus for this window only.
+     * Touches can slide out of the window but they cannot necessarily slide
+     * back in (unless the other window with touch focus permits it).
+     */
     private void setWindowSlippery(boolean enable) {
         Window w = mLauncher.getWindow();
         WindowManager.LayoutParams wlp = w.getAttributes();
@@ -170,4 +169,4 @@
         }
         return SystemUiProxy.INSTANCE.get(mLauncher).isActive();
     }
-}
\ No newline at end of file
+}
diff --git a/res/values/config.xml b/res/values/config.xml
index 75fcc90..a3b2866 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -89,7 +89,7 @@
     <integer name="config_removeNotificationViewDuration">300</integer>
 
     <!-- Default packages -->
-    <string name="wallpaper_picker_package" translatable="false"></string>
+    <string name="wallpaper_picker_package" translatable="false">com.android.wallpaperpicker</string>
     <string name="calendar_component_name" translatable="false"></string>
     <string name="clock_component_name" translatable="false"></string>
 
diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml
index 1c99dfc..5462a97 100644
--- a/res/xml/device_profiles.xml
+++ b/res/xml/device_profiles.xml
@@ -87,14 +87,6 @@
             launcher:iconTextSize="13.0"
             launcher:canBeDefault="true" />
 
-        <display-option
-            launcher:name="Nexus 5"
-            launcher:minWidthDps="335"
-            launcher:minHeightDps="567"
-            launcher:iconImageSize="54"
-            launcher:iconTextSize="13.0"
-            launcher:canBeDefault="true" />
-
     </grid-option>
 
     <grid-option
@@ -108,6 +100,14 @@
         launcher:defaultLayoutId="@xml/default_workspace_5x5" >
 
         <display-option
+            launcher:name="Nexus 5"
+            launcher:minWidthDps="335"
+            launcher:minHeightDps="567"
+            launcher:iconImageSize="54"
+            launcher:iconTextSize="13.0"
+            launcher:canBeDefault="true" />
+
+        <display-option
             launcher:name="Large Phone"
             launcher:minWidthDps="406"
             launcher:minHeightDps="694"
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index ae89ded..6053b802 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -433,6 +433,10 @@
         // Listen for broadcasts
         registerReceiver(mScreenOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
 
+        IntentFilter pkgAddIntentFilter = new  IntentFilter(Intent.ACTION_PACKAGE_ADDED);
+        pkgAddIntentFilter.addDataScheme("package");
+        registerReceiver(mPkgAddReceiver, pkgAddIntentFilter);
+
         getSystemUiController().updateUiState(SystemUiController.UI_STATE_BASE_WINDOW,
                 Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText));
 
@@ -1330,7 +1334,26 @@
         }
     };
 
-    private void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
+    private final BroadcastReceiver mPkgAddReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+                 Log.i(TAG,"---receive package_added, App drawer visible:" + mAppsView.getVisibility());
+                 LauncherAppState app = LauncherAppState.getInstanceNoCreate();
+
+                 if ((app != null) && (mAppsView.getVisibility()!=View.VISIBLE)) {
+                     Log.i(TAG,"---receive package_added,reload launcher");
+
+                     // Reset AllApps to its initial state only if we are not in the middle of processing a multi-step drop
+                     if (mPendingRequestArgs == null) {
+                         mStateManager.goToState(NORMAL);
+                     }
+
+                     app.getModel().forceReload();
+                 }
+        }
+    };
+
+    public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
         mWorkspace.updateNotificationDots(updatedDots);
         mAppsView.getAppsStore().updateNotificationDots(updatedDots);
     }
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 19a314f..3d63d3c 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -537,9 +537,10 @@
             }
             if (loader == null) {
                 final Partner partner = Partner.get(getContext().getPackageManager());
-                if (partner != null && partner.hasDefaultLayout()) {
+                if (partner != null && partner.hasDefaultLayout(getContext())) {
                     final Resources partnerRes = partner.getResources();
-                    int workspaceResId = partnerRes.getIdentifier(Partner.RES_DEFAULT_LAYOUT,
+                    int workspaceResId = partnerRes.getIdentifier(
+                            partner.getDefaltLayoutName(getContext()),
                             "xml", partner.getPackageName());
                     if (workspaceResId != 0) {
                         loader = new DefaultLayoutParser(getContext(), widgetHost,
diff --git a/src/com/android/launcher3/Partner.java b/src/com/android/launcher3/Partner.java
index d79f62d..f7ad478 100644
--- a/src/com/android/launcher3/Partner.java
+++ b/src/com/android/launcher3/Partner.java
@@ -18,6 +18,7 @@
 
 import static com.android.launcher3.util.PackageManagerHelper.findSystemApk;
 
+import android.content.Context;
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.util.DisplayMetrics;
@@ -43,6 +44,9 @@
     public static final String RES_WALLPAPERS = "partner_wallpapers";
     public static final String RES_DEFAULT_LAYOUT = "partner_default_layout";
 
+    private static final String RES_DEFAULT_LAYOUT_ORANGE_SPAIN =
+            "partner_default_layout_orange_spain";
+
     public static final String RES_DEFAULT_WALLPAPER_HIDDEN = "default_wallpapper_hidden";
     public static final String RES_SYSTEM_WALLPAPER_DIR = "system_wallpaper_directory";
 
@@ -77,9 +81,37 @@
         return mResources;
     }
 
-    public boolean hasDefaultLayout() {
-        int defaultLayout = getResources().getIdentifier(Partner.RES_DEFAULT_LAYOUT,
-                "xml", getPackageName());
+    private int getLayoutResId(String layoutResName) {
+        return getResources().getIdentifier(layoutResName, "xml", getPackageName());
+    }
+
+    /*
+     * Get customized default layout resource name.
+     *
+     * If there is a resource for dedicate operator, use it, otherwise use default.
+     */
+    public String getDefaltLayoutName(Context ctx) {
+        final String mccmnc = Utilities.getMccMnc(ctx);
+        final String customResName;
+        if ("21403".equals(mccmnc)) {
+            customResName = RES_DEFAULT_LAYOUT_ORANGE_SPAIN;
+        } else {
+            // Default: No custom layout for current operator.
+            return RES_DEFAULT_LAYOUT;
+        }
+
+        if (getLayoutResId(customResName) == 0) {
+            Log.e(TAG, "Custom layout " + customResName + " for mccmnc=" + mccmnc
+                + " not found. Falling back to default.");
+            return RES_DEFAULT_LAYOUT;
+        }
+
+        Log.d(TAG, "getCustomDefaultLayout customResName=" + customResName);
+        return customResName;
+    }
+
+    public boolean hasDefaultLayout(Context ctx) {
+        int defaultLayout = getLayoutResId(getDefaltLayoutName(ctx));
         return defaultLayout != 0;
     }
 
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 292a808..bd1a58c 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -51,6 +51,7 @@
 import android.os.PowerManager;
 import android.os.TransactionTooLargeException;
 import android.provider.Settings;
+import android.telephony.TelephonyManager;
 import android.text.Spannable;
 import android.text.SpannableString;
 import android.text.TextUtils;
@@ -691,4 +692,15 @@
             return mSize;
         }
     }
+
+    public static String getMccMnc(Context context) {
+        if (context == null) {
+            Log.e(TAG, "getMccMnc, failed to get operator because of null context.");
+            return "";
+        }
+
+        TelephonyManager tm =
+                (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
+        return tm.getSimOperator();
+    }
 }