Merge branch 'feature/qa_f' into dev
This commit is contained in:
@@ -75,7 +75,7 @@ MOGO_MODULE_GUIDESHOW_PROVIDER_VERSION=1.0.2-SNAPSHOT
|
||||
# 在线车辆F
|
||||
MOGO_MODULE_ONLINECAR_VERSION=1.0.3.2
|
||||
# 推送
|
||||
MOGO_MODULE_PUSH_VERSION=1.1.6.1
|
||||
MOGO_MODULE_PUSH_VERSION=1.1.6.2
|
||||
MOGO_MODULE_PUSH_BASE_VERSION=1.1.5.5
|
||||
MOGO_MODULE_PUSH_NOOP_VERSION=1.1.5.6
|
||||
# 广告资源位
|
||||
|
||||
@@ -3,9 +3,15 @@ package com.mogo.module.apps;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.module.common.utils.CarSeries;
|
||||
import com.mogo.utils.FileUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -21,6 +27,8 @@ public class AppFilterImpl implements AppFilter {
|
||||
private final Context mContext;
|
||||
private List< String > mFilterPackages;
|
||||
|
||||
private static String sExternalPath = "/system/etc/packagesFilterList.txt";
|
||||
private static List< String > sExternalConfigPackages = new ArrayList<>();
|
||||
|
||||
public AppFilterImpl( Context context ) {
|
||||
mContext = context;
|
||||
@@ -42,6 +50,9 @@ public class AppFilterImpl implements AppFilter {
|
||||
// if ( isSystemApp( packageInfo ) ) {
|
||||
// return true;
|
||||
// }
|
||||
if ( isInExternalFilter( packageInfo ) ) {
|
||||
return true;
|
||||
}
|
||||
if ( isFilterPackages( packageInfo ) ) {
|
||||
return true;
|
||||
}
|
||||
@@ -63,4 +74,30 @@ public class AppFilterImpl implements AppFilter {
|
||||
return mContext.getPackageManager().getLaunchIntentForPackage( packageInfo.packageName ) == null;
|
||||
}
|
||||
|
||||
private boolean isInExternalFilter( PackageInfo packageInfo ) {
|
||||
return sExternalConfigPackages.contains( packageInfo.packageName );
|
||||
}
|
||||
|
||||
public static void loadExternalFilterPackagesList() throws Exception {
|
||||
sExternalConfigPackages.clear();
|
||||
File file = new File( sExternalPath );
|
||||
if ( !file.exists() || file.length() == 0 ) {
|
||||
return;
|
||||
}
|
||||
FileInputStream fis = new FileInputStream( file );
|
||||
InputStreamReader isr = new InputStreamReader( fis );
|
||||
BufferedReader br = new BufferedReader( isr );
|
||||
String line = "";
|
||||
while ( ( line = br.readLine() ) != null ) {
|
||||
line = line.trim();
|
||||
if ( TextUtils.isEmpty( line ) ) {
|
||||
continue;
|
||||
}
|
||||
sExternalConfigPackages.add( line );
|
||||
}
|
||||
br.close();
|
||||
isr.close();
|
||||
fis.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.mogo.module.apps.model;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
@@ -12,6 +10,7 @@ import com.mogo.module.apps.AppFilter;
|
||||
import com.mogo.module.apps.AppFilterImpl;
|
||||
import com.mogo.module.apps.AppsConst;
|
||||
import com.mogo.module.apps.AppsListChangedLiveData;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -26,6 +25,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* 加载并保存 app 列表
|
||||
*/
|
||||
public class AppsModel {
|
||||
|
||||
private static final String TAG = "AppsModel";
|
||||
|
||||
private static volatile AppsModel sInstance;
|
||||
private Context mContext;
|
||||
@@ -72,6 +73,12 @@ public class AppsModel {
|
||||
if ( mAppFilter == null ) {
|
||||
mAppFilter = new AppFilterImpl( mContext );
|
||||
}
|
||||
try {
|
||||
AppFilterImpl.loadExternalFilterPackagesList();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
e.printStackTrace();
|
||||
}
|
||||
final PackageManager packageManager = mContext.getPackageManager();
|
||||
List< PackageInfo > packages = packageManager.getInstalledPackages( 0 );
|
||||
int counter = 0;
|
||||
|
||||
Reference in New Issue
Block a user