Fix a crash where the deletion helper crashes when app sizes load.
This was caused by a change I made to the extraInfo on the app. The extra info used to be a long which was the last usage time. I changed it to a UsageStatsState and missed this usage of it. The attempted cast to long caused a crash. Bug: 28885317 Change-Id: Ie0d6bcea5d0afccd2762acd19d628c742c7e3db9
This commit is contained in:
@@ -22,6 +22,7 @@ import android.text.format.Formatter;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import com.android.settings.deletionhelper.AppStateUsageStatsBridge.UsageStatsState;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
import com.android.settingslib.applications.ApplicationsState;
|
import com.android.settingslib.applications.ApplicationsState;
|
||||||
@@ -72,18 +73,18 @@ public class AppDeletionPreference extends SwitchPreference {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long daysSinceLastUse = (long) mEntry.extraInfo;
|
UsageStatsState extraData = (UsageStatsState) mEntry.extraInfo;
|
||||||
String fileSize = Formatter.formatFileSize(mContext, mEntry.size);
|
String fileSize = Formatter.formatFileSize(mContext, mEntry.size);
|
||||||
if (daysSinceLastUse == AppStateUsageStatsBridge.NEVER_USED) {
|
if (extraData.daysSinceLastUse == AppStateUsageStatsBridge.NEVER_USED) {
|
||||||
summary.setText(mContext.getString(R.string.deletion_helper_app_summary_never_used,
|
summary.setText(mContext.getString(R.string.deletion_helper_app_summary_never_used,
|
||||||
fileSize));
|
fileSize));
|
||||||
} else if (daysSinceLastUse == AppStateUsageStatsBridge.UNKNOWN_LAST_USE) {
|
} else if (extraData.daysSinceLastUse == AppStateUsageStatsBridge.UNKNOWN_LAST_USE) {
|
||||||
summary.setText(mContext.getString(R.string.deletion_helper_app_summary_unknown_used,
|
summary.setText(mContext.getString(R.string.deletion_helper_app_summary_unknown_used,
|
||||||
fileSize));
|
fileSize));
|
||||||
} else {
|
} else {
|
||||||
summary.setText(mContext.getString(R.string.deletion_helper_app_summary,
|
summary.setText(mContext.getString(R.string.deletion_helper_app_summary,
|
||||||
fileSize,
|
fileSize,
|
||||||
daysSinceLastUse));
|
extraData.daysSinceLastUse));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -137,7 +137,10 @@ public class AppStateUsageStatsBridge extends AppStateBaseBridge {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private class UsageStatsState {
|
/**
|
||||||
|
* UsageStatsState contains the days since the last use and first install of a given app.
|
||||||
|
*/
|
||||||
|
public static class UsageStatsState {
|
||||||
public long daysSinceLastUse;
|
public long daysSinceLastUse;
|
||||||
public long daysSinceFirstInstall;
|
public long daysSinceFirstInstall;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user