Skip to content
Browse files

1) fix the issue for mediaProvider that some keys does not exist in DB

2) keep some application as request from users

Change-Id: I98258ddf48a8a5b7ecb9e825a093fb36ac7a51f0
  • Loading branch information...
1 parent f5ceb1e commit 6534a24e4a6673a601cc8105e53bed34310dfd06 @fanoge fanoge committed Feb 11, 2012
View
BIN 9000_final.zip
Binary file not shown.
View
4 MediaProvider/smali/com/android/providers/media/MediaProvider$DatabaseHelper.smali
@@ -55,7 +55,7 @@
.line 828
const/4 v0, 0x0
- const/16 v1, 0x64
+ const/16 v1, 0x65
invoke-direct {p0, p1, p2, v0, v1}, Landroid/database/sqlite/SQLiteOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;I)V
@@ -95,7 +95,7 @@
const/4 v1, 0x0
- const/16 v2, 0x64
+ const/16 v2, 0x65
#calls: Lcom/android/providers/media/MediaProvider;->updateDatabase(Landroid/database/sqlite/SQLiteDatabase;ZII)V
invoke-static {p1, v0, v1, v2}, Lcom/android/providers/media/MediaProvider;->access$1200(Landroid/database/sqlite/SQLiteDatabase;ZII)V
View
388 MediaProvider/smali/com/android/providers/media/MediaProvider.smali
@@ -1570,6 +1570,272 @@
return-object v0
.end method
+.method private static addForSortKey(Landroid/database/sqlite/SQLiteDatabase;)V
+.locals 15
+.parameter
+
+.prologue
+const/4 v14, 0x2
+
+const/4 v13, 0x1
+
+const/4 v12, 0x0
+
+const/4 v3, 0x0
+
+
+invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
+
+move-result-wide v8
+
+
+sget-object v0, Lcom/android/providers/media/MediaProvider;->TAG:Ljava/lang/String;
+
+const-string v1, "databases update to 95, add sort_key for audio_meida, artists and albums"
+
+invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
+
+
+const-string v0, "ALTER TABLE audio_meta ADD COLUMN sort_key TEXT COLLATE LOCALIZED;"
+
+invoke-virtual {p0, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+const-string v0, "ALTER TABLE artists ADD COLUMN artist_sort_key TEXT COLLATE LOCALIZED;"
+
+invoke-virtual {p0, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+const-string v0, "ALTER TABLE albums ADD COLUMN album_sort_key TEXT COLLATE LOCALIZED;"
+
+invoke-virtual {p0, v0}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
+
+move-result-wide v10
+
+
+new-array v2, v14, [Ljava/lang/String;
+
+const-string v0, "_id"
+
+aput-object v0, v2, v12
+
+const-string v0, "title"
+
+aput-object v0, v2, v13
+
+
+const-string v1, "audio_meta"
+
+move-object v0, p0
+
+move-object v4, v3
+
+move-object v5, v3
+
+move-object v6, v3
+
+move-object v7, v3
+
+invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
+
+move-result-object v0
+
+
+if-eqz v0, :cond_0
+
+
+const-string v1, "UPDATE audio_meta SET sort_key = ? WHERE _id=?"
+
+invoke-virtual {p0, v1}, Landroid/database/sqlite/SQLiteDatabase;->compileStatement(Ljava/lang/String;)Landroid/database/sqlite/SQLiteStatement;
+
+move-result-object v1
+
+
+invoke-static {v1, v0, v12, v13}, Lcom/android/providers/media/MediaProvider;->updateForSortKey(Landroid/database/sqlite/SQLiteStatement;Landroid/database/Cursor;II)V
+
+
+invoke-interface {v0}, Landroid/database/Cursor;->close()V
+
+
+:cond_0
+new-array v2, v14, [Ljava/lang/String;
+
+const-string v0, "artist_id"
+
+aput-object v0, v2, v12
+
+const-string v0, "artist"
+
+aput-object v0, v2, v13
+
+
+const-string v1, "artists"
+
+move-object v0, p0
+
+move-object v4, v3
+
+move-object v5, v3
+
+move-object v6, v3
+
+move-object v7, v3
+
+invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
+
+move-result-object v0
+
+
+if-eqz v0, :cond_1
+
+
+const-string v1, "UPDATE artists SET artist_sort_key =?WHERE artist_id=?"
+
+invoke-virtual {p0, v1}, Landroid/database/sqlite/SQLiteDatabase;->compileStatement(Ljava/lang/String;)Landroid/database/sqlite/SQLiteStatement;
+
+move-result-object v1
+
+
+invoke-static {v1, v0, v12, v13}, Lcom/android/providers/media/MediaProvider;->updateForSortKey(Landroid/database/sqlite/SQLiteStatement;Landroid/database/Cursor;II)V
+
+
+invoke-interface {v0}, Landroid/database/Cursor;->close()V
+
+
+:cond_1
+new-array v2, v14, [Ljava/lang/String;
+
+const-string v0, "album_id"
+
+aput-object v0, v2, v12
+
+const-string v0, "album"
+
+aput-object v0, v2, v13
+
+
+const-string v1, "albums"
+
+move-object v0, p0
+
+move-object v4, v3
+
+move-object v5, v3
+
+move-object v6, v3
+
+move-object v7, v3
+
+invoke-virtual/range {v0 .. v7}, Landroid/database/sqlite/SQLiteDatabase;->query(Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;
+
+move-result-object v0
+
+
+if-eqz v0, :cond_2
+
+
+const-string v1, "UPDATE albums SET album_sort_key = ? WHERE album_id = ? "
+
+invoke-virtual {p0, v1}, Landroid/database/sqlite/SQLiteDatabase;->compileStatement(Ljava/lang/String;)Landroid/database/sqlite/SQLiteStatement;
+
+move-result-object v1
+
+
+invoke-static {v1, v0, v12, v13}, Lcom/android/providers/media/MediaProvider;->updateForSortKey(Landroid/database/sqlite/SQLiteStatement;Landroid/database/Cursor;II)V
+
+
+invoke-interface {v0}, Landroid/database/Cursor;->close()V
+
+
+:cond_2
+invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
+
+move-result-wide v0
+
+
+invoke-static {p0}, Lcom/android/providers/media/MediaProvider;->recreateAudioView(Landroid/database/sqlite/SQLiteDatabase;)V
+
+
+const-string v2, "DROP VIEW IF EXISTS artist_info"
+
+invoke-virtual {p0, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+const-string v2, "CREATE VIEW IF NOT EXISTS artist_info AS SELECT artist_id AS _id, artist, artist_key, artist_sort_key, COUNT(DISTINCT album) AS number_of_albums, COUNT(*) AS number_of_tracks FROM audio WHERE is_music=1 GROUP BY artist_key;"
+
+invoke-virtual {p0, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+const-string v2, "DROP VIEW IF EXISTS album_info"
+
+invoke-virtual {p0, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+const-string v2, "CREATE VIEW IF NOT EXISTS album_info AS SELECT audio.album_id AS _id, album, album_key, album_sort_key, MIN(year) AS minyear, MAX(year) AS maxyear, artist, artist_id, artist_key, count(*) AS numsongs,album_art._data AS album_art FROM audio LEFT OUTER JOIN album_art ON audio.album_id=album_art.album_id WHERE is_music=1 GROUP BY audio.album_id;"
+
+invoke-virtual {p0, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+
+
+sget-object v2, Lcom/android/providers/media/MediaProvider;->TAG:Ljava/lang/String;
+
+new-instance v3, Ljava/lang/StringBuilder;
+
+invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
+
+const-string v4, "time for insert sort_key "
+
+invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+move-result-object v3
+
+sub-long/2addr v0, v10
+
+invoke-virtual {v3, v0, v1}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
+
+move-result-object v0
+
+invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
+
+move-result-object v0
+
+invoke-static {v2, v0}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
+
+
+sget-object v0, Lcom/android/providers/media/MediaProvider;->TAG:Ljava/lang/String;
+
+new-instance v1, Ljava/lang/StringBuilder;
+
+invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
+
+const-string v2, "total time for upgrade to 95 "
+
+invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
+
+move-result-object v1
+
+invoke-static {}, Ljava/lang/System;->currentTimeMillis()J
+
+move-result-wide v2
+
+sub-long/2addr v2, v8
+
+invoke-virtual {v1, v2, v3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;
+
+move-result-object v1
+
+invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
+
+move-result-object v1
+
+invoke-static {v0, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I
+
+
+return-void
+.end method
+
.method private attachVolume(Ljava/lang/String;)Landroid/net/Uri;
.locals 9
.parameter
@@ -6755,6 +7021,10 @@
invoke-virtual {v0, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
+ invoke-virtual {v5}, Ljava/lang/String;->trim()Ljava/lang/String;
+
+ move-result-object v5
+
.line 3555
const-string v6, "title"
@@ -6767,6 +7037,22 @@
.line 3556
const-string v6, "title"
+ move-object/from16 v0, v27
+
+ move-object v1, v6
+
+ move-object v2, v5
+
+ invoke-virtual {v0, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
+
+ const-string v6, "sort_key"
+
+ invoke-static {}, Lmiui/util/LocaleUtils;->getIntance()Lmiui/util/LocaleUtils;
+
+ move-result-object v7
+
+ invoke-virtual {v7, v5}, Lmiui/util/LocaleUtils;->getSortKey(Ljava/lang/String;)Ljava/lang/String;
+
invoke-virtual {v5}, Ljava/lang/String;->trim()Ljava/lang/String;
move-result-object v5
@@ -11656,7 +11942,7 @@
.prologue
const/16 v3, 0x3f
- const/16 v8, 0x64
+ const/16 v8, 0x65
const/16 v7, 0x5d
@@ -13227,6 +13513,8 @@
invoke-virtual {p0, v6}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V
+ invoke-static {p0}, Lcom/android/providers/media/MediaProvider;->addForSortKey(Landroid/database/sqlite/SQLiteDatabase;)V
+
.line 2240
:cond_1e
invoke-static {p0, v0}, Lcom/android/providers/media/MediaProvider;->sanityCheck(Landroid/database/sqlite/SQLiteDatabase;I)V
@@ -13618,6 +13906,82 @@
return-void
.end method
+.method private static updateForSortKey(Landroid/database/sqlite/SQLiteStatement;Landroid/database/Cursor;II)V
+ .locals 6
+ .parameter "updateStatement"
+ .parameter "c"
+ .parameter "idIdx"
+ .parameter "titleIdx"
+
+ .prologue
+ const/4 v5, 0x1
+
+
+ invoke-static {}, Lmiui/util/LocaleUtils;->getIntance()Lmiui/util/LocaleUtils;
+
+ move-result-object v2
+
+
+ .local v2, localeUtils:Lmiui/util/LocaleUtils;
+ invoke-interface {p1}, Landroid/database/Cursor;->moveToFirst()Z
+
+ :goto_0
+ invoke-interface {p1}, Landroid/database/Cursor;->isAfterLast()Z
+
+ move-result v4
+
+ if-nez v4, :cond_1
+
+
+ invoke-interface {p1, p2}, Landroid/database/Cursor;->getLong(I)J
+
+ move-result-wide v0
+
+
+ .local v0, id:J
+ invoke-interface {p1, p3}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
+
+ move-result-object v3
+
+
+ .local v3, title:Ljava/lang/String;
+ if-nez v3, :cond_0
+
+
+ invoke-virtual {p0, v5}, Landroid/database/sqlite/SQLiteStatement;->bindNull(I)V
+
+
+ :goto_1
+ const/4 v4, 0x2
+
+ invoke-virtual {p0, v4, v0, v1}, Landroid/database/sqlite/SQLiteStatement;->bindLong(IJ)V
+
+
+ invoke-virtual {p0}, Landroid/database/sqlite/SQLiteStatement;->execute()V
+
+
+ invoke-interface {p1}, Landroid/database/Cursor;->moveToNext()Z
+
+ goto :goto_0
+
+
+ :cond_0
+ invoke-virtual {v2, v3}, Lmiui/util/LocaleUtils;->getSortKey(Ljava/lang/String;)Ljava/lang/String;
+
+ move-result-object v3
+
+
+ invoke-virtual {p0, v5, v3}, Landroid/database/sqlite/SQLiteStatement;->bindString(ILjava/lang/String;)V
+
+ goto :goto_1
+
+
+ .end local v0 #id:J
+ .end local v3 #title:Ljava/lang/String;
+ :cond_1
+ return-void
+.end method
+
.method private waitForThumbnailReady(Landroid/net/Uri;)Z
.locals 11
.parameter
@@ -23792,6 +24156,10 @@
invoke-virtual {v0, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
+ invoke-virtual {v5}, Ljava/lang/String;->trim()Ljava/lang/String;
+
+ move-result-object v5
+
.line 4310
const-string v7, "title"
@@ -23804,7 +24172,23 @@
.line 4311
const-string v7, "title"
- invoke-virtual {v5}, Ljava/lang/String;->trim()Ljava/lang/String;
+
+ move-object/from16 v0, v24
+
+ move-object v1, v7
+
+ move-object v2, v5
+
+ invoke-virtual {v0, v1, v2}, Landroid/content/ContentValues;->put(Ljava/lang/String;Ljava/lang/String;)V
+
+
+ const-string v7, "sort_key"
+
+ invoke-static {}, Lmiui/util/LocaleUtils;->getIntance()Lmiui/util/LocaleUtils;
+
+ move-result-object v8
+
+ invoke-virtual {v8, v5}, Lmiui/util/LocaleUtils;->getSortKey(Ljava/lang/String;)Ljava/lang/String;
move-result-object v5
View
2 makefile
@@ -5,7 +5,7 @@ local-zip-file := 9000_final.zip
local-out-zip-file := NEW_9000.zip
# All apps from zip and has smali files chanded(need to be builded by apktool)
-local-modified-apps := Phone CSC LogsProvider SettingsProvider
+local-modified-apps := Phone CSC LogsProvider SettingsProvider MediaProvider
# All apks from MIUI execept MIUISystemUI and framework-res.apk
local-miui-apps := Contacts ContactsProvider Mms TelephonyProvider ThemeManager \

0 comments on commit 6534a24

Please sign in to comment.
Something went wrong with that request. Please try again.