Snap for 6367459 from e48b6a0539 to mainline-release
Change-Id: Ie2704102f66fbcd869ccc5e7fa354612f4a6250a
This commit is contained in:
@@ -3817,9 +3817,9 @@
|
||||
<string name="bluetooth_untether_blank"><xliff:g id="device_name">%1$s</xliff:g> will be untethered.</string>
|
||||
|
||||
<!-- Ethernet Tethering settings-->
|
||||
<!-- Label for ethernet tether checkbox [CHAR LIMIT=25]-->
|
||||
<!-- Label for ethernet tether checkbox [CHAR LIMIT=NONE]-->
|
||||
<string name="ethernet_tether_checkbox_text">Ethernet tethering</string>
|
||||
<!-- Ethernet Tethering subtext [CHAR LIMIT=70]-->
|
||||
<!-- Ethernet Tethering subtext [CHAR LIMIT=NONE]-->
|
||||
<string name="ethernet_tethering_subtext" product="default">Share phone\u2019s internet connection via USB Ethernet</string>
|
||||
|
||||
<!-- Tethering footer info [CHAR LIMIT=NONE]-->
|
||||
@@ -11837,6 +11837,8 @@
|
||||
<string name="dsu_loader_description" translatable="false">Load a Dynamic System Update Image</string>
|
||||
<!-- DSU Loader Loading. Do not translate. -->
|
||||
<string name="dsu_loader_loading" translatable="false">Loading...</string>
|
||||
<!-- DSU Loader. Do not translate. -->
|
||||
<string name="dsu_is_running" translatable="false">DSU is running</string>
|
||||
|
||||
<!-- Name of dev option called "Bug report handler" [CHAR LIMIT=NONE] -->
|
||||
<string name="bug_report_handler_title">Bug report handler</string>
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemProperties;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Slog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -40,8 +41,11 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
@@ -62,6 +66,7 @@ public class DSULoader extends ListActivity {
|
||||
private static final String PROPERTY_KEY_OS = "ro.system.build.version.release";
|
||||
private static final String PROPERTY_KEY_VNDK = "ro.vndk.version";
|
||||
private static final String PROPERTY_KEY_LIST = "ro.vendor.dsu.list";
|
||||
private static final String PROPERTY_KEY_SPL = "ro.build.version.security_patch";
|
||||
private static final String DSU_LIST =
|
||||
"https://dl.google.com/developers/android/gsi/gsi-src.json";
|
||||
|
||||
@@ -121,7 +126,8 @@ public class DSULoader extends ListActivity {
|
||||
mDsuList = dsuList;
|
||||
}
|
||||
|
||||
private void fetch(URL url) throws IOException, JSONException, MalformedURLException {
|
||||
private void fetch(URL url)
|
||||
throws IOException, JSONException, MalformedURLException, ParseException {
|
||||
String content = readAll(url);
|
||||
JSONObject jsn = new JSONObject(content);
|
||||
// The include primitive is like below
|
||||
@@ -195,6 +201,8 @@ public class DSULoader extends ListActivity {
|
||||
private static final String OS_VERSION = "os_version";
|
||||
private static final String VNDK = "vndk";
|
||||
private static final String PUBKEY = "pubkey";
|
||||
private static final String SPL = "spl";
|
||||
private static final String SPL_FORMAT = "yyyy-MM-dd";
|
||||
private static final String TOS = "tos";
|
||||
|
||||
String mName = null;
|
||||
@@ -203,10 +211,11 @@ public class DSULoader extends ListActivity {
|
||||
int mOsVersion = -1;
|
||||
int[] mVndk = null;
|
||||
String mPubKey = "";
|
||||
Date mSPL = null;
|
||||
URL mTosUrl = null;
|
||||
URL mUri;
|
||||
|
||||
DSUPackage(JSONObject jsn) throws JSONException, MalformedURLException {
|
||||
DSUPackage(JSONObject jsn) throws JSONException, MalformedURLException, ParseException {
|
||||
Slog.i(TAG, "DSUPackage: " + jsn.toString());
|
||||
mName = jsn.getString(NAME);
|
||||
mDetails = jsn.getString(DETAILS);
|
||||
@@ -228,6 +237,9 @@ public class DSULoader extends ListActivity {
|
||||
if (jsn.has(TOS)) {
|
||||
mTosUrl = new URL(jsn.getString(TOS));
|
||||
}
|
||||
if (jsn.has(SPL)) {
|
||||
mSPL = new SimpleDateFormat(SPL_FORMAT).parse(jsn.getString(SPL));
|
||||
}
|
||||
}
|
||||
|
||||
int dessertNumber(String s, int base) {
|
||||
@@ -265,6 +277,18 @@ public class DSULoader extends ListActivity {
|
||||
return cpu;
|
||||
}
|
||||
|
||||
Date getDeviceSPL() {
|
||||
String spl = SystemProperties.get(PROPERTY_KEY_SPL);
|
||||
if (TextUtils.isEmpty(spl)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new SimpleDateFormat(SPL_FORMAT).parse(spl);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isSupported() {
|
||||
boolean supported = true;
|
||||
String cpu = getDeviceCpu();
|
||||
@@ -301,6 +325,16 @@ public class DSULoader extends ListActivity {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mSPL != null) {
|
||||
Date spl = getDeviceSPL();
|
||||
if (spl == null) {
|
||||
Slog.i(TAG, "Failed to getDeviceSPL");
|
||||
supported = false;
|
||||
} else if (spl.getTime() > mSPL.getTime()) {
|
||||
Slog.i(TAG, "Device SPL:" + spl.toString() + " > " + mSPL.toString());
|
||||
supported = false;
|
||||
}
|
||||
}
|
||||
Slog.i(TAG, mName + " isSupported " + supported);
|
||||
return supported;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.settings.development;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.SystemProperties;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -37,9 +38,16 @@ class SelectDSUPreferenceController extends DeveloperOptionsPreferenceController
|
||||
return DSU_LOADER_KEY;
|
||||
}
|
||||
|
||||
private boolean isDSURunning() {
|
||||
return SystemProperties.getBoolean("ro.gsid.image_running", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (DSU_LOADER_KEY.equals(preference.getKey())) {
|
||||
if (isDSURunning()) {
|
||||
return true;
|
||||
}
|
||||
final Intent intent = new Intent(mContext, DSULoader.class);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
@@ -49,6 +57,7 @@ class SelectDSUPreferenceController extends DeveloperOptionsPreferenceController
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setSummary(mContext.getResources().getString(R.string.dsu_loader_description));
|
||||
int key = isDSURunning() ? R.string.dsu_is_running : R.string.dsu_loader_description;
|
||||
preference.setSummary(mContext.getResources().getString(key));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user