summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-05-11 14:30:53 -0700
committerEd Carrigan <cretin45@gmail.com>2016-05-11 14:58:51 -0700
commitede95367cbb766b57b0a4c5bc224a0c0f9901ac6 (patch)
tree64188924ce959ad764965abd1a58b2f99c37929a /src/com
parentaac0d8f5db77d5ab81e7073bb37ea554f21ab408 (diff)
downloadandroid_packages_apps_Trebuchet-ede95367cbb766b57b0a4c5bc224a0c0f9901ac6.tar.gz
android_packages_apps_Trebuchet-ede95367cbb766b57b0a4c5bc224a0c0f9901ac6.tar.bz2
android_packages_apps_Trebuchet-ede95367cbb766b57b0a4c5bc224a0c0f9901ac6.zip
Trebuchet: Make workspace layout configurable by prebundled mcc
Ported patch: http://review.cyanogenmod.org/#/c/111725/ Issue-id: PAELLA-236 Change-Id: I1d02cfc4f1e7e7fc5b1aaf326072b0ffe8966c05 (cherry picked from commit fe7faac0dba67667ae671e6cf59c9706d45e579b)
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/LauncherProvider.java49
1 files changed, 48 insertions, 1 deletions
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 088863ad7..caa05975f 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -30,7 +30,10 @@ import android.content.Context;
import android.content.Intent;
import android.content.OperationApplicationException;
import android.content.SharedPreferences;
+import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.AssetManager;
+import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.SQLException;
@@ -44,8 +47,10 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Process;
import android.os.StrictMode;
+import android.os.SystemProperties;
import android.os.UserManager;
import android.text.TextUtils;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.util.SparseArray;
@@ -79,6 +84,8 @@ public class LauncherProvider extends ContentProvider {
private static final String RESTRICTION_PACKAGE_NAME = "workspace.configuration.package.name";
+ private static final String MCC_PROP_NAME = "ro.prebundled.mcc";
+
@Thunk LauncherProviderChangeListener mListener;
@Thunk DatabaseHelper mOpenHelper;
@@ -442,10 +449,50 @@ public class LauncherProvider extends ContentProvider {
}
private DefaultLayoutParser getDefaultLayoutParser() {
+ String mcc = SystemProperties.get(MCC_PROP_NAME);
+ Resources customResources = null;
+ if (!TextUtils.isEmpty(mcc)) {
+ if (LOGD) Log.d(TAG, "mcc: " + mcc);
+
+ Configuration tempConfiguration = new Configuration(getContext().getResources().
+ getConfiguration());
+ boolean shouldUseTempConfig = false;
+
+ try {
+ tempConfiguration.mcc = Integer.parseInt(mcc);
+ shouldUseTempConfig = true;
+ } catch (NumberFormatException e) {
+ // not able to parse mcc, catch exception and exit out of this logic
+ Log.e(TAG, "Unable to parse mcc", e);
+ }
+
+ if (shouldUseTempConfig) {
+ String publicSrcDir = null;
+ try {
+ String packageName = getContext().getPackageName();
+ publicSrcDir = getContext().getPackageManager().
+ getApplicationInfo(packageName, 0).publicSourceDir;
+ } catch (PackageManager.NameNotFoundException e) {
+ Log.e(TAG, "Failed getting source dir", e);
+ }
+
+ AssetManager assetManager = new AssetManager();
+ if (!TextUtils.isEmpty(publicSrcDir)) {
+ assetManager.addAssetPath(publicSrcDir);
+ }
+ customResources = new Resources(assetManager, new DisplayMetrics(),
+ tempConfiguration);
+ }
+ }
+
int defaultLayout = LauncherAppState.getInstance()
.getInvariantDeviceProfile().defaultLayoutId;
+
return new DefaultLayoutParser(getContext(), mOpenHelper.mAppWidgetHost,
- mOpenHelper, getContext().getResources(), defaultLayout);
+ mOpenHelper, customResources != null ?
+ customResources :
+ getContext().getResources(),
+ defaultLayout);
}
public void migrateLauncher2Shortcuts() {