sm8350-common: parts: Checkout thermal profiles to xiaomi-sm8250 implementation
This commit is contained in:
parent
8d1447e38e
commit
f407164d2e
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2022 The LineageOS Project
|
* Copyright (C) 2020 The LineageOS Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -17,11 +17,14 @@
|
|||||||
package org.lineageos.settings.thermal;
|
package org.lineageos.settings.thermal;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
|
import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
|
||||||
|
|
||||||
public class ThermalActivity extends CollapsingToolbarBaseActivity {
|
public class ThermalActivity extends CollapsingToolbarBaseActivity {
|
||||||
|
|
||||||
private static final String TAG_THERMAL = "thermal";
|
private static final String TAG_THERMAL = "thermal";
|
||||||
|
private static final String THERMAL_SCONFIG = "/sys/class/thermal/thermal_message/sconfig";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -30,4 +33,13 @@ public class ThermalActivity extends CollapsingToolbarBaseActivity {
|
|||||||
getFragmentManager().beginTransaction().replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame,
|
getFragmentManager().beginTransaction().replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame,
|
||||||
new ThermalSettingsFragment(), TAG_THERMAL).commit();
|
new ThermalSettingsFragment(), TAG_THERMAL).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
if (item.getItemId() == android.R.id.home) {
|
||||||
|
onBackPressed();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@ package org.lineageos.settings.thermal;
|
|||||||
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityTaskManager;
|
import android.app.ActivityTaskManager;
|
||||||
|
import android.app.ActivityTaskManager.RootTaskInfo;
|
||||||
|
import android.app.IActivityTaskManager;
|
||||||
import android.app.TaskStackListener;
|
import android.app.TaskStackListener;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.app.TaskStackListener;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -37,6 +40,8 @@ public class ThermalService extends Service {
|
|||||||
private String mPreviousApp;
|
private String mPreviousApp;
|
||||||
private ThermalUtils mThermalUtils;
|
private ThermalUtils mThermalUtils;
|
||||||
|
|
||||||
|
private IActivityTaskManager mActivityTaskManager;
|
||||||
|
|
||||||
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
@ -49,7 +54,8 @@ public class ThermalService extends Service {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
if (DEBUG) Log.d(TAG, "Creating service");
|
if (DEBUG) Log.d(TAG, "Creating service");
|
||||||
try {
|
try {
|
||||||
ActivityTaskManager.getService().registerTaskStackListener(mTaskListener);
|
mActivityTaskManager = ActivityTaskManager.getService();
|
||||||
|
mActivityTaskManager.registerTaskStackListener(mTaskListener);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
@ -80,16 +86,16 @@ public class ThermalService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onTaskStackChanged() {
|
public void onTaskStackChanged() {
|
||||||
try {
|
try {
|
||||||
final ActivityTaskManager.RootTaskInfo focusedTask =
|
final RootTaskInfo info = mActivityTaskManager.getFocusedRootTaskInfo();
|
||||||
ActivityTaskManager.getService().getFocusedRootTaskInfo();
|
if (info == null || info.topActivity == null) {
|
||||||
if (focusedTask != null && focusedTask.topActivity != null) {
|
return;
|
||||||
ComponentName taskComponentName = focusedTask.topActivity;
|
}
|
||||||
String foregroundApp = taskComponentName.getPackageName();
|
|
||||||
|
String foregroundApp = info.topActivity.getPackageName();
|
||||||
if (!foregroundApp.equals(mPreviousApp)) {
|
if (!foregroundApp.equals(mPreviousApp)) {
|
||||||
mThermalUtils.setThermalProfile(foregroundApp);
|
mThermalUtils.setThermalProfile(foregroundApp);
|
||||||
mPreviousApp = foregroundApp;
|
mPreviousApp = foregroundApp;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2020 The LineageOS Project
|
* Copyright (C) 2020 The LineageOS Project
|
||||||
*
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
* <p>
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
* <p>
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -100,6 +100,7 @@ public class ThermalSettingsFragment extends PreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
getActivity().setTitle(getResources().getString(R.string.thermal_title));
|
||||||
rebuild();
|
rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,6 +275,7 @@ public class ThermalSettingsFragment extends PreferenceFragment
|
|||||||
|
|
||||||
view.setText(items[position]);
|
view.setText(items[position]);
|
||||||
view.setTextSize(14f);
|
view.setTextSize(14f);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,20 +304,22 @@ public class ThermalSettingsFragment extends PreferenceFragment
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
return new ViewHolder(LayoutInflater.from(parent.getContext())
|
ViewHolder holder = new ViewHolder(LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.thermal_list_item, parent, false));
|
.inflate(R.layout.thermal_list_item, parent, false));
|
||||||
|
Context context = holder.itemView.getContext();
|
||||||
|
holder.mode.setAdapter(new ModeAdapter(context));
|
||||||
|
holder.mode.setOnItemSelectedListener(this);
|
||||||
|
return holder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||||
Context context = holder.itemView.getContext();
|
|
||||||
ApplicationsState.AppEntry entry = mEntries.get(position);
|
ApplicationsState.AppEntry entry = mEntries.get(position);
|
||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.mode.setAdapter(new ModeAdapter(context));
|
|
||||||
holder.mode.setOnItemSelectedListener(this);
|
|
||||||
holder.title.setText(entry.label);
|
holder.title.setText(entry.label);
|
||||||
holder.title.setOnClickListener(v -> holder.mode.performClick());
|
holder.title.setOnClickListener(v -> holder.mode.performClick());
|
||||||
mApplicationsState.ensureIcon(entry);
|
mApplicationsState.ensureIcon(entry);
|
||||||
|
Loading…
Reference in New Issue
Block a user