Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f52b272 authored by jackmu95's avatar jackmu95 Committed by Gerrit Code Review
Browse files

framework: Custom lock screen background [1/2]

Patch Set 1:    * port the custom lock screen feature from
                  ics (http://review.cyanogenmod.org/#/c/16915)

                * thanks to Danny Baumann, who reworked the
                  framework part to work after Jelly Bean 4.2
                  lockscreen changes

Patch Set 2-3:  * remove obsolete files

Patch Set 4-7:  * revert XML changes

Patch Set 8,9:  * rebased

Patch Set 10:   * fix minor code style

Change-Id: I800506a9f9e001f659ee29b8b2dbe3464e5198f9
parent 750229c0
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -33,10 +33,14 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.UserInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcelable;
@@ -233,6 +237,7 @@ public class KeyguardHostView extends KeyguardViewBase {
            setSystemUiVisibility(getSystemUiVisibility() | View.STATUS_BAR_DISABLE_BACK);
        }

        updateBackground();
        addDefaultWidgets();

        addWidgetsFromSettings();
@@ -267,6 +272,32 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
    };

    private void updateBackground() {
        String background = Settings.System.getStringForUser(getContext().getContentResolver(),
                Settings.System.LOCKSCREEN_BACKGROUND, UserHandle.USER_CURRENT);

        if (background == null) {
            return;
        }

        if (!background.isEmpty()) {
            try {
                setBackgroundColor(Integer.parseInt(background));
            } catch(NumberFormatException e) {
                Log.e(TAG, "Invalid background color " + background);
            }
        } else {
            try {
                Context settingsContext = getContext().createPackageContext("com.android.settings", 0);
                String wallpaperFile = settingsContext.getFilesDir() + "/lockwallpaper";
                Bitmap backgroundBitmap = BitmapFactory.decodeFile(wallpaperFile);
                setBackgroundDrawable(new BitmapDrawable(backgroundBitmap));
            } catch (NameNotFoundException e) {
            // Do nothing here
            }
        }
    }

    private int getDisabledFeatures(DevicePolicyManager dpm) {
        int disabledFeatures = DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE;
        if (dpm != null) {