Launcher change corresponding to platform change.
Here is platform change : ag/540450 Added try catch block so the APK works on older builds as well. Bug: 17390424 Change-Id: Id5731c65f036e35b71aa74ce6d8ae031107ed60b
This commit is contained in:
@@ -121,12 +121,15 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
||||
} else {
|
||||
badgeLocation.offset(bitmap.getWidth() - badgeSize - badgeMargin, top);
|
||||
}
|
||||
|
||||
UserManager userManager = (UserManager) mContext.getSystemService(
|
||||
Context.USER_SERVICE);
|
||||
|
||||
Drawable drawable = userManager.getBadgedDrawableForUser(new BitmapDrawable(res, bitmap),
|
||||
info.getProfile(), badgeLocation, 0);
|
||||
Drawable drawable = null;
|
||||
// STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
|
||||
// This hack is just to prevent crash in older builds.
|
||||
try {
|
||||
drawable = mPm.getUserBadgedDrawableForDensity(new BitmapDrawable(res, bitmap),
|
||||
info.getProfile(), badgeLocation, 0);
|
||||
} catch (Exception e) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return ((BitmapDrawable) drawable).getBitmap();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
mResumed = false;
|
||||
mBound = false;
|
||||
|
||||
mInstaller.addSessionCallback(mCallback);
|
||||
mInstaller.registerSessionCallback(mCallback);
|
||||
// On start, send updates for all active sessions
|
||||
for (SessionInfo info : mInstaller.getAllSessions()) {
|
||||
mPendingReplays.append(info.getSessionId(), info);
|
||||
@@ -72,7 +72,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mInstaller.removeSessionCallback(mCallback);
|
||||
mInstaller.unregisterSessionCallback(mCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,10 +168,9 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpened(int sessionId) { }
|
||||
public void onActiveChanged(int sessionId, boolean active) { }
|
||||
|
||||
@Override
|
||||
public void onClosed(int sessionId) { }
|
||||
|
||||
public void onBadgingChanged(int sessionId) { }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
@@ -27,9 +28,11 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class UserManagerCompatVL extends UserManagerCompatV17 {
|
||||
private final PackageManager mPm;
|
||||
|
||||
UserManagerCompatVL(Context context) {
|
||||
super(context);
|
||||
mPm = context.getPackageManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +51,13 @@ public class UserManagerCompatVL extends UserManagerCompatV17 {
|
||||
|
||||
@Override
|
||||
public Drawable getBadgedDrawableForUser(Drawable unbadged, UserHandleCompat user) {
|
||||
return mUserManager.getBadgedIconForUser(unbadged, user.getUser());
|
||||
// STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
|
||||
// This hack is just to prevent crash in older builds.
|
||||
try {
|
||||
return mPm.getUserBadgedIcon(unbadged, user.getUser());
|
||||
} catch (Exception e) {
|
||||
return unbadged;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +65,13 @@ public class UserManagerCompatVL extends UserManagerCompatV17 {
|
||||
if (user == null) {
|
||||
return label;
|
||||
}
|
||||
return mUserManager.getBadgedLabelForUser(label, user.getUser());
|
||||
// STOPSHIP(mokani): Remove catch block once dogfood build is bigger than LRW70.
|
||||
// This hack is just to prevent crash in older builds.
|
||||
try {
|
||||
return mPm.getUserBadgedLabel(label, user.getUser());
|
||||
} catch (Exception e) {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user