[Settings] Start SettingsDumpService to dump the db log after the db is
created. Bug: 275144372 Test: adb bugreport Change-Id: I9d7fe2e763b9e5840ee76c5eb00bc88288e7ee41
This commit is contained in:
@@ -31,12 +31,15 @@ import android.os.storage.VolumeInfo;
|
|||||||
import android.telephony.SubscriptionInfo;
|
import android.telephony.SubscriptionInfo;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.util.IndentingPrintWriter;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
|
|
||||||
import com.android.settings.applications.ProcStatsData;
|
import com.android.settings.applications.ProcStatsData;
|
||||||
import com.android.settings.datausage.lib.DataUsageLib;
|
import com.android.settings.datausage.lib.DataUsageLib;
|
||||||
import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
|
import com.android.settings.fuelgauge.batterytip.AnomalyConfigJobService;
|
||||||
|
import com.android.settings.network.MobileNetworkRepository;
|
||||||
import com.android.settingslib.net.DataUsageController;
|
import com.android.settingslib.net.DataUsageController;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
@@ -48,6 +51,10 @@ import java.io.FileDescriptor;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
public class SettingsDumpService extends Service {
|
public class SettingsDumpService extends Service {
|
||||||
|
|
||||||
|
public static final String EXTRA_KEY_SHOW_NETWORK_DUMP = "show_network_dump";
|
||||||
|
|
||||||
|
private static final String TAG = "SettingsDumpService";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_SERVICE = "service";
|
static final String KEY_SERVICE = "service";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -64,6 +71,16 @@ public class SettingsDumpService extends Service {
|
|||||||
static final Intent BROWSER_INTENT =
|
static final Intent BROWSER_INTENT =
|
||||||
new Intent("android.intent.action.VIEW", Uri.parse("http://"));
|
new Intent("android.intent.action.VIEW", Uri.parse("http://"));
|
||||||
|
|
||||||
|
private boolean mShouldShowNetworkDump = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
if (intent != null) {
|
||||||
|
mShouldShowNetworkDump = intent.getBooleanExtra(EXTRA_KEY_SHOW_NETWORK_DUMP, false);
|
||||||
|
}
|
||||||
|
return Service.START_REDELIVER_INTENT;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
return null;
|
return null;
|
||||||
@@ -71,8 +88,11 @@ public class SettingsDumpService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||||
|
IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
|
||||||
|
if (!mShouldShowNetworkDump) {
|
||||||
JSONObject dump = new JSONObject();
|
JSONObject dump = new JSONObject();
|
||||||
|
pw.println(TAG + ": ");
|
||||||
|
pw.increaseIndent();
|
||||||
try {
|
try {
|
||||||
dump.put(KEY_SERVICE, "Settings State");
|
dump.put(KEY_SERVICE, "Settings State");
|
||||||
dump.put(KEY_STORAGE, dumpStorage());
|
dump.put(KEY_STORAGE, dumpStorage());
|
||||||
@@ -81,10 +101,14 @@ public class SettingsDumpService extends Service {
|
|||||||
dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
|
dump.put(KEY_DEFAULT_BROWSER_APP, dumpDefaultBrowser());
|
||||||
dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
|
dump.put(KEY_ANOMALY_DETECTION, dumpAnomalyDetection());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Log.w(TAG, "exception in dump: ", e);
|
||||||
|
}
|
||||||
|
pw.println(dump);
|
||||||
|
pw.flush();
|
||||||
|
pw.decreaseIndent();
|
||||||
|
} else {
|
||||||
|
dumpMobileNetworkSettings(pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.println(dump);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject dumpMemory() throws JSONException {
|
private JSONObject dumpMemory() throws JSONException {
|
||||||
@@ -186,4 +210,8 @@ public class SettingsDumpService extends Service {
|
|||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dumpMobileNetworkSettings(IndentingPrintWriter writer) {
|
||||||
|
MobileNetworkRepository.getInstance(this).dump(writer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,6 +39,7 @@ import android.telephony.UiccCardInfo;
|
|||||||
import android.telephony.UiccPortInfo;
|
import android.telephony.UiccPortInfo;
|
||||||
import android.telephony.UiccSlotInfo;
|
import android.telephony.UiccSlotInfo;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
|
import android.util.IndentingPrintWriter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.settings.network.telephony.MobileNetworkUtils;
|
import com.android.settings.network.telephony.MobileNetworkUtils;
|
||||||
@@ -736,4 +737,17 @@ public class MobileNetworkRepository extends SubscriptionManager.OnSubscriptions
|
|||||||
default void onCallStateChanged(int state) {
|
default void onCallStateChanged(int state) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dump(IndentingPrintWriter printwriter) {
|
||||||
|
printwriter.println(TAG + ": ");
|
||||||
|
printwriter.increaseIndent();
|
||||||
|
printwriter.println(" availableSubInfoEntityList= " + mAvailableSubInfoEntityList);
|
||||||
|
printwriter.println(" activeSubInfoEntityList=" + mActiveSubInfoEntityList);
|
||||||
|
printwriter.println(" mobileNetworkInfoEntityList= " + mMobileNetworkInfoEntityList);
|
||||||
|
printwriter.println(" uiccInfoEntityList= " + mUiccInfoEntityList);
|
||||||
|
printwriter.println(" CacheSubscriptionInfoEntityMap= " + sCacheSubscriptionInfoEntityMap);
|
||||||
|
printwriter.println(" SubscriptionInfoMap= " + mSubscriptionInfoMap);
|
||||||
|
printwriter.flush();
|
||||||
|
printwriter.decreaseIndent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.lifecycle.LifecycleOwner;
|
import androidx.lifecycle.LifecycleOwner;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SettingsDumpService;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.OnActivityResultListener;
|
import com.android.settings.core.OnActivityResultListener;
|
||||||
import com.android.settings.dashboard.DashboardFragment;
|
import com.android.settings.dashboard.DashboardFragment;
|
||||||
@@ -122,6 +123,11 @@ public class NetworkDashboardFragment extends DashboardFragment implements
|
|||||||
}
|
}
|
||||||
controllers.add(privateDnsPreferenceController);
|
controllers.add(privateDnsPreferenceController);
|
||||||
controllers.add(new NetworkProviderCallsSmsController(context, lifecycle, lifecycleOwner));
|
controllers.add(new NetworkProviderCallsSmsController(context, lifecycle, lifecycleOwner));
|
||||||
|
|
||||||
|
// Start SettingsDumpService after the MobileNetworkRepository is created.
|
||||||
|
Intent intent = new Intent(context, SettingsDumpService.class);
|
||||||
|
intent.putExtra(SettingsDumpService.EXTRA_KEY_SHOW_NETWORK_DUMP, true);
|
||||||
|
context.startService(intent);
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user