Merge "Fix DynamicSystemClient.start() exceptions" am: f2bf58fb9b am: 318dd035a6
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1541268 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I29f91caa3f49d5961f736cee9a809c687e00d47b
This commit is contained in:
@@ -35,8 +35,6 @@ import android.os.Message;
|
|||||||
import android.os.Messenger;
|
import android.os.Messenger;
|
||||||
import android.os.ParcelableException;
|
import android.os.ParcelableException;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.SystemProperties;
|
|
||||||
import android.util.FeatureFlagUtils;
|
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@@ -251,13 +249,7 @@ public class DynamicSystemClient {
|
|||||||
mService.send(msg);
|
mService.send(msg);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Slog.e(TAG, "Unable to get status from installation service");
|
Slog.e(TAG, "Unable to get status from installation service");
|
||||||
if (mExecutor != null) {
|
notifyOnStatusChangedListener(STATUS_UNKNOWN, CAUSE_ERROR_IPC, 0, e);
|
||||||
mExecutor.execute(() -> {
|
|
||||||
mListener.onStatusChanged(STATUS_UNKNOWN, CAUSE_ERROR_IPC, 0, e);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
mListener.onStatusChanged(STATUS_UNKNOWN, CAUSE_ERROR_IPC, 0, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,6 +303,20 @@ public class DynamicSystemClient {
|
|||||||
mExecutor = null;
|
mExecutor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void notifyOnStatusChangedListener(
|
||||||
|
int status, int cause, long progress, Throwable detail) {
|
||||||
|
if (mListener != null) {
|
||||||
|
if (mExecutor != null) {
|
||||||
|
mExecutor.execute(
|
||||||
|
() -> {
|
||||||
|
mListener.onStatusChanged(status, cause, progress, detail);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mListener.onStatusChanged(status, cause, progress, detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind to {@code DynamicSystem} installation service. Binding to the installation service
|
* Bind to {@code DynamicSystem} installation service. Binding to the installation service
|
||||||
* allows it to send status updates to {@link #OnStatusChangedListener}. It is recommanded
|
* allows it to send status updates to {@link #OnStatusChangedListener}. It is recommanded
|
||||||
@@ -320,11 +326,6 @@ public class DynamicSystemClient {
|
|||||||
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
|
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
|
||||||
@SystemApi
|
@SystemApi
|
||||||
public void bind() {
|
public void bind() {
|
||||||
if (!featureFlagEnabled()) {
|
|
||||||
Slog.w(TAG, FeatureFlagUtils.DYNAMIC_SYSTEM + " not enabled; bind() aborted.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setClassName("com.android.dynsystem",
|
intent.setClassName("com.android.dynsystem",
|
||||||
"com.android.dynsystem.DynamicSystemInstallationService");
|
"com.android.dynsystem.DynamicSystemInstallationService");
|
||||||
@@ -395,11 +396,6 @@ public class DynamicSystemClient {
|
|||||||
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
|
@RequiresPermission(android.Manifest.permission.INSTALL_DYNAMIC_SYSTEM)
|
||||||
public void start(@NonNull Uri systemUrl, @BytesLong long systemSize,
|
public void start(@NonNull Uri systemUrl, @BytesLong long systemSize,
|
||||||
@BytesLong long userdataSize) {
|
@BytesLong long userdataSize) {
|
||||||
if (!featureFlagEnabled()) {
|
|
||||||
Slog.w(TAG, FeatureFlagUtils.DYNAMIC_SYSTEM + " not enabled; start() aborted.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
|
||||||
intent.setClassName("com.android.dynsystem",
|
intent.setClassName("com.android.dynsystem",
|
||||||
@@ -407,6 +403,7 @@ public class DynamicSystemClient {
|
|||||||
|
|
||||||
intent.setData(systemUrl);
|
intent.setData(systemUrl);
|
||||||
intent.setAction(ACTION_START_INSTALL);
|
intent.setAction(ACTION_START_INSTALL);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
intent.putExtra(KEY_SYSTEM_SIZE, systemSize);
|
intent.putExtra(KEY_SYSTEM_SIZE, systemSize);
|
||||||
intent.putExtra(KEY_USERDATA_SIZE, userdataSize);
|
intent.putExtra(KEY_USERDATA_SIZE, userdataSize);
|
||||||
@@ -414,11 +411,6 @@ public class DynamicSystemClient {
|
|||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean featureFlagEnabled() {
|
|
||||||
return SystemProperties.getBoolean(
|
|
||||||
FeatureFlagUtils.PERSIST_PREFIX + FeatureFlagUtils.DYNAMIC_SYSTEM, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleMessage(Message msg) {
|
private void handleMessage(Message msg) {
|
||||||
switch (msg.what) {
|
switch (msg.what) {
|
||||||
case MSG_POST_STATUS:
|
case MSG_POST_STATUS:
|
||||||
@@ -432,13 +424,7 @@ public class DynamicSystemClient {
|
|||||||
|
|
||||||
Throwable detail = t == null ? null : t.getCause();
|
Throwable detail = t == null ? null : t.getCause();
|
||||||
|
|
||||||
if (mExecutor != null) {
|
notifyOnStatusChangedListener(status, cause, progress, detail);
|
||||||
mExecutor.execute(() -> {
|
|
||||||
mListener.onStatusChanged(status, cause, progress, detail);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
mListener.onStatusChanged(status, cause, progress, detail);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|||||||
Reference in New Issue
Block a user