Merge "Fix issue #5317970: Removing active wallpaper from manifest crashes phone"
This commit is contained in:
committed by
Android (Google) Code Review
commit
b59d270df7
@ -120,7 +120,8 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
notifyCallbacksLocked();
|
notifyCallbacksLocked();
|
||||||
if (mWallpaperComponent == null || mImageWallpaperPending) {
|
if (mWallpaperComponent == null || mImageWallpaperPending) {
|
||||||
mImageWallpaperPending = false;
|
mImageWallpaperPending = false;
|
||||||
bindWallpaperComponentLocked(mImageWallpaperComponent, true);
|
bindWallpaperComponentLocked(mImageWallpaperComponent,
|
||||||
|
true, false);
|
||||||
saveSettingsLocked();
|
saveSettingsLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +202,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
if (!mWallpaperUpdating && (mLastDiedTime+MIN_WALLPAPER_CRASH_TIME)
|
if (!mWallpaperUpdating && (mLastDiedTime+MIN_WALLPAPER_CRASH_TIME)
|
||||||
> SystemClock.uptimeMillis()) {
|
> SystemClock.uptimeMillis()) {
|
||||||
Slog.w(TAG, "Reverting to built-in wallpaper!");
|
Slog.w(TAG, "Reverting to built-in wallpaper!");
|
||||||
bindWallpaperComponentLocked(null, true);
|
clearWallpaperLocked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,10 +231,24 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
mWallpaperUpdating = false;
|
mWallpaperUpdating = false;
|
||||||
ComponentName comp = mWallpaperComponent;
|
ComponentName comp = mWallpaperComponent;
|
||||||
clearWallpaperComponentLocked();
|
clearWallpaperComponentLocked();
|
||||||
bindWallpaperComponentLocked(comp, false);
|
if (!bindWallpaperComponentLocked(comp, false, false)) {
|
||||||
|
Slog.w(TAG, "Wallpaper no longer available; reverting to default");
|
||||||
|
clearWallpaperLocked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPackageModified(String packageName) {
|
||||||
|
synchronized (mLock) {
|
||||||
|
if (mWallpaperComponent == null ||
|
||||||
|
!mWallpaperComponent.getPackageName().equals(packageName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doPackagesChanged(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPackageUpdateStarted(String packageName, int uid) {
|
public void onPackageUpdateStarted(String packageName, int uid) {
|
||||||
@ -265,7 +280,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
changed = true;
|
changed = true;
|
||||||
if (doit) {
|
if (doit) {
|
||||||
Slog.w(TAG, "Wallpaper uninstalled, removing: " + mWallpaperComponent);
|
Slog.w(TAG, "Wallpaper uninstalled, removing: " + mWallpaperComponent);
|
||||||
clearWallpaperLocked();
|
clearWallpaperLocked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +298,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
mWallpaperComponent, 0);
|
mWallpaperComponent, 0);
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
Slog.w(TAG, "Wallpaper component gone, removing: " + mWallpaperComponent);
|
Slog.w(TAG, "Wallpaper component gone, removing: " + mWallpaperComponent);
|
||||||
clearWallpaperLocked();
|
clearWallpaperLocked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mNextWallpaperComponent != null
|
if (mNextWallpaperComponent != null
|
||||||
@ -321,45 +336,51 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
public void systemReady() {
|
public void systemReady() {
|
||||||
if (DEBUG) Slog.v(TAG, "systemReady");
|
if (DEBUG) Slog.v(TAG, "systemReady");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
|
RuntimeException e = null;
|
||||||
try {
|
try {
|
||||||
bindWallpaperComponentLocked(mNextWallpaperComponent, false);
|
if (bindWallpaperComponentLocked(mNextWallpaperComponent, false, false)) {
|
||||||
} catch (RuntimeException e) {
|
return;
|
||||||
|
}
|
||||||
|
} catch (RuntimeException e1) {
|
||||||
|
e = e1;
|
||||||
|
}
|
||||||
Slog.w(TAG, "Failure starting previous wallpaper", e);
|
Slog.w(TAG, "Failure starting previous wallpaper", e);
|
||||||
try {
|
clearWallpaperLocked(false);
|
||||||
bindWallpaperComponentLocked(null, false);
|
|
||||||
} catch (RuntimeException e2) {
|
|
||||||
Slog.w(TAG, "Failure starting default wallpaper", e2);
|
|
||||||
clearWallpaperComponentLocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearWallpaper() {
|
public void clearWallpaper() {
|
||||||
if (DEBUG) Slog.v(TAG, "clearWallpaper");
|
if (DEBUG) Slog.v(TAG, "clearWallpaper");
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
clearWallpaperLocked();
|
clearWallpaperLocked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearWallpaperLocked() {
|
public void clearWallpaperLocked(boolean defaultFailed) {
|
||||||
File f = WALLPAPER_FILE;
|
File f = WALLPAPER_FILE;
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
f.delete();
|
f.delete();
|
||||||
}
|
}
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
RuntimeException e = null;
|
||||||
try {
|
try {
|
||||||
mImageWallpaperPending = false;
|
mImageWallpaperPending = false;
|
||||||
bindWallpaperComponentLocked(null, false);
|
if (bindWallpaperComponentLocked(defaultFailed
|
||||||
} catch (IllegalArgumentException e) {
|
? mImageWallpaperComponent : null, true, false)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e1) {
|
||||||
|
e = e1;
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
|
||||||
// This can happen if the default wallpaper component doesn't
|
// This can happen if the default wallpaper component doesn't
|
||||||
// exist. This should be a system configuration problem, but
|
// exist. This should be a system configuration problem, but
|
||||||
// let's not let it crash the system and just live with no
|
// let's not let it crash the system and just live with no
|
||||||
// wallpaper.
|
// wallpaper.
|
||||||
Slog.e(TAG, "Default wallpaper component not found!", e);
|
Slog.e(TAG, "Default wallpaper component not found!", e);
|
||||||
} finally {
|
clearWallpaperComponentLocked();
|
||||||
Binder.restoreCallingIdentity(ident);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDimensionHints(int width, int height) throws RemoteException {
|
public void setDimensionHints(int width, int height) throws RemoteException {
|
||||||
@ -469,14 +490,14 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
try {
|
try {
|
||||||
mImageWallpaperPending = false;
|
mImageWallpaperPending = false;
|
||||||
bindWallpaperComponentLocked(name, false);
|
bindWallpaperComponentLocked(name, false, true);
|
||||||
} finally {
|
} finally {
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bindWallpaperComponentLocked(ComponentName componentName, boolean force) {
|
boolean bindWallpaperComponentLocked(ComponentName componentName, boolean force, boolean fromUser) {
|
||||||
if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
|
if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
|
||||||
|
|
||||||
// Has the component changed?
|
// Has the component changed?
|
||||||
@ -486,12 +507,12 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
if (componentName == null) {
|
if (componentName == null) {
|
||||||
if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: still using default");
|
if (DEBUG) Slog.v(TAG, "bindWallpaperComponentLocked: still using default");
|
||||||
// Still using default wallpaper.
|
// Still using default wallpaper.
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (mWallpaperComponent.equals(componentName)) {
|
} else if (mWallpaperComponent.equals(componentName)) {
|
||||||
// Changing to same wallpaper.
|
// Changing to same wallpaper.
|
||||||
if (DEBUG) Slog.v(TAG, "same wallpaper");
|
if (DEBUG) Slog.v(TAG, "same wallpaper");
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,9 +537,14 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName,
|
ServiceInfo si = mContext.getPackageManager().getServiceInfo(componentName,
|
||||||
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
|
PackageManager.GET_META_DATA | PackageManager.GET_PERMISSIONS);
|
||||||
if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
|
if (!android.Manifest.permission.BIND_WALLPAPER.equals(si.permission)) {
|
||||||
throw new SecurityException("Selected service does not require "
|
String msg = "Selected service does not require "
|
||||||
+ android.Manifest.permission.BIND_WALLPAPER
|
+ android.Manifest.permission.BIND_WALLPAPER
|
||||||
+ ": " + componentName);
|
+ ": " + componentName;
|
||||||
|
if (fromUser) {
|
||||||
|
throw new SecurityException(msg);
|
||||||
|
}
|
||||||
|
Slog.w(TAG, msg);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
WallpaperInfo wi = null;
|
WallpaperInfo wi = null;
|
||||||
@ -535,16 +561,29 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
try {
|
try {
|
||||||
wi = new WallpaperInfo(mContext, ris.get(i));
|
wi = new WallpaperInfo(mContext, ris.get(i));
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
|
if (fromUser) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
|
}
|
||||||
|
Slog.w(TAG, e);
|
||||||
|
return false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
if (fromUser) {
|
||||||
throw new IllegalArgumentException(e);
|
throw new IllegalArgumentException(e);
|
||||||
}
|
}
|
||||||
|
Slog.w(TAG, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wi == null) {
|
if (wi == null) {
|
||||||
throw new SecurityException("Selected service is not a wallpaper: "
|
String msg = "Selected service is not a wallpaper: "
|
||||||
+ componentName);
|
+ componentName;
|
||||||
|
if (fromUser) {
|
||||||
|
throw new SecurityException(msg);
|
||||||
|
}
|
||||||
|
Slog.w(TAG, msg);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,8 +600,13 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
0));
|
0));
|
||||||
if (!mContext.bindService(intent, newConn,
|
if (!mContext.bindService(intent, newConn,
|
||||||
Context.BIND_AUTO_CREATE)) {
|
Context.BIND_AUTO_CREATE)) {
|
||||||
throw new IllegalArgumentException("Unable to bind service: "
|
String msg = "Unable to bind service: "
|
||||||
+ componentName);
|
+ componentName;
|
||||||
|
if (fromUser) {
|
||||||
|
throw new IllegalArgumentException(msg);
|
||||||
|
}
|
||||||
|
Slog.w(TAG, msg);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearWallpaperComponentLocked();
|
clearWallpaperComponentLocked();
|
||||||
@ -577,8 +621,14 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
throw new IllegalArgumentException("Unknown component " + componentName);
|
String msg = "Unknown component " + componentName;
|
||||||
|
if (fromUser) {
|
||||||
|
throw new IllegalArgumentException(msg);
|
||||||
}
|
}
|
||||||
|
Slog.w(TAG, msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearWallpaperComponentLocked() {
|
void clearWallpaperComponentLocked() {
|
||||||
@ -611,7 +661,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.w(TAG, "Failed attaching wallpaper; clearing", e);
|
Slog.w(TAG, "Failed attaching wallpaper; clearing", e);
|
||||||
if (!mWallpaperUpdating) {
|
if (!mWallpaperUpdating) {
|
||||||
bindWallpaperComponentLocked(null, false);
|
bindWallpaperComponentLocked(null, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -765,13 +815,11 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
loadSettingsLocked();
|
loadSettingsLocked();
|
||||||
if (mNextWallpaperComponent != null &&
|
if (mNextWallpaperComponent != null &&
|
||||||
!mNextWallpaperComponent.equals(mImageWallpaperComponent)) {
|
!mNextWallpaperComponent.equals(mImageWallpaperComponent)) {
|
||||||
try {
|
if (!bindWallpaperComponentLocked(mNextWallpaperComponent, false, false)) {
|
||||||
bindWallpaperComponentLocked(mNextWallpaperComponent, false);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
// No such live wallpaper or other failure; fall back to the default
|
// No such live wallpaper or other failure; fall back to the default
|
||||||
// live wallpaper (since the profile being restored indicated that the
|
// live wallpaper (since the profile being restored indicated that the
|
||||||
// user had selected a live rather than static one).
|
// user had selected a live rather than static one).
|
||||||
bindWallpaperComponentLocked(null, false);
|
bindWallpaperComponentLocked(null, false, false);
|
||||||
}
|
}
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
@ -786,7 +834,7 @@ class WallpaperManagerService extends IWallpaperManager.Stub {
|
|||||||
}
|
}
|
||||||
if (DEBUG) Slog.v(TAG, "settingsRestored: success=" + success);
|
if (DEBUG) Slog.v(TAG, "settingsRestored: success=" + success);
|
||||||
if (success) {
|
if (success) {
|
||||||
bindWallpaperComponentLocked(null, false);
|
bindWallpaperComponentLocked(null, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user