Merge "Remove reflection for a couple of methods" into ub-launcher3-dorval
This commit is contained in:
commit
46b3a13528
2 files changed
+3
-29
No files matched your search
@@ -16,17 +16,12 @@
|
|||||||
|
|
||||||
package com.android.launcher3.compat;
|
package com.android.launcher3.compat;
|
||||||
|
|
||||||
import android.appwidget.AppWidgetManager;
|
|
||||||
import android.appwidget.AppWidgetProviderInfo;
|
import android.appwidget.AppWidgetProviderInfo;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.UserHandle;
|
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.android.launcher3.util.PackageUserKey;
|
import com.android.launcher3.util.PackageUserKey;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
class AppWidgetManagerCompatVO extends AppWidgetManagerCompatVL {
|
class AppWidgetManagerCompatVO extends AppWidgetManagerCompatVL {
|
||||||
@@ -40,14 +35,7 @@ class AppWidgetManagerCompatVO extends AppWidgetManagerCompatVL {
|
|||||||
if (packageUser == null) {
|
if (packageUser == null) {
|
||||||
return super.getAllProviders(null);
|
return super.getAllProviders(null);
|
||||||
}
|
}
|
||||||
// TODO: don't use reflection once API and sdk are ready.
|
return mAppWidgetManager.getInstalledProvidersForPackage(packageUser.mPackageName,
|
||||||
try {
|
packageUser.mUser);
|
||||||
return (List<AppWidgetProviderInfo>) AppWidgetManager.class.getMethod(
|
|
||||||
"getInstalledProvidersForPackage", String.class, UserHandle.class)
|
|
||||||
.invoke(mAppWidgetManager, packageUser.mPackageName, packageUser.mUser);
|
|
||||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
|
||||||
Log.e("AppWidgetManagerCompat", "Failed to call new API", e);
|
|
||||||
}
|
|
||||||
return super.getAllProviders(packageUser);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,6 @@ import android.graphics.drawable.Drawable;
|
|||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.launcher3.Launcher;
|
import com.android.launcher3.Launcher;
|
||||||
@@ -66,20 +65,7 @@ public class NotificationInfo implements View.OnClickListener {
|
|||||||
title = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
|
title = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
|
||||||
text = notification.extras.getCharSequence(Notification.EXTRA_TEXT);
|
text = notification.extras.getCharSequence(Notification.EXTRA_TEXT);
|
||||||
|
|
||||||
// TODO(b/36855196): use getBadgeIconType() without reflection
|
mBadgeIcon = notification.getBadgeIconType();
|
||||||
int badgeIcon = Notification.BADGE_ICON_NONE;
|
|
||||||
try {
|
|
||||||
badgeIcon = (int) Notification.class.getMethod("getBadgeIconType").invoke(notification);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.w("NotificationInfo", "getBadgeIconType() failed", e);
|
|
||||||
// Try the old name, getBadgeIcon(), instead.
|
|
||||||
try {
|
|
||||||
badgeIcon = (int) Notification.class.getMethod("getBadgeIcon").invoke(notification);
|
|
||||||
} catch (Exception e1) {
|
|
||||||
Log.e("NotificationInfo", "getBadgeIcon() failed", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mBadgeIcon = badgeIcon;
|
|
||||||
// Load the icon. Since it is backed by ashmem, we won't copy the entire bitmap
|
// Load the icon. Since it is backed by ashmem, we won't copy the entire bitmap
|
||||||
// into our process as long as we don't touch it and it exists in systemui.
|
// into our process as long as we don't touch it and it exists in systemui.
|
||||||
Icon icon = mBadgeIcon == Notification.BADGE_ICON_SMALL ? null : notification.getLargeIcon();
|
Icon icon = mBadgeIcon == Notification.BADGE_ICON_SMALL ? null : notification.getLargeIcon();
|
||||||
|
|||||||
Reference in new issue
Block a user